Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Import code actions don't work on net8.0 projects with aspnet core #2586

Closed
jacekjarosz55 opened this issue Nov 17, 2023 · 8 comments · Fixed by #2588
Closed

Import code actions don't work on net8.0 projects with aspnet core #2586

jacekjarosz55 opened this issue Nov 17, 2023 · 8 comments · Fixed by #2588

Comments

@jacekjarosz55
Copy link

Tested on both windows and linux on 8.0.100

@jacekjarosz55
Copy link
Author

jacekjarosz55 commented Nov 17, 2023

[ERROR][2023-11-17 13:23:03] ...lsp/handlers.lua:535	"OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/codeAction 84 - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c.<LoadFrom>b__6_0(AnalyzerFileReference analyzerFileReference) in D:\\a\\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 D:\\a\\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 D:\\a\\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 D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Refactoring\\V2\\BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Refactoring\\V2\\BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Refactoring\\V2\\BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Refactoring\\V2\\BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Refactoring\\V2\\GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in D:\\a\\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()
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' | Method='textDocument/codeAction' RequestId='84'"

@JoeRobich
Copy link
Member

Could not load file or assembly 'Microsoft.CodeAnalysis.ExternalAccess.AspNetCore, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

@333fred We recently started shipping the Razor EA lib. Does this error mean we should be shipping the AspNet EA lib as well?

@JoeRobich
Copy link
Member

@jacekjarosz55 What version of O# are you running? Also, which dotnet project template would I want to use to reproduce this issue?

@333fred
Copy link
Contributor

333fred commented Nov 21, 2023

I wasn't expecting us to need to. @dibarbet, does the roslyn lsp include that assembly?

@dibarbet
Copy link
Contributor

@333fred It didn't previously, but I just sent out dotnet/roslyn#70927 otherwise route embedded language features don't work.

@333fred
Copy link
Contributor

333fred commented Nov 22, 2023

So I guess the answer, @JoeRobich, is yes, O# needs to do that too.

@jacekjarosz55
Copy link
Author

jacekjarosz55 commented Nov 22, 2023

@jacekjarosz55 What version of O# are you running? Also, which dotnet project template would I want to use to reproduce this issue?

latest release (v1.39.10)

my template was dotnet new webapi --use-controllers

@jacekjarosz55 jacekjarosz55 changed the title Import code actions don't work on net8.0 projects Import code actions don't work on net8.0 projects with aspnet core Dec 5, 2023
@Green0wl
Copy link

Green0wl commented Dec 9, 2023

exactly the same error when switching to .net8.
if you set something like

{
    "sdk": {
        "path": "/usr/local/share/dotnet/sdk/6.0.403/",
        "version": "6.0.403"
    }
}

, as you have in the wiki with versions .net6 or .net7, the imports start working correctly.

logs: https://pastebin.com/6KMr3XDp

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

Successfully merging a pull request may close this issue.

5 participants