dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.06k stars 4.69k forks source link

Fix RS1038 related warnings found in Interop source generators #88701

Open buyaa-n opened 1 year ago

buyaa-n commented 1 year ago

Fix warnings found with RS1038 analyzer

Recent analyzer updates flown to the runtime repo having build failures related to RS1038: Compiler extensions should be implemented in assemblies with compiler-provided references. The warnings looks valid and needs a proper fix, for now they are suppressed.

Sample log:

warning RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably.

Related to https://github.com/dotnet/runtime/pull/87768 CC @jkoritzinsky

ghost commented 1 year ago

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

Issue Details
## Fix warnings found with RS1038 analyzer Recent analyzer updates flown to the runtime repo having build failures related to `RS1038: Compiler extensions should be implemented in assemblies with compiler-provided references`. The warnings looks valid and needs a proper fix, for now they are suppressed. Sample log: ```log warning RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. ``` Related to https://github.com/dotnet/runtime/pull/87768 CC @jkoritzinsky
Author: buyaa-n
Assignees: -
Labels: `area-System.Runtime.InteropServices`
Milestone: -
jkoritzinsky commented 1 year ago

This is due to the interop analyzers putting analyzers and code fixes into the same assembly. It looks like we need to split them into separate assemblies for the re-written RS1038 rule to be satisfied. Moving to .NET 9 as this is more infra work than anything else (as we're careful to not use the workspaces APIs in the analyzer or generator code).