Skip to content

Commit 8454c8f

Browse files
committed
Merge branch 'main' into winui
# Conflicts: # UITests/UITests.App/UITests.App.csproj # UnitTests/UnitTests.SourceGenerators/Test_SourceGeneratorsDiagnostics.cs # UnitTests/UnitTests.SourceGenerators/UnitTests.SourceGenerators.csproj
2 parents 25f4bdc + 0ce4553 commit 8454c8f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

UnitTests/UnitTests.SourceGenerators/Test_SourceGeneratorsDiagnostics.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using Microsoft.CodeAnalysis;
1111
using Microsoft.CodeAnalysis.CSharp;
12+
using CommunityToolkit.Mvvm.ComponentModel;
1213
using CommunityToolkit.Mvvm.SourceGenerators;
1314
using 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
}

UnitTests/UnitTests.SourceGenerators/UnitTests.SourceGenerators.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>net5.0</TargetFrameworks>
@@ -15,6 +15,7 @@
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>

build/build.cake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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("\nRunning 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

296308
Task("UITest")

0 commit comments

Comments
 (0)