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

TypeLookUp Structured Documentation Feature to be used by VS Code #1038

Merged
merged 16 commits into from
Dec 8, 2017

Conversation

akshita31
Copy link
Contributor

@akshita31 akshita31 commented Nov 30, 2017

Issue : dotnet/vscode-csharp#1057

To display the XML Documentation properly, we need omnisharp-roslyn to send a documentation object to omnisharp-vscode with different parts of the documentation in separate fields so that newlines can then be added to the documentation appropriately on the vscode side. So a V2 endpoint has been created that will be invoked by omnisharp-vscode and appropriate test cases have been added.

Edit : Instead of a V2 endpoint, a property has been added to V1 with the structuredDocumentation
Please Review @DustinCampbell @TheRealPiotrP @rchande

Copy link

@rchande rchande left a comment

Choose a reason for hiding this comment

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

Overall, looking pretty good. Some style issues and possible test improvements. Thanks!

{
public class DocumentationComment
{
//[DefaultValue("")]
Copy link

Choose a reason for hiding this comment

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

Unused?

public string ReturnsText { get; set; }
public string SummaryText { get; set; }
public string ValueText { get; set; }
public string [] Param { get; set; }
Copy link

Choose a reason for hiding this comment

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

No space between type and array brackets


public DocumentationComment()
{
RemarksText = "";
Copy link

Choose a reason for hiding this comment

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

Do we need to initialize the arrays to empty arrays, or does json.net not care?

@@ -0,0 +1,11 @@
using OmniSharp.Mef;

namespace OmniSharp.Models.v2.TypeLookUp
Copy link

Choose a reason for hiding this comment

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

Is it upper or lowercase "v" in the rest of the project?

namespace OmniSharp.Models.v2.TypeLookUp
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.TypeLookup, typeof(TypeLookupRequest), typeof(TypeLookupResponse))]
public class TypeLookupRequest:Request
Copy link

Choose a reason for hiding this comment

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

Space on both sides of the colon

var symbol = await SymbolFinder.FindSymbolAtPositionAsync(semanticModel, position, _workspace);
if (symbol != null)
{
response.Type = symbol.Kind == SymbolKind.NamedType ?
Copy link

Choose a reason for hiding this comment

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

How much of this is duplicated from the v1 endpoint? Wondering if there's a refactoring we can do here.

var expected =
@"gameObject: The game object.";
Assert.Equal(2,response.DocComment.Param.Length);
Assert.Equal(expected, response.DocComment.Param[0]);
Copy link

Choose a reason for hiding this comment

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

You can combine this test and the one below it and check both parameters.

var expected =
@"T: The element type of the array";
Assert.Single(response.DocComment.TypeParam);
Assert.Equal(expected, response.DocComment.TypeParam[0]);
Copy link

Choose a reason for hiding this comment

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

Can you verify it works for more than 1 type parameter?

}
";
var response = await GetTypeLookUpResponse(content);
var expected =
Copy link

Choose a reason for hiding this comment

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

Why isn't the summary text in the response?

Assert.Equal(expected.Replace("\r",""), response.DocComment.SummaryText);
}

}
Copy link

@rchande rchande Nov 30, 2017

Choose a reason for hiding this comment

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

I like that you have tests for each type of section or tag, but there aren't many tests that validate that multiple sections all show up correctly together? Could you add some tests that verify what happens if you have a <summary>, <params> and <returns> all in one doc comment (for example).

Can you also add tests that validate the behavior if elements are interleaved with other elements? eg... ... ...`

@filipw
Copy link
Member

filipw commented Nov 30, 2017

The entire new handler is really a copy of the old one, except for the one line that computes documentation.
Wouldn't it be simpler to just extend the old endpoint with something like WantStructuredDocumentation on the request object and just use that?

@DustinCampbell
Copy link
Contributor

Is this new endpoint actually necessary? Can't these properties (or a property returning a richer object) by returned by the v1 endpoint?

@rchande
Copy link

rchande commented Nov 30, 2017

I think @TheRealPiotrP wanted us to start being more diligent about versioning endpoints.

@DustinCampbell
Copy link
Contributor

@rchande : That seems reasonable, but it's a change in approach that the OmniSharp community has not taken in the past. I don't think copying and pasting entire endpoints to add a property is worthwhile. 😄 @david-driscoll, how do you feel about this?

@rchande
Copy link

rchande commented Dec 1, 2017

@DustinCampbell, there's definitely a refactoring that needs to happen. I think @akshita31 is working on it.

@DustinCampbell
Copy link
Contributor

FWIW, I'm totally comfortable adding new V2 end points if they make sense. However, general policy decisions around versioning of the protocol need to happen with the OmniSharp community.

@filipw
Copy link
Member

filipw commented Dec 1, 2017

While proper versioning is always welcome, at the same time don't think it's sustainable to have a new version with every new property being added - it only would make sense for breaking changes.

Since this (structured documentation) doesn't have to replace the old documentation property and therefore can be seen as an additive and non-breaking change, IMHO it should just be added to the existing endpoint and the complexity of the PR drastically reduced.

@rchande
Copy link

rchande commented Dec 1, 2017

Fair enough, I don't have super strong feelings about this one way or the other.

@david-driscoll
Copy link
Member

Yeah, if we can get by using a new property instead of fracturing endpoints it would be preferable. I'm fine making breaking changes when required, because I want to avoid causing problems for consumers that may be integrating slower, or can't/won't make use of the new endpoint.

Copy link

@rchande rchande left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

return null;
}

docComment.RemarksText = remarksText.ToString();
Copy link

Choose a reason for hiding this comment

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

How do you feel about adding a constructor to docComment that takes all of these, rather than having to remember to set all of the properties? (Maybe makes it easier to not forget a section if we refactor).

@akshita31 akshita31 changed the title V2 TypeLookUp Endpoint to be used by VS Code TypeLookUp Structured Documentation Feature to be used by VS Code Dec 8, 2017
@DustinCampbell DustinCampbell merged commit aadc234 into OmniSharp:master Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants