Skip to content

Removing Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler #71024

@jaredpar

Description

@jaredpar

This external access DLL was added to allow experimentation between compiler and the razor source generator. The external access approach was chosen because it was a proven method in other parts of the Roslyn code base and seemed like a good fit for the compiler.

After our experiences in 17.8 around ABI changes though we've discovered this is not a good fit for the compiler. The compiler does not own it's deployment, instead it's deployed / hosted by a number of applications: VS, VS Code, Workspaces, dotnet format, etc ... All of these hosts now must be aware of and ship a copy of the MS.CA.EA.RazorCompiler DLL. This DLL is not part of the core NuGet package set which means the hosts must find the correct version and keep it up to date with the compiler (version mismatches can fail due to IVT differences). This leads to a very fragile deployment model and it bit us many times during the 17.8 release cycle.

Going forward the compiler will likely use reflection or possibly [Experimental] for future experiments. In the short term though our desire is to remove this DLL from our deployments. To do this we're going to take the following measures:

17.9

  • Publish the MS.CA.EA.RazorCompiler NuPkg to nuget.org so existing hosts have a place to download the 4.8.0 compatible version.
  • Take the APIs that exist in MS.CA.EA.RazorCompiler today and move them into a new type in MS.CA under the namespace Microsoft.CodeAnalysis.Experimental. These APIs will be internal.
  • Change the MS.CA.EA.RazorCompiler assembly to point their implementation to those methods. At this point the MS.CA.EA.RazorCompiler assembly is just a shell that redirects method calls into MS.CA.
  • Change the razor source generator to use reflection to access the APIs inside of MS.CA.EA. If those APIs do not exist then fall back to calling MS.CA.EA.RazorCompiler. This fallback is necessary for situations where the razor source generator from 17.9 is run on the 17.8 compiler.

17.10

  • Delete MS.CA.EA.RazorCompiler entirely from razor. From here on out it will use reflection to grab the experimental API.
  • Delete the MS.CA.EA.RazorCompiler project from roslyn

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions