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 99using System . Linq ;
1010using Microsoft . CodeAnalysis ;
1111using Microsoft . CodeAnalysis . CSharp ;
12+ using Microsoft . Toolkit . Mvvm . ComponentModel ;
1213using Microsoft . Toolkit . 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 1515
1616 <ItemGroup >
1717 <ProjectReference Include =" ..\..\Microsoft.Toolkit.Mvvm.SourceGenerators\Microsoft.Toolkit.Mvvm.SourceGenerators.csproj" />
18+ <ProjectReference Include =" ..\..\Microsoft.Toolkit.Mvvm\Microsoft.Toolkit.Mvvm.csproj" />
1819 </ItemGroup >
1920
2021</Project >
Original file line number Diff line number Diff line change @@ -270,6 +270,18 @@ Task("Test")
270270 ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
271271 } ;
272272 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 ) ;
273285} ) . DeferOnError ( ) ;
274286
275287Task ( "UITest" )
You can’t perform that action at this time.
0 commit comments