Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine why analyzers are running on generated not supported assemblies auto-generated files #84104

Open
stephentoub opened this issue Mar 30, 2023 · 4 comments
Labels
area-Infrastructure-libraries tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone

Comments

@stephentoub
Copy link
Member

Our root .editorconfig lists *.notsupported.cs as being consider auto-generated, but for some reason that .editorconfig isn't being passed to csc when building those assemblies, e.g. Microsoft.Win32.Registry. As a result, analyzers are running on the auto-generated .notsupported.cs file there.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Mar 30, 2023
@ghost
Copy link

ghost commented Mar 30, 2023

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

Our root .editorconfig lists *.notsupported.cs as being consider auto-generated, but for some reason that .editorconfig isn't being passed to csc when building those assemblies, e.g. Microsoft.Win32.Registry. As a result, analyzers are running on the auto-generated .notsupported.cs file there.

Author: stephentoub
Assignees: -
Labels:

area-Infrastructure-libraries

Milestone: -

@ViktorHofer
Copy link
Member

ViktorHofer commented Apr 12, 2023

Roslyn's msbuild targets auto-discover editorconfig files based on the compile items defined: https://github.com/dotnet/roslyn/blob/3b23723934d3c7d0b3c1a0165def4a7f0e6e3a19/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets#L125-L140

TFMs that are pure PNSEs don't have any compile items defined at evaluation time. The compile item that is generated by GenFacades which is called NotSupported.cs doesn't exist at evaluation time and hence the logic is skipped.

To fix this for PNSE projects (which are a dotnet/runtime only concept), we could trigger the auto-discovery based on the project file instead. That could be accomplished here: https://github.com/dotnet/arcade/blob/17d9eee32f20a6af0ebb620254a22f601d159578/src/Microsoft.DotNet.GenFacades/build/Microsoft.DotNet.GenFacades.NotSupported.targets#L20

@carlossanlop @ericstj this is another refcount on issues with our PNSE custom infrastructure (in addition to the /// xml comment source of truth issue with PNSEs).

@ViktorHofer
Copy link
Member

ViktorHofer commented Apr 13, 2023

Filed dotnet/roslyn#67793 as the auto-discovery doesn't work either for projects which define their compile items outside of the project file, in a Directory.Build.targets file. Adding the tracking-external-issue label.

@ViktorHofer ViktorHofer added tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly and removed untriaged New issue has not been triaged by the area owner labels Apr 13, 2023
@ViktorHofer ViktorHofer added this to the Future milestone Apr 13, 2023
@stephentoub
Copy link
Member Author

Thanks, @ViktorHofer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-libraries tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Projects
None yet
Development

No branches or pull requests

2 participants