Skip to content

Commit 7b47e6d

Browse files
authored
+semver:minor - Support F# and VB.NET via Reflection (#2250)
* WIP * WIP * Compiling * Working * Run Engine tests in Reflection Mode too * Update Public API * WIP * WIP * WIP * Update ReflectionTestsConstructor.cs * catch TargetInvocationException * Woops * Update snaps * WIP * Pass `TestMode` into `InvokableTestBase` * Add missing usings * Fix * Update * Don't hangdump * Remove hardcoded property * --property * Use test session id * Revert * LogInformation * WIP: ReflectionHooksCollector * WIP * Update snaps * Tweak * Test on more frameworks * Rework MSBuild * Rework MSBuild * TestLibrary.props * Tidy usings * WIP * Fixes * Speed up pipelines on failures * Working directory * framework * Snaps * Fix * Fix * Fix * Tweak * TargetFrameworks * Fix * Sourcy.DotNet.Projects.TUnit_TestProject.DirectoryName! * Tweak * Fix * Fix * TUnitReflectionScanner * Remove debugger launch call * Fixes * Collect more hooks * Update snaps * Comment * Substring * Not abstract * Better exception * Tweak logic * Fix implicit casts in reflection mode * Update snaps * Capture `TargetInvocationException` * Distinct types * Set * Print names of hooks when printing debug statements * Update snaps * AssemblyMetadata * Fix * Re-work DependencyCollector.cs * Fix error message * Wait for dependencies * Fix? * RuntimeFeature.IsDynamicCodeSupported * Fix * Tweak * DeclaredOnly * Fixes * Uncomment * Fixes * EngineMode.cs * Update snaps * Fix * Fix * Fix * Fix * Remove debug line * Fix setting properties in reflection mode * Initialize injected objects in reflection mode * Update snaps * Tweak tests to not run in parallel so thread pool is free * Update snaps * Log * Tweak names * Fix invoking generic test classes in reflection mode * Update snaps * Tidy * Tweak * Better error messages * Update snaps * Type.FullName * Fix * Remove log statements * Fixes * Remove more log statements * ReflectionTestsConstructor.cs to honour repeatCount * Fix? * Fix * Fix picking up tests in abstract classes * Update snaps * Fix generic test methods in reflection mode * Whoops * NotInParallel * Create instances with IClassConstructor in Reflection mode * Fix tests * Add class name * Pass through type * Fix dependency chain validation * Whoops * Rework * Fix? * wip * wip * DependencyCollectorTests * More tests * Fix? * Fixes * Fix assertions * Fix repeat count * Fix test executors in reflection mode * Fix string enumerable * Fixes * Fix UniqueBuilderContextsOnEnumerableDataGeneratorTests * Fix static properties in reflection mode * Update snaps * Update snaps * Fix * Fixes * Tweak build property * NuGet testers for FSharp and VB.NET * Fix * Fix * Update snaps * FSharp.Core * Fix * Fix * CreateRetryPolicy(3) * Fix * Fix * Fix * Fix * Fix
1 parent d00378e commit 7b47e6d

File tree

476 files changed

+6508
-3098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

476 files changed

+6508
-3098
lines changed

.github/workflows/dotnet-framework.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/dotnet.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ jobs:
5050
with:
5151
dotnet-version: 9.0.x
5252

53+
- name: Setup .NET Framework
54+
if: matrix.os == 'windows-latest'
55+
uses: microsoft/setup-msbuild@v2
56+
5357
- name: Build .NET 9
54-
run: dotnet build -c Release -p:SDK_VERSION=net9
58+
run: dotnet build -c Release
5559

5660
- name: Run Pipeline
5761
uses: ./.github/actions/execute-pipeline

Directory.Build.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup Condition="'$(TargetFramework)' == '' and '$(TargetFrameworks)' == ''">
4-
<TargetFrameworks Condition="'$(SDK_VERSION)' == ''">net8.0;net9.0</TargetFrameworks>
5-
<!--suppress MsbuildTargetFrameworkTagInspection -->
6-
<TargetFrameworks Condition="'$(SDK_VERSION)' == 'net8'">net8.0</TargetFrameworks>
7-
<TargetFrameworks Condition="'$(SDK_VERSION)' == 'net9'">net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<LibraryTargetFramework Condition="$(TargetFramework.StartsWith('net4'))">netstandard2.0</LibraryTargetFramework>
9+
<LibraryTargetFramework Condition="!$(TargetFramework.StartsWith('net4'))">$(TargetFramework)</LibraryTargetFramework>
810
</PropertyGroup>
911

