MoveToGlobalUsingsAnalyzer 1.0.1
See the version list below for details.
dotnet add package MoveToGlobalUsingsAnalyzer --version 1.0.1
NuGet\Install-Package MoveToGlobalUsingsAnalyzer -Version 1.0.1
<PackageReference Include="MoveToGlobalUsingsAnalyzer" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add MoveToGlobalUsingsAnalyzer --version 1.0.1
#r "nuget: MoveToGlobalUsingsAnalyzer, 1.0.1"
// Install MoveToGlobalUsingsAnalyzer as a Cake Addin #addin nuget:?package=MoveToGlobalUsingsAnalyzer&version=1.0.1 // Install MoveToGlobalUsingsAnalyzer as a Cake Tool #tool nuget:?package=MoveToGlobalUsingsAnalyzer&version=1.0.1
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
- 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.
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.