Skip to content

Commit 8e88f30

Browse files
committed
Add unit test for new async void analyzer
1 parent 5e8096f commit 8e88f30

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,25 @@ public class TestAttribute : Attribute
18011801
VerifyGeneratedDiagnostics<RelayCommandGenerator>(source, "MVVMTK0038");
18021802
}
18031803

1804+
[TestMethod]
1805+
public async Task AsyncVoidReturningRelayCommandMethodAnalyzer()
1806+
{
1807+
string source = """
1808+
using System;
1809+
using CommunityToolkit.Mvvm.Input;
1810+
1811+
public partial class MyViewModel
1812+
{
1813+
[RelayCommand]
1814+
private async void {|MVVMTK0039:TestAsync|}()
1815+
{
1816+
}
1817+
}
1818+
""";
1819+
1820+
await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration<AsyncVoidReturningRelayCommandMethodAnalyzer>(source, LanguageVersion.CSharp8);
1821+
}
1822+
18041823
/// <summary>
18051824
/// Verifies the diagnostic errors for a given analyzer, and that all available source generators can run successfully with the input source (including subsequent compilation).
18061825
/// </summary>

0 commit comments

Comments
 (0)