1012
<PropertyGroup>
1113
<ImplicitUsings>enable</ImplicitUsings>
1214
<Nullable>enable</Nullable>
13-
<LangVersion>latest</LangVersion>
15+
<LangVersion>preview</LangVersion>
1416
<TrimmerSingleWarn>false</TrimmerSingleWarn>
1517
<NoWarn>NU1507;NU1903;CS9107</NoWarn>
1618
<BuildTransitivePath>buildTransitive/$(TargetFramework)/</BuildTransitivePath>

Directory.Build.targets

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,5 @@
11
<Project>
2-
<Import
3-
Condition="('$(IsLibraryPackage)' == 'true' or '$(IsLibraryTestProject)' == 'true') and '$(EnablePolyfill)' != 'false'"
4-
Project="$(MSBuildThisFileDirectory)Polyfill.props" />
5-
6-
<PropertyGroup Condition="'$(IsLibraryPackage)' == 'true'">
7-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8-
</PropertyGroup>
9-
10-
<PropertyGroup Condition="'$(IsLibraryTestProject)' == 'true'">
11-
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
12-
</PropertyGroup>
13-
14-
<PropertyGroup>
15-
<TargetFrameworks Condition="'$(IsLibraryPackage)' == 'true'">netstandard2.0;net8.0;net9.0</TargetFrameworks>
16-
<TargetFrameworks Condition="'$(IsLibraryTestProject)' == 'true'">net472;net8.0;net9.0</TargetFrameworks>
17-
</PropertyGroup>
18-
<PropertyGroup Condition="'$(IsTestingPlatformApplication)' == 'true'">
19-
<OutputType>Exe</OutputType>
20-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
21-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
22-
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
23-
<IsTestProject>true</IsTestProject>
24-
</PropertyGroup>
25-
26-
<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0' and '$(IsLibraryPackage)' == 'true'">
27-
<IsAotCompatible>true</IsAotCompatible>
28-
</PropertyGroup>
29-
302
<PropertyGroup>
313
<DefineConstants Condition="$(RoslynVersion) >= 4.7">$(DefineConstants);ROSLYN4_7_OR_GREATER</DefineConstants>
32-
<EnableTrimAnalyzer Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</EnableTrimAnalyzer>
33-
</PropertyGroup>
34-
35-
<PropertyGroup Condition="'$(IsLibraryPackage)' == 'true'">
36-
<SignAssembly>true</SignAssembly>
37-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongname.snk</AssemblyOriginatorKeyFile>
38-
<PublicKey>0024000004800000940000000602000000240000525341310004000001000100698a70398fa0b2230c5a72e3bd9d56b48f809f6173e49a19fbb942d621be93ad48c5566b47b28faabc359b9ad3ff4e00bbdea88f5bdfa250f391fedd28182b2e37b55d429c0151a42a98ea7a5821818cd15a79fef9903e8607a88304cf3e0317bf86ec96e32e1381535a6582251e5a6eed40b5a3ed82bc444598b1269cce57a7</PublicKey>
394
</PropertyGroup>
40-
41-
<ItemGroup Condition="'$(IsTestingPlatformApplication)' == 'true'">
42-
<Using Include="TUnit.Core.HookType" Static="True" />
43-
<Using Include="TUnit.Core" />
44-
45-
<ProjectReference Include="..\TUnit.Engine\TUnit.Engine.csproj" />
46-
<ProjectReference Include="..\TUnit.Assertions\TUnit.Assertions.csproj" />
47-
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" />
48-
49-
<ProjectReference
50-
Include="$(MSBuildThisFileDirectory)TUnit.Core.SourceGenerator\TUnit.Core.SourceGenerator.csproj"
51-
OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
52-
<ProjectReference Include="$(MSBuildThisFileDirectory)TUnit.Analyzers\TUnit.Analyzers.csproj"
53-
OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
54-
<ProjectReference
55-
Include="$(MSBuildThisFileDirectory)TUnit.Assertions.Analyzers\TUnit.Assertions.Analyzers.csproj"
56-
OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
57-
58-
<TestingPlatformBuilderHook Include="6ADF853A-6945-4A06-9A4B-D99BC1DC1094">
59-
<DisplayName>TUnit</DisplayName>
60-
<TypeFullName>TUnit.Engine.Framework.TestingPlatformBuilderHook</TypeFullName>
61-
</TestingPlatformBuilderHook>
62-
</ItemGroup>
635
</Project>

