Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ public void PublishCSharp(ProjectKey projectKey, string filePath, SourceText sou
ProjectKeyId = projectKey.Id,
Changes = textChanges.Select(static t => t.ToRazorTextChange()).ToArray(),
HostDocumentVersion = hostDocumentVersion,
PreviousWasEmpty = previouslyPublishedData.SourceText.Length == 0
PreviousWasEmpty = previouslyPublishedData.SourceText.Length == 0,
Checksum = Convert.ToBase64String(sourceText.GetChecksum().ToArray()),
ChecksumAlgorithm = sourceText.ChecksumAlgorithm,
SourceEncodingCodePage = sourceText.Encoding?.CodePage
};

_clientConnection.SendNotificationAsync(CustomMessageNames.RazorUpdateCSharpBufferEndpoint, request, CancellationToken.None).Forget();
Expand Down Expand Up @@ -145,7 +148,10 @@ public void PublishHtml(ProjectKey projectKey, string filePath, SourceText sourc
ProjectKeyId = projectKey.Id,
Changes = textChanges.Select(static t => t.ToRazorTextChange()).ToArray(),
HostDocumentVersion = hostDocumentVersion,
PreviousWasEmpty = previouslyPublishedData.SourceText.Length == 0
PreviousWasEmpty = previouslyPublishedData.SourceText.Length == 0,
Checksum = Convert.ToBase64String(sourceText.GetChecksum().ToArray()),
ChecksumAlgorithm = sourceText.ChecksumAlgorithm,
SourceEncodingCodePage = sourceText.Encoding?.CodePage
};

_clientConnection.SendNotificationAsync(CustomMessageNames.RazorUpdateHtmlBufferEndpoint, request, CancellationToken.None).Forget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.Razor.Protocol;

Expand All @@ -21,4 +22,13 @@ internal sealed class UpdateBufferRequest

[JsonPropertyName("previousWasEmpty")]
public bool PreviousWasEmpty { get; set; }

[JsonPropertyName("checksum")]
public required string Checksum { get; set; }

[JsonPropertyName("checksumAlgorithm")]
public SourceHashAlgorithm ChecksumAlgorithm { get; set; }

[JsonPropertyName("encodingCodePage")]
public int? SourceEncodingCodePage { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
Expand Down Expand Up @@ -71,7 +72,10 @@ public async Task UpdateCSharpBuffer_CannotLookupDocument_NoopsGracefully()
var request = new UpdateBufferRequest()
{
HostDocumentFilePath = "C:/path/to/file.razor",
Changes = null
Changes = null,
Checksum = "",
ChecksumAlgorithm = SourceHashAlgorithm.Sha256,
SourceEncodingCodePage = null,
};

// Act & Assert
Expand Down Expand Up @@ -115,6 +119,9 @@ public async Task UpdateCSharpBuffer_UpdatesDocument()
HostDocumentFilePath = "C:/path/to/file.razor",
HostDocumentVersion = 1337,
Changes = [],
Checksum = "",
ChecksumAlgorithm = SourceHashAlgorithm.Sha256,
SourceEncodingCodePage = null,
};

// Act
Expand Down Expand Up @@ -169,6 +176,9 @@ public async Task UpdateCSharpBuffer_UpdatesCorrectDocument()
HostDocumentFilePath = "C:/path/to/file.razor",
HostDocumentVersion = 1337,
Changes = [],
Checksum = "",
ChecksumAlgorithm = SourceHashAlgorithm.Sha256,
SourceEncodingCodePage = null,
};

// Act
Expand Down
Loading