File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
UnitTests/UnitTests.SourceGenerators Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 9
9
using System . Linq ;
10
10
using Microsoft . CodeAnalysis ;
11
11
using Microsoft . CodeAnalysis . CSharp ;
12
+ using Microsoft . Toolkit . Mvvm . ComponentModel ;
12
13
using Microsoft . Toolkit . Mvvm . SourceGenerators ;
13
14
using Microsoft . VisualStudio . TestTools . UnitTesting ;
14
15
@@ -249,6 +250,7 @@ public partial class SampleViewModel
249
250
private void VerifyGeneratedDiagnostics < TGenerator > ( string source , params string [ ] diagnosticsIds )
250
251
where TGenerator : class , ISourceGenerator , new ( )
251
252
{
253
+ Type observableObjectType = typeof ( ObservableObject ) ;
252
254
Type validationAttributeType = typeof ( ValidationAttribute ) ;
253
255
254
256
SyntaxTree syntaxTree = CSharpSyntaxTree . ParseText ( source ) ;
@@ -271,6 +273,7 @@ from assembly in AppDomain.CurrentDomain.GetAssemblies()
271
273
272
274
Assert . IsTrue ( resultingIds . SetEquals ( diagnosticsIds ) ) ;
273
275
276
+ GC . KeepAlive ( observableObjectType ) ;
274
277
GC . KeepAlive ( validationAttributeType ) ;
275
278
}
276
279
}
Original file line number Diff line number Diff line change 15
15
16
16
<ItemGroup >
17
17
<ProjectReference Include =" ..\..\Microsoft.Toolkit.Mvvm.SourceGenerators\Microsoft.Toolkit.Mvvm.SourceGenerators.csproj" />
18
+ <ProjectReference Include =" ..\..\Microsoft.Toolkit.Mvvm\Microsoft.Toolkit.Mvvm.csproj" />
18
19
</ItemGroup >
19
20
20
21
</Project >
Original file line number Diff line number Diff line change @@ -270,6 +270,18 @@ Task("Test")
270
270
ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
271
271
} ;
272
272
DotNetCoreTest ( file . FullPath , testSettings ) ;
273
+ } ) . DoesForEach ( GetFiles ( baseDir + "/**/UnitTests.SourceGenerators.csproj" ) , ( file ) =>
274
+ {
275
+ Information ( "\n Running NetCore Source Generator Unit Tests" ) ;
276
+ var testSettings = new DotNetCoreTestSettings
277
+ {
278
+ Configuration = configuration ,
279
+ NoBuild = true ,
280
+ Loggers = new [ ] { "trx;LogFilePrefix=VsTestResults" } ,
281
+ Verbosity = DotNetCoreVerbosity . Normal ,
282
+ ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
283
+ } ;
284
+ DotNetCoreTest ( file . FullPath , testSettings ) ;
273
285
} ) . DeferOnError ( ) ;
274
286
275
287
Task ( "UITest" )
You can’t perform that action at this time.
0 commit comments