-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add command to create an issue from within the extension #2503
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7b1c30d
Add command to create an issue
akshita31 599794b
use child process promise
akshita31 afd08ba
Add
akshita31 6f563df
add mono information
akshita31 42fa329
Use existing child-process
akshita31 7876468
refactoring for testing
akshita31 c2c2e7e
rename
akshita31 63e1746
Add the unit test
akshita31 44d4085
Remove package-lock
akshita31 e548da2
add tests for the observer
akshita31 7b2ee67
Merge remote-tracking branch 'upstream/master' into bug_generator
akshita31 440b0e3
add encoding and some structure change
akshita31 543ad48
make bold
akshita31 3a7ac64
add encoding and some structure change
akshita31 aed6f9a
Add the changes
akshita31 8980a2c
using the openurl observer
akshita31 d47164a
Modify the tests for the observer
akshita31 c15eb7d
Rename to report issue
akshita31 379654c
PR feedback
akshita31 6537a8d
Add refactoring for the mono options
akshita31 293c97b
Some more refactoring
akshita31 3835cfb
Add the global mono information
akshita31 1a2dcdc
add the mono resolver to the issue creator
akshita31 834f8d1
small changes
akshita31 5c5304e
should throw error when not valid
akshita31 cb72d3f
Do not use mono information interface
akshita31 5cd3196
using the mono resolver interface
akshita31 cdb2345
rename
akshita31 2eee6b7
pass the GetMonoVersion
akshita31 baed655
Add the environment to the information
akshita31 053f326
add tests for the mono resolver
akshita31 f29f892
remove file
akshita31 2d963c2
Merge branch 'master' into bug_generator
akshita31 8e55eb4
Rename and add interfaces
akshita31 0c543b8
using more interfaces
akshita31 dfc383f
refactor the test
akshita31 30b3995
soe more changes
akshita31 61a2efb
Merge branch 'bug_generator' of https://github.com/akshita31/omnishar…
akshita31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export const CSharpExtensionId = 'ms-vscode.csharp'; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export interface IGetDotnetInfo { | ||
(): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export interface IGetMonoVersion { | ||
(environment: NodeJS.ProcessEnv): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Options } from "../omnisharp/options"; | ||
import { MonoInformation } from "./MonoInformation"; | ||
|
||
export interface IMonoResolver { | ||
getGlobalMonoInfo(options: Options): Promise<MonoInformation>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export interface MonoInformation { | ||
version: string; | ||
path: string; | ||
env: NodeJS.ProcessEnv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { vscode } from "../vscodeAdapter"; | ||
import { Extension } from "../vscodeAdapter"; | ||
import { CSharpExtensionId } from "../constants/CSharpExtensionId"; | ||
import { EventStream } from "../EventStream"; | ||
import { OpenURL } from "../omnisharp/loggingEvents"; | ||
import { Options } from "../omnisharp/options"; | ||
import { IMonoResolver } from "../constants/IMonoResolver"; | ||
import { IGetDotnetInfo } from "../constants/IGetDotnetInfo"; | ||
|
||
const issuesUrl = "https://github.com/OmniSharp/omnisharp-vscode/issues/new"; | ||
|
||
export default async function reportIssue(vscode: vscode, eventStream: EventStream, getDotnetInfo: IGetDotnetInfo, isValidPlatformForMono: boolean, options: Options, monoResolver: IMonoResolver) { | ||
const dotnetInfo = await getDotnetInfo(); | ||
const monoInfo = await getMonoIfPlatformValid(isValidPlatformForMono, options, monoResolver); | ||
let extensions = getInstalledExtensions(vscode); | ||
let csharpExtVersion = getCsharpExtensionVersion(vscode); | ||
|
||
const body = encodeURIComponent(`## Issue Description ## | ||
## Steps to Reproduce ## | ||
|
||
## Expected Behavior ## | ||
|
||
## Actual Behavior ## | ||
|
||
## Logs ## | ||
|
||
### OmniSharp log ### | ||
<details>Post the output from Output-->OmniSharp log here</details> | ||
|
||
### C# log ### | ||
<details>Post the output from Output-->C# here</details> | ||
|
||
## Environment information ## | ||
|
||
**VSCode version**: ${vscode.version} | ||
**C# Extension**: ${csharpExtVersion} | ||
|
||
${monoInfo} | ||
<details><summary>Dotnet Information</summary> | ||
${dotnetInfo}</details> | ||
<details><summary>Visual Studio Code Extensions</summary> | ||
${generateExtensionTable(extensions)} | ||
</details> | ||
`); | ||
|
||
const encodedBody = encodeURIComponent(body); | ||
const queryStringPrefix: string = "?"; | ||
const fullUrl = `${issuesUrl}${queryStringPrefix}body=${encodedBody}`; | ||
eventStream.post(new OpenURL(fullUrl)); | ||
} | ||
|
||
function sortExtensions(a: Extension<any>, b: Extension<any>): number { | ||
|
||
if (a.packageJSON.name.toLowerCase() < b.packageJSON.name.toLowerCase()) { | ||
return -1; | ||
} | ||
if (a.packageJSON.name.toLowerCase() > b.packageJSON.name.toLowerCase()) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
function generateExtensionTable(extensions: Extension<any>[]) { | ||
if (extensions.length <= 0) { | ||
return "none"; | ||
} | ||
|
||
const tableHeader = `|Extension|Author|Version|\n|---|---|---|`; | ||
const table = extensions.map((e) => `|${e.packageJSON.name}|${e.packageJSON.publisher}|${e.packageJSON.version}|`).join("\n"); | ||
|
||
const extensionTable = ` | ||
${tableHeader}\n${table}; | ||
`; | ||
|
||
return extensionTable; | ||
} | ||
|
||
async function getMonoIfPlatformValid(isValidPlatformForMono: boolean, options: Options, monoResolver: IMonoResolver): Promise<string> { | ||
if (isValidPlatformForMono) { | ||
let monoVersion: string; | ||
try { | ||
let globalMonoInfo = await monoResolver.getGlobalMonoInfo(options); | ||
if (globalMonoInfo) { | ||
monoVersion = `OmniSharp using global mono :${globalMonoInfo.version}`; | ||
} | ||
else { | ||
monoVersion = `OmniSharp using built-in mono`; | ||
} | ||
} | ||
catch (error) { | ||
monoVersion = `There is a problem with running OmniSharp on mono: ${error}`; | ||
} | ||
|
||
return `<details><summary>Mono Information</summary> | ||
${monoVersion}</details>`; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
|
||
|
||
function getInstalledExtensions(vscode: vscode) { | ||
let extensions = vscode.extensions.all | ||
.filter(extension => extension.packageJSON.isBuiltin === false); | ||
|
||
return extensions.sort(sortExtensions); | ||
} | ||
|
||
function getCsharpExtensionVersion(vscode: vscode): string { | ||
const extension = vscode.extensions.getExtension(CSharpExtensionId); | ||
return extension.packageJSON.version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { vscode } from "../vscodeAdapter"; | ||
import { BaseEvent, OpenURL } from "../omnisharp/loggingEvents"; | ||
|
||
export class OpenURLObserver { | ||
|
||
constructor(private vscode: vscode) { | ||
} | ||
|
||
public post = (event: BaseEvent) => { | ||
switch (event.constructor.name) { | ||
case OpenURL.name: | ||
let url = (<OpenURL>event).url; | ||
this.vscode.commands.executeCommand("vscode.open", this.vscode.Uri.parse(url)); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { satisfies } from 'semver'; | ||
import * as path from 'path'; | ||
import { Options } from './options'; | ||
import { IMonoResolver } from '../constants/IMonoResolver'; | ||
import { MonoInformation } from '../constants/MonoInformation'; | ||
import { IGetMonoVersion } from '../constants/IGetMonoVersion'; | ||
|
||
export class OmniSharpMonoResolver implements IMonoResolver { | ||
private minimumMonoVersion = "5.8.1"; | ||
constructor(private getMonoVersion: IGetMonoVersion) { | ||
} | ||
|
||
private async configureEnvironmentAndGetInfo(options: Options): Promise<MonoInformation> { | ||
let env = { ...process.env }; | ||
let monoPath: string; | ||
if (options.useGlobalMono !== "never" && options.monoPath !== undefined) { | ||
env['PATH'] = path.join(options.monoPath, 'bin') + path.delimiter + env['PATH']; | ||
env['MONO_GAC_PREFIX'] = options.monoPath; | ||
monoPath = options.monoPath; | ||
} | ||
|
||
let version = await this.getMonoVersion(env); | ||
|
||
return { | ||
version, | ||
path: monoPath, | ||
env | ||
}; | ||
} | ||
|
||
public async getGlobalMonoInfo(options: Options): Promise<MonoInformation> { | ||
let monoInfo = await this.configureEnvironmentAndGetInfo(options); | ||
let isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`); | ||
|
||
if (options.useGlobalMono === "always") { | ||
if (!isValid) { | ||
throw new Error(`Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`); | ||
} | ||
|
||
return monoInfo; | ||
} | ||
else if (options.useGlobalMono === "auto" && isValid) { | ||
return monoInfo; | ||
} | ||
|
||
return undefined; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If this appears in package.json, can we read it from there instead of redefining it here?
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 package json has a publisher name and the name of the extension combining which gives the extension id, but to get access to the package.json we need the extension first and to get the extension we need the extension id. Hence from what I understand there is no way to get the extension id directly from the package.json.