Skip to content

Improvements to single-file analysis #44488

@agocke

Description

@agocke

The existing single-file analyzer covers the top issues customers will likely hit with single-file, but it has some shortcomings.

Goals

  • Single-file analyzer is moved next to the trimming analyzer in the mono/linker repo
  • Single-file analyzer is enabled in the dotnet/runtime repo to identify problems in the framework
  • Users can annotate their own APIs as being not compatible with single-file

Work

  • Add an attribute similar to RequiresUnreferencedCode (code, ref assemblies)
  • Annotate low-level APIs with the attribute - One more run over all "dangerous" APIs
    • Make sure that the attributes show up in ref assemblies.
    • Validate that the ref assembly validator in dotnet/runtime enforces inclusion of this attribute (we had issues with this for RequiresUnreferencedCode)
  • At least plan on adding a docs page on the topic with some thoughts/guides on how to “fix” – ideally link to this from the attributes (see https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file#api-incompatibility)
  • Synchronize with mono/Xamarin to annotate low level APIs which are problematic because of mono/Xamarin single-bundle publishing (mono itself can do a single-file bundle similar to CoreCLR's single-file, but Xamarin has other single-file like bundles for devices - Android, iOS).
  • Improve existing Roslyn analyzer
    • Move the analyzer next to the trimming analyzer in the mono/linker repo
    • Support for the new attribute
      • Implicit suppression on annotated methods
  • Integrate the analyzers with SDK - probably conditioned on PublishSingleFile property - warnings on-by-default??? (they already are for user code, what about whole-program analysis done by linker)
  • Enable Roslyn analyzer on dotnet/runtime repo (similar to TrimAnalysis) - probably add baselines as well (not sure how to do baselines for Roslyn analyzer - .cs file with SuppressMessage attributes which will be removed by compilation?)
  • Go over reported warnings from within the framework in dotnet/runtime and “do something about them” (suppress, propagate to public API via attributes)
    • Ideally also look through other features which might be affected by single-file and annotate
  • ?? Run the analysis on higher-level frameworks – ASP.NET, WinForms, WPF and file issues as appropriate

Metadata

Metadata

Assignees

Labels

Priority:0Work that we can't release withouttrackingThis issue is tracking the completion of other related issues.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions