Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/xunit.analyzers/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Tag | Meani
| [xUnit1067](/xunit.analyzers/rules/xUnit1067) | ::v2::{.label .label-version-True} ::v3::{.label .label-version-True} ::AOT::{.label .label-version-True} | ::E::{.label .label-Error .label-Fixed} | There is no matching MemberData method argument
| [xUnit1068](/xunit.analyzers/rules/xUnit1068) | ::v2::{.label .label-version-False} ::v3::{.label .label-version-False} ::AOT::{.label .label-version-True} | ::E::{.label .label-Error .label-Fixed} | MemberData cannot point to an open generic type
| [xUnit1069](/xunit.analyzers/rules/xUnit1069) | ::v2::{.label .label-version-False} ::v3::{.label .label-version-True} ::AOT::{.label .label-version-True} | ::W::{.label .label-Warning .label-Fixed} | Test methods with a Timeout should reference TestContext.Current.CancellationToken
| [xUnit1070](/xunit.analyzers/rules/xUnit1070) | ::v2::{.label .label-version-False} ::v3::{.label .label-version-True} ::AOT::{.label .label-version-True} | ::E::{.label .label-Error .label-Fixed} | Cultured test methods cannot have null cultures
| [xUnit1071](/xunit.analyzers/rules/xUnit1071) | ::v2::{.label .label-version-False} ::v3::{.label .label-version-True} ::AOT::{.label .label-version-True} | ::W::{.label .label-Warning .label-Fixed} | Cultured test methods should not have duplicate cultures

## Assertion Analyzers (2xxx)

Expand Down
49 changes: 49 additions & 0 deletions site/xunit.analyzers/rules/xUnit1070.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
analyzer: true
title: xUnit1070
description: Cultured test methods cannot have null cultures
severity: Error
v2: false
v3: true
aot: true
---

## Cause

A violation of this rule occurs when one of the cultures declared on a cultured test is `null`.

## Reason for rule

Cultured test methods run one test for each declared culture, so every culture must be a valid culture name. A `null` culture cannot be turned into a culture, so the test framework fails with an error when it discovers the test.

## How to fix violations

To fix a violation of this rule, replace the `null` value with a valid culture name, or remove it.

## Examples

### Violates

```csharp
using Xunit;

public class xUnit1070
{
[CulturedFact(["en-US", null])]
public void FactMethod()
{ }
}
```

### Does not violate

```csharp
using Xunit;

public class xUnit1070
{
[CulturedFact(["en-US", "fr-FR"])]
public void FactMethod()
{ }
}
```
49 changes: 49 additions & 0 deletions site/xunit.analyzers/rules/xUnit1071.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
analyzer: true
title: xUnit1071
description: Cultured test methods should not have duplicate cultures
severity: Warning
v2: false
v3: true
aot: true
---

## Cause

A violation of this rule occurs when the same culture is declared more than once on a cultured test. Culture names are compared case-insensitively, so `"en-US"` and `"en-us"` count as duplicates.

## Reason for rule

Cultured test methods run one test for each declared culture. A duplicated culture runs the same test more than once under the same culture, which adds no coverage and produces test cases with the same display name and unique ID.

## How to fix violations

To fix a violation of this rule, remove the duplicated culture.

## Examples

### Violates

```csharp
using Xunit;

public class xUnit1071
{
[CulturedFact(["en-US", "fr-FR", "en-US"])]
public void FactMethod()
{ }
}
```

### Does not violate

```csharp
using Xunit;

public class xUnit1071
{
[CulturedFact(["en-US", "fr-FR"])]
public void FactMethod()
{ }
}
```