Skip to content
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 38 commits into from
Sep 19, 2018

Conversation

akshita31
Copy link
Contributor

@akshita31 akshita31 commented Sep 7, 2018

Fixes: #2498

To do:

  • Try to make the component unit testable using the vscode adapter and mocking the functions

Here is a preview of all the fields added:

Issue Description

Steps to Reproduce

Expected Behaviour

Actual Behaviour

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.27.1
C# Extension: 1.16.0

Mono Information A valid mono installation could not be found. Using the built-in mono
Dotnet Info .NET Command Line Tools (2.1.200)

Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1

Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.200/

Microsoft .NET Core Shared Framework Host

Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11

Visual Studio Code Extensions
Extension Author Version
cpptools ms-vscode 0.18.1
csharp ms-vscode 1.16.0

@akshita31 akshita31 added this to the 1.17 milestone Sep 7, 2018
@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@a813b0d). Click here to learn what that means.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2503   +/-   ##
=========================================
  Coverage          ?   64.74%           
=========================================
  Files             ?       93           
  Lines             ?     4173           
  Branches          ?      598           
=========================================
  Hits              ?     2702           
  Misses            ?     1298           
  Partials          ?      173
Flag Coverage Δ
#integration 53.28% <21.56%> (?)
#unit 84.31% <77.77%> (?)
Impacted Files Coverage Δ
src/omnisharp/loggingEvents.ts 98.97% <ø> (ø)
src/platform.ts 76.13% <100%> (ø)
src/features/commands.ts 35.48% <100%> (ø)
src/main.ts 93.2% <100%> (ø)
src/features/utils/openUrlWithBody.ts 100% <100%> (ø)
src/constants/CSharpExtensionId.ts 100% <100%> (ø)
src/features/reportIssue.ts 83.78% <83.78%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a813b0d...b7557d7. Read the comment docs.

@akshita31 akshita31 requested review from DustinCampbell, rchande, colombod and TheRealPiotrP and removed request for rchande September 8, 2018 00:37
package.json Outdated
@@ -643,6 +643,11 @@
"command": "csharp.listRemoteProcess",
"title": "List processes on remote connection for attach",
"category": "CSharp"
},
{
"command": "csharp.fileBugReport",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"reportIssue"

}

async function getMonoVersion(): Promise<string>{
return execChildProcess("dotnet --info", process.cwd());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"mono --version"?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if mono isn't on the path (eg, they depend on the one from the run script)

@akshita31
Copy link
Contributor Author

akshita31 commented Sep 11, 2018

To do:

  • Add the test for the issue reporter observer

package.json Outdated
},
{
"command": "csharp.reportIssue",
"title": "Upload bug report to github",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upload implies that there's no work to done. Maybe phrase it like "Start authoring a new issue on GitHub" or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const issuesUrl = "https://github.com/OmniSharp/omnisharp-vscode/issues/new";

export default async function fileIssue(vscode: vscode, eventStream: EventStream, execChildProcess: (command: string, workingDirectory?: string) => Promise<string>, isValidPlatformForMono: boolean) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reportIssue

monoInfo = await getMonoVersion(execChildProcess);
}
catch (error) {
monoInfo = "A valid mono installation could not be found. Using the built-in mono"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension has logic that determines the version of mono found and only using it if it's new enough. Can we try to follow the same logic here? We don't want to report mono versions that are old enough that we use the built in one instead.

}

async function getDotnetInfo(execChildProcess: (command: string, workingDirectory?: string) => Promise<string>): Promise<string> {
return execChildProcess("dotnet --info", process.cwd());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also needs to handle no dotnet on path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export const CSharpExtensionId = 'ms-vscode.csharp';
Copy link

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?

Copy link
Contributor Author

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.

public post = (event: BaseEvent) => {
switch (event.constructor.name) {
case ReportIssue.name:
let issue = <ReportIssue>event;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about needing to dispatch to the message bus to do this...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that there could be a component that's basically identical to the observer youa dded, but they could be directly composed together as opposed to going over the message bus.

import { ReportIssue } from "../../../src/omnisharp/loggingEvents";
import { vscode } from "../../../src/vscodeAdapter";

suite("File Issue", () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make names consistent, whatever we land on :)

src/omnisharp/loggingEvents.ts Show resolved Hide resolved
}
}

function configureCustomMono(childEnv: NodeJS.ProcessEnv, options: Options): string {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you move this underneath the getGlobalMono method?

return undefined;
}

export async function getMonoVersion( environment: NodeJS.ProcessEnv): Promise<string> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this one different from the one that's passed into the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a separate function that is used to initialise the OmniSharpMonoResolver class.

return new Promise<string>((resolve, reject) => {
let childprocess: ChildProcess;
try {
childprocess = spawn('mono', ['--version'], { env: environment });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this makes it untestable, no?

import { MonoInformation } from "./MonoInformation";

export interface IMonoResolver {
shouldUseGlobalMono(options: Options): Promise<MonoInformation>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should" in the name makes me think this returns a boolean. Maybe call this "getMonoInfo" or somethign?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants