Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
pg_db: marten_testing
pg_user: postgres
# CONFIGURATION binds to the Nuke [Parameter] of the same name (Nuke reads parameters from the
# environment), so it genuinely selects the Release build. FRAMEWORK and
# DISABLE_TEST_PARALLELIZATION used to sit here too but bound to nothing: there is no Framework
# parameter, and no test project, runner config, or build target ever read the latter. The two
# suites that actually must not run concurrently (CodegenTests mutates process-wide statics and
# compiles assemblies; CommandLineTests redirects Console) declare that in code via
# [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)], which xunit v3 still
# honors, so the serialization is enforced where it can't be silently dropped.
CONFIGURATION: Release
FRAMEWORK: net9.0
DISABLE_TEST_PARALLELIZATION: true
NUKE_TELEMETRY_OPTOUT: true

jobs:
Expand Down
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="9.7.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageVersion Include="xunit.v3" Version="3.2.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/CodegenTests.FSharp/CodegenTests.FSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests.FSharp/FSharpCompilationGate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests.FSharp;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/CodeGeneration_ordering_determinism.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using JasperFx.CodeGeneration.Model;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests;

Expand Down
2 changes: 1 addition & 1 deletion src/CodegenTests/CodegenTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="FSharp.Core" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/FSharpControlFlowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using JasperFx.CodeGeneration.Frames;
using JasperFx.CodeGeneration.Model;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/GeneratedTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using JasperFx.CodeGeneration.Model;
using JasperFx.Core;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests;

Expand Down
13 changes: 11 additions & 2 deletions src/CodegenTests/MethodCallTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using JasperFx.CodeGeneration.Model;
using NSubstitute;
using Shouldly;
using Xunit.Sdk;

namespace CodegenTests;

Expand Down Expand Up @@ -478,5 +477,15 @@ public Task<string> GetString()

public interface IMartenOp
{


}

/// <summary>
/// A return type for the MethodCallTarget probes below. The tests only assert that
/// MethodCall infers this exact type (and the argument name derived from it), so any reference
/// type does; it previously borrowed Xunit.Sdk.ErrorMessage via a stray `using Xunit.Sdk`,
/// which quietly tied a codegen test to xunit's internals and broke on the v3 upgrade.
/// </summary>
public class ErrorMessage
{
}
1 change: 0 additions & 1 deletion src/CodegenTests/Samples/Frames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using JasperFx.CodeGeneration.Frames;
using JasperFx.CodeGeneration.Model;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests.Samples;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Samples/HelloWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using JasperFx.RuntimeCompiler;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests.Samples;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Samples/InjectedFieldUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using JasperFx.CodeGeneration.Frames;
using JasperFx.CodeGeneration.Model;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests.Samples;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Samples/UsingSourceWriter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using JasperFx.CodeGeneration;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests.Samples;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Services/BruteForceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using JasperFx.RuntimeCompiler;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using JasperFx.RuntimeCompiler;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests.Services;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Services/keyed_constructor_injection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace CodegenTests.Services;

Expand Down
1 change: 0 additions & 1 deletion src/CodegenTests/Services/keyed_service_location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using JasperFx.RuntimeCompiler;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit.Abstractions;

namespace CodegenTests.Services;

Expand Down
12 changes: 12 additions & 0 deletions src/CommandLineTests/CommandExecutorTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using JasperFx.CommandLine;
using JasperFx.Core;
using Shouldly;
using Spectre.Console;

namespace CommandLineTests
{
Expand All @@ -23,6 +24,17 @@ public CommandExecutorTester()
{
Console.SetOut(theOutput);

// CommandExecutor renders failures through Spectre's AnsiConsole, which caches the
// TextWriter it binds to on first use anywhere in the process. Console.SetOut alone
// therefore does NOT redirect the failure path -- whichever test touched Spectre first
// has already pinned the writer. That made run_an_async_command_that_fails pass or fail
// purely on test ordering (it survived xunit v2's order and broke under v3's). Bind
// Spectre explicitly so this class captures failure output regardless of order.
AnsiConsole.Console = AnsiConsole.Create(new AnsiConsoleSettings
{
Out = new AnsiConsoleOutput(theOutput)
});

executor = CommandExecutor.For(_ =>
{
_.RegisterCommands(GetType().GetTypeInfo().Assembly);
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLineTests/CommandLineTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/CoreTests/Core/data_segregation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using JasperFx.Core;
using Xunit.Abstractions;

namespace CoreTests.Core;

Expand Down
2 changes: 1 addition & 1 deletion src/CoreTests/CoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
17 changes: 7 additions & 10 deletions src/DocSamples/DocSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!--
No test packages here on purpose. This project holds compile-checked documentation samples
(mdsnippets sources), contains zero [Fact]/[Theory] methods, and is not in jasperfx.slnx or
any Nuke target. It carried xunit + the VSTest runner + Microsoft.NET.Test.Sdk purely as
inherited boilerplate; xunit.v3 would additionally have forced OutputType=Exe on a
Microsoft.NET.Sdk.Web project for no benefit.
-->
<ItemGroup>
<ProjectReference Include="..\JasperFx\JasperFx.csproj" />
<ProjectReference Include="..\JasperFx.RuntimeCompiler\JasperFx.RuntimeCompiler.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/EventStoreTests/EventStoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/EventStoreTests/TestingSupport/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using JasperFx.Core.Reflection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace EventStoreTests.TestingSupport;

Expand Down
2 changes: 1 addition & 1 deletion src/EventTests/EventTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
5 changes: 4 additions & 1 deletion src/EventTests/Projections/SliceGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,12 @@ Task<User> IProjectionStorage<User, string>.LoadAsync(string id, CancellationTok
throw new NotImplementedException();
}

// Part of the IProjectionStorage contract this class self-stubs, NOT xunit lifecycle -- but
// xunit v3 disposes a test class that implements IAsyncDisposable, so a throwing stub here
// fails every test in the class during teardown. Nothing in these tests needs disposal.
ValueTask IAsyncDisposable.DisposeAsync()
{
throw new NotImplementedException();
return ValueTask.CompletedTask;
}

Task<IProjectionStorage<TDoc, TId>> IStorageOperations.FetchProjectionStorageAsync<TDoc, TId>(string tenantId, CancellationToken cancellationToken)
Expand Down
1 change: 0 additions & 1 deletion src/EventTests/TestingSupport/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using JasperFx.Core.Reflection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace EventTests.TestingSupport;

Expand Down
2 changes: 1 addition & 1 deletion src/JasperFx.Aspire.Tests/JasperFx.Aspire.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="4.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
17 changes: 15 additions & 2 deletions src/JasperFx/JasperFxOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ public static bool HasReferenceToJasperFxTool(Assembly assembly)
var names = assembly.GetReferencedAssemblies();
foreach (var name in names)
{
var reference = Assembly.Load(name);
if (reference != null && reference.HasAttribute<JasperFxToolAttribute>()) return true;
// Best-effort detection: an application's assembly graph routinely contains references
// that cannot be loaded or reflected over at runtime -- optional dependencies that were
// never deployed, assemblies trimmed away, or (as here) a reference whose own
// dependencies are missing from the output so that enumerating its custom attributes
// throws. None of that means the app is a JasperFx tool, and none of it is worth
// failing host startup over, so skip the assembly and keep looking.
try
{
var reference = Assembly.Load(name);
if (reference != null && reference.HasAttribute<JasperFxToolAttribute>()) return true;
}
catch (Exception)
{
// Intentionally ignored; see above.
}
}

return false;
Expand Down
Loading