-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Update gladstone/roslyn api #78057
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
Update gladstone/roslyn api #78057
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Extensions; | ||
|
|
||
| internal sealed record class ExtensionException( | ||
| [property: JsonPropertyName("typeName")] string TypeName, | ||
| [property: JsonPropertyName("message")] string Message, | ||
| [property: JsonPropertyName("stackTrace"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] string? StackTrace, | ||
| [property: JsonPropertyName("innerException"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] ExtensionException? InnerException) | ||
| { | ||
| public static ExtensionException? FromException(Exception? exception) | ||
| => exception is null | ||
| ? null | ||
| : new ExtensionException(exception.GetType().ToString(), exception.Message, exception.StackTrace, FromException(exception.InnerException)); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,11 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Extensions; | |
| /// <summary> | ||
| /// Return type for the roslyn/extensionWorkspaceMessage and roslyn/extensionDocumentMessage request. | ||
| /// </summary> | ||
| /// <param name="Response">Json response returned by the extension message handler.</param> | ||
| /// <param name="Response">Json response returned by the extension message handler. Can be <see langword="null"/> if the | ||
| /// extension was unloaded concurrently with the response being issued, or if the extension threw an exception while | ||
| /// processing.</param> | ||
| internal readonly record struct ExtensionMessageResponse( | ||
| [property: JsonPropertyName("response")] string Response); | ||
| [property: JsonPropertyName("response"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] string? Response, | ||
| [property: JsonPropertyName("extensionWasUnloaded"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] bool ExtensionWasUnloaded, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New field to represent a supported failure mode that does not return a respone and was not an exception itself throwing an exception. |
||
| [property: JsonPropertyName("extensionException"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
| ExtensionException? ExtensionException); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matteo-prosperi up to you what you will do with this info on the gladstone side. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,9 @@ public async Task<ExtensionRegisterResponse> HandleRequestAsync(ExtensionRegiste | |
| if (handlerNames.ExtensionException is not null) | ||
| context.Logger.LogException(handlerNames.ExtensionException); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dibarbet i'm still logging this here (as well as passing back to Gladstone). is that ok with you ? |
||
|
|
||
| return new(handlerNames.WorkspaceMessageHandlers, handlerNames.DocumentMessageHandlers); | ||
| return new( | ||
| handlerNames.WorkspaceMessageHandlers, | ||
| handlerNames.DocumentMessageHandlers, | ||
| ExtensionException.FromException(handlerNames.ExtensionException)); | ||
| } | ||
| } | ||
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.
I'm fine with this - however I would have naively started with serializing System.Exception - I assume we don't want that here? I know the exception type may not exist on the other side, but that is something jsonrpc already has to deal with when we throw exceptions for example.