Directory.Packages.props

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<ItemGroup>
99
<PackageVersion Include="AutoFixture" Version="4.18.1" />
1010
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
11-
<PackageVersion Include="Confluent.SchemaRegistry.Serdes.Protobuf" Version="2.10.0" />
1211
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
1312
<PackageVersion Include="CliWrap" Version="3.8.2" />
1413
<PackageVersion Include="EnumerableAsyncProcessor" Version="2.1.0" />
1514
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
15+
<PackageVersion Include="FSharp.Core" Version="9.0.300" />
1616
<PackageVersion Include="Humanizer" Version="2.14.1" />
1717
<PackageVersion Include="MessagePack" Version="3.1.3" />
1818
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.5" />
@@ -34,7 +34,7 @@
3434
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
3535
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
3636
<PackageVersion Include="Microsoft.Playwright" Version="1.52.0" />
37-
<PackageVersion Include="Microsoft.TemplateEngine.Authoring.TemplateVerifier" Version="9.0.0" />
37+
<PackageVersion Include="Microsoft.TemplateEngine.Authoring.TemplateVerifier" Version="9.0.100" />
3838
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.14.2" />
3939
<PackageVersion Include="Microsoft.Testing.Extensions.CrashDump" Version="1.6.3" />
4040
<PackageVersion Include="Microsoft.Testing.Extensions.HangDump" Version="1.6.3" />
@@ -47,6 +47,7 @@
4747
<PackageVersion Include="ModularPipelines.GitHub" Version="2.43.0" />
4848
<PackageVersion Include="MSTest.TestAdapter" Version="3.8.3" />
4949
<PackageVersion Include="MSTest.TestFramework" Version="3.8.3" />
50+
<PackageVersion Include="NSubstitute" Version="5.3.0" />
5051
<PackageVersion Include="NuGet.Protocol" Version="6.13.2" />
5152
<PackageVersion Include="NUnit" Version="4.3.2" />
5253
<PackageVersion Include="NUnit.Analyzers" Version="4.7.0" />
@@ -56,6 +57,7 @@
5657
<PackageVersion Include="Polly" Version="8.5.2" />
5758
<PackageVersion Include="Polyfill" Version="7.31.0" />
5859
<PackageVersion Include="PublicApiGenerator" Version="11.4.6" />
60+
<PackageVersion Include="RandomDataGenerator.Net" Version="1.0.18" />
5961
<PackageVersion Include="Shouldly" Version="4.3.0" />
6062
<PackageVersion Include="Sourcy.DotNet" Version="0.7.6" />
6163
<PackageVersion Include="Sourcy.Git" Version="0.7.6" />
@@ -73,7 +75,6 @@
7375
<PackageVersion Include="TUnit.Assertions" Version="0.19.148" />
7476
<PackageVersion Include="Verify.TUnit" Version="30.1.0" />
7577
<PackageVersion Include="Vogen" Version="7.0.3" />
76-
<PackageVersion Include="WireMock.Net" Version="1.8.5" />
7778
<PackageVersion Include="xunit" Version="2.9.3" />
7879
<PackageVersion Include="xunit.assert" Version="2.9.3" />
7980
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.0" />

