-
Notifications
You must be signed in to change notification settings - Fork 678
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
Handling Newlines in XML Documentation #1869
Conversation
await csharpExtension.activate(); | ||
} | ||
|
||
testAssetWorkspace.deleteBuildArtifacts(); |
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 this?
|
||
testAssetWorkspace.deleteBuildArtifacts(); | ||
|
||
await fs.rimraf(testAssetWorkspace.vsCodeDirectoryPath); |
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.
or this?
|
||
await csharpExtension.exports.initializationFinished; | ||
|
||
await vscode.commands.executeCommand("dotnet.generateAssets"); |
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.
or this?
|
||
await vscode.commands.executeCommand("dotnet.generateAssets"); | ||
|
||
await poll(async () => await fs.exists(testAssetWorkspace.launchJsonPath), 10000, 100); |
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.
or this?
await vscode.commands.executeCommand("vscode.open", fileUri); | ||
|
||
let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri,new vscode.Position(10,30)); | ||
let answer:string = "Checks if object is tagged with the tag.\n\ngameObject: The game object.\n\ntagName: Name of the tag \n\nReturns: Returns trueif object is tagged with tag."; |
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.
the :string
type specifier should not be necessary here.
|
||
let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri,new vscode.Position(10,30)); | ||
let answer:string = "Checks if object is tagged with the tag.\n\ngameObject: The game object.\n\ntagName: Name of the tag \n\nReturns: Returns trueif object is tagged with tag."; | ||
expect(c[0].contents[0].value).to.equal(answer); |
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.
for my own education, why might contents
have multiple values?
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.
There are 2 parts to the hover: the type info, and the documentation.
|
||
test("Hover returns the correct XML", async () => { | ||
|
||
let program : string = "using System;\ |
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 we use a multi-line string instead? it should be much easier to maintain since we won't be in the business of moving around \n
's and \
's.
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.
+1
expect(c[0].contents[0].value).to.equal(answer); | ||
|
||
}); | ||
|
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.
extra blank line
@@ -0,0 +1,63 @@ | |||
|
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.
Missing copyright header
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.
@akshita31 if you install the tslint
extension for vs code you will get notification for this and similar issues.
@@ -21,7 +21,8 @@ export default class OmniSharpHoverProvider extends AbstractSupport implements H | |||
|
|||
return serverUtils.typeLookup(this._server, req, token).then(value => { | |||
if (value && value.Type) { | |||
let contents = [extractSummaryText(value.Documentation), { language: 'csharp', value: value.Type }]; | |||
let addLine = value.Documentation.split("\n").join("\n\n"); |
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'm not convinced that this is correct. The bug wants us to have line breaks between sections (summary, parameter, etc), but this seems like it's going to add them anywhere a newline appears in the doc comment. Can you post a screenshot with your changes, with a doc comment with a multline summary section?
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.
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 don't think there should be a visible line break between "the" and "tag".
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.
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.
There are multiple "kinds" of newlines at play.
- There are single newlines that have to be in doc comments if a section spans more than one line. I contend that we should not cause a visible line break for those
- There might be multiple consecutive newlines in a doc comment section where the user was trying to separate paragraphs. We should make those visible.
- There are visible line breaks between sections (like between summary and parameters, or between parameters). We should always show those, even if the user wrote all their parameter documentation sections on one line.
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.
This is the output from the master branch(where no changes have been made). As noticeable, the problem is that vscode doesn't show a newline for a single newline.It shows a "single" newline for 2 or more newlines(irrespective of whether they were part of the text originally or added by roslyn to separate the tags). Hence a quick solution was to double the '\n' character before being passed to the Hover object.
If we have to deal with single newlines and double newlines already present in the text separately, we will have to make changes on the roslyn side.Is that what you are suggesting?
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.
Yes, it looks like we will need to make a change that spans both repos. I propose that we:
- Augment Roslyn to be able to return some data structure that contains all of the "sections"
- Consume that on the VSCode side and properly insert newlines between sections.
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.
@rchande can we split this up into two features? @akshita31's change here makes the text much more readable than before, though it does not replicate VS's behavior. I'd start by finishing off this PR, then making it better once we have a chance to close on and implement the relevant change in omnisharp-roslyn. Thoughts?
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.
@TheRealPiotrP I pulled @akshita31's branch to play with the behavior. Given the doc comment in the first screenshot, this is what it looks like before and after the change, respectively. I feel that the second example is enough of a regression to the readability of longer documentation comments that we should wait until we have an appropriate change on the roslyn side. @DustinCampbell what do you think?
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 agree. Let's not merge changes that regress the user experience.
|
||
test("Hover returns the correct XML", async () => { | ||
|
||
let program : string = "using System;\ |
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.
+1
\n{\ | ||
\n class testissue\ | ||
\n {\ | ||
\n ///<summary>Checks if object is tagged with the tag.</summary>\ |
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.
Put a newline inside this tag.
|
||
let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri,new vscode.Position(10,30)); | ||
let answer:string = "Checks if object is tagged with the tag.\n\ngameObject: The game object.\n\ntagName: Name of the tag \n\nReturns: Returns trueif object is tagged with tag."; | ||
expect(c[0].contents[0].value).to.equal(answer); |
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.
There are 2 parts to the hover: the type info, and the documentation.
}); | ||
|
||
|
||
test("Hover returns the correct XML", async () => { |
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 we make this more specific? Perhaps HoverProvider replaces \n with \n\n
? Hover does not return XML, and this test is validating our newline replacement strategy.
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.
One remaining comment about test name, and a question to @rchande. LGTM otherwise.
Except that, looking at the new hover tooltip, this change doesn't solve the problem. 😄 |
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.
It seems that simply replacing all \n
with \n\n
does not produce the right user experience.
@akshita31 : Should this be closed in favor of #1918? |
Yes .Closing this in favor of #1918 |
Issue : #1057
The XML Documentation being returned by omnisharp-roslyn contained newlines properly, however vscode is displaying a single newline when there are two consecutive new lines are provided. Hence a change has been made to the hoverProvider to replace a single newline with two new lines. An integration test has been added for the same. However on adding this test, the "Launch singleCsproj Workspace Tests" and "Launch slnWithCsproj Workspace Tests" are failing.
Please review @DustinCampbell @TheRealPiotrP @rchande