Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Return meaningful error when pinned SDK version is not found. #2403

Merged
merged 1 commit into from
May 28, 2022

Conversation

JoeRobich
Copy link
Member

Reported in dotnet/vscode-csharp#5128

As part of creating the TestManager OmniSharp attempts to parse the .NET CLI version. When a global.json is being used by a project and the SDK version pinned in the SDK is not installed a detailed error message is output to a combination of stderr and stdout. OmniSharp would then fail to parse a valid SemanticVersion from this output and the user would be given a generic FormatException. This change adds additional parsing of the output when it is not a valid SemanticVersion to provide the user with a more meaningful error.

Prior to this change users would see the following error in their OmniSharp log:

[fail]: OmniSharp.Stdio.Host
        ************  Response (35.0185ms) ************ 
{
  "Request_seq": 1013,
  "Command": "/v2/debugtest/getstartinfo",
  "Running": true,
  "Success": false,
  "Message": "\"System.FormatException: version\\n  at OmniSharp.SemanticVersion.Parse (System.String version) [0x0001b] in <04928efb700c47abb8cc2114b31a9ccb>:0 \\n  at OmniSharp.Services.DotNetCliService.GetVersion (System.String workingDirectory) [0x00011] in <3d93fabea6954f4ba147450b0cf4332a>:0 \\n  at OmniSharp.DotNetTest.TestManager.Create (Microsoft.CodeAnalysis.Project project, OmniSharp.Services.IDotNetCliService dotNetCli, OmniSharp.Eventing.IEventEmitter eventEmitter, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) [0x0000c] in <9d87b466e5a04dffb95becc0b4dfd560>:0 \\n  at OmniSharp.DotNetTest.TestManager.Start (Microsoft.CodeAnalysis.Project project, OmniSharp.Services.IDotNetCliService dotNetCli, OmniSharp.Eventing.IEventEmitter eventEmitter, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Boolean noBuild) [0x00000] in <9d87b466e5a04dffb95becc0b4dfd560>:0 \\n  at OmniSharp.DotNetTest.Services.BaseTestService.CreateTestManager (System.String fileName, System.Boolean noBuild) [0x00011] in <9d87b466e5a04dffb95becc0b4dfd560>:0 \\n  at OmniSharp.DotNetTest.Services.DebugTestService.Handle (OmniSharp.DotNetTest.Models.DebugTestGetStartInfoRequest request) [0x0000d] in <9d87b466e5a04dffb95becc0b4dfd560>:0 \\n  at OmniSharp.Endpoint.Exports.RequestHandlerExportHandler`2[TRequest,TResponse].Handle (TRequest request) [0x00000] in <3d93fabea6954f4ba147450b0cf4332a>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00022] in <3d93fabea6954f4ba147450b0cf4332a>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <3d93fabea6954f4ba147450b0cf4332a>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <3d93fabea6954f4ba147450b0cf4332a>:0 \\n  at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <2584067dfcea42a69c19a025cfbc4799>:0 \"",
  "Body": null,
  "Seq": 3637,
  "Type": "response"
}

With this change they will see a more actionable message.

Install the [6.0.301-rtm.22263.15] .NET SDK or update [/Users/joeyrobichaud/Source/format/global.json] to match an installed SDK.

Example from VS Code:
image

@JoeRobich JoeRobich requested a review from filipw May 24, 2022 03:03
Copy link
Member

@filipw filipw left a comment

Choose a reason for hiding this comment

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

thanks a lot - and sorry for the delay, I was away

@filipw filipw merged commit c723326 into OmniSharp:master May 28, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants