Skip to content

Commit 7723c1e

Browse files
committed
Code style tweaks
1 parent 61e9e47 commit 7723c1e

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Microsoft.CodeAnalysis.CSharp;
1212
using CommunityToolkit.Mvvm.ComponentModel;
1313
using Microsoft.VisualStudio.TestTools.UnitTesting;
14-
using System.Reflection.Emit;
1514

1615
namespace CommunityToolkit.Mvvm.SourceGenerators.UnitTests;
1716

@@ -249,7 +248,6 @@ public partial class SampleViewModel
249248
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
250249
"MVVMTK0008");
251250

252-
// Ensure that it succeeds with the minimum supported language version
253251
VerifySuccessfulGeneration(source);
254252
}
255253

@@ -271,7 +269,6 @@ public partial class SampleViewModel
271269
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
272270
"MVVMTK0008");
273271

274-
// Ensure that it succeeds with the minimum supported language version
275272
VerifySuccessfulGeneration(source);
276273
}
277274

@@ -295,7 +292,6 @@ public partial class SampleViewModel
295292
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
296293
"MVVMTK0008");
297294

298-
// Ensure that it succeeds with the minimum supported language version
299295
VerifySuccessfulGeneration(source);
300296
}
301297

@@ -319,7 +315,6 @@ public partial class SampleViewModel : ObservableValidator
319315
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
320316
"MVVMTK0008");
321317

322-
// Ensure that it succeeds with the minimum supported language version
323318
VerifySuccessfulGeneration(source);
324319
}
325320

@@ -344,7 +339,6 @@ private void GreetUser(object value)
344339
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
345340
"MVVMTK0008");
346341

347-
// Ensure that it succeeds with the minimum supported language version
348342
VerifySuccessfulGeneration(source);
349343
}
350344

@@ -372,7 +366,6 @@ public void Receive(MyMessage message)
372366
CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_3)),
373367
"MVVMTK0008");
374368

375-
// Ensure that it succeeds with the minimum supported language version
376369
VerifySuccessfulGeneration(source);
377370
}
378371

@@ -1454,22 +1447,9 @@ public partial class SampleViewModel
14541447
}
14551448

14561449
/// <summary>
1457-
/// Verifies the output of a source generator.
1450+
/// Verifies that all available source generators can run successfully with the input source (including subsequent compilation).
14581451
/// </summary>
1459-
/// <typeparam name="TGenerator">The generator type to use.</typeparam>
14601452
/// <param name="source">The input source to process.</param>
1461-
/// <param name="diagnosticsIds">The diagnostic ids to expect for the input source code.</param>
1462-
private static void VerifyGeneratedDiagnostics<TGenerator>(string source, params string[] diagnosticsIds)
1463-
where TGenerator : class, IIncrementalGenerator, new()
1464-
{
1465-
IIncrementalGenerator generator = new TGenerator();
1466-
VerifyGeneratedDiagnostics(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8)), new[] { generator }, diagnosticsIds);
1467-
}
1468-
1469-
/// <summary>
1470-
/// Verifies the output of all source generators for input source (including subsequent compilation).
1471-
/// </summary>
1472-
/// <param name="source"></param>
14731453
private static void VerifySuccessfulGeneration(string source)
14741454
{
14751455
IIncrementalGenerator[] generators =
@@ -1483,7 +1463,22 @@ private static void VerifySuccessfulGeneration(string source)
14831463
new ObservableValidatorValidateAllPropertiesGenerator(),
14841464
new RelayCommandGenerator()
14851465
};
1486-
VerifyGeneratedDiagnostics(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8)), generators, new string[] { });
1466+
1467+
VerifyGeneratedDiagnostics(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8)), generators, Array.Empty<string>());
1468+
}
1469+
1470+
/// <summary>
1471+
/// Verifies the output of a source generator.
1472+
/// </summary>
1473+
/// <typeparam name="TGenerator">The generator type to use.</typeparam>
1474+
/// <param name="source">The input source to process.</param>
1475+
/// <param name="diagnosticsIds">The diagnostic ids to expect for the input source code.</param>
1476+
private static void VerifyGeneratedDiagnostics<TGenerator>(string source, params string[] diagnosticsIds)
1477+
where TGenerator : class, IIncrementalGenerator, new()
1478+
{
1479+
IIncrementalGenerator generator = new TGenerator();
1480+
1481+
VerifyGeneratedDiagnostics(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8)), new[] { generator }, diagnosticsIds);
14871482
}
14881483

14891484
/// <summary>
@@ -1496,6 +1491,7 @@ private static void VerifyGeneratedDiagnostics<TGenerator>(SyntaxTree syntaxTree
14961491
where TGenerator : class, IIncrementalGenerator, new()
14971492
{
14981493
IIncrementalGenerator generator = new TGenerator();
1494+
14991495
VerifyGeneratedDiagnostics(syntaxTree, new[] { generator }, diagnosticsIds);
15001496
}
15011497

0 commit comments

Comments
 (0)