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

Wire up the UseRoslynTokenizer feature properly #11386

Merged
merged 10 commits into from
Jan 15, 2025

Conversation

davidwengier
Copy link
Contributor

Fixes #11120

This wires up UseRoslynTokenizer properly, so we read from the project not from our feature flag, in time for it being on by default for .NET 10. It also serializes pre-processor symbols so they will work with it. It is not serializing the whole C# parse options because we need to do work in Roslyn to share that code properly.

@davidwengier davidwengier requested review from a team as code owners January 13, 2025 23:00
@davidwengier
Copy link
Contributor Author

RPS and Speedometer runs in https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/602694


// We use the new tokenizer only when requested for now.
var useRoslynTokenizer = parseOptions.Features.TryGetValue("use-roslyn-tokenizer", out var useRoslynTokenizerValue)
&& string.Equals(useRoslynTokenizerValue, "true", StringComparison.OrdinalIgnoreCase);

var razorConfiguration = new RazorConfiguration(razorLanguageVersion, configurationName ?? "default", Extensions: [], UseConsolidatedMvcViews: true, SuppressAddComponentParameter: !isComponentParameterSupported);
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't you passing usesRoslynTokenizer to this ctor?


// We use the new tokenizer only when requested for now.
var useRoslynTokenizer = parseOptions.Features.TryGetValue("use-roslyn-tokenizer", out var useRoslynTokenizerValue)
&& string.Equals(useRoslynTokenizerValue, "true", StringComparison.OrdinalIgnoreCase);

var razorConfiguration = new RazorConfiguration(razorLanguageVersion, configurationName ?? "default", Extensions: [], UseConsolidatedMvcViews: true, SuppressAddComponentParameter: !isComponentParameterSupported);

var razorSourceGenerationOptions = new RazorSourceGenerationOptions()
Copy link
Member

Choose a reason for hiding this comment

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

Thiss constructor ends up with an object where options.UseRoslynTokenizer != options.Configuration.UseRoslyntokenizer. Is there a place where we could add validation to catch this dissagreement? Or is it a valid setup and I'm missing it. Could RazorSourceGenerationOptions just have UseRoslynTokenizer be a passthrough to the property on Configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RazorConfiguration is currently not ideal IMO. It's why I logged #11182. Tooling passes a RazorConfiguration to the compiler when configuring the project engine, but the compiler doesn't use all of the configuration, so we also have to read properties off that configuration again, and do more config in the configure lambda. Ideally we'd just give the compiler some type it needed, and it would go from there.

So yeah, UseRoslynTokenizer could be passed in here, and in fact thats why I moved it, but then I realised it wasn't necessary and forgot to move it back.

@davidwengier
Copy link
Contributor Author

davidwengier commented Jan 14, 2025

Perf DDRITs and Speedometer are all happy 🎉🎉🎉

(Nobody breathe on the PR)

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Compiler change LGTM, and the parts of the IDE that are creating parse options appear correct.

@davidwengier davidwengier merged commit e076a7b into main Jan 15, 2025
12 checks passed
@davidwengier davidwengier deleted the dev/dawengie/RoslynTokenizerTakeEightySix branch January 15, 2025 01:23
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 15, 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.

Preprocessor directives don't flow from the IDE to the compiler
5 participants