Skip to content

Commit 3d1bc9f

Browse files
authored
Migrate tests to MSTest and fix COM IIDs (#6)
* Migrate tests to MSTest and fix COM IIDs * Fix CI for MSTest on Microsoft Testing Platform * Address PR feedback * Remove public COM IID Guid shims
1 parent caedb5e commit 3d1bc9f

27 files changed

Lines changed: 144 additions & 96 deletions

.github/workflows/dotnet.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,19 @@ jobs:
3232
$resultsDir = Join-Path $PWD.Path 'artifacts/test-results/debug'
3333
New-Item -ItemType Directory -Force -Path $resultsDir | Out-Null
3434
35-
dotnet test --no-build `
36-
-p:TestingPlatformCaptureOutput=false `
37-
-- `
35+
dotnet test --project vsinterop.tests/vsinterop.tests.csproj --no-build `
3836
--results-directory "$resultsDir" `
39-
--report-xunit-trx `
40-
--show-live-output on
37+
--report-trx `
38+
--output Detailed
4139
- name: Test release
4240
run: |
4341
$resultsDir = Join-Path $PWD.Path 'artifacts/test-results/release'
4442
New-Item -ItemType Directory -Force -Path $resultsDir | Out-Null
4543
46-
dotnet test -c Release --no-build `
47-
-p:TestingPlatformCaptureOutput=false `
48-
-- `
44+
dotnet test --project vsinterop.tests/vsinterop.tests.csproj -c Release --no-build `
4945
--results-directory "$resultsDir" `
50-
--report-xunit-trx `
51-
--show-live-output on
46+
--report-trx `
47+
--output Detailed
5248
- name: Upload raw logs
5349
if: always()
5450
uses: actions/upload-artifact@v4

Directory.Packages.props

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="KlutzyNinja.Madowaku" Version="0.1.0-alpha.2" />
7+
<PackageVersion Include="KlutzyNinja.Madowaku" Version="0.2.0-alpha.1" />
88
<PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
9-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
10-
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
9+
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
10+
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
1111
<PackageVersion Include="Microsoft.Build" Version="17.14.8" />
1212
<PackageVersion Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="5.0.0-1.25277.114" />
1313
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
14-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
15-
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.183" />
16-
<PackageVersion Include="MinVer" Version="6.0.0" />
17-
<PackageVersion Include="xunit.v3" Version="3.0.1" />
14+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.300" />
15+
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.275" />
16+
<PackageVersion Include="MinVer" Version="7.0.0" />
17+
<PackageVersion Include="MSTest" Version="4.2.3" />
1818
</ItemGroup>
1919
<ItemGroup Condition="'$(TargetFramework)' != '$(DotNetCoreVersion)' and '$(TargetFramework)' != '$(DotNetCoreVersion)-$(WindowsPlatformVersion)'">
2020
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
@@ -23,4 +23,4 @@
2323
<PackageVersion Include="PolySharp" Version="1.15.0" />
2424
<PackageVersion Include="System.Memory" Version="4.6.3" />
2525
</ItemGroup>
26-
</Project>
26+
</Project>

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"test": {
3+
"runner": "Microsoft.Testing.Platform"
4+
}
5+
}

vsinterop.tests/Microsoft/VisualStudio/Setup/Configuration/SetupConfigurationTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,32 @@
88

99
namespace Microsoft.VisualStudio.Setup.Configuration;
1010

