Skip to content

Conversation

davidwengier
Copy link
Member

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
Member 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
Member 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
Member 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.

@jjonescz jjonescz modified the milestones: Next, 17.14 P1 Mar 11, 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
6 participants