Skip to content

Prevent analyzer/generator authors from using banned APIs #63290

@RikkiGibson

Description

@RikkiGibson

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions