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
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
<PackageVersion Include="Grpc.StatusProto" Version="2.76.0" />
<PackageVersion Include="Grpc.Tools" Version="2.76.0" />
<PackageVersion Include="HtmlTags" Version="9.0.0" />
<PackageVersion Include="JasperFx" Version="2.2.4" />
<PackageVersion Include="JasperFx.Events" Version="2.2.4" />
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.2.4" />
<PackageVersion Include="JasperFx" Version="2.2.5" />
<PackageVersion Include="JasperFx.Events" Version="2.2.5" />
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.2.5" />
<!-- RuntimeCompiler is on its own 5.x line (the Roslyn compiler package) — not the 2.1.x
family; it stays at 5.0.0. -->
<PackageVersion Include="JasperFx.RuntimeCompiler" Version="5.0.0" />
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.2.4" />
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.2.5" />
<PackageVersion Include="Marten" Version="9.2.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.3" />
<PackageVersion Include="Polecat" Version="4.2.1" />
Expand Down
25 changes: 3 additions & 22 deletions src/Wolverine/Configuration/FSharpEmitHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using JasperFx.CodeGeneration;
using JasperFx.CodeGeneration.Frames;
using JasperFx.CodeGeneration.Model;
using JasperFx.Core.Reflection;

namespace Wolverine.Configuration;

/// <summary>
/// Small shared helpers for emitting F# from Wolverine frames (issue GH-2969). These cover gaps in
/// the JasperFx-layer model where a value's C# rendering is not valid F#, plus the recurring
/// "abort-or-continue" continuation shape.
/// Small shared helper for emitting F# from Wolverine frames (issue GH-2969): the recurring
/// "abort-or-continue" continuation shape. (The former CastVariable workaround was retired once
/// JasperFx 2.2.5 added the built-in <c>Variable.FSharpUsage</c>; frames now use that directly.)
/// </summary>
internal static class FSharpEmitHelpers
{
Expand Down Expand Up @@ -40,21 +38,4 @@ public static void WriteAbortGuard(ISourceWriter writer, GeneratedMethod method,

writer.FinishBlock();
}

/// <summary>
/// The F# rendering of a variable's usage. F# has no C-style cast, but
/// <see cref="CastVariable" /> bakes a C# <c>((Type)x)</c> cast into its <see cref="Variable.Usage" />
/// (e.g. the injected <c>ILogger&lt;TMessage&gt;</c> handed to validation frames as <c>ILogger</c>).
/// Rewrite that as an F# upcast <c>(x :&gt; Type)</c>; everything else uses its usage verbatim.
/// </summary>
/// <remarks>
/// The proper fix is an F#-aware usage on JasperFx's <c>CastVariable</c> itself; tracked as an
/// upstream JasperFx gap. Until then this keeps the audit moving without leaving Wolverine.
/// </remarks>
public static string FSharpUsage(Variable variable)
{
return variable is CastVariable cast
? $"({cast.Inner.Usage} :> {cast.VariableType.FSharpName()})"
: variable.Usage;
}
}
2 changes: 1 addition & 1 deletion src/Wolverine/Logging/AuditToActivityFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void GenerateFSharpCode(GeneratedMethod method, ISourceWriter wr
foreach (var member in _members)
{
writer.Write(
$"{current}.{nameof(Activity.SetTag)}(\"{member.OpenTelemetryName}\", {FSharpEmitHelpers.FSharpUsage(_input!)}.{member.Member.Name}) |> ignore");
$"{current}.{nameof(Activity.SetTag)}(\"{member.OpenTelemetryName}\", {_input!.FSharpUsage}.{member.Member.Name}) |> ignore");
}

writer.FinishBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override void GenerateFSharpCode(GeneratedMethod method, ISourceWriter wr
// F# has no early `return`; render the remainder of the chain inside the `else` branch.
writer.WriteComment("Check RequirementResult and abort if Branch == Stop");
var condition =
$"{typeof(RequirementResultContinuationPolicy).FSharpName()}.{nameof(RequirementResultContinuationPolicy.ShouldStop)}({FSharpEmitHelpers.FSharpUsage(_logger!)}, {_variable.Usage})";
$"{typeof(RequirementResultContinuationPolicy).FSharpName()}.{nameof(RequirementResultContinuationPolicy.ShouldStop)}({_logger!.FSharpUsage}, {_variable.Usage})";
FSharpEmitHelpers.WriteAbortGuard(writer, method, condition, Next);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public override void GenerateFSharpCode(GeneratedMethod method, ISourceWriter wr
// `else` branch so the abort path simply yields the method's result.
writer.WriteComment("Check for any simple validation messages and abort if any exist");
var condition =
$"{typeof(SimpleValidationContinuationPolicy).FSharpName()}.{nameof(SimpleValidationContinuationPolicy.LogValidationMessages)}({FSharpEmitHelpers.FSharpUsage(_logger!)}, {_variable.Usage})";
$"{typeof(SimpleValidationContinuationPolicy).FSharpName()}.{nameof(SimpleValidationContinuationPolicy.LogValidationMessages)}({_logger!.FSharpUsage}, {_variable.Usage})";
FSharpEmitHelpers.WriteAbortGuard(writer, method, condition, Next);
}
}
2 changes: 1 addition & 1 deletion src/Wolverine/Persistence/Sagas/SetSagaIdFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)

public override void GenerateFSharpCode(GeneratedMethod method, ISourceWriter writer)
{
var sagaId = FSharpEmitHelpers.FSharpUsage(_sagaId);
var sagaId = _sagaId.FSharpUsage;
writer.Write($"{_context!.Usage}.{nameof(MessageContext.SetSagaId)}({sagaId})");

// F# has no null-conditional `?.`, and SetTag returns the Activity; guard once and pipe to ignore.
Expand Down
Loading