Library.props

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project>
2+
<Import
3+
Condition="'$(EnablePolyfill)' != 'false'"
4+
Project="$(MSBuildThisFileDirectory)Polyfill.props" />
5+
6+
<PropertyGroup>
7+
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
8+
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<IsAotCompatible
11+
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
12+
13+
<EnableTrimAnalyzer
14+
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</EnableTrimAnalyzer>
15+
16+
<SignAssembly>true</SignAssembly>
17+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongname.snk</AssemblyOriginatorKeyFile>
18+
<PublicKey>0024000004800000940000000602000000240000525341310004000001000100698a70398fa0b2230c5a72e3bd9d56b48f809f6173e49a19fbb942d621be93ad48c5566b47b28faabc359b9ad3ff4e00bbdea88f5bdfa250f391fedd28182b2e37b55d429c0151a42a98ea7a5821818cd15a79fef9903e8607a88304cf3e0317bf86ec96e32e1381535a6582251e5a6eed40b5a3ed82bc444598b1269cce57a7</PublicKey>
19+
</PropertyGroup>
20+
</Project>

Playground/Playground.csproj

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<Import Project="..\TestProject.props" />
24

35
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
<IsPackable>false</IsPackable>
9-
<IsTestingPlatformApplication>true</IsTestingPlatformApplication>
10-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
11-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
12-
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
6+
<TUnitReflectionScanner>true</TUnitReflectionScanner>
137
</PropertyGroup>
148

159
<ItemGroup>
@@ -32,9 +26,10 @@
3226
<ProjectReference Include="..\TUnit\TUnit.csproj" />
3327
</ItemGroup>
3428

35-
<ItemGroup>
36-
<ProjectReference Include="..\TUnit.Analyzers\TUnit.Analyzers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
37-
<ProjectReference Include="..\TUnit.Analyzers.CodeFixers\TUnit.Analyzers.CodeFixers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
38-
</ItemGroup>
39-
29+
<Import Project="..\TestProject.targets" />
30+
31+
<PropertyGroup>
32+
<GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>
33+
</PropertyGroup>
34+
4035
</Project>

Playground/Program.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
1-
using Testcontainers.PostgreSql;
1+
using Microsoft.Testing.Platform.MSBuild;
2+
using Testcontainers.PostgreSql;
23
using Testcontainers.Redis;
4+
using TUnit.Engine.Extensions;
35
using Xunit;
46

57
namespace Playground;
68

9+
public static class Program
10+
{
11+
#pragma warning disable TUnit0034
12+
public static async Task<int> Main(string[] args)
13+
#pragma warning restore TUnit0034
14+
{
15+
var builder = await Microsoft.Testing.Platform.Builder.TestApplication.CreateBuilderAsync(args);
16+
17+
builder.AddSelfRegisteredExtensions(args);
18+
builder.AddMSBuild();
19+
builder.AddTUnit();
20+
21+
using var app = await builder.BuildAsync();
22+
23+
return await app.RunAsync();
24+
}
25+
}
26+
727
public class Tests
828
{
929
[Fact]
1030
public void Test()
1131
{
1232
var one = "1";
1333

14-
Assert.Equal("1", one);
34+
Xunit.Assert.Equal("1", one);
1535
}
1636
}
1737

TUnit.Analyzers.CodeFixers/InheritsTestsCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace TUnit.Analyzers.CodeFixers;
1616
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(InheritsTestsCodeFixProvider)), Shared]
1717
public class InheritsTestsCodeFixProvider : CodeFixProvider
1818
{
19-
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } =
19+
public override sealed ImmutableArray<string> FixableDiagnosticIds { get; } =
2020
ImmutableArray.Create(Rules.DoesNotInheritTestsWarning.Id);
2121

2222
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
2323

24-
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
24+
public override sealed async Task RegisterCodeFixesAsync(CodeFixContext context)
2525
{
2626
foreach (var diagnostic in context.Diagnostics)
2727
{

TUnit.Analyzers.CodeFixers/XUnitAttributesCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace TUnit.Analyzers.CodeFixers;
1212
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(XUnitAttributesCodeFixProvider)), Shared]
1313
public class XUnitAttributesCodeFixProvider : CodeFixProvider
1414
{
15-
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } =
15+
public override sealed ImmutableArray<string> FixableDiagnosticIds { get; } =
1616
ImmutableArray.Create(Rules.XunitAttributes.Id);
1717

1818
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
1919

20-
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
20+
public override sealed async Task RegisterCodeFixesAsync(CodeFixContext context)
2121
{
2222
foreach (var diagnostic in context.Diagnostics)
2323
{

0 commit comments

Comments
 (0)