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
4 changes: 4 additions & 0 deletions WolverineWebApiFSharp/WolverineWebApiFSharp.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<ProjectReference Include="..\src\Http\Wolverine.Http\Wolverine.Http.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="9.0.303" />
</ItemGroup>

</Project>
12 changes: 11 additions & 1 deletion docs/guide/durability/marten/event-sourcing.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,17 @@ public class MarkItemReadyHandler1442193977 : MessageHandler
As you probably guessed, there are some naming conventions or other questions you need to be aware of
before you use this middleware strategy.

Alternatively, there is also the newer `[WriteAttribute]` usage, with this example being a functional alternative
::: warning
There are some open, let's call them _imperfections_ with Wolverine's code generation against the `[WriteAggregate]` and `[ReadAggregate]`
usage. For best results, only use these attributes on a parameter within the main HTTP endpoint method and not in `Validate/Before/Load` methods.
:::

::: info
The `[Aggregate]` and `[WriteAggregate]` attributes _require the requested stream and aggregate to be found by default_, meaning that the handler or HTTP
endpoint will be stopped if the requested data is not found. You can explicitly mark individual attributes as `Required=false`.
:::

Alternatively, there is also the newer `[WriteAggregate]` usage, with this example being a functional alternative
mark up:

<!-- snippet: sample_MarkItemReadyHandler_with_WriteAggregate -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ await theHost.Scenario(x =>

public static class LetterAggregateEndpointWithValidation
{
public static ProblemDetails Validate([WriteAggregate(Required = true, OnMissing = OnMissing.ProblemDetailsWith404)] LetterAggregate letters)
public static ProblemDetails Validate(LetterAggregate letters)
{
if (letters.ACount is 0)
{
Expand All @@ -134,10 +134,11 @@ public static ProblemDetails Validate([WriteAggregate(Required = true, OnMissing
}

[WolverinePost("/letters-validation/{id}")]
public static LetterAggregate PostLetter(LetterAggregate letters)
public static LetterAggregate PostLetter([WriteAggregate(Required = true, OnMissing = OnMissing.ProblemDetailsWith404)] LetterAggregate letters)
=> letters;
}


public static class LetterAggregateEndpoint
{
#region sample_read_aggregate_fine_grained_validation_control
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Wolverine.Http/Wolverine.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="[4.7.2,)" />
<PackageReference Include="FSharp.Core" Version="9.0.303" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Http/WolverineWebApi/WolverineWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="9.0.300" />
<PackageReference Include="FSharp.Core" Version="9.0.303" />
<PackageReference Include="FSharp.Core" Version="9.0.202" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
Expand Down
10 changes: 5 additions & 5 deletions src/Persistence/Wolverine.Marten/AggregateHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ internal static void DetermineEventCaptureHandling(IChain chain, MethodCall firs
internal Variable RelayAggregateToHandlerMethod(Variable eventStream, IChain chain, MethodCall firstCall,
Type aggregateType)
{
if (aggregateType.Name == "LetterAggregate")
{
Debug.WriteLine("Here");
}

Variable aggregateVariable = new MemberAccessVariable(eventStream,
typeof(IEventStream<>).MakeGenericType(aggregateType).GetProperty(nameof(IEventStream<string>.Aggregate)));

Expand All @@ -211,6 +206,11 @@ internal Variable RelayAggregateToHandlerMethod(Variable eventStream, IChain cha
firstCall.TrySetArgument(aggregateVariable);
}

foreach (var methodCall in chain.Middleware.OfType<MethodCall>())
{
methodCall.TrySetArgument(aggregateVariable);
}

return aggregateVariable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal class LoadDocumentFrame : AsyncFrame
public LoadDocumentFrame(Type sagaType, Variable sagaId)
{
_sagaId = sagaId;
uses.Add(sagaId);

Saga = new Variable(sagaType, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ internal class SetVariableToNullIfSoftDeletedFrame : AsyncFrame
public SetVariableToNullIfSoftDeletedFrame(Variable entity)
{
_entity = entity;
uses.Add(entity);
}

public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence/Wolverine.Marten/WriteAggregateAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public WriteAggregateAttribute(string? routeOrParameterName)

public string? RouteOrParameterName { get; }

public bool Required { get; set; }
public bool Required { get; set; } = true;
public string MissingMessage { get; set; }
public OnMissing OnMissing { get; set; }

Expand All @@ -45,7 +45,7 @@ public override Variable Modify(IChain chain, ParameterInfo parameter, IServiceC
if (chain.HandlerCalls().First().Method.GetParameters().Count(x => x.HasAttribute<WriteAggregateAttribute>()) > 1)
{
throw new InvalidOperationException(
"It is only possible (today) to use a single [Aggregate] attribute on an HTTP handler method. Maybe use [ReadAggregate] if all you need is the projected data");
"It is only possible (today) to use a single [Aggregate] or [WriteAggregate] attribute on an HTTP handler method. Maybe use [ReadAggregate] if all you need is the projected data");
}

var aggregateType = parameter.ParameterType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Alba" Version="8.1.1" />
<PackageReference Include="Alba" Version="8.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Alba" Version="7.4.1"/>
<PackageReference Include="Alba" Version="8.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="Shouldly" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Alba" Version="8.2.0" />
<PackageReference Include="Alba" Version="8.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Alba" Version="7.4.1"/>
<PackageReference Include="Alba" Version="8.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Alba" Version="7.4.1"/>
<PackageReference Include="Alba" Version="8.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Alba" Version="8.1.1" />
<PackageReference Include="Alba" Version="8.2.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -35,7 +35,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Alba" Version="8.1.1" />
<PackageReference Include="Alba" Version="8.2.1" />
</ItemGroup>

</Project>
7 changes: 5 additions & 2 deletions src/Wolverine/Persistence/EntityAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Reflection;
using JasperFx.CodeGeneration;
using JasperFx.CodeGeneration.Frames;
Expand Down Expand Up @@ -42,6 +43,10 @@ public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)

_guardFrames[0].GenerateCode(method, writer);
}
else if (_creator.Next != null)
{
Debug.WriteLine("What the heck?");
}
else
{
var previous = _creator;
Expand Down Expand Up @@ -87,8 +92,6 @@ public EntityAttribute(string argumentName) : base(argumentName)
{
ValueSource = ValueSource.Anything;
}



/// <summary>
/// Is the existence of this entity required for the rest of the handler action or HTTP endpoint
Expand Down
Loading