Microsoft.CodeAnalysis.BannedApiAnalyzer
1.0.0-beta.5
I would like to set the diagnostic severity of my banned types case by case.
Is that possible or does anybody know a way? I don't mind using some hack.
In the archived wiki readme it syas
The severity of individual rules may be configured using rule set files in Visual Studio 2015 or newer. See Configuration.md for more information.
It's unclear if it means each individual banned symbol rule, or just the usaual analzyer rules with a .ruleset or .editorconfig file.
Also the link pointing to "Configuration.md" is broken.
@rtnlmeme-DestroyerOfDeath You can only configure the rule severity per project, not per symbol.
@mavasani This is one more request toward having per symbol severity, I don't know how hard this would be (and I know this is on roslyn's side) but that might be interesting to investigate.
This is duplicate of https://github.com/dotnet/roslyn/issues/27712, which @sharwell is driving.
@Evangelink We can work around by defining a new option that allows fine grained configuration, but it seems better to wait for https://github.com/dotnet/roslyn/issues/27712 and report sub-diagnostics with different sub-ID per banned type to get this functionality.
Ah thanks for the replies!
I forked the repo and hacked support for it
scratch commit: (not build etc)
https://github.com/rtnlmeme-DestroyerOfDeath/BannedApiAnalyzer/tree/feature/seperate_warn_levels
you can now define symbols like:
symbol;message;warnLevel
check the DOCUMENTATION.md of that branch, I describe it there.
Thanks @rtnlmeme-DestroyerOfDeath. Unfortunately, analyzer specified diagnostic severity will be overridden by compiler if user configured the ID. Your solution will work for majority of cases, but it would be a much better and complete solution to support this via sub-diagnostics feature.
Offtopic:
How would you generate those docstring ids?
I found the doc string id class.
But do I have to do the shennanigans of compiling my project, and getting the symbol by metaDataName?
Offtopic:
How would you generate those docstring ids?
You can enable XML doc comments for your project, add a dummy xml doc comment to the relevant symbol, if one does not exist, and then build the project. This should output an xml comments file with doc comment ID of the symbol.
You can enable XML doc comments for your project, add a dummy xml doc comment to the relevant symbol, if one does not exist, and then build the project. This should output an xml comments file with doc comment ID of the symbol.
You compiling with csc and the -doc option, right? Seems to work nicely, yea.
How would you achieve generating them let's say for all the methods in the System.Linq.Enumerable class?
What I would do now is putting my own dummy class and copy the linq code in there.
Is there some generic way for that?
Most helpful comment
This is duplicate of https://github.com/dotnet/roslyn/issues/27712, which @sharwell is driving.