Rhetos / LanguageServices

Visual Studio IntelliSense for Rhetos.
Other
1 stars 0 forks source link

Duplicate DSL error in Error List tab in Visual Studio #14

Open bantolov opened 2 years ago

bantolov commented 2 years ago

For example, after adding "qwe" at the beginning of a DSL script, building the project will result with 2 errors in Error List tab in Visual Studio:

Severity    Code    Description Project Path    File    Line    Column  Category    Source  Tool
Error   RH0004  Unrecognized concept keyword 'qwe'.     c:\My Projects\RhetosPackages\Bookstore\src\Bookstore.Service\DslScripts    c:\My Projects\RhetosPackages\Bookstore\src\Bookstore.Service\DslScripts\BookInfo.rhe   1   1       IntelliSense    
Severity    Code    Description Project Path    File    Line    Column  Category    Source  Tool
Error   RH0004  Unrecognized concept keyword 'qwe'. Bookstore.Service   C:\My Projects\RhetosPackages\Bookstore\src\Bookstore.Service\DslScripts    C:\My Projects\RhetosPackages\Bookstore\src\Bookstore.Service\DslScripts\BookInfo.rhe   1   1       Build   Exec

It seems that Visual Studio automatically detects when Build error and IntelliSense error are identical to avoid showing duplicate errors, but in Rhetos DSL some errors are duplicated in errors list in Visual Studio.

Perhaps the errors are not merged into a single error because some of the differences:

  1. Rhetos Language Server (DSL IntelliSense) returns Path lowercase drive letter, while build returns with uppercase.
  2. RLS error does not have Project set, while build error has Project set correctly.
  3. The Code has different metadata associated (Diagnostic.CodeDescription.Href).
bantolov commented 2 years ago

Initial analysis results:

  1. Difference in lowercase/uppercase drive letter:
    • Internally, RLS returns DocumentUri with uppercase drive letter, but DocumentUri seems to convert it to lowercase when extracting the path (ToString and similar methods). We might return lowercase letter in build output instead, but this is unexpected, because C# IntelliSense errors display uppercase drive letter.
  2. RLS error does not have Project set:
    • I cannot find Project in OmniShart API (PublishDiagnosticsParams and Diagnostic classes), it might be implicitly set by Visual Studio based on some other data.
  3. The Code has different metadata associated
    • It should not affect merging of the errors. For example, C# error CS1002 "; expected" has different web link for IntelliSense and Build error, and it is still merged into a single error. When the Error List is filter by "Build only", it links to bingdev.couldapp.net, and when filtered by "IntelliSense only" it links to msdn.microsoft.com. Also, DSL errors without the code result with duplicate entries in Error List.

I have tried removing error code and reporting lowercase drive letter in rhetos build to match the intellisense error. It still resulted with the two DSL errors in VS Error List. The only significant difference seems to be missing Project in the IntelliSense error.