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

Enable Binding inteceptors source generator by default #22856

Conversation

simonrozsival
Copy link
Member

Description of Change

This is a follow-up to #21725, contributes to #22384

The binding interceptors generator can be disabled by setting the existing $(DisableMauiAnalyzers) property or by setting _MauiEnableBindingInterceptors to false.

@simonrozsival simonrozsival requested a review from a team as a code owner June 5, 2024 15:01
@simonrozsival simonrozsival marked this pull request as draft June 5, 2024 18:13
@simonrozsival simonrozsival marked this pull request as ready for review June 6, 2024 18:32
@PureWeen PureWeen added the area-core-platform Integration with platforms label Jun 8, 2024
@simonrozsival simonrozsival force-pushed the enable-set-binding-inteceptors-sourcegen branch from cb80320 to 1f1878d Compare June 10, 2024 14:12
src/Core/src/RuntimeFeature.cs Outdated Show resolved Hide resolved
src/Core/src/RuntimeFeature.cs Outdated Show resolved Hide resolved
@@ -21,6 +21,15 @@
<Analyzer Include="$(MSBuildThisFileDirectory)Microsoft.Maui.Controls.SourceGen.dll" IsImplicitlyDefined="true" />
</ItemGroup>

<!-- Enable BindingSourceGen -->
<PropertyGroup>
<_MauiEnableBindingInterceptors Condition=" '$(_MauiEnableBindingInterceptors)' == '' and '$(DisableMauiAnalyzers)' != 'true' ">true</_MauiEnableBindingInterceptors>
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to have a private MSBuild property to turn it off. 👍 Customers can opt out of the new source generator with _MauiEnableBindingInterceptors=false if something goes wrong with their build.

@simonrozsival simonrozsival force-pushed the enable-set-binding-inteceptors-sourcegen branch from 04e81a8 to 8c5d218 Compare June 19, 2024 10:37
@@ -32,3 +33,31 @@ When disabled, MAUI won't look for implicit cast operators when converting value
If your library or your app defines an implicit operator on a type that can be used in one of the previous scenarios, you should define a custom `TypeConverter` for your type and attach it to the type using the `[TypeConverter(typeof(MyTypeConverter))]` attribute.

_Note: Prefer using the `TypeConverterAttribute` as it can help the trimmer achieve better binary size in certain scenarios._

## _MauiEnableBindingInterceptors
Copy link
Contributor

Choose a reason for hiding this comment

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

MSBuild properties are tricky, as everything is public, but a kind of convention is to treat those starting with an '_' as private, or for internal usage. But documenting it make me feel like it's for public consumption... so I feel a mismatch

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I initially wanted this to be a "private" flag but at the same time it seems like something that we should document at least in Preview builds, until we make sure the feature works well and there's no real need to disable the analyzer.

@jonathanpeppers what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Some of the MSBuild properties listed here are private:

I think for feature switches, we should document them even if something is private.

Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
@mattleibow mattleibow merged commit 27a83b7 into dotnet:net9.0 Jun 24, 2024
48 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 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.

6 participants