33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as vscode from "vscode" ;
7- import { execChildProcess } from "../common" ;
6+ import { vscode } from "../vscodeAdapter" ;
7+ import { Extension } from "../vscodeAdapter" ;
8+ import { CSharpExtensionId } from "../constants/CSharpExtensionId" ;
9+ import { EventStream } from "../EventStream" ;
10+ import { ReportIssue } from "../omnisharp/loggingEvents" ;
811
9- const extensionId = 'ms-vscode.csharp' ;
10- const extension = vscode . extensions . getExtension ( extensionId ) ;
11- const extensionVersion = extension . packageJSON . version ;
1212const issuesUrl = "https://github.com/OmniSharp/omnisharp-vscode/issues/new" ;
13- const queryStringPrefix : string = "?" ;
1413
15- let extensions = vscode . extensions . all
16- . filter ( extension => extension . packageJSON . isBuiltin === false ) ;
17-
18- extensions . sort ( sortExtensions ) ;
14+ export default async function generateBugReport ( vscode : vscode , eventStream : EventStream , execChildProcess :( command : string , workingDirectory ?: string ) => Promise < string > , isValidPlatformForMono : boolean ) {
15+ const dotnetInfo = await getDotnetInfo ( execChildProcess ) ;
16+ const monoInfo = await getMonoIfPlatformValid ( execChildProcess , isValidPlatformForMono ) ;
17+ let extensions = getInstalledExtensions ( vscode ) ;
18+ let csharpExtVersion = getCsharpExtensionVersion ( vscode ) ;
1919
20- export default async function generateBugReport ( isValidPlatformForMono : boolean ) {
21- const dotnetInfo = await getDotnetInfo ( ) ;
22-
23- const body = encodeURIComponent ( `## Issue Description ##
20+ const body = `## Issue Description ##
2421## Steps to Reproduce ##
2522
2623## Expected Behavior ##
@@ -30,8 +27,8 @@ export default async function generateBugReport(isValidPlatformForMono: boolean)
3027## Environment Information ##
3128
3229VSCode version: ${ vscode . version }
33- C# Extension: ${ extensionVersion }
34- ${ getMonoIfPlatformValid ( isValidPlatformForMono ) }
30+ C# Extension: ${ csharpExtVersion }
31+ ${ monoInfo }
3532
3633<details><summary>Dotnet Info</summary>
3734${ dotnetInfo } </details>
@@ -46,14 +43,12 @@ Post the output from Output-->C# here
4643<details><summary>Visual Studio Code Extensions</summary>
4744${ generateExtensionTable ( extensions ) }
4845</details>
49- ` ) ;
46+ ` ;
5047
51- const encodedBody = encodeURIComponent ( body ) ;
52- const fullUrl = `${ issuesUrl } ${ queryStringPrefix } body=${ encodedBody } ` ;
53- vscode . commands . executeCommand ( "vscode.open" , vscode . Uri . parse ( fullUrl ) ) ;
48+ eventStream . post ( new ReportIssue ( issuesUrl , body ) ) ;
5449}
5550
56- function sortExtensions ( a : vscode . Extension < any > , b : vscode . Extension < any > ) : number {
51+ function sortExtensions ( a : Extension < any > , b : Extension < any > ) : number {
5752
5853 if ( a . packageJSON . name . toLowerCase ( ) < b . packageJSON . name . toLowerCase ( ) ) {
5954 return - 1 ;
@@ -64,7 +59,7 @@ function sortExtensions(a: vscode.Extension<any>, b: vscode.Extension<any>): num
6459 return 0 ;
6560}
6661
67- function generateExtensionTable ( extensions : vscode . Extension < any > [ ] ) {
62+ function generateExtensionTable ( extensions : Extension < any > [ ] ) {
6863 if ( extensions . length <= 0 ) {
6964 return "none" ;
7065 }
@@ -83,18 +78,30 @@ ${tableHeader}\n${table};
8378 return extensionTable ;
8479}
8580
86- function getMonoIfPlatformValid ( isValidPlatformForMono : boolean ) : string {
81+ async function getMonoIfPlatformValid ( execChildProcess : ( command : string , workingDirectory ?: string ) => Promise < string > , isValidPlatformForMono : boolean ) : Promise < string > {
8782 if ( isValidPlatformForMono ) {
88- return `Mono: ${ getMonoVersion ( ) } ` ;
83+ return `Mono: ${ await getMonoVersion ( execChildProcess ) } ` ;
8984 }
9085
9186 return "" ;
9287}
9388
94- async function getDotnetInfo ( ) : Promise < string > {
89+ async function getDotnetInfo ( execChildProcess : ( command : string , workingDirectory ?: string ) => Promise < string > ) : Promise < string > {
9590 return execChildProcess ( "dotnet --info" , process . cwd ( ) ) ;
9691}
9792
98- async function getMonoVersion ( ) : Promise < string > {
99- return execChildProcess ( "dotnet --info " , process . cwd ( ) ) ;
93+ async function getMonoVersion ( execChildProcess : ( command : string , workingDirectory ?: string ) => Promise < string > ) : Promise < string > {
94+ return execChildProcess ( "mono --version " , process . cwd ( ) ) ;
10095}
96+
97+ function getInstalledExtensions ( vscode : vscode ) {
98+ let extensions = vscode . extensions . all
99+ . filter ( extension => extension . packageJSON . isBuiltin === false ) ;
100+
101+ return extensions . sort ( sortExtensions ) ;
102+ }
103+
104+ function getCsharpExtensionVersion ( vscode : vscode ) : string {
105+ const extension = vscode . extensions . getExtension ( CSharpExtensionId ) ;
106+ return extension . packageJSON . version ;
107+ }
0 commit comments