Open Sergio0694 opened 2 months ago
This issue tracks adding a new source generator for CanvasEffect properties. It will be conceptually similar to the MVVM Toolkit observable property generator.
CanvasEffect
In ComputeSharp.D2D1.WinUI:
namespace ComputeSharp.D2D1.WinUI; [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public sealed class GeneratedCanvasEffectPropertyAttribute(CanvasEffectInvalidationType invalidationType = CanvasEffectInvalidationType.Update) : Attribute { public CanvasEffectInvalidationType InvalidationType { get; } }
User code:
public sealed partial class MyEffect : CanvasEffect { [GeneratedCanvasEffectProperty] public partial int BlurAmount { get; set; } }
Generated code:
partial class MyEffect : CanvasEffect { public partial int BlurAmount { get => field; set { if (EqualityComparer<int>.Default.Equals(field, value)) { return; } int oldValue = field; OnBlurAmountChanging(value); OnBlurAmountChanging(oldValue, value); field = value; OnBlurAmountChanged(value); OnBlurAmountChanged(oldValue, value); InvalidateEffectGraph(invalidationType); } } partial void OnBlurAmountChanging(int newValue); partial void OnBlurAmountChanging(int oldValue, int newValue); partial void OnBlurAmountChanged(int newValue); partial void OnBlurAmountChanged(int oldValue, int newValue); }
This should contain any drawbacks for the proposal that came up during the discussions.
Just do nothing.
Description
This issue tracks adding a new source generator for
CanvasEffect
properties. It will be conceptually similar to the MVVM Toolkit observable property generator.Proposed API
In ComputeSharp.D2D1.WinUI:
Example use
User code:
Generated code:
This should contain any drawbacks for the proposal that came up during the discussions.
Alternatives
Just do nothing.
Work items