-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow services to use System.Text.Json for OOP comms in Razor #74280
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1d389e6
Allow services to use System.Text.Json for OOP comms
davidwengier 551bda4
Add System.Text.Json compatible equivalents of common parameter types
davidwengier a1ef6aa
Remove Newtonsoft, and allow existing LSP converters to be used
davidwengier aabb4ab
Restricted IVT to where Razor OOP services are defined
davidwengier 8ff45d7
Fix header accidenatlly copied from Razor
davidwengier e8a490a
Merge remote-tracking branch 'upstream/main' into RemoteSTJServices
davidwengier 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
27 changes: 27 additions & 0 deletions
27
src/Tools/ExternalAccess/Razor/Remote/JsonSerializableDocumentId.cs
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,27 @@ | ||
// 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.ExternalAccess.Razor | ||
{ | ||
/// <summary> | ||
/// Represents a DocumentId that can be used by Razor for OOP services that communicate via System.Text.Json | ||
/// </summary> | ||
internal readonly record struct JsonSerializableDocumentId( | ||
[property: JsonPropertyName("projectId")] Guid ProjectId, | ||
[property: JsonPropertyName("id")] Guid Id) | ||
{ | ||
public static implicit operator JsonSerializableDocumentId(DocumentId documentId) | ||
{ | ||
return new JsonSerializableDocumentId(documentId.ProjectId.Id, documentId.Id); | ||
} | ||
|
||
public static implicit operator DocumentId(JsonSerializableDocumentId serializableDocumentId) | ||
{ | ||
return DocumentId.CreateFromSerialized(CodeAnalysis.ProjectId.CreateFromSerialized(serializableDocumentId.ProjectId), serializableDocumentId.Id); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Tools/ExternalAccess/Razor/Remote/JsonSerializableRazorPinnedSolutionInfoWrapper.cs
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,27 @@ | ||
// 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.ExternalAccess.Razor | ||
{ | ||
/// <summary> | ||
/// A wrapper for a solution that can be used by Razor for OOP services that communicate via System.Text.Json | ||
/// </summary> | ||
internal readonly record struct JsonSerializableRazorPinnedSolutionInfoWrapper( | ||
[property: JsonPropertyName("data1")] long Data1, | ||
[property: JsonPropertyName("data2")] long Data2) | ||
{ | ||
public static implicit operator JsonSerializableRazorPinnedSolutionInfoWrapper(RazorPinnedSolutionInfoWrapper info) | ||
{ | ||
return new JsonSerializableRazorPinnedSolutionInfoWrapper(info.UnderlyingObject.Data1, info.UnderlyingObject.Data2); | ||
} | ||
|
||
public static implicit operator RazorPinnedSolutionInfoWrapper(JsonSerializableRazorPinnedSolutionInfoWrapper serializableDocumentId) | ||
{ | ||
return new RazorPinnedSolutionInfoWrapper(new Checksum(serializableDocumentId.Data1, serializableDocumentId.Data2)); | ||
} | ||
} | ||
} |
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
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.
interesting. would like to know more about this. when are you guuys pinning solutions?
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.
@eiriktsarpalis how do longs get serialized in STJ? Are they guaranteed to roundtrip?
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.
hopefully never? This is just a version of RazorPinnedSolutionInfoWrapper, which is really just Checksum, but this serializes with STJ and that uses messagepack. I could add STJ attributes to
RazorPinnedSolutionInfoWrapper
, but then I'd need them onChecksum
too.This type is only used to call OOP, and is then passed back to roslyn to get the real solution
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.
They serialize to JSON numbers which have arbitrary precision. They are guaranteed to roundtrip.
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.
Thanks!