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

VS Code Issue 1057 - Problem with Newlines in displaying XML Documentation #1019

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 5 additions & 2 deletions src/OmniSharp.Roslyn.CSharp/Services/Types/TypeLookup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Composition;
using System;
using System.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.FindSymbols;
Expand Down Expand Up @@ -45,7 +46,9 @@ public async Task<TypeLookupResponse> Handle(TypeLookupRequest request)

if (request.IncludeDocumentation)
{
response.Documentation = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(), _formattingOptions.NewLine);
string newLine = Environment.NewLine + Environment.NewLine;
//VS Code renders a single new line for two newline sequences in the response, hence two new lines are passed in the lineEnding parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a VS Code-specific tweak, why does it belong in omnisharp-roslyn? Shouldn't the fix be in omnisharp-vscode? After all, other editors use omnisharp-roslyn (e.g. Emacs, Vim, Atom, Sublime, etc.). Wouldn't this be a breaking change for them?

response.Documentation = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(),newLine);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add space before 'newLine'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, if this is a VS Code-specific bug then we should move the fix to omnisharp-vscode. We can capture the output coming from O# and map it to what VS Code expects.

}
}
}
Expand Down
38 changes: 38 additions & 0 deletions tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using OmniSharp.Models.TypeLookup;
using OmniSharp.Options;
Expand Down Expand Up @@ -242,5 +243,42 @@ public async Task DisplayFormatFor_PropertySymbol_WithGenerics()
var response = await GetTypeLookUpResponse(line: 15, column: 70);
Assert.Equal("IDictionary<string, IEnumerable<int>> Foo.SomeDict", response.Type);
}

[Fact]
public async Task CheckParsedXMLDocumentation()
{
string source =
@"using System;
namespace class1
{
class testissue
{
///<summary>
/// Checks if object is tagged with the tag</summary>
/// <param name=""gameObject"">The game object.</param>
/// <param name=""tagName"">Name of the tag.</param>
/// <returns>Returns <c> true</c>if object is tagged with tag.</returns>
public static bool Compare(int gameObject, string tagName)
{
return gameObject.TagifyCompareTag(tagName);
}
";
var testFile = new TestFile("dummy.cs", source);
using (var host = CreateOmniSharpHost(testFile))
{
var requestHandler = GetRequestHandler(host);

var request = new TypeLookupRequest { FileName = testFile.FileName, Line = 10, Column = 31, IncludeDocumentation=true };
var response = await requestHandler.Handle(request);
var expected =
@"Checks if object is tagged with the tag
gameObject: The game object.
tagName: Name of the tag.
Returns: Returns trueif object is tagged with tag.";
string lineEnding = Environment.NewLine;
//To remove the extra new lines added for VS Code for comparison, Replace function is being used
Assert.Equal(expected, response.Documentation.Replace(lineEnding + lineEnding, lineEnding));
}
}
}
}