MoveToGlobalUsingsAnalyzer 1.2.2
See the version list below for details.
dotnet add package MoveToGlobalUsingsAnalyzer --version 1.2.2
NuGet\Install-Package MoveToGlobalUsingsAnalyzer -Version 1.2.2
<PackageReference Include="MoveToGlobalUsingsAnalyzer" Version="1.2.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add MoveToGlobalUsingsAnalyzer --version 1.2.2
#r "nuget: MoveToGlobalUsingsAnalyzer, 1.2.2"
// Install MoveToGlobalUsingsAnalyzer as a Cake Addin #addin nuget:?package=MoveToGlobalUsingsAnalyzer&version=1.2.2 // Install MoveToGlobalUsingsAnalyzer as a Cake Tool #tool nuget:?package=MoveToGlobalUsingsAnalyzer&version=1.2.2
GlobalUsingsAnalyzer
This is a analyzer and code fix provider for C# that moves usings from the file they are used to a file called Usings.cs.
Usage
- Install the nuget package https://www.nuget.org/packages/MoveToGlobalUsingsAnalyzer
- The code fix will appear as a lightbulb with action 'Move to Global Usings' next to using statement, or you can use the Fix all button to fix all occurrences in the document at once.
Configuration
.editorconfig
- dotnet_diagnostic.global_usings.severity = suggestion
- dotnet_diagnostic.global_usings.file_name = Usings.cs
Versions - features
v1.0.0
Move to Global Usings
v1.1.0
Support for .editorconfig - severity and file name
v1.2.0
CodeFix CS0246
Implementation
CodeFixProvider
The GlobalUsingsAnalyzerCodeFixProvider class is responsible for providing the code fix. It contains the following methods:
- FixableDiagnosticIds: Returns the diagnostic IDs that this provider can fix.
- GetFixAllProvider: Returns a FixAllProvider that can handle the Fix all button.
- RegisterCodeFixesAsync: Registers the code fix action for each diagnostic.
The code fix is implemented in the ReplaceUsingWithGlobalAsync method, which takes the document, the using directive syntax node, and a cancellation token as parameters. It first removes the using directive from the original file and adds it to the Usings.cs file, creating the file if it does not exist. It then returns the updated solution.
GlobalUsingsFixAllProvider
The GlobalUsingsFixAllProvider is the class that handle the Fix All button.
CodeFixResources
The CodeFixResources is a class that contains the title of the code fix action.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on MoveToGlobalUsingsAnalyzer:
Repository | Stars |
---|---|
KUTlime/Stock-value
> A minimal, non-syntetic, clean architecture, modern C# 11 syntax, feature rich demo application for checking stock prices.
|
Summary of changes made in this release of the package.