Is there any way to disable a specific C# 9 source generator? Or alternatively disable them all?
the package in question is https://github.com/Husqvik/GraphQlClientGenerator#c-9-source-generator which is mean to be able to be used as both a lib and a source generator. but those are mutually exclusive, ie the majority of use cases it make no sense to gen code both by executing code and by code gen
To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.
I have seen this queston: Is it possible to disable specific compiler warnings? but it is for Visual studio, not Visual Studio Code. 1. Solution Explorer > View > Properties > Build > Suppress Warnings
That can happen if your application is deployed on multiple OSes, or if you write a library for the general population of C++ programmers. This is where the fun begins. Since disabling warnings is done at the level of the pre-processor, we’re going to need a macro.
#pragma warning( pop ) And to disable a specific warning, we need to write code like this: #pragma warning( disable : 4100 ) Remember, in Visual Studio warnings are identified with numbers, not names. If we have to suppress the warning in our example code on Visual Studio, we would write this:
seems this will disable all
<Target Name="DisableAnalyzers"
BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
removing a named one uses the file path
<Target Name="DisableAnalyzers"
BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="D:\nugets\nugetx\0.9.2\analyzers\dotnet\cs\NugetXAnalizer.dll" />
</ItemGroup>
</Target>
ok and finally u can remove based on filename
<Target Name="DisableAnalyzers"
BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)"
Condition="'%(Filename)' == 'NugetXAnalizer'"/>
</ItemGroup>
</Target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With