Analyzers do not work with GlobalUsings
See original GitHub issueDescription
When using global usings, analyzers no longer report any diagnostics.
Expected behavior:
Be able to use global usings, either:
- From a source file
GlobalUsings.cs
that contains:
with the next snippet in project file:global using Xunit; global using FluentAssertions;
<ItemGroup> <Compile Include="GlobalUsings.cs" /> </ItemGroup>
- From project file directly:
<ItemGroup> <Using Include="FluentAssertions" /> <Using Include="Xunit" /> </ItemGroup>
Versions
- Fluent Assertions: 6.7.0
- Fluent Assertions Analyzers: 0.17.2
- .NET 6
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
c# - Why does StyleCopAnalyzers think that global usings ...
Why does StyleCopAnalyzers think that global usings should be declared within a namespace, when such syntax is not possible?
Read more >IDE0065: Global usings must not be places inside ...
Steps to Reproduce: Add a Usings.cs with following code. global using System.Text;. Run dotnet format. Expected Behavior: Expected to format to ...
Read more >GlobalUsingsAnalyzer 1.4.0
A C# analyzer that will suggest moving usings to a single project file. Defaults to GlobalUsings.cs but can be changed using a .editorconfig...
Read more >Welcome to C# 10 - .NET Blog
The scope of global usings is the current compilation, which generally corresponds to the current project. For more information, see global ...
Read more >Project property settings in Visual Studio - .NET MAUI
Describes the Visual Studio project properties available to a .NET MAUI app. The properties and settings are related to building the app, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another source for inspiration: The Sonar analyzer for S2699: Tests should include assertions, which supports xUnit and FluentAssertions. These analyzers are widely-used and optimized for high performance in large codebases. Source code at https://github.com/SonarSource/sonar-dotnet/blob/18eb2f6d6c4655f8b259744ef210347d12ce8b94/analyzers/src/SonarAnalyzer.CSharp/Rules/TestMethodShouldContainAssertion.cs.
Thanks for the fix, this is working correctly now.