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

Use new [Interceptable] ctor for source gen #104180

Merged
merged 8 commits into from
Jul 10, 2024

Conversation

steveharter
Copy link
Member

@steveharter steveharter commented Jun 28, 2024

Fixes #101079

This changes the use of the experimental [Interceptable] attribute to use the newer version provided by Roslyn.

This affects the test baselines, and depending on the environment there may be an older Roslyn present, so both the original and the new baselines are in this PR. See the linked issue as well as the ReadMe.md file in the changed files here to get more information.

To avoid breaking v8, this PR will eventually need to be ported to v8 since the original version of the attribute will eventually no longer be supported. It may be possible to only have the newer baseline for v9, however both are included here, and the plan is to essentially port this PR as-is to v8. Once the original version is no longer necessary, we can remove the "version 0" baselines and perhaps the infrastructure for having two baselines, assuming at that time Rosyln has no plans to add a third version.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

@steveharter steveharter marked this pull request as ready for review July 2, 2024 18:54
@steveharter steveharter changed the title Use new interceptor pattern Use new [Interceptable] attribute for source gen Jul 2, 2024
int? interceptableVersion = null;

#if UPDATE_BASELINES
const string envVarName = "InterceptableAttributeVersion";
Copy link
Member

Choose a reason for hiding this comment

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

InterceptableAttributeVersion

Is this specific only to the config binder source gen? or we expect usage in other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just here. I removed the const and just inlined the string.

@@ -7,6 +7,7 @@
<AnalyzerLanguage>cs</AnalyzerLanguage>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants Condition="'$(LaunchDebugger)' == 'true'">$(DefineConstants);LAUNCH_DEBUGGER</DefineConstants>
<DefineConstants Condition="'$(UpdateBaselines)' == 'true'">$(DefineConstants);UPDATE_BASELINES</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

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

$(DefineConstants);UPDATE_BASELINES

Love it :-)

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

Left minor comments, LGTM otherwise.

We need to decide if we continue to go with the environment variable. Will be good if @RikkiGibson look too. Thanks!

@steveharter steveharter changed the title Use new [Interceptable] attribute for source gen Use new [Interceptable] ctor for source gen Jul 3, 2024
@steveharter steveharter merged commit 0413759 into dotnet:main Jul 10, 2024
84 checks passed
@steveharter steveharter deleted the NewInterceptors branch July 10, 2024 18:50
matouskozak added a commit to matouskozak/runtime that referenced this pull request Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConfigurationBindingGenerator should move to GetInterceptableLocation API
2 participants