roslyn: Load roslyn version of the codestyle analyzers to fix torn load state (causes ReflectionTypeLoadException)
Version Used: 4.10.0-3.24175.2+919d4dbfb0dffb35a702417e28ceea652d248bc6
Steps to Reproduce: Trigger CSharpUseCollectionInitializerCodeFixProvider
Expected Behavior:
Fix applied
Actual Behavior:
"Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.10.10.15805, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation." string
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 32
- Comments: 44 (18 by maintainers)
I have this in VS Code since earlier this morning, after I bumped some assets. I think it was the
"C# Base language support"extension I bumped, and it’s now onv2.23.15.It’s pretty intrusive too.
Haven’t analyzed it much, but it breaks commonly used code actions, e.g.
Remove unnecessary usings.Sample:
More investigation this morning on this
get_IsParamsArrayerror… I discovered this problem is with the C# extension (I disabled my other C# Dev Kit and related extensions). The problem started happening in the2.23.15release. The previous release (2.22.5) doesn’t have the problem, so I’m going to downgrade for now.I think it’s the use of
EnforceCodeStyleInBuild. It tries to load the older version of some analyzers from packages you have loaded into vs, where they don’t abide by these changed interfaces.If you disable that, we won’t try to load them and things should hopefully be ok
17.11 is out and the issue is still not fixed. What is the ETA?
Same issue here, using latest preview of the C# DevKit (
v1.5.14 (pre-release)) and C#v2.26.13 (pre-release). I’m using Apple Silicon, .NET 8.@CyrusNajmabadi Yes this was fixed in 17.12
@canselcik See my comment above, I just edited it with a description of how to rollback the C# extension to 2.22.5 which worked for me.
I posted https://github.com/dotnet/roslyn/issues/72811#issuecomment-2248715193 just as I saw the latest round of comments and noticed that nobody had explicitly posted that on this thread.
I already understood that it is an complex issue. But again: It was done with one release and no quality check was triggered during the release process that basically all “productivity features” are broken.
This is very surprising. And obviously it is not “my setup” loading the wrong dlls, but many people’s setups loading the front dlls.
I understand that there may be no quick fix. But for me (and probably many others) a quite expensive tool lost many of its features.
And it’s not that Microsoft is just a 2 man company that struggles with manpower to maintain VS. And my opinion is still: Breaking a payed product and not fixing it for 4+ month. Especially if going back is not easy and would also require to go back in SDK version etc.
The fix is not simple. And it will take time to get working.
there is no relation on the two. fixes take the time needed to fix them. In this case due to the size and complexity of the fix, that means it takes a while.
–
Fundamentally, the issue is due to your setup loading DLLs that are not compatible with binary changes made in VS. We have no workaround on that until new versions of those DLLs ship that actually work with VS, or we mandate that we will not load dlls from your setup. These are non trivial pieces of work.
We worked around it by turning off
EnforceCodeStyleInBuildfor now.dotnet format --verify-no-changesis almost as good for us, and this issue did seem to completely disappear once we did, so I’ve been content with waiting for a fix to be done properly.This is occurring because
CodeGenerationParameterSymbolin the code style layer breaks Roslyn’s rule that the code style layer must only reference public APIs.ISymboldoes not allow public implementations:https://github.com/dotnet/roslyn/blob/0f35ec3b83a0291003bb64fd7b78de0d423d704f/src/Compilers/Core/Portable/Symbols/ISymbol.cs#L22-L23
This type must be removed from the code style layer and/or updated to no longer implement
ISymbol.