Skip to content

Warn about multiple IFactAttribute attributes#27

Merged
olstakh merged 4 commits intomainfrom
users/olstakh/analyzer-multiple-dependson
Apr 2, 2026
Merged

Warn about multiple IFactAttribute attributes#27
olstakh merged 4 commits intomainfrom
users/olstakh/analyzer-multiple-dependson

Conversation

@olstakh
Copy link
Copy Markdown
Owner

@olstakh olstakh commented Apr 2, 2026

This pull request introduces a new analyzer to the Xunit.v3.IntegrationTesting.Analyzers project that enforces correct usage of dependency attributes on test methods. It ensures that methods do not have multiple dependency attributes or mix dependency attributes with standard fact/theory attributes. The changes include the implementation of the analyzer, its diagnostic descriptors, comprehensive tests, and updates to the analyzer release notes.

Analyzer implementation and diagnostics:

  • Added MultipleDependsOnAttributeAnalyzer to detect and report when a test method has more than one attribute derived from DependsOnAttributeBase (e.g., both [FactDependsOn] and [TheoryDependsOn]) or when a dependency attribute is combined with another IFactAttribute (e.g., [Fact] or [Theory]).
  • Introduced new diagnostic descriptors XIT0015 ("Method has multiple DependsOn attributes") and XIT0016 ("Method has DependsOn attribute combined with another IFactAttribute") in AttributeUsageDescriptors.
  • Updated AnalyzerReleases.Unshipped.md to document the new diagnostics.

Testing:

  • Added comprehensive tests for the new analyzer in MultipleDependsOnAttributeAnalyzerTests, covering scenarios with multiple dependency attributes, mixing with standard fact/theory attributes, and valid attribute usage.

Development tooling:

  • Updated .vscode/settings.json to auto-approve dotnet test commands for improved developer experience.

Fixes #23

@olstakh olstakh merged commit 84ee5b3 into main Apr 2, 2026
2 checks passed
@olstakh olstakh deleted the users/olstakh/analyzer-multiple-dependson branch April 2, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Produce error when more than one *DependsOn attribute is applied on a method

1 participant