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

With "enableAnalyzersSupport': true, System.InvalidOperationException: Unable to load Microsoft.Extensions.Logging.Generators #2648

Open
sin-ack opened this issue Jan 13, 2025 · 1 comment

Comments

@sin-ack
Copy link

sin-ack commented Jan 13, 2025

System information

OS: Gentoo Linux 2.17 amd64 (x86_64-pc-linux-gnu)
.NET versions:

  • 8.0.107 (active)
  • 9.0.101

OmniSharp version: 1.39
Editor: Emacs 30.0.92
Language Server Client: lsp-mode
Project Package Manager: Paket 9.0.2
Project .NET Version: .NET 8.0

Expected behavior

Hovering over analyzer-generated diagnostics and attempting to apply code fixes should work without errors.

Actual behavior

I decided to try out "RosylnExtensionsOptions": {"enableAnalyzersSupport": true}. It works fine most of the time, however when I hover over an IDE warning generated by such an analyzer, I get the following in my messages area. Example diagnostic with this error: IDE0290.

Error message

Error from the Language Server: Internal Error - System.InvalidOperationException: Unable to load Microsoft.Extensions.Logging.Generators
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Generators, Version=8.0.10.46610, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.Extensions.Logging.Generators, Version=8.0.10.46610, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|49_0(NativeAssemblyNameParts* __pAssemblyNameParts_native, ObjectHandleOnStack __requestingAssembly_native, StackCrawlMarkHandle __stackMark_native, Int32 __throwOnFileNotFound_native, ObjectHandleOnStack __assemblyLoadContext_native, ObjectHandleOnStack __retAssembly_native)
   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at System.AppDomain.Load(AssemblyName assemblyRef)
   at Microsoft.CodeAnalysis.AnalyzerAssemblyLoader.Load(AssemblyName assemblyName, String assemblyOriginalPath)
   at Microsoft.CodeAnalysis.AnalyzerAssemblyLoader.LoadFromPath(String originalAnalyzerPath)
   --- End of inner exception stack trace ---
   at Microsoft.CodeAnalysis.AnalyzerAssemblyLoader.LoadFromPath(String originalAnalyzerPath)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetAssembly()
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c__DisplayClass6_0.<LoadFrom>b__0(AnalyzerFileReference analyzerFileReference) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 64
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 166
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 139
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 133
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 85
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpCodeActionHandler.cs:line 70
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() (Internal Error)
@sin-ack
Copy link
Author

sin-ack commented Jan 13, 2025

I tried to build OmniSharp to see whether I could figure out what path it was trying to load that was causing this error but I'm having a lot of trouble getting Cake to cooperate. Is there a way to avoid publishing every single version and just run the latest .NET version for debugging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant