-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74280 from davidwengier/RemoteSTJServices
Allow services to use System.Text.Json for OOP comms in Razor
- Loading branch information
Showing
6 changed files
with
88 additions
and
10 deletions.
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