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
38 changes: 38 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and Test

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build-test:
name: Build and test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
cache: true
cache-dependency-path: |
examples/Eventa.Example/packages.lock.json
tests/Eventa.Tests/packages.lock.json

- name: Restore
run: dotnet restore Eventa.slnx --locked-mode
Comment thread
Garfield550 marked this conversation as resolved.

- name: Build
run: dotnet build Eventa.slnx --configuration Release --no-restore

- name: Test
run: dotnet test --project tests/Eventa.Tests/Eventa.Tests.csproj --configuration Release --no-build
Comment thread
Garfield550 marked this conversation as resolved.
35 changes: 35 additions & 0 deletions .github/workflows/run-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run Example

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
run-example:
name: Run example
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
cache: true
cache-dependency-path: |
examples/Eventa.Example/packages.lock.json
tests/Eventa.Tests/packages.lock.json

- name: Restore
run: dotnet restore Eventa.slnx --locked-mode
Comment thread
Garfield550 marked this conversation as resolved.

- name: Run example
run: dotnet run --project examples/Eventa.Example/Eventa.Example.csproj --configuration Release --no-restore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
# !.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand Down
1 change: 1 addition & 0 deletions examples/Eventa.Example/Eventa.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions examples/Eventa.Example/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": 1,
"dependencies": {
"net10.0": {
"Microsoft.Extensions.DependencyInjection": {
"type": "Direct",
"requested": "[10.0.7, )",
"resolved": "10.0.7",
"contentHash": "91F/o3emPV/+xY/ip3s2LqDNF14kjttlVtq0BXgg6p4MnCzeSZxnUJm+t6WRrtD3JdGo88/oX+z7OwK4y8PZuw==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.7"
}
},
"FSharp.Core": {
"type": "Transitive",
"resolved": "11.0.100",
"contentHash": "ijfOz8ihqkFNdKUY57l8YTrbJNfQW/6tFYAUU57ByZzmTxxf1o12cQaCqDOjNqAz4h86AKS7IwQkNhYcrjLeCQ=="
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "Z6mfFEaFcwCfSboxJwOLfu7/31npCY9q70WUamHW/vRQhDvBKOT4Vf9YkZj5J6hLvJpb0oDEYfHunQZj0xxvKw=="
},
"pblasucci.ananoid": {
"type": "Transitive",
"resolved": "2.0.0",
"contentHash": "9QIgX+KrA7WYcJKq54y+A/ncKTKMlR7h95i38wSgb37y5l3XpYrybCcUx/uGH/d3FGCRieLNyUkC7XACgVsurA=="
},
"eventa": {
"type": "Project",
"dependencies": {
"FSharp.Core": "[11.0.100, )",
"pblasucci.ananoid": "[2.0.0, )"
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Eventa/Support/InvokeHandlerRegistrationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public async Task ForwardStreamResponsesAsync(
// Avoid starting handler-stream enumeration after an early abort won.
if (cancellationToken.IsCancellationRequested) return;

await foreach (var item in responses.ConfigureAwait(false))
await foreach (var item in responses.WithCancellation(cancellationToken).ConfigureAwait(false))
{
// Cancellation can win after MoveNextAsync but before we emit this item.
if (cancellationToken.IsCancellationRequested) return;
Expand Down
2 changes: 1 addition & 1 deletion src/Eventa/Support/InvokeSessionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void DispatchSendRequest(Action onCancellation, Action<Exception> onSend
return;
}

_ = Task.Run(() => ExecuteSendRequestAsync(onSendFault), CancellationToken.None);
_ = Task.Run(() => ExecuteSendRequestAsync(onSendFault), _requestCancellationSource.Token);
}
Comment thread
Garfield550 marked this conversation as resolved.

/// <summary>
Expand Down
9 changes: 5 additions & 4 deletions tests/Eventa.Tests/Eventa.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<RootNamespace>Eventa.Tests</RootNamespace>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
Expand Down
13 changes: 8 additions & 5 deletions tests/Eventa.Tests/StreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,10 @@ public async Task InvokeStreamClient_AbortsRequestStreamBeforeFirstItem_AndNotif
var definition = new InvokeEventDefinition<int, int>("abort-request-stream-before-first-item");
var receiveErrorEvent = new EventDefinition<ReceiveErrorPayload>(definition.ReceiveErrorId);
var handlerNotified = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var handlerObservedCancellation = new TaskCompletionSource<OperationCanceledException>(
TaskCreationOptions.RunContinuationsAsynchronously);
var received = new List<int>();
var responses = new List<int>();
var handlerObservedCanceledToken = false;
var receiveErrorCount = 0;
Exception? handlerError = null;
Exception? receiveError = null;
Expand Down Expand Up @@ -806,13 +807,14 @@ async IAsyncEnumerable<int> Handler(
}
catch (OperationCanceledException error) when (cancellationToken.IsCancellationRequested)
{
handlerObservedCanceledToken = true;
handlerError = error;
handlerObservedCancellation.TrySetResult(error);
throw;
}
catch (Exception error)
{
handlerError = error;
handlerObservedCancellation.TrySetException(error);
throw;
}

Expand Down Expand Up @@ -851,15 +853,16 @@ async IAsyncEnumerable<int> Handler(

await readTask.WaitAsync(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken);
await handlerNotified.Task.WaitAsync(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken);
var observedHandlerError = await handlerObservedCancellation.Task.WaitAsync(
TimeSpan.FromSeconds(5),
TestContext.Current.CancellationToken);

Assert.Empty(received);
Assert.Empty(responses);
Assert.True(handlerObservedCanceledToken);
Assert.NotNull(handlerError);
Assert.Same(observedHandlerError, handlerError);
Assert.Null(receiveError);
Assert.Equal(0, Volatile.Read(ref receiveErrorCount));
Assert.NotNull(readError);
Assert.IsAssignableFrom<OperationCanceledException>(handlerError);
Assert.IsAssignableFrom<OperationCanceledException>(readError);
}

Expand Down
137 changes: 137 additions & 0 deletions tests/Eventa.Tests/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"version": 1,
"dependencies": {
"net10.0": {
"xunit.v3.mtp-v2": {
"type": "Direct",
"requested": "[3.2.2, )",
"resolved": "3.2.2",
"contentHash": "S0LJpeMIMrmbVLXDCvPVX47OLk28qBYfGU+5SNCbarOEdw8oKLfiVqaACwuYRvLiOqDEB/+VJ8gTSB1ZwheoOQ==",
"dependencies": {
"xunit.analyzers": "1.27.0",
"xunit.v3.assert": "[3.2.2]",
"xunit.v3.core.mtp-v2": "[3.2.2]"
}
},
"FSharp.Core": {
"type": "Transitive",
"resolved": "11.0.100",
"contentHash": "ijfOz8ihqkFNdKUY57l8YTrbJNfQW/6tFYAUU57ByZzmTxxf1o12cQaCqDOjNqAz4h86AKS7IwQkNhYcrjLeCQ=="
},
"Microsoft.ApplicationInsights": {
"type": "Transitive",
"resolved": "2.23.0",
"contentHash": "nWArUZTdU7iqZLycLKWe0TDms48KKGE6pONH2terYNa8REXiqixrMOkf1sk5DHGMaUTqONU2YkS4SAXBhLStgw=="
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
},
"Microsoft.Testing.Extensions.Telemetry": {
"type": "Transitive",
"resolved": "2.0.2",
"contentHash": "H580BvHyuADoWzlH9zRk5fqVyGucm6mhph+k40CQc9O4ie+Buxa4Pk9Q92BEClqIICqi25J7fuMII9qFYYgKtw==",
"dependencies": {
"Microsoft.ApplicationInsights": "2.23.0",
"Microsoft.Testing.Platform": "2.0.2"
}
},
"Microsoft.Testing.Extensions.TrxReport.Abstractions": {
"type": "Transitive",
"resolved": "2.0.2",
"contentHash": "MrHYdPZ1CiyYp5bfjzNSghfVwl/I9osMazcZMAbwZY0BhR32i70YLf4zSXECvU2qt2PvDdrjYpGRgBscFbjDpw==",
"dependencies": {
"Microsoft.Testing.Platform": "2.0.2"
}
},
"Microsoft.Testing.Platform": {
"type": "Transitive",
"resolved": "2.0.2",
"contentHash": "43NCOTEENtdc9fmlzX9KHQR14AZEYek5r4jOJlWPhTyV1+aYAQYl4x773nYXU5TKxV6+rMuniJ7wcj9C9qrP1A=="
},
"Microsoft.Testing.Platform.MSBuild": {
"type": "Transitive",
"resolved": "2.0.2",
"contentHash": "2zKkQKaUoaKgb/3AekboWOdLMh4upCo1nLWQnjGzp8r9YjiNOZRrzTsJQ3A4U03AcbH0evlIvFDKYSUqmTVuug==",
"dependencies": {
"Microsoft.Testing.Platform": "2.0.2"
}
},
"Microsoft.Win32.Registry": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg=="
},
"pblasucci.ananoid": {
"type": "Transitive",
"resolved": "2.0.0",
"contentHash": "9QIgX+KrA7WYcJKq54y+A/ncKTKMlR7h95i38wSgb37y5l3XpYrybCcUx/uGH/d3FGCRieLNyUkC7XACgVsurA=="
},
"xunit.analyzers": {
"type": "Transitive",
"resolved": "1.27.0",
"contentHash": "y/pxIQaLvk/kxAoDkZW9GnHLCEqzwl5TW0vtX3pweyQpjizB9y3DXhb9pkw2dGeUqhLjsxvvJM1k89JowU6z3g=="
},
"xunit.v3.assert": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "BPciBghgEEaJN/JG00QfCYDfEfnLgQhfnYEy+j1izoeHVNYd5+3Wm8GJ6JgYysOhpBPYGE+sbf75JtrRc7jrdA=="
},
"xunit.v3.common": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "Hj775PEH6GTbbg0wfKRvG2hNspDCvTH9irXhH4qIWgdrOSV1sQlqPie+DOvFeigsFg2fxSM3ZAaaCDQs+KreFA==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "6.0.0"
}
},
"xunit.v3.core.mtp-v2": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "zW82tdCm+T1uUD1JKE+SmhgMq8nCAvcFPRLIVEiRgaxBSjcyJEKopLU3bHGOa416q+N3Dz7m1zLoPR5VJ5OQ+Q==",
"dependencies": {
"Microsoft.Testing.Extensions.Telemetry": "2.0.2",
"Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.0.2",
"Microsoft.Testing.Platform": "2.0.2",
"Microsoft.Testing.Platform.MSBuild": "2.0.2",
"xunit.v3.extensibility.core": "[3.2.2]",
"xunit.v3.runner.inproc.console": "[3.2.2]"
}
},
"xunit.v3.extensibility.core": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "srY8z/oMPvh/t8axtO2DwrHajhFMH7tnqKildvYrVQIfICi8fOn3yIBWkVPAcrKmHMwvXRJ/XsQM3VMR6DOYfQ==",
"dependencies": {
"xunit.v3.common": "[3.2.2]"
}
},
"xunit.v3.runner.common": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "/hkHkQCzGrugelOAehprm7RIWdsUFVmIVaD6jDH/8DNGCymTlKKPTbGokD5czbAfqfex47mBP0sb0zbHYwrO/g==",
"dependencies": {
"Microsoft.Win32.Registry": "[5.0.0]",
"xunit.v3.common": "[3.2.2]"
}
},
"xunit.v3.runner.inproc.console": {
"type": "Transitive",
"resolved": "3.2.2",
"contentHash": "ulWOdSvCk+bPXijJZ73bth9NyoOHsAs1ZOvamYbCkD4DNLX/Bd29Ve2ZNUwBbK0MqfIYWXHZViy/HKrdEC/izw==",
"dependencies": {
"xunit.v3.extensibility.core": "[3.2.2]",
"xunit.v3.runner.common": "[3.2.2]"
}
},
"eventa": {
"type": "Project",
"dependencies": {
"FSharp.Core": "[11.0.100, )",
"pblasucci.ananoid": "[2.0.0, )"
}
}
}
}
}