roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

ProjectSystemProject.UpdateProjectAnalyzerReferences is causing I/O under a lock

Open jasonmalinowski opened this issue 10 months ago • 0 comments

ProjectSystemProject.UpdateProjectAnalyzerReferences has this line:

https://github.com/dotnet/roslyn/blob/a89e286de3a509dd1d96db7d7e131a0c10a77917/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs#L830

The constructor for AnalyzerFileReference calls IAnalyzerAssemblyLoader.AddDependencyLocation, which does a bunch of I/O to read the assembly from disk to check its assembly name. This is happening under the main workspace lock which can slow things down during solution load. I see a few possible fixes:

  1. Have the work in AnalyzerAssemblyLoader.AddDependencyLocation be lazy until the first time a load actually happens.
  2. Just use a no-op implementation of IAnalyzerAssemblyLoader, since at this point we don't expect to be loading analyzers at all in-process.

jasonmalinowski avatar Jun 17 '25 19:06 jasonmalinowski