Giter Site home page Giter Site logo

Comments (9)

per-samuelsson avatar per-samuelsson commented on June 19, 2024 9

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.

from roslyn.

kylepope-ge avatar kylepope-ge commented on June 19, 2024 5

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.

from roslyn.

sharwell avatar sharwell commented on June 19, 2024 1

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.

from roslyn.

abbottdev avatar abbottdev commented on June 19, 2024 1

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]

from roslyn.

CyrusNajmabadi avatar CyrusNajmabadi commented on June 19, 2024

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.

from roslyn.

AnthonyMastrean avatar AnthonyMastrean commented on June 19, 2024

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.

from roslyn.

kylepope-ge avatar kylepope-ge commented on June 19, 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]

from roslyn.

Tum4ik avatar Tum4ik commented on June 19, 2024

I have the same problem when trying to get SyntaxGenerator for my source generation purposes.
The creation of AdhocWorkspace causes the exception:

try
{
  var syntaxGenerator = SyntaxGenerator.GetGenerator(new AdhocWorkspace(), LanguageNames.CSharp);
}
catch (ReflectionTypeLoadException e)
{
  throw;
}

from roslyn.

sharwell avatar sharwell commented on June 19, 2024

@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.

from roslyn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.