-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load roslyn version of the codestyle analyzers to fix torn load state (causes ReflectionTypeLoadException) #72811
Comments
This is occurring because roslyn/src/Compilers/Core/Portable/Symbols/ISymbol.cs Lines 22 to 23 in 0f35ec3
This type must be removed from the code style layer and/or updated to no longer implement |
That's not the case. Isymbol does not allow 3rd party impls. It allows first party impls. I know, I created it for that purpose :-) When this interface was updated, we appropriately updated all our apis. We need to ship that updated API now. |
I have this in VS Code since earlier this morning, after I bumped some assets. I think it was the It's pretty intrusive too. Haven't analyzed it much, but it breaks commonly used code actions, e.g. Sample:
|
Same issue here, using latest preview of the C# DevKit (
|
Affects the misplaced using directives quick fix / code action, too.
|
I have been having this exact problem on my M1 Mac as well. Happens on pretty much any codeAction which makes those unable to be used entirely. I'm using Visual Studio Code
|
More investigation this morning on this |
I have the same problem when trying to get SyntaxGenerator for my source generation purposes. try
{
var syntaxGenerator = SyntaxGenerator.GetGenerator(new AdhocWorkspace(), LanguageNames.CSharp);
}
catch (ReflectionTypeLoadException e)
{
throw;
} |
@Tum4ik Yours is a separate issue even if it's the same exception. It's caused by attempting to load a different version of Microsoft.CodeAnalysis.dll from the version of Microsoft.CodeAnalysis.Workspaces.dll, which is not supported. |
what is the workaround? |
There is no workaround currently. These features are currently broken even for ourselves. |
@mcallaghan-geotab I have Visual Studio 17.9 on my another PC, I didn't update that to 17.10 and I don't have the problem there. But @sharwell mentioned I have a different problem. Who knows... maybe you can downgrade to 17.9. |
(experiencing the problem in Rider fwiw - not visual studio) |
Updating |
I posted #72811 (comment) just as I saw the latest round of comments and noticed that nobody had explicitly posted that on this thread. |
That slipped through. Thanks! |
17.11 is out and the issue is still not fixed. What is the ETA? |
Having the same issue. tried modifying the sstyle packages and it is a no go. Momentarily using copilot as well to do code checks if needed, but can't use the quick tools for code cleanup on the UI of vscode. |
The bug here is that That's a binary breaking change. It will break anyone that implemented To workaround this you need to update the assembly that contains the type implementing |
The attached repro demonstrates this binary-breaking change: <ItemGroup>
<!-- compile against older CodeAnalysis -->
<PackageDownload Include="Microsoft.CodeAnalysis.Common" Version="[4.8.0]" />
<Reference Include="$(NuGetPackageRoot)\microsoft.codeanalysis.common\4.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll" />
<!-- run against newer one -->
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.11.0" ExcludeAssets="Compile"/>
</ItemGroup> var mySymbol = new MyParameterSymbol();
Console.WriteLine(((IParameterSymbol)mySymbol).Name);
#pragma warning disable RS1009 // suppress the warning to repro components allowed to implement IParameterSymbol
public class MyParameterSymbol : IParameterSymbol
{
// IParameterSymbol implementation
}
#pragma warning restore RS1009 run it:
|
The only supported scenario (currently) is using a version of Roslyn sdk built against the version of Roslyn your ide uses. We are working on making it so this requirement is no longer in place. But it will change such that it is irrelevant which version you reference. You will get the version in your ide. |
@CyrusNajmabadi I believe you mean "a version of .NET SDK where the built-in Roslyn version matches the version of Roslyn your IDE uses". When using the Roslyn SDK, e.g. for creating an analyzer or source generator, this limitation does not apply to the chosen Roslyn SDK version. |
@sharwell Can we have the design time build disable |
This thread has been spiraling since March 29th. Are there concrete plans for a fix here soon?
Today I learned you can right-click an extension and choose "Install Specific Version" to roll back to a much wider selection of releases, very cool. I can confirm that rolling back to 2.22.5 solved this for me as a temp workaround. |
The fix is in progress here #75250 |
Added Basically everything worked fine until I had to touch this thing called Entity Framework. I don't even want to use Entity Framework.
|
@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. |
That worked, I appreciate it. The UI definitely doesn't help the situation. |
@sharwell is this complete? If not, waht is left to be done? |
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
The text was updated successfully, but these errors were encountered: