File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
UnitTests/UnitTests.SourceGenerators Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 99using System . Linq ;
1010using Microsoft . CodeAnalysis ;
1111using Microsoft . CodeAnalysis . CSharp ;
12+ using CommunityToolkit . Mvvm . ComponentModel ;
1213using CommunityToolkit . Mvvm . SourceGenerators ;
1314using Microsoft . VisualStudio . TestTools . UnitTesting ;
1415
@@ -249,6 +250,7 @@ public partial class SampleViewModel
249250 private void VerifyGeneratedDiagnostics < TGenerator > ( string source , params string [ ] diagnosticsIds )
250251 where TGenerator : class , ISourceGenerator , new ( )
251252 {
253+ Type observableObjectType = typeof ( ObservableObject ) ;
252254 Type validationAttributeType = typeof ( ValidationAttribute ) ;
253255
254256 SyntaxTree syntaxTree = CSharpSyntaxTree . ParseText ( source ) ;
@@ -271,6 +273,7 @@ from assembly in AppDomain.CurrentDomain.GetAssemblies()
271273
272274 Assert . IsTrue ( resultingIds . SetEquals ( diagnosticsIds ) ) ;
273275
276+ GC . KeepAlive ( observableObjectType ) ;
274277 GC . KeepAlive ( validationAttributeType ) ;
275278 }
276279 }
Original file line number Diff line number Diff line change 1- <Project Sdk =" Microsoft.NET.Sdk" >
1+ <Project Sdk =" Microsoft.NET.Sdk" >
22
33 <PropertyGroup >
44 <TargetFrameworks >net5.0</TargetFrameworks >
1515
1616 <ItemGroup >
1717 <ProjectReference Include =" ..\..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.csproj" />
18+ <ProjectReference Include =" ..\..\CommunityToolkit.Mvvm\CommunityToolkit.Mvvm.csproj" />
1819 </ItemGroup >
1920
2021</Project >
Original file line number Diff line number Diff line change @@ -291,6 +291,18 @@ Task("Test")
291291 ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
292292 } ;
293293 DotNetCoreTest ( file . FullPath , testSettings ) ;
294+ } ) . DoesForEach ( GetFiles ( baseDir + "/**/UnitTests.SourceGenerators.csproj" ) , ( file ) =>
295+ {
296+ Information ( "\n Running NetCore Source Generator Unit Tests" ) ;
297+ var testSettings = new DotNetCoreTestSettings
298+ {
299+ Configuration = configuration ,
300+ NoBuild = true ,
301+ Loggers = new [ ] { "trx;LogFilePrefix=VsTestResults" } ,
302+ Verbosity = DotNetCoreVerbosity . Normal ,
303+ ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
304+ } ;
305+ DotNetCoreTest ( file . FullPath , testSettings ) ;
294306} ) . DeferOnError ( ) ;
295307
296308Task ( "UITest" )
You can’t perform that action at this time.
0 commit comments