Skip to content

Commit e8d545b

Browse files
authored
Remove analyzer redirecting DLL (#51511)
1 parent ebd7dad commit e8d545b

File tree

11 files changed

+8
-394
lines changed

11 files changed

+8
-394
lines changed

documentation/general/analyzer-redirecting.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ Targeting an SDK (and hence also loading analyzers) with newer major version in
1919
2020
## Overview
2121

22-
- The SDK will contain a VSIX with the analyzer DLLs and an MEF-exported implementation of `IAnalyzerAssemblyRedirector`.
22+
- The SDK will deploy analyzer DLLs and Roslyn will deploy an implementation of `IAnalyzerAssemblyRedirector`
23+
(could be deployed by SDK but we are saving on analyzer loads and Roslyn already has a VSIX with a DLL).
2324
Implementations of this interface are imported by Roslyn and can redirect analyzer DLL loading.
2425

25-
- The SDK's implementation of `IAnalyzerAssemblyRedirector` will redirect any analyzer DLL matching some pattern
26-
to the corresponding DLL deployed via the VSIX.
26+
- That implementation of `IAnalyzerAssemblyRedirector` will redirect any analyzer DLL matching some pattern
27+
to the corresponding DLL deployed with VS.
2728
Details of this process are described below.
2829

2930
- Note that when `IAnalyzerAssemblyRedirector` is involved, Roslyn is free to not use shadow copy loading and instead load the DLLs directly.
@@ -33,7 +34,7 @@ Targeting an SDK (and hence also loading analyzers) with newer major version in
3334

3435
## Details
3536

36-
The VSIX contains some analyzers, for example:
37+
The VS deployment contains some analyzers, for example:
3738

3839
```
3940
AspNetCoreAnalyzers\analyzers\dotnet\cs\Microsoft.AspNetCore.App.Analyzers.dll
@@ -69,7 +70,7 @@ C:\Program Files\dotnet\sdk\9.0.100-preview.5.24307.3\Sdks\Microsoft.NET.Sdk\ana
6970
will be redirected to
7071

7172
```
72-
{VSIX}\SDKAnalyzers\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll
73+
{InstallDir}\SDKAnalyzers\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll
7374
```
7475

7576
where `metadata.json` has `"SDKAnalyzers": "9.0.100-dev"`, because
@@ -83,6 +84,5 @@ Analyzers that cannot be matched will continue to be loaded from the SDK
8384
### Implementation
8485

8586
Analyzer DLLs are contained in transport package `VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers`.
86-
The redirecting logic lives in "system" VS extension `Microsoft.Net.Sdk.AnalyzerRedirecting`.
8787

8888
[torn-sdk]: https://github.com/dotnet/sdk/issues/42087

sdk.slnx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
</Folder>
2525
<Folder Name="/src/">
2626
<Project Path="src/Microsoft.DotNet.TemplateLocator/Microsoft.DotNet.TemplateLocator.csproj" />
27-
<Project Path="src/Microsoft.Net.Sdk.AnalyzerRedirecting/Microsoft.Net.Sdk.AnalyzerRedirecting.csproj" />
2827
<Project Path="src/Microsoft.Net.Sdk.Compilers.Toolset/Microsoft.Net.Sdk.Compilers.Toolset.csproj" />
2928
<Project Path="src/Microsoft.Win32.Msi/Microsoft.Win32.Msi.csproj" />
3029
<Project Path="src/System.CommandLine.StaticCompletions/System.CommandLine.StaticCompletions.csproj" />
@@ -337,7 +336,6 @@
337336
<Project Path="test/Microsoft.NET.Publish.Tests/Microsoft.NET.Publish.Tests.csproj" />
338337
<Project Path="test/Microsoft.NET.Rebuild.Tests/Microsoft.NET.Rebuild.Tests.csproj" />
339338
<Project Path="test/Microsoft.NET.Restore.Tests/Microsoft.NET.Restore.Tests.csproj" />
340-
<Project Path="test/Microsoft.Net.Sdk.AnalyzerRedirecting.Tests/Microsoft.Net.Sdk.AnalyzerRedirecting.Tests.csproj" />
341339
<Project Path="test/Microsoft.NET.Sdk.BlazorWebAssembly.AoT.Tests/Microsoft.NET.Sdk.BlazorWebAssembly.AoT.Tests.csproj" />
342340
<Project Path="test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests.csproj" />
343341
<Project Path="test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj" />

src/Layout/VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers/VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.proj

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="$(RepoRoot)src\Microsoft.Net.Sdk.AnalyzerRedirecting\Microsoft.Net.Sdk.AnalyzerRedirecting.csproj" />
1514
<ProjectReference Include="..\redist\redist.csproj" />
1615
</ItemGroup>
1716

@@ -30,49 +29,29 @@
3029
<RedistRuntimeAnalyzersContent Include="$(RedistInstallerLayoutPath)packs\Microsoft.AspNetCore.App.Ref\*\analyzers\**\*.*" DeploymentSubpath="AspNetCoreAnalyzers" />
3130
<RedistRuntimeAnalyzersContent Include="$(RedistInstallerLayoutPath)sdk\*\Sdks\Microsoft.NET.Sdk\analyzers\**\*.*" DeploymentSubpath="SDKAnalyzers" />
3231
<RedistRuntimeAnalyzersContent Include="$(RedistInstallerLayoutPath)sdk\*\Sdks\Microsoft.NET.Sdk.Web\analyzers\**\*.*" DeploymentSubpath="WebSDKAnalyzers" />
33-
<RedirectingRuntimeAnalyzersContent Include="$(ArtifactsBinDir)Microsoft.Net.Sdk.AnalyzerRedirecting\$(Configuration)\net472\**\*.*" DeploymentSubpath="AnalyzerRedirecting" />
3432
</ItemGroup>
3533

3634
<Error Condition="'@(RedistRuntimeAnalyzersContent)' == ''" Text="The 'RedistRuntimeAnalyzersContent' items are empty. This shouldn't happen!" />
37-
<Error Condition="'@(RedirectingRuntimeAnalyzersContent)' == ''" Text="The 'RedirectingRuntimeAnalyzersContent' items are empty. This shouldn't happen!" />
3835

3936
<!-- The custom task cannot access %(RecursiveDir) without this. -->
4037
<ItemGroup>
4138
<RedistRuntimeAnalyzersContent Update="@(RedistRuntimeAnalyzersContent)">
4239
<CustomRecursiveDir>%(RecursiveDir)</CustomRecursiveDir>
4340
</RedistRuntimeAnalyzersContent>
44-
<RedirectingRuntimeAnalyzersContent Update="@(RedirectingRuntimeAnalyzersContent)">
45-
<CustomRecursiveDir>%(RecursiveDir)</CustomRecursiveDir>
46-
</RedirectingRuntimeAnalyzersContent>
4741
</ItemGroup>
4842

4943
<ProcessRuntimeAnalyzerVersions Inputs="@(RedistRuntimeAnalyzersContent)" MetadataFilePath="$(SdkRuntimeAnalyzersMetadataFile)">
5044
<Output TaskParameter="Outputs" ItemName="ProcessedRedistRuntimeAnalyzersContent" />
5145
</ProcessRuntimeAnalyzerVersions>
5246

5347
<ItemGroup>
54-
<RuntimeAnalyzersContent Include="@(ProcessedRedistRuntimeAnalyzersContent);@(RedirectingRuntimeAnalyzersContent)" />
48+
<RuntimeAnalyzersContent Include="@(ProcessedRedistRuntimeAnalyzersContent)" />
5549
</ItemGroup>
5650

5751
<Copy SourceFiles="@(RuntimeAnalyzersContent)"
5852
DestinationFiles="@(RuntimeAnalyzersContent->'$(OutputPath)\%(DeploymentSubpath)\%(CustomRecursiveDir)%(Filename)%(Extension)')"
5953
UseHardlinksIfPossible="true" />
6054

61-
<!-- Replace Experimental=true with SystemComponent=true in the VS extension manifest. -->
62-
<PropertyGroup>
63-
<_VsixNamespace>
64-
<Namespace Prefix="pm" Uri="http://schemas.microsoft.com/developer/vsx-schema/2011" />
65-
</_VsixNamespace>
66-
</PropertyGroup>
67-
<XmlPoke XmlInputPath="$(OutputPath)\AnalyzerRedirecting\extension.vsixmanifest"
68-
Namespaces="$(_VsixNamespace)"
69-
Query="/pm:PackageManifest/pm:Installation/@Experimental"
70-
Value="false" />
71-
<XmlPoke XmlInputPath="$(OutputPath)\AnalyzerRedirecting\extension.vsixmanifest"
72-
Namespaces="$(_VsixNamespace)"
73-
Query="/pm:PackageManifest/pm:Installation/@SystemComponent"
74-
Value="true" />
75-
7655
<GenerateRuntimeAnalyzersSWR RuntimeAnalyzersLayoutDirectory="$(OutputPath)"
7756
OutputFile="$(SdkRuntimeAnalyzersSwrFile)" />
7857

src/Microsoft.Net.Sdk.AnalyzerRedirecting/AnalyzerRedirectingPackage.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Microsoft.Net.Sdk.AnalyzerRedirecting/Microsoft.Net.Sdk.AnalyzerRedirecting.csproj

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Microsoft.Net.Sdk.AnalyzerRedirecting/SdkAnalyzerAssemblyRedirector.cs

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/Microsoft.Net.Sdk.AnalyzerRedirecting/source.extension.vsixmanifest

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Tasks/sdk-tasks/GenerateRuntimeAnalyzersSWR.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ public override bool Execute()
2929
"metadata.json",
3030
]);
3131

32-
AddFolder(sb,
33-
"AnalyzerRedirecting",
34-
@$"{installDir}\AnalyzerRedirecting",
35-
filesToInclude:
36-
[
37-
"Microsoft.Net.Sdk.AnalyzerRedirecting.dll",
38-
"Microsoft.Net.Sdk.AnalyzerRedirecting.pkgdef",
39-
"extension.vsixmanifest",
40-
]);
41-
4232
AddFolder(sb,
4333
"AspNetCoreAnalyzers",
4434
@$"{installDir}\AspNetCoreAnalyzers");

0 commit comments

Comments
 (0)