-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/8.0] Optimize Options Source Gen when no need to run #93481
Conversation
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsBackport of #93427 to release/8.0 /cc @tarekgh Customer ImpactTestingRiskIMPORTANT: If this backport is for a servicing release, please verify that:
|
Tagging subscribers to this area: @dotnet/area-extensions-options Issue DetailsBackport of #93427 to release/8.0 /cc @tarekgh Customer ImpactTestingRiskIMPORTANT: If this backport is for a servicing release, please verify that:
|
@artl93 this one is ready for your review. |
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.
M2 approved.
@tarekgh - Just a thought - is it possible to assert the optimization worked for this case in a unit test? E.g. context did not end up adding sources, perhaps? (Curious)
@artl93 part of my manual testing I did is I confirmed the behavior under the debugger and ensured the generator didn't do anything and exited early when there is no need to generate any code. We have a work planned for 9.0 to address the whole incremental change with this generator and other generators. When we do that, I expect we'll add more granular test cases that should cover the concerned scenarios. Checking added sources is not going to confirm our scenario here because the generator can run fully and still does not generate any code. |
Approved by Tactics via email. |
Backport of #93427 to release/8.0
/cc @tarekgh
Customer Impact
The Options source generator was introduced in .NET 8.0 and is activated by default, requiring no user intervention for its use. During design time, the generator is invoked with every keystroke. The modification here aims to prevent the generator from executing when no code generation is required. This enhancement accelerates this scenario and minimizes unnecessary memory allocation, addressing a minor performance regression that we have already observed.
Testing
Successfully passed all regression tests without any failures. We don't currently have a way to test privates for VS test runs and we'll look into improving that once we have the VMR
Risk
There is virtually no risk associated with this change. It is a minor, non-impactful modification that should not disrupt the logic of the source generator.
IMPORTANT: If this backport is for a servicing release, please verify that:
The PR target branch is
release/X.0-staging
, notrelease/X.0
.If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.