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

Always use designtime document for formatting with FUSE #10640

Merged
merged 7 commits into from
Jul 22, 2024

Conversation

ryzngard
Copy link
Contributor

Separated commits to functional change and code moving. This moves the feature flag check into tooling instead of relying on the compiler to know and generate documents differently.

That also allows for correctly doing document generation of designtime/runtime from the tooling side. If FUSE is enabled tooling will use runtime in all places except formatting. This is to keep formatting working as it does today without FUSE and start A/B testing faster.

@@ -261,284 +260,48 @@ internal static ImmutableArray<IDocumentSnapshot> GetImportsCore(IProjectSnapsho
return imports.ToImmutable();
}

// Internal, because we are temporarily sharing code with CohostDocumentSnapshot
internal class ComputedStateTracker
internal static async Task<RazorCodeDocument> GenerateCodeDocumentAsync(ImmutableArray<TagHelperDescriptor> tagHelpers, RazorProjectEngine projectEngine, IDocumentSnapshot document, ImmutableArray<ImportItem> imports, bool forceRuntimeCodeGeneration)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved stuff around but I'm not totally happy with how it ended up. Maybe it's time to move these into a static class on their own?

@ryzngard ryzngard marked this pull request as ready for review July 18, 2024 00:04
@ryzngard ryzngard requested review from a team as code owners July 18, 2024 00:04
@ryzngard
Copy link
Contributor Author

@@ -59,4 +59,30 @@ public static bool IsPathCandidateForComponent(this IDocumentSnapshot documentSn
var fileName = Path.GetFileNameWithoutExtension(documentSnapshot.FilePath);
return fileName.AsSpan().Equals(path.Span, FilePathComparison.Instance);
}

public static Task<RazorCodeDocument> GetFormatterCodeDocumentAsync(this IDocumentSnapshot documentSnapshot)
Copy link
Member

Choose a reason for hiding this comment

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

Should this take a CancellationToken and pass it to GetDesignTimeDocumentAsync(...) and then into project.GetTagHelpersAsync(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of the stack this depends on doesn't currently take cancellation tokens. I think they should so I'll file a tech debt issue.

internal partial class DocumentState
{
// Internal, because we are temporarily sharing code with CohostDocumentSnapshot
private class ComputedStateTracker
Copy link
Member

Choose a reason for hiding this comment

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

All of this green made me remember how much I hate how confusing ComputedStateTracker is and how much I want to rewrite it. Sigh... MUST RESIST BEING NERD-SNIPED. 😁

ryzngard and others added 2 commits July 18, 2024 15:14
…Formatting_NetFx/FormattingTestBase.cs

Co-authored-by: Dustin Campbell <dustin@teamcampbell.org>
@ryzngard ryzngard merged commit b52ed1a into dotnet:main Jul 22, 2024
12 checks passed
@ryzngard ryzngard deleted the formatting_always_uses_designtime branch July 22, 2024 21:02
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 22, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 Preview 1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants