Support required partial properties

このコミットが含まれているのは:
Sergio Pedri committed 2024-11-30 10:50:18 -08:00
1 親 9cfa571922
コミット e80b110023
4ファイル変更
+93 -3

検索条件に一致するファイルはありません

@@ -344,6 +344,90 @@ public class Test_CanvasEffectPropertyGenerator
VerifyGeneratedDiagnostics(source, ("MyNamespace.MyEffect.g.cs", result));
}
[TestMethod]
public void SingleProperty_Required()
{
const string source = """
using ComputeSharp.D2D1.WinUI;
namespace MyNamespace;
public abstract partial class MyEffect : CanvasEffect
{
[GeneratedCanvasEffectProperty]
public required partial int Number { get; set; }
}
""";
const string result = """"
// <auto-generated/>
#pragma warning disable
namespace MyNamespace
{
/// <inheritdoc cref="MyEffect"/>
partial class MyEffect
{
/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.WinUI.CanvasEffectPropertyGenerator", <ASSEMBLY_VERSION>)]
[global::System.Diagnostics.DebuggerNonUserCode]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public required partial int Number
{
get => field;
set
{
if (global::System.Collections.Generic.EqualityComparer<int>.Default.Equals(field, value))
{
return;
}
int oldValue = field;
OnNumberChanging(value);
OnNumberChanging(oldValue, value);
field = value;
OnNumberChanged(value);
OnNumberChanged(oldValue, value);
InvalidateEffectGraph(global::ComputeSharp.D2D1.WinUI.CanvasEffectInvalidationType.Update);
}
}
/// <summary>Executes the logic for when <see cref="Number"/> is changing.</summary>
/// <param name="value">The new property value being set.</param>
/// <remarks>This method is invoked right before the value of <see cref="Number"/> is changed.</remarks>
[global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.WinUI.CanvasEffectPropertyGenerator", <ASSEMBLY_VERSION>)]
partial void OnNumberChanging(int newValue);
/// <summary>Executes the logic for when <see cref="Number"/> is changing.</summary>
/// <param name="oldValue">The previous property value that is being replaced.</param>
/// <param name="newValue">The new property value being set.</param>
/// <remarks>This method is invoked right before the value of <see cref="Number"/> is changed.</remarks>
[global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.WinUI.CanvasEffectPropertyGenerator", <ASSEMBLY_VERSION>)]
partial void OnNumberChanging(int oldValue, int newValue);
/// <summary>Executes the logic for when <see cref="Number"/> has just changed.</summary>
/// <param name="value">The new property value that has been set.</param>
/// <remarks>This method is invoked right after the value of <see cref="Number"/> is changed.</remarks>
[global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.WinUI.CanvasEffectPropertyGenerator", <ASSEMBLY_VERSION>)]
partial void OnNumberChanged(int newValue);
/// <summary>Executes the logic for when <see cref="Number"/> has just changed.</summary>
/// <param name="oldValue">The previous property value that has been replaced.</param>
/// <param name="newValue">The new property value that has been set.</param>
/// <remarks>This method is invoked right after the value of <see cref="Number"/> is changed.</remarks>
[global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.WinUI.CanvasEffectPropertyGenerator", <ASSEMBLY_VERSION>)]
partial void OnNumberChanged(int oldValue, int newValue);
}
}
"""";
VerifyGeneratedDiagnostics(source, ("MyNamespace.MyEffect.g.cs", result));
}
[TestMethod]
public void MultipleProperties()
{