Add incrementality tests for new generator
このコミットが含まれているのは:
1 親
251640f4b6
コミット
cc5bbd48c1
6ファイル変更
+123
-4
検索条件に一致するファイルはありません
+2
-2
@@ -357,7 +357,7 @@ public class Test_CanvasEffectPropertyGenerator
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int X { get; set; }
|
||||
|
||||
[GeneratedCanvasEffectProperty]
|
||||
[GeneratedCanvasEffectProperty(CanvasEffectInvalidationType.Creation)]
|
||||
public int Y { get; set; }
|
||||
}
|
||||
""";
|
||||
@@ -423,7 +423,7 @@ public class Test_CanvasEffectPropertyGenerator
|
||||
OnYChanged(value);
|
||||
OnYChanged(oldValue, value);
|
||||
|
||||
InvalidateEffectGraph(global::ComputeSharp.D2D1.WinUI.CanvasEffectInvalidationType.Update);
|
||||
InvalidateEffectGraph(global::ComputeSharp.D2D1.WinUI.CanvasEffectInvalidationType.Creation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
using ComputeSharp.D2D1.WinUI.SourceGenerators;
|
||||
using ComputeSharp.Tests.SourceGenerators.Helpers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI.Tests.SourceGenerators;
|
||||
|
||||
[TestClass]
|
||||
public class Test_CanvasEffectPropertyGenerator_Incrementality
|
||||
{
|
||||
[TestMethod]
|
||||
public void ModifiedOptions_ModifiesOutput()
|
||||
{
|
||||
const string source = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
const string updatedSource = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
[GeneratedCanvasEffectProperty(CanvasEffectInvalidationType.Creation)]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
CSharpGeneratorTest<CanvasEffectPropertyGenerator>.VerifyIncrementalSteps(
|
||||
source,
|
||||
updatedSource,
|
||||
executeReason: IncrementalStepRunReason.Modified,
|
||||
diagnosticsReason: null,
|
||||
outputReason: IncrementalStepRunReason.Modified,
|
||||
diagnosticsSourceReason: null,
|
||||
sourceReason: IncrementalStepRunReason.Modified);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddedLeadingTrivia_DoesNotModifyOutput()
|
||||
{
|
||||
const string source = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
const string updatedSource = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// This is some property.
|
||||
/// </summary>
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
CSharpGeneratorTest<CanvasEffectPropertyGenerator>.VerifyIncrementalSteps(
|
||||
source,
|
||||
updatedSource,
|
||||
executeReason: IncrementalStepRunReason.Unchanged,
|
||||
diagnosticsReason: null,
|
||||
outputReason: IncrementalStepRunReason.Cached,
|
||||
diagnosticsSourceReason: null,
|
||||
sourceReason: IncrementalStepRunReason.Cached);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddedOtherMember_DoesNotModifyOutput()
|
||||
{
|
||||
const string source = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
const string updatedSource = """"
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
|
||||
abstract partial class MyEffect : CanvasEffect
|
||||
{
|
||||
public void Foo()
|
||||
{
|
||||
}
|
||||
|
||||
[GeneratedCanvasEffectProperty]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
"""";
|
||||
|
||||
CSharpGeneratorTest<CanvasEffectPropertyGenerator>.VerifyIncrementalSteps(
|
||||
source,
|
||||
updatedSource,
|
||||
executeReason: IncrementalStepRunReason.Unchanged,
|
||||
diagnosticsReason: null,
|
||||
outputReason: IncrementalStepRunReason.Cached,
|
||||
diagnosticsSourceReason: null,
|
||||
sourceReason: IncrementalStepRunReason.Cached);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする