Skip to content
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

ReflectionTypeLoadException: CodeGenerationParameterSymbol.get_IsParamsArray #72811

Open
amcasey opened this issue Mar 29, 2024 · 7 comments
Open
Assignees
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Milestone

Comments

@amcasey
Copy link
Member

amcasey commented Mar 29, 2024

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

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 29, 2024
@sharwell
Copy link
Member

sharwell commented Mar 29, 2024

This is occurring because CodeGenerationParameterSymbol in the code style layer breaks Roslyn's rule that the code style layer must only reference public APIs. ISymbol does not allow public implementations:

[InternalImplementationOnly]
public interface ISymbol : IEquatable<ISymbol?>

This type must be removed from the code style layer and/or updated to no longer implement ISymbol.

@sharwell sharwell added Bug Area-IDE IDE-CodeStyle Built-in analyzers, fixes, and refactorings and removed Area-Compilers labels Mar 29, 2024
@CyrusNajmabadi
Copy link
Member

ISymbol does not allow public implementations:

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.

@per-samuelsson
Copy link

per-samuelsson commented Apr 3, 2024

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 on v2.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:

[Error - 9:56:18 AM] [LanguageServerHost] System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.9.10.6718, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
   at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.MefHostExportProvider.Create(String languageName)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices..ctor(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.Create(HostLanguageServices hostLanguageServices)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryImports.AbstractRemoveUnnecessaryImportsCodeFixProvider.RemoveUnnecessaryImportsAsync(Document document, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 350
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 304
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.GetOperationsCoreAsync(Solution originalSolution, IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 241
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActionResolveHandler.HandleRequestAsync(CodeAction codeAction, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs:line 92
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
System.TypeLoadException: Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.9.10.6718, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

@abbottdev
Copy link

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.

Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.9.10.12906, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
   at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.MefHostExportProvider.Create(String languageName)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices..ctor(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.Create(HostLanguageServices hostLanguageServices)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryImports.AbstractRemoveUnnecessaryImportsCodeFixProvider.RemoveUnnecessaryImportsAsync(Document document, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 356
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 310
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.GetOperationsCoreAsync(Solution originalSolution, IProgress`1 progress, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 247
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActionResolveHandler.HandleRequestAsync(CodeAction codeAction, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs:line 92
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 150
System.TypeLoadException: Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.9.10.12906, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
[Error - 15:16:11] Request codeAction/resolve failed.
  Message: Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.9.10.12906, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
  Code: -32000 
[object Object]

@AnthonyMastrean
Copy link

Affects the misplaced using directives quick fix / code action, too.

[Error - 3:13:33 PM] [LanguageServerExtensionManager] Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives.MisplacedUsingDirectivesCodeFixProvider threw an exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.7.9.1717, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
   at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.MefHostExportProvider.Create(String languageName)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices..ctor(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.Create(HostLanguageServices hostLanguageServices)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
   at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices)
   at Microsoft.CodeAnalysis.CodeActions.CSharpCodeFixOptionsProviders.GetCSharpCodeFixOptionsProviderAsync(Document document, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives.MisplacedUsingDirectivesCodeFixProvider.RegisterCodeFixesAsync(CodeFixContext context)
   at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(TextDocument document, TextSpan span, CodeFixProvider fixer, CodeChangeProviderMetadata fixerMetadata, CodeActionOptionsProvider fallbackOptions, ImmutableArray`1 diagnostics, Dictionary`2 uniqueDiagosticToEquivalenceKeysMap, Dictionary`2 diagnosticAndEquivalenceKeyToFixersMap, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs:line 661
   at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](IExtensionManager extensionManager, Object extension, Func`2 function, T defaultValue, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/ExtensionManager/IExtensionManagerExtensions.cs:line 84
System.TypeLoadException: Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.7.9.1717, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

@kylepope-ge
Copy link

kylepope-ge commented May 9, 2024

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 1.89.0, C# extension 2.28.11, C# Dev Kit extension 1.5.20. Error messages look like the following every time:

[Error - 9:38:55 AM] Request codeAction/resolve failed.
  Message: Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.CodeStyle.Fixes, Version=4.8.9.2411, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
  Code: -32000 
[object Object]

@kylepope-ge
Copy link

More investigation this morning on this get_IsParamsArray error... I discovered this problem is with the C# extension (I disabled my other C# Dev Kit and related extensions). The problem started happening in the 2.23.15 release. The previous release (2.22.5) doesn't have the problem, so I'm going to downgrade for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
None yet
Development

No branches or pull requests

8 participants