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

Cherry pick fix for expanded message to 17.10 #73405

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ LSP.VSDiagnostic CreateLspDiagnostic(

if (capabilities.HasVisualStudioLspCapability())
{
var expandedMessage = string.IsNullOrEmpty(diagnosticData.Description) ? null : diagnosticData.Description;
diagnostic.DiagnosticType = diagnosticData.Category;
diagnostic.ExpandedMessage = diagnosticData.Description;
diagnostic.ExpandedMessage = expandedMessage;
diagnostic.Projects =
[
new VSDiagnosticProjectInformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ static void Main(string[] args)
Assert.Equal(vsDiagnostic.ExpandedMessage, AnalyzersResources.Avoid_unused_parameters_in_your_code_If_the_parameter_cannot_be_removed_then_change_its_name_so_it_starts_with_an_underscore_and_is_optionally_followed_by_an_integer_such_as__comma__1_comma__2_etc_These_are_treated_as_special_discard_symbol_names);
}

[Theory, CombinatorialData, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2050705")]
public async Task TestDocumentDiagnosticsUsesNullForExpandedMessage(bool mutatingLspWorkspace)
{
var markup =
@"class A {";
await using var testLspServer = await CreateTestWorkspaceWithDiagnosticsAsync(markup, mutatingLspWorkspace, BackgroundAnalysisScope.OpenFiles, useVSDiagnostics: true);

// Calling GetTextBuffer will effectively open the file.
testLspServer.TestWorkspace.Documents.Single().GetTextBuffer();

var document = testLspServer.GetCurrentSolution().Projects.Single().Documents.Single();

await OpenDocumentAsync(testLspServer, document);

var results = await RunGetDocumentPullDiagnosticsAsync(
testLspServer, document.GetURI(), useVSDiagnostics: true);

Assert.Equal("CS1513", results.Single().Diagnostics.Single().Code);
var vsDiagnostic = (VSDiagnostic)results.Single().Diagnostics.Single();
Assert.Null(vsDiagnostic.ExpandedMessage);
}

[Theory, CombinatorialData]
public async Task TestDocumentTodoCommentsDiagnosticsForOpenFile_NoCategory(bool useVSDiagnostics, bool mutatingLspWorkspace)
{
Expand Down
Loading