dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

Razor Language Server fails to autocomplete on Razor-specific html tag #14322

Closed SimantoR closed 4 years ago

SimantoR commented 5 years ago

Describe the bug

A clear and concise description of what the bug is. Intellisense from Razor Language Server fails when using EditForm. Not sure if its for any other type or just custom types like EditForms.

To Reproduce

Steps to reproduce the behavior:

  1. Using .NET Core SDK 3.0.100-preview5-011568 on MacOS 10.14.4 (18E227)
  2. Create a <EditForm></EditForm> tag.
  3. With cursor at ${cursor} press ctrl+space: <EditForm ${cursor}></EditForm>

Expected behavior

Expected behavior includes autocomplete for things like OnValidSubmit and Model

Screenshots

ezgif com-optimize

Razor Log:

[Error - 2:20:52 AM] Request textDocument/completion failed.
  Message: Internal Error - System.ArgumentNullException: Value cannot be null.
Parameter name: propertyName
   at Microsoft.AspNetCore.Razor.LanguageServer.TagHelperAttributeDescriptionInfo..ctor(String displayName, String propertyName, String returnTypeName, String documentation) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/TagHelperAttributeDescriptionInfo.cs:line 26
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.<>c__DisplayClass7_0.<GetAttributeCompletions>b__0(BoundAttributeDescriptor boundAttribute) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetAttributeCompletions(SyntaxNode containingAttribute, String containingTagName, String selectedAttributeName, IEnumerable`1 attributes, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetCompletionsAt(SourceSpan location, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 194
   at Microsoft.AspNetCore.Razor.LanguageServer.RazorCompletionEndpoint.Handle(CompletionParams request, CancellationToken cancellationToken) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorCompletionEndpoint.cs:line 134
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest(IHandlerDescriptor descriptor, Request request)
  Code: -32602 
[Error - 2:21:18 AM] Request textDocument/completion failed.
  Message: Internal Error - System.ArgumentNullException: Value cannot be null.
Parameter name: propertyName
   at Microsoft.AspNetCore.Razor.LanguageServer.TagHelperAttributeDescriptionInfo..ctor(String displayName, String propertyName, String returnTypeName, String documentation) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/TagHelperAttributeDescriptionInfo.cs:line 26
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.<>c__DisplayClass7_0.<GetAttributeCompletions>b__0(BoundAttributeDescriptor boundAttribute) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetAttributeCompletions(SyntaxNode containingAttribute, String containingTagName, String selectedAttributeName, IEnumerable`1 attributes, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetCompletionsAt(SourceSpan location, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 194
   at Microsoft.AspNetCore.Razor.LanguageServer.RazorCompletionEndpoint.Handle(CompletionParams request, CancellationToken cancellationToken) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorCompletionEndpoint.cs:line 134
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest(IHandlerDescriptor descriptor, Request request)
  Code: -32602 
[Error - 2:22:02 AM] Request textDocument/completion failed.
  Message: Internal Error - System.ArgumentNullException: Value cannot be null.
Parameter name: propertyName
   at Microsoft.AspNetCore.Razor.LanguageServer.TagHelperAttributeDescriptionInfo..ctor(String displayName, String propertyName, String returnTypeName, String documentation) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/TagHelperAttributeDescriptionInfo.cs:line 28
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.<>c__DisplayClass7_0.<GetAttributeCompletions>b__0(BoundAttributeDescriptor boundAttribute) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetAttributeCompletions(SyntaxNode containingAttribute, String containingTagName, String selectedAttributeName, IEnumerable`1 attributes, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetCompletionsAt(SourceSpan location, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 194
   at Microsoft.AspNetCore.Razor.LanguageServer.RazorCompletionEndpoint.Handle(CompletionParams request, CancellationToken cancellationToken) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorCompletionEndpoint.cs:line 134
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest(IHandlerDescriptor descriptor, Request request)
  Code: -32602 
[Error - 2:23:43 AM] Request textDocument/completion failed.
  Message: Internal Error - System.ArgumentNullException: Value cannot be null.
Parameter name: propertyName
   at Microsoft.AspNetCore.Razor.LanguageServer.TagHelperAttributeDescriptionInfo..ctor(String displayName, String propertyName, String returnTypeName, String documentation) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/TagHelperAttributeDescriptionInfo.cs:line 28
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.<>c__DisplayClass7_0.<GetAttributeCompletions>b__0(BoundAttributeDescriptor boundAttribute) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetAttributeCompletions(SyntaxNode containingAttribute, String containingTagName, String selectedAttributeName, IEnumerable`1 attributes, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 271
   at Microsoft.AspNetCore.Razor.LanguageServer.DefaultTagHelperCompletionService.GetCompletionsAt(SourceSpan location, RazorCodeDocument codeDocument) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultTagHelperCompletionService.cs:line 194
   at Microsoft.AspNetCore.Razor.LanguageServer.RazorCompletionEndpoint.Handle(CompletionParams request, CancellationToken cancellationToken) in /_/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorCompletionEndpoint.cs:line 134
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest(IHandlerDescriptor descriptor, Request request)
  Code: -32602 
NTaylorMullen commented 5 years ago

@SimantoR thanks for the detailed description and bug report. This is definitely something we want to fix! It looks like the description parsing logic is barfing on some of the documentation that's associated with EditForm.

@mkArtakMSFT do you have a good way to move this issue to aspnet/Razor.VSCode or should I just manually do it? Not sure how we're moving issues these days.

SimantoR commented 5 years ago

Thank you for the quick response @NTaylorMullen. I started building few internal tools with Blazor and would like this bug rooted out as best as possible. I will try to help with my limited abilities. Blazor is amazing and managing states with it is so much easier and better than the previous webapp with razor approach.

One thing I do wanna ask is, is there any plans to support browser APIs through Blazor or do we have to rely heavily on JS for those things (like camera access)?

danroth27 commented 5 years ago

@SimantoR We provide integration with browser APIs (through Mono) when they overlap with core .NET APIs, like HttpClient. The community has implement a bunch of JS interop libraries for some browser APIs that you can find on NuGet (see https://github.com/AdrienTorris/awesome-blazor#libraries--extensions for a listing). For other browser APIs you will need to write the JS interop code yourself. Mono may also generate API wrappers for the browser APIs at some future point, but that's not something we're shipping yet.

ryanbrandenburg commented 4 years ago

Just FYI @SimantoR, I sent dotnet/aspnetcore-tooling#1545 which should solve this problem going forward. Thanks again for the detailed report!