From 755aa7d52818224e4bc295ad923268f4e5505bf6 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Thu, 9 Nov 2017 17:37:41 -0800 Subject: [PATCH 1/3] VS Code Iss 1057 fix --- .../Services/Types/TypeLookup.cs | 7 +++- .../DocumentationConverterFacts.cs | 12 +++++- .../TypeLookupFacts.cs | 38 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Types/TypeLookup.cs b/src/OmniSharp.Roslyn.CSharp/Services/Types/TypeLookup.cs index 9eda51d4f5..92eb3b71ca 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Types/TypeLookup.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Types/TypeLookup.cs @@ -1,4 +1,5 @@ -using System.Composition; +using System; +using System.Composition; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.FindSymbols; @@ -45,7 +46,9 @@ public async Task 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 + response.Documentation = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(),newLine); } } } diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs index 9a32f5a459..e1e4506bd0 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs @@ -1,4 +1,5 @@ using OmniSharp.Roslyn.CSharp.Services.Documentation; +using System; using Xunit; namespace OmniSharp.Roslyn.CSharp.Tests @@ -26,7 +27,9 @@ static int Main() "; - var plainText = DocumentationConverter.ConvertDocumentation(documentation, "\n"); + string lineEnding = 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 + var plainText = DocumentationConverter.ConvertDocumentation(documentation,lineEnding+lineEnding); var expected = @"The GetZero method. @@ -41,6 +44,8 @@ static int Main() } } "; + //To remove the extra new lines added for VS Code for comparison, Replace function is being used + plainText = plainText.Replace(lineEnding + lineEnding, lineEnding); Assert.Equal(expected, plainText, ignoreLineEndingDifferences: true); } @@ -51,10 +56,13 @@ public void Has_correct_spacing_around_paramref() DoWork is a method in the TestClass class. The parameter takes a number and takes a string. "; - var plainText = DocumentationConverter.ConvertDocumentation(documentation, "\n"); + string lineEnding = Environment.NewLine; + var plainText = DocumentationConverter.ConvertDocumentation(documentation, lineEnding+lineEnding); var expected = @"DoWork is a method in the TestClass class. The arg parameter takes a number and arg2 takes a string."; + + plainText = plainText.Replace(lineEnding+lineEnding,lineEnding); Assert.Equal(expected, plainText, ignoreLineEndingDifferences: true); } } diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs index 371a71de97..61d5c346f8 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using OmniSharp.Models.TypeLookup; using OmniSharp.Options; @@ -242,5 +243,42 @@ public async Task DisplayFormatFor_PropertySymbol_WithGenerics() var response = await GetTypeLookUpResponse(line: 15, column: 70); Assert.Equal("IDictionary> Foo.SomeDict", response.Type); } + + [Fact] + public async Task CheckParsedXMLDocumentation() + { + string source = +@"using System; +namespace class1 +{ + class testissue + { + /// +/// Checks if object is tagged with the tag +/// The game object. +/// Name of the tag. +/// Returns trueif object is tagged with tag. + 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)); + } + } } } From 15aba501c9789e7e190b2aaf39c05fd12576d697 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Thu, 9 Nov 2017 17:43:19 -0800 Subject: [PATCH 2/3] VS Code Issue 1057 fix --- .../DocumentationConverterFacts.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs index e1e4506bd0..712f30ba3d 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs @@ -1,5 +1,5 @@ -using OmniSharp.Roslyn.CSharp.Services.Documentation; using System; +using OmniSharp.Roslyn.CSharp.Services.Documentation; using Xunit; namespace OmniSharp.Roslyn.CSharp.Tests @@ -61,7 +61,6 @@ public void Has_correct_spacing_around_paramref() var expected = @"DoWork is a method in the TestClass class. The arg parameter takes a number and arg2 takes a string."; - plainText = plainText.Replace(lineEnding+lineEnding,lineEnding); Assert.Equal(expected, plainText, ignoreLineEndingDifferences: true); } From 9eb0cfbfa9524da846ef5f897e03b6d928f7774e Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Thu, 9 Nov 2017 18:08:37 -0800 Subject: [PATCH 3/3] Issue 1057 Fix --- .../DocumentationConverterFacts.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs index 712f30ba3d..9a32f5a459 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/DocumentationConverterFacts.cs @@ -1,4 +1,3 @@ -using System; using OmniSharp.Roslyn.CSharp.Services.Documentation; using Xunit; @@ -27,9 +26,7 @@ static int Main() "; - string lineEnding = 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 - var plainText = DocumentationConverter.ConvertDocumentation(documentation,lineEnding+lineEnding); + var plainText = DocumentationConverter.ConvertDocumentation(documentation, "\n"); var expected = @"The GetZero method. @@ -44,8 +41,6 @@ static int Main() } } "; - //To remove the extra new lines added for VS Code for comparison, Replace function is being used - plainText = plainText.Replace(lineEnding + lineEnding, lineEnding); Assert.Equal(expected, plainText, ignoreLineEndingDifferences: true); } @@ -56,12 +51,10 @@ public void Has_correct_spacing_around_paramref() DoWork is a method in the TestClass class. The parameter takes a number and takes a string. "; - string lineEnding = Environment.NewLine; - var plainText = DocumentationConverter.ConvertDocumentation(documentation, lineEnding+lineEnding); + var plainText = DocumentationConverter.ConvertDocumentation(documentation, "\n"); var expected = @"DoWork is a method in the TestClass class. The arg parameter takes a number and arg2 takes a string."; - plainText = plainText.Replace(lineEnding+lineEnding,lineEnding); Assert.Equal(expected, plainText, ignoreLineEndingDifferences: true); } }