Skip to content

Source Generator for Bindable Property#1321

Merged
TheCodeTraveler merged 16 commits into
mainfrom
pj/bindable-property-SG
Aug 2, 2024
Merged

Source Generator for Bindable Property#1321
TheCodeTraveler merged 16 commits into
mainfrom
pj/bindable-property-SG

Conversation

@pictos

@pictos pictos commented Aug 7, 2023

Copy link
Copy Markdown
Member

This will be used by the lib only, it shouldn't be part of our public nuget, because of that I deleted the template...

I'll point out the code areas that, I believe, can cause questions. In the future should be easier to port the code to the public SG project and delete this one

Fixes #542

Comment thread src/CommunityToolkit.Maui.BindablePropertySG/BindablePropertySG.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/BindablePropertySG.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/BindablePropertySG.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/BindablePropertySG.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/BindablePropertySG.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/Helpers/HashCode.cs
Comment thread src/CommunityToolkit.Maui.BindablePropertySG/Models/Records.cs Outdated
Comment thread src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
Comment thread src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
{
var data = attribute.ConstructorArguments[0];

return data.Value is null ? throw new NullReferenceException() : data.Value.ToString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we add a message for NRE describing what is null?

@TheCodeTraveler

TheCodeTraveler commented Aug 12, 2023

Copy link
Copy Markdown
Collaborator

Thanks Pedro! Just FYI - I renamed the new class and its namespace to CommunityToolkit.Maui.SourceGenerators.Internal.

This opens up the opportunity for us to use this csproj for additional internal source generators in the future.

And let's convert all of our BindablePropertys in this PR before we merge. I'm happy to help convert them all.

@TheCodeTraveler

TheCodeTraveler commented Aug 12, 2023

Copy link
Copy Markdown
Collaborator

Hey Pedro! This is looking really really cool!

Could you add the ability to include XML comments in the attribute? Right now <inheritdoc /> is hardcoded, but many of our already-implemented properties have customized XML docs. I tried to convert a couple existing BindablePropertys, but ran into this as a blocker.

👇 Maybe it'd look something like this?

[BindableProperty<bool>("IsExpanded", PropertyChangedMethodName = nameof(OnIsExpandedPropertyChanged), XMLComment="<inheritdoc />")]

@pictos

pictos commented Aug 12, 2023

Copy link
Copy Markdown
Member Author

@brminnick I didn't have a good approach for XML docs, because they can be small or big, and not sure how that will fit with SG... Maybe let this be solved when C# has partial properties?

OF course, you may have a bunch of const string to reference, but I don't feel it very idiomatic

@ghost ghost added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels Sep 27, 2023
@VladislavAntonyuk

Copy link
Copy Markdown
Contributor

@pictos do we need any unresolved issues or open questions? Can we merge this PR as it is?

@pictos pictos force-pushed the pj/bindable-property-SG branch from 4542d2f to 067a1ff Compare December 14, 2023 22:26
@listepo

listepo commented Apr 14, 2024

Copy link
Copy Markdown

any news?

@TheCodeTraveler TheCodeTraveler removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days labels Aug 2, 2024

@TheCodeTraveler TheCodeTraveler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Pedro! Thanks Vlad!

@TheCodeTraveler TheCodeTraveler merged commit 2baab31 into main Aug 2, 2024
@TheCodeTraveler TheCodeTraveler deleted the pj/bindable-property-SG branch August 2, 2024 16:58
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] BindableProperty generator

4 participants