diff --git a/src/features/hoverProvider.ts b/src/features/hoverProvider.ts index 2285b1c00..c795bb6b0 100644 --- a/src/features/hoverProvider.ts +++ b/src/features/hoverProvider.ts @@ -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"); + let contents = [extractSummaryText(addLine), { language: 'csharp', value: value.Type }]; return new Hover(contents); } }); diff --git a/test/integrationTests/hoverProvider.integration.test.ts b/test/integrationTests/hoverProvider.integration.test.ts new file mode 100644 index 000000000..b2b2ad3d3 --- /dev/null +++ b/test/integrationTests/hoverProvider.integration.test.ts @@ -0,0 +1,57 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as fs from 'async-file'; +import * as vscode from 'vscode'; +import * as path from 'path'; + +import poll from './poll'; +import { should, expect } from 'chai'; +import testAssetWorkspace from './testAssets/testAssetWorkspace'; + +const chai = require('chai'); +chai.use(require('chai-arrays')); +chai.use(require('chai-fs')); + +suite(`Test Hover Behavior ${testAssetWorkspace.description}`, function() { + suiteSetup(async function() { + should(); + + let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp"); + if (!csharpExtension.isActive) { + await csharpExtension.activate(); + } + + await csharpExtension.exports.initializationFinished; + }); + + + test("Hover returns the correct XML", async () => { + + var program = +`using System; +namespace hoverXmlDoc +{ + 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); + } + } +}`; + let fileUri = await testAssetWorkspace.projects[0].addFileWithContents("test.cs", program); + await vscode.commands.executeCommand("vscode.open", fileUri); + + let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri,new vscode.Position(10,29)); + 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); + }); +}); \ No newline at end of file diff --git a/test/integrationTests/testAssets/testAssets.ts b/test/integrationTests/testAssets/testAssets.ts index 5451abe57..1d83fc29e 100644 --- a/test/integrationTests/testAssets/testAssets.ts +++ b/test/integrationTests/testAssets/testAssets.ts @@ -31,6 +31,12 @@ export class TestAssetProject { await fs.rimraf(this.binDirectoryPath); await fs.rimraf(this.objDirectoryPath); } + + async addFileWithContents(fileName: string, contents: string) : Promise { + let loc = path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, fileName); + await fs.writeTextFile(loc, contents); + return vscode.Uri.file(loc); + } } export class TestAssetWorkspace {