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

Proposal: Add option to exclude (obsolete) properties from GeneratedBindableCustomProperty #1912

Open
Marv51 opened this issue Feb 4, 2025 · 2 comments

Comments

@Marv51
Copy link

Marv51 commented Feb 4, 2025

Summary

When you add the [GeneratedBindableCustomProperty] the generator creates all the necessary code to make that class bindable when using AOT compilation.

I have a sample class that contains an obsolete property:

[WinRT.GeneratedBindableCustomProperty]
public class BlogPostViewModel{
     [Obsolete("Do not use this property")]
     public int BlogId => Random.Shared.Next();
}

The CsWinRT created code produces a warning (in the generated WinRTCustomBindableProperties.g.cs):

Warning CS0618: 'BlogPostViewModel.BlogId' is obsolete: 'Do not use this property'

Rationale

I think this warning is not helpful and should go away.

Currently I can include all other properties in the propertyNames property of the attribute to exclude the one obsolete property. This makes the warning go away, but requires me to keep a list of all properties (minus the obsolete one).

Important Notes

No response

Open Questions

I could imagine one of these 3 approaches:

  • suppress CS0618 for the generated code
  • add an "excludedPropertiesNames" option to the attribute and the generator to exclude individual properties
  • add an "exclude obsolete properties" option to the attribute and the generator
@dongle-the-gadget
Copy link
Contributor

I think it would be helpful if we could generalize this and instead use an opt-in/opt-out system.

@manodasanW
Copy link
Member

Given we already have an opt-in approach for specific properties in addition to all, what it sounds like to me is we also just need an opt-out approach for specific properties and that would satisfy this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants