-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Simplify language version check in Regex generator #81678
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue Detailsnull
|
{ | ||
if (method.MethodSyntax.SyntaxTree.Options is CSharpParseOptions { LanguageVersion: <= LanguageVersion.CSharp10 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, MethodSyntax
shouldn't exist in the RegexMethod
model at all. I could eliminate this usage, but not the other one. (the other usage can be changed to be Location
instead of MethodDeclarationSyntax
but that is not good as well)
So I simplified this usage for now.
Someone from Roslyn team should be able to advise about the other usage.
487a46b
to
c780c4d
Compare
This isn't really "simpler". What are the benefits of this change? Without it, do we not correctly handle regenerating if the language version changes? |
It's not good to have So, ideally, to have something more meaningful, the other usage should be eliminated as well. But I thought it's good to eliminate one usage for now. The reason |
Tagging @CyrusNajmabadi and @333fred as well. |
Can you point to where such comparisons are being performed and how that would impact things? I'm fine with the change if there's benefit, I was just highlighting I don't think the change makes anything in the code "simpler" as the title suggests, so I'm trying to understand the ramifications of the change. I assume the primary benefit is if we're not currently including the language version in |
In both cases we will regenerate when language version changes. To be clear, the change in this PR alone doesn't have benefits on its own, but I think it is on the correct path to achieve a benefit. See discussion in dotnet/roslyn-analyzers#6352. Regarding "where the comparisons are done", I'm not familiar with the compiler implementation in this area. But it is simply that when |
Well, the intent of But separate from that, if the problem is that the object being returned from a stage in the pipeline contains a reference to a MethodSyntax, and replacing that with a Location isn't sufficient to thwart the issues being cited, then this really doesn't do anything other than move the cheese around. How is code later in a pipeline supposed to report diagnostics if it can't reference the Location to report them at? It's not feasible to report all diagnostics as part of the very first discovery stage, unless the entire pipeline is collapsed down to that single stage, which then also defeats the purpose. |
|
That would end up duplicating a lot of the work that's being performed, as the generator would still need to perform all of the same work (the outcome of that work fuels not just the diagnostics but the actual generated code). That's really the model we encourage? |
No description provided.