-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Prevent analyzer/generator authors from using banned APIs #63290
Copy link
Copy link
Closed
Description
We want to leverage BannedApiAnalyzer to try and prevent analyzer/generator authors from using APIs known to be problematic.
We'd like to include BannedSymbols.txt in Microsoft.CodeAnalysis.nupkg and have projects which reference it automatically pick it up and enforce the bans in a "downstream" fashion. It looks like BannedApiAnalyzer might be tooled toward having the BannedSymbols.txt only in the consuming project, so modifications to the analyzer or the build authoring might be needed.
Some APIs we'd like to ban:
- System.IO.File. Basically all file I/O.
- System.IO.Directory.
- System.IO.Path.GetTempPath. Other stuff in Path is fine, like GetFileName, etc.
- System.Environment. Analyzers should not read their settings directly from environment variables.
- Assembly.Load and similar APIs.
- CurrentUICulture. Should look at CommandLineArguments instead. This can come in implicitly through things like string.ToLower but we're probably not going to go searching exhaustively for things like that at this point.
Reactions are currently unavailable