-
Notifications
You must be signed in to change notification settings - Fork 420
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
Conversation
There was a problem hiding this 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("")] |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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 = ""; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ? |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
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
... ... ...`
The entire new handler is really a copy of the old one, except for the one line that computes documentation. |
Is this new endpoint actually necessary? Can't these properties (or a property returning a richer object) by returned by the v1 endpoint? |
I think @TheRealPiotrP wanted us to start being more diligent about versioning endpoints. |
@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? |
@DustinCampbell, there's definitely a refactoring that needs to happen. I think @akshita31 is working on it. |
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. |
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. |
Fair enough, I don't have super strong feelings about this one way or the other. |
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. |
67df3f8
to
884742f
Compare
884742f
to
a6b1a97
Compare
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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).
…comment class itself
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