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 9
9
using System . Linq ;
10
10
using Microsoft . CodeAnalysis ;
11
11
using Microsoft . CodeAnalysis . CSharp ;
12
+ using CommunityToolkit . Mvvm . ComponentModel ;
12
13
using CommunityToolkit . 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 1
- <Project Sdk =" Microsoft.NET.Sdk" >
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
2
3
3
<PropertyGroup >
4
4
<TargetFrameworks >net5.0</TargetFrameworks >
15
15
16
16
<ItemGroup >
17
17
<ProjectReference Include =" ..\..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.csproj" />
18
+ <ProjectReference Include =" ..\..\CommunityToolkit.Mvvm\CommunityToolkit.Mvvm.csproj" />
18
19
</ItemGroup >
19
20
20
21
</Project >
Original file line number Diff line number Diff line change @@ -291,6 +291,18 @@ Task("Test")
291
291
ArgumentCustomization = arg => arg . Append ( $ "-s { baseDir } /.runsettings /p:Platform=AnyCPU") ,
292
292
} ;
293
293
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 ) ;
294
306
} ) . DeferOnError ( ) ;
295
307
296
308
Task ( "UITest" )
You can’t perform that action at this time.
0 commit comments