.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
When working with nullable libraries, being able to add the required keyword to properties is helpful. I have reviewed the source generator and dont believe this is currently supported when using ObservablePropertyAttribute . I propose adding properties to the this class to signal to the generator to add this modifier where required. This would default to false to not impact existing usage.
As the code would be similar, I propose to add the virtual modifier at the same time for completeness.
API breakdown
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class ObservablePropertyAttribute : Attribute
{
public bool Virtual { get; set; } = false;
public bool Required { get; set; } = false;
}
Overview
When working with nullable libraries, being able to add the required keyword to properties is helpful. I have reviewed the source generator and dont believe this is currently supported when using ObservablePropertyAttribute . I propose adding properties to the this class to signal to the generator to add this modifier where required. This would default to false to not impact existing usage.
As the code would be similar, I propose to add the virtual modifier at the same time for completeness.
API breakdown
Usage example
Breaking change?
No
Alternatives
Current alternative is to selectively use source generator, and use the underlying methods when creating properties by hand.
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item