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

Provide option to only update source-generators on special events (like a build) #72494

Merged
merged 224 commits into from
Apr 5, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Mar 12, 2024

Followup to #72490

This approach ensures that when SGs are very expensive (even incremental ones) that they can be set to run only when a build happens. That allows hte price to be paid at that point, with all further compilation requests using the results of that SG run up until the point of the next run.

This puts the user in control of that expense and provides a buffer against poorly run (or just very very expensive) generators. This is user configurable, allowing users to pick between this behavior, or the current behavior where generators just run automatically after any change.

Options looks like this:

image

There's also an option to force reloading of generators:

regen

Tests incoming.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 12, 2024
@@ -40,4 +37,7 @@ public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(thi

public static readonly Option2<bool> EnableOpeningSourceGeneratedFilesInWorkspaceFeatureFlag = new(
"dotnet_enable_opening_source_generated_files_in_workspace_feature_flag", WorkspaceConfigurationOptions.Default.EnableOpeningSourceGeneratedFiles);

public static readonly Option2<bool> RunSourceGeneratorsExplicitly = new(
"dotnet_run_source_generators_explicitly", WorkspaceConfigurationOptions.Default.RunSourceGeneratorsExplicitly);
Copy link
Member Author

Choose a reason for hiding this comment

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

@tmat do i need to do anything to ensure that this works if the user sets this in their editorconfig?

@@ -61,9 +61,6 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_run_code_analysis_on_dotnet}" />
</StackPanel>

<CheckBox x:Name="Analyze_source_generated_files"
Content="{x:Static local:AdvancedOptionPageStrings.Option_analyze_source_generated_files}" />
Copy link
Member Author

Choose a reason for hiding this comment

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

moved down to a dedicated source-generator section.


var bindingExpression = radiobutton.SetBinding(RadioButton.IsCheckedProperty, binding);
_bindingExpressions.Add(bindingExpression);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

same as the code below. just works for options that are not PerLanguage ones.

Copy link
Member Author

Choose a reason for hiding this comment

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

this code was needed to support a non-per-language nullable enum option value.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge April 5, 2024 00:25
@CyrusNajmabadi CyrusNajmabadi merged commit 8ca49e5 into dotnet:main Apr 5, 2024
28 of 30 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 5, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the runSGOnBuild branch April 5, 2024 01:38
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants