Skip to content

Conversation

DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Mar 31, 2025

This is a follow up to #11675 that cleans up and removes some code in the "ProjectEngineHost" folder. Notably, it turns out that the system for marking projects as "unsupported" is no longer used. So, checks for RazorCodeDocument.IsUnsupported() can be removed from the language server and tests for this scenario can be removed.

NOTE: This PR is currently based on pre-snap-code-clean-up to aid code reviews. I'll rebase it to main once #11675 is merged.
Changed the base to main

- Nest ProjectEngineFactory inside ProjeectEngineFactories, make it private, and rename it to SimpleFactory.
- Mark ProjectEngineFactoryProvider as sealed
- Mark DefaultProjectEngineFactory as sealed
There's a surprising amount of production code checking IsUnsupported() and specific tests calling SetUnsuported() that can be removed.
After calling DocumentContext.GetCodeDocumentAsync(...), it's unnecessary to call DocumentContext.GetSourceTextAync(...). Instead, just use RazorCodeDocument.Source.Text.
@DustinCampbell DustinCampbell requested a review from a team as a code owner March 31, 2025 18:55
}

var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
if (codeDocument.IsUnsupported())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm so happy to see this go 🥳

}

var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

not for this PR, but should DocumentContext.GetCodeDocumentAsync populate _sourceText with this value as well? I assume we have the two separated for some optimization where you need sourcetext but not a full RazorCodeDocument

Copy link
Member Author

@DustinCampbell DustinCampbell Mar 31, 2025

Choose a reason for hiding this comment

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

Yes, that's a very good idea.

@ryzngard
Copy link
Contributor

Thanks for making this easy to review!

@DustinCampbell DustinCampbell changed the base branch from dev/dustinca/pre-snap-code-clean-up to main March 31, 2025 19:57
@DustinCampbell DustinCampbell merged commit cbdb58f into dotnet:main Apr 1, 2025
11 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 1, 2025
@DustinCampbell DustinCampbell deleted the update-projectenginehost branch April 1, 2025 20:40
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 20, 2025
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.

4 participants