dotnet / dotnet/roslyn

Diagnostic without location does not show full message and does not allow to click the help link

Open
#74,647 3 comments 0 reactions 0 assignees View on GitHub
Area-Analyzers Bug
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**:
Version 17.10.5

I have a custom diagnostic reported with or without location, in syntax node action or in compilation end action.
In both cases the message is a multiline string, and MyDiagnosticDescriptor has correct HelpLink property.

**Actual Behavior**:

When I use similar code in a **SyntaxNode action**, everything looks ok in the ErrorList tool window. I can see whole message, and I can click diagnostic ID to go to the corresponding help page:

var message = ComposeMessage();
var diagnostic = Diagnostic.Create(MyDiagnosticDescriptor.DiagnosticRule, c.Node.GetLocation(), message);
c.ReportDiagnostic(diagnostic);

However, when I report this in a **compilation end action**, only the first line of the message is visible, and no link is presented for diagnostic ID - I can see it only as a plain text:

var message = ComposeMessage();
var diagnostic = Diagnostic.Create(MyDiagnosticDescriptor.DiagnosticRule, Location.None, message);
c.ReportDiagnostic(diagnostic);

**Expected Behavior**:

Diagnostic is presented the same way regardless of the action it was reported in, and regardless of provided location. I need to see the whole message, and the diagnostic ID should be a link.

Contributor guide

Open the contributing guide

Research direction

Reproduce the two reported paths in the ErrorList tool window using Diagnostic.Create with a location from a SyntaxNode action and Location.None from a compilation end action. Compare how the multiline message and MyDiagnosticDescriptor.DiagnosticRule help link are presented; done means both paths show the full message and a clickable diagnostic ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.