11+
[TestClass]
1112
public unsafe class SetupConfigurationTests
1213
{
13-
[Fact]
14+
[TestMethod]
1415
public void CanCreateSetupConfigurationFactory()
1516
{
1617
using ComClassFactory factory = new(CLSID.SetupConfiguration);
1718
}
1819

19-
[Fact]
20+
[TestMethod]
2021
public void CanCreateISetupConfiguration2Instance()
2122
{
2223
using ComClassFactory factory = new(CLSID.SetupConfiguration);
2324
using var setupConfig = factory.CreateInstance<ISetupConfiguration2>();
24-
Assert.False(setupConfig.IsNull);
25+
Assert.IsFalse(setupConfig.IsNull);
2526
}
2627

27-
[Fact]
28+
[TestMethod]
2829
public void EnumInstances()
2930
{
3031
using ComClassFactory factory = new(CLSID.SetupConfiguration);
3132
using var setupConfig = factory.CreateInstance<ISetupConfiguration2>();
3233

3334
using ComScope<IEnumSetupInstances> enumInstances = default;
3435
setupConfig.Pointer->EnumInstances(enumInstances).ThrowOnFailure();
35-
Assert.False(enumInstances.IsNull);
36+
Assert.IsFalse(enumInstances.IsNull);
3637

3738
using ComScope<ISetupInstance> setupInstance = default;
3839
uint fetched;
@@ -43,10 +44,10 @@ public void EnumInstances()
4344
using BSTR displayName = default;
4445
setupInstance.Pointer->GetDisplayName(0, &displayName).ThrowOnFailure();
4546
string name = displayName.ToString();
46-
Assert.NotEmpty(name);
47+
Assert.IsFalse(string.IsNullOrEmpty(name));
4748
}
4849

49-
[Fact]
50+
[TestMethod]
5051
public void SetupInstance2_PropertyStore()
5152
{
5253
using ComClassFactory factory = new(CLSID.SetupConfiguration);
@@ -67,9 +68,9 @@ public void SetupInstance2_PropertyStore()
6768
using SafeArrayScope<BSTR> namesArray = default;
6869
properties.Pointer->GetNames(namesArray).ThrowOnFailure();
6970

70-
Assert.True(namesArray.Length > 0, "There are names.");
71+
Assert.IsTrue(namesArray.Length > 0, "There are names.");
7172
using BSTR name = namesArray[0];
72-
Assert.False(name.IsNull, "Name is not null");
73+
Assert.IsFalse(name.IsNull, "Name is not null");
7374

7475
using VARIANT value = default;
7576
properties.Pointer->GetValue(name.Value, &value).ThrowOnFailure();

vsinterop.tests/vsinterop.tests.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@
99
<Nullable>enable</Nullable>
1010
<IsPackable>false</IsPackable>
1111
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
12-
<RootNamespace/>
12+
<RootNamespace />
1313

1414
<!-- Use the Microsoft Testing Platform -->
1515
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
16+
<EnableMSTestRunner>true</EnableMSTestRunner>
1617
</PropertyGroup>
1718

1819
<ItemGroup>
19-
<PackageReference Include="coverlet.collector"/>
20-
<PackageReference Include="xunit.v3"/>
21-
<PackageReference Include="FluentAssertions" />
20+
<PackageReference Include="coverlet.collector">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
<PackageReference Include="MSTest" />
25+
<PackageReference Include="AwesomeAssertions" />
2226
</ItemGroup>
2327

2428
<ItemGroup>
2529
<ProjectReference Include="..\vsinterop\vsinterop.csproj" AdditionalProperties="TargetFramework=$(TargetFramework)" />
2630
</ItemGroup>
2731

2832
<ItemGroup>
29-
<Using Include="Xunit" />
33+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
3034
</ItemGroup>
3135

3236
<ItemGroup>

vsinterop/Microsoft/VisualStudio/Setup/Configuration/IEnumSetupInstances.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Jeremy W Kuhne
1+
// Copyright (c) 2025 Jeremy W Kuhne
22
// SPDX-License-Identifier: MIT
33
// See LICENSE file in the project root for full license information
44

@@ -14,10 +14,12 @@ namespace Microsoft.VisualStudio.Setup.Configuration;
1414
public unsafe struct IEnumSetupInstances : IComIID
1515
{
1616
/// <inheritdoc cref="IComIID.Guid"/>
17-
public static Guid Guid { get; } = new(0x6380BCFF, 0x41D3, 0x4B2E, 0x8B, 0x2E, 0xBF, 0x8A, 0x68, 0x10, 0xC8, 0x48);
17+
#pragma warning disable IDE1006 // Naming Styles
18+
public static readonly Guid IID_Guid = new(0x6380BCFF, 0x41D3, 0x4B2E, 0x8B, 0x2E, 0xBF, 0x8A, 0x68, 0x10, 0xC8, 0x48);
19+
#pragma warning restore IDE1006
1820

1921
#if NETFRAMEWORK
20-
readonly Guid IComIID.Guid => Guid;
22+
readonly ref readonly Guid IComIID.Guid => ref IID_Guid;
2123
#else
2224
static ref readonly Guid IComIID.Guid
2325
{

vsinterop/Microsoft/VisualStudio/Setup/Configuration/ISetupConfiguration.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Jeremy W Kuhne
1+
// Copyright (c) 2025 Jeremy W Kuhne
22
// SPDX-License-Identifier: MIT
33
// See LICENSE file in the project root for full license information
44

@@ -14,10 +14,12 @@ namespace Microsoft.VisualStudio.Setup.Configuration;
1414
public unsafe struct ISetupConfiguration : IComIID
1515
{
1616
/// <inheritdoc cref="IComIID.Guid"/>
17-
public static Guid Guid { get; } = new(0x42843719, 0xDB4C, 0x46C2, 0x8E, 0x7C, 0x64, 0xF1, 0x81, 0x6E, 0xFD, 0x5B);
17+
#pragma warning disable IDE1006 // Naming Styles
18+
public static readonly Guid IID_Guid = new(0x42843719, 0xDB4C, 0x46C2, 0x8E, 0x7C, 0x64, 0xF1, 0x81, 0x6E, 0xFD, 0x5B);
19+
#pragma warning restore IDE1006
1820

1921
#if NETFRAMEWORK
20-
readonly Guid IComIID.Guid => Guid;
22+
readonly ref readonly Guid IComIID.Guid => ref IID_Guid;
2123
#else
2224
static ref readonly Guid IComIID.Guid
2325
{

vsinterop/Microsoft/VisualStudio/Setup/Configuration/ISetupConfiguration2.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Jeremy W Kuhne
1+
// Copyright (c) 2025 Jeremy W Kuhne
22
// SPDX-License-Identifier: MIT
33
// See LICENSE file in the project root for full license information
44

@@ -14,10 +14,12 @@ namespace Microsoft.VisualStudio.Setup.Configuration;
1414
public unsafe struct ISetupConfiguration2 : IComIID
1515
{
1616
/// <inheritdoc cref="IComIID.Guid"/>
17-
public static Guid Guid { get; } = new(0x26AAB78C, 0x4A60, 0x49D6, 0xAF, 0x3B, 0x3C, 0x35, 0xBC, 0x93, 0x36, 0x5D);
17+
#pragma warning disable IDE1006 // Naming Styles
18+
public static readonly Guid IID_Guid = new(0x26AAB78C, 0x4A60, 0x49D6, 0xAF, 0x3B, 0x3C, 0x35, 0xBC, 0x93, 0x36, 0x5D);
19+
#pragma warning restore IDE1006
1820

1921
#if NETFRAMEWORK
20-
readonly Guid IComIID.Guid => Guid;
22+
readonly ref readonly Guid IComIID.Guid => ref IID_Guid;
2123
#else
2224
static ref readonly Guid IComIID.Guid
2325
{

vsinterop/Microsoft/VisualStudio/Setup/Configuration/ISetupErrorInfo.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Jeremy W Kuhne
1+
// Copyright (c) 2025 Jeremy W Kuhne
22
// SPDX-License-Identifier: MIT
33
// See LICENSE file in the project root for full license information
44

@@ -14,10 +14,12 @@ namespace Microsoft.VisualStudio.Setup.Configuration;
1414
public unsafe struct ISetupErrorInfo : IComIID
1515
{
1616
/// <inheritdoc cref="IComIID.Guid"/>
17-
public static Guid Guid { get; } = new(0x2A2F3292, 0x958E, 0x4905, 0xB3, 0x6E, 0x01, 0x3B, 0xE8, 0x4E, 0x27, 0xAB);
17+
#pragma warning disable IDE1006 // Naming Styles
18+
public static readonly Guid IID_Guid = new(0x2A2F3292, 0x958E, 0x4905, 0xB3, 0x6E, 0x01, 0x3B, 0xE8, 0x4E, 0x27, 0xAB);
19+
#pragma warning restore IDE1006
1820

1921
#if NETFRAMEWORK
20-
readonly Guid IComIID.Guid => Guid;
22+
readonly ref readonly Guid IComIID.Guid => ref IID_Guid;
2123
#else
2224
static ref readonly Guid IComIID.Guid
2325
{

vsinterop/Microsoft/VisualStudio/Setup/Configuration/ISetupErrorState.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Jeremy W Kuhne
1+
// Copyright (c) 2025 Jeremy W Kuhne
22
// SPDX-License-Identifier: MIT
33
// See LICENSE file in the project root for full license information
44

@@ -14,10 +14,12 @@ namespace Microsoft.VisualStudio.Setup.Configuration;
1414
public unsafe struct ISetupErrorState : IComIID
1515
{
1616
/// <inheritdoc cref="IComIID.Guid"/>
17-
public static Guid Guid { get; } = new(0x46DCCD94, 0xA287, 0x476A, 0x85, 0x1E, 0xDF, 0xBC, 0x2F, 0xFD, 0xBC, 0x20);
17+
#pragma warning disable IDE1006 // Naming Styles
18+
public static readonly Guid IID_Guid = new(0x46DCCD94, 0xA287, 0x476A, 0x85, 0x1E, 0xDF, 0xBC, 0x2F, 0xFD, 0xBC, 0x20);
19+
#pragma warning restore IDE1006
1820

1921
#if NETFRAMEWORK
20-
readonly Guid IComIID.Guid => Guid;
22+
readonly ref readonly Guid IComIID.Guid => ref IID_Guid;
2123
#else
2224
static ref readonly Guid IComIID.Guid
2325
{

0 commit comments

Comments
 (0)