Skip to content
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 Razor DynamicFile Provider #76050

Merged
merged 15 commits into from
Dec 5, 2024
Merged

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Nov 23, 2024

Roslyn side of dotnet/vscode-csharp#7826

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 23, 2024
@ryzngard ryzngard changed the title Update Razor DynamicFile Provider [Draft] Update Razor DynamicFile Provider Nov 23, 2024
@ryzngard ryzngard marked this pull request as ready for review November 26, 2024 02:20
@ryzngard ryzngard requested a review from a team as a code owner November 26, 2024 02:20
@ryzngard ryzngard changed the title [Draft] Update Razor DynamicFile Provider Update Razor DynamicFile Provider Nov 27, 2024
d => d.FilePath is not null && PathUtilities.PathsEqual(d.FilePath, dynamicFileInfoFilePath));

var textChanges = response.Edits.Select(e => new TextChange(e.Span.ToTextSpan(), e.NewText));
var textLoader = new TextChangesTextLoader(document, textChanges);
Copy link
Member

Choose a reason for hiding this comment

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

how often does this happen? Wondering if we need to instantiate a new loader each time or there was one TextLoader that we updated with the latest edits

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For closed documents it shouldn't be too often. It would be based on how often we have a diff when we generate. The most immediate cause I can think of would be if project info changed (going from unknown project to known project).

var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

// Validate the checksum information so the edits are known to be correct
if (IsSourceTextMatching(sourceText))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidwengier @dibarbet this is the logic I was thinking of on how to handle checksums. Telemetry would probably be done on the razor client side unless there's a preference for something else?

Copy link
Member

Choose a reason for hiding this comment

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

We should definitely track it, fine with doing on the Razor side. However if we're doing the checks here (and reporting in Razor) we're going to lose the reason why they were different in telemetry, which might be key to figuring out where things are going wrong.

@davidwengier
Copy link
Member

Love the idea that this gives us a "get out of jail free card", in being able to get the whole document contents. Will be curious what the telemetry looks like for sure

var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

// Validate the checksum information so the edits are known to be correct
if (IsSourceTextMatching(sourceText))
Copy link
Member

Choose a reason for hiding this comment

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

We should definitely track it, fine with doing on the Razor side. However if we're doing the checks here (and reporting in Razor) we're going to lose the reason why they were different in telemetry, which might be key to figuring out where things are going wrong.

return TextAndVersion.Create(newText, version.GetNewerVersion());
}

return await GetFullDocumentFromServerAsync(razorUri, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

I would say though we should evaluate this in a month or so - if we never get non-matching texts this should be changed into an assert, and if we do, we should track down where

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💯 should revisit to make sure this number is not high because that indicates perf is suboptimal

public ServerTextChange[]? Edits { get; set; }

[JsonPropertyName("checksum")]
public required byte[] Checksum { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Did this need to change to string? or did you work that out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh woops. Have it local and didn't push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants