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
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
- os: ubuntu-latest
docsTarget: true
cloudTestTarget: true
# This is here alongside docsTarget because newer docfx doesn't work
# with .NET 6.
dotNetVersionOverride: |
6.x
8.x
- os: ubuntu-arm
runsOn: ubuntu-24.04-arm64-2-core
- os: macos-intel
Expand Down Expand Up @@ -54,7 +49,7 @@ jobs:
with:
# Specific .NET version required because GitHub macos ARM image has
# bad pre-installed .NET version
dotnet-version: ${{ matrix.dotNetVersionOverride || '6.x' }}
dotnet-version: '10.x'

- name: Install protoc
uses: arduino/setup-protoc@v3
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/package.yml
Comment thread
jmaeagle99 marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
out-file: libtemporal_sdk_core_c_bridge.so
out-prefix: linux-musl-x64
# Need Alpine container since GH runner doesn't have one
container: mcr.microsoft.com/dotnet/sdk:8.0-alpine
container: mcr.microsoft.com/dotnet/sdk:10.0-alpine
protobuf-url: https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-x86_64.zip
runsOn: ubuntu-latest
- os: macos-intel
Expand Down Expand Up @@ -135,6 +135,8 @@ jobs:

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x

- name: Build package
run: dotnet pack -c Release /p:BridgeLibraryRoot=${{ github.workspace }}/bridge-libraries
Expand Down Expand Up @@ -164,7 +166,7 @@ jobs:
- os: ubuntu-arm
runsOn: ubuntu-24.04-arm64-2-core
- os: alpine-latest
container: mcr.microsoft.com/dotnet/sdk:6.0-alpine
container: mcr.microsoft.com/dotnet/sdk:10.0-alpine
runsOn: ubuntu-latest
- os: macos-intel
runsOn: macos-13
Expand Down Expand Up @@ -192,11 +194,7 @@ jobs:
with:
# Specific .NET version required because GitHub macos ARM image has
# bad pre-installed .NET version
dotnet-version: 6.x

- name: Setup .NET (Alpine)
if: ${{ matrix.os == 'alpine-latest' }}
run: apk add dotnet6-sdk
dotnet-version: 10.x

- name: Run smoke test (non-Windows)
if: ${{ matrix.os != 'windows-latest' && matrix.os != 'windows-arm' }}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ dotnet_diagnostic.CA1024.severity = none
# Don't force workflows to have static methods
dotnet_diagnostic.CA1822.severity = none

# Don't force workflows to call async methods
dotnet_diagnostic.CA1849.severity = none

# Do not need ConfigureAwait for workflows
dotnet_diagnostic.CA2007.severity = none

Expand All @@ -815,6 +818,9 @@ dotnet_diagnostic.CA5394.severity = none
# Allow async methods to not have await in them
dotnet_diagnostic.CS1998.severity = none

# Don't force workflows to call async methods
dotnet_diagnostic.VSTHRD103.severity = none

# Don't avoid, but rather encourage things using TaskScheduler.Current in workflows
dotnet_diagnostic.VSTHRD105.severity = none
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/Temporalio.SimpleBench/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
resultWatch.Stop();

// Cancel worker and wait for cancelled
cancelSource.Cancel();
await cancelSource.CancelAsync();
try
{
await workerTask;
Expand Down
6 changes: 3 additions & 3 deletions tests/Temporalio.SimpleBench/Temporalio.SimpleBench.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Temporalio\Temporalio.csproj" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/Temporalio.SmokeTest/Temporalio.SmokeTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public TestCounterService()

public int Increment()
{
if (isDisposed)
{
throw new ObjectDisposedException(nameof(TestCounterService));
}
ObjectDisposedException.ThrowIf(isDisposed, nameof(TestCounterService));

return ++value;
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Temporalio.Tests/KitchenSinkWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ action with
tasks.Add(Task.Factory.StartNew(async () =>
{
await Workflow.DelayAsync((int)action.ExecuteActivity.CancelAfterMS);
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
cancelSource.Cancel();
Comment thread
jmaeagle99 marked this conversation as resolved.
Resolved
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}).Unwrap());
}
// Start all activities
Expand Down
13 changes: 3 additions & 10 deletions tests/Temporalio.Tests/Temporalio.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,20 @@
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="1.4.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="8.0.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.console" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />

<!-- Resolve https://github.com/advisories/GHSA-7jgj-8wvc-jh57 -->
<PackageReference Include="System.Net.Http" Version="4.3.4" />

<!-- Resolve https://github.com/advisories/GHSA-cmhx-cq75-c4mj -->
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Temporalio.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static string ReadAllFileText(

public static int FreePort()
{
var l = new TcpListener(IPAddress.Loopback, 0);
using var l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task RunAsync_SimpleActivity_Succeeds()
Info = ActivityEnvironment.DefaultInfo with { ActivityType = "SomeActivity" },
Heartbeater = heartbeats.Add,
};
env.WorkerShutdownTokenSource.Cancel();
await env.WorkerShutdownTokenSource.CancelAsync();
env.Cancel(ActivityCancelReason.Timeout);
var ret = await env.RunAsync(async () =>
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Temporalio.Tests/Worker/ActivityWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => ExecuteActivityAsy
workflowId = handle.Id;
// Wait for activity to be reached, then stop the worker
await activityReached.Task.WaitAsync(TimeSpan.FromSeconds(20));
workerStoppingSource.Cancel();
await workerStoppingSource.CancelAsync();
}));
Assert.True(gotCancellation);
// Check the workflow error
Expand Down
5 changes: 5 additions & 0 deletions tests/Temporalio.Tests/Worker/NexusWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ await AssertMore.HasEventEventuallyAsync(
svc => svc.DoSomething("some-name"),
new() { CancellationToken = cancelSource.Token });
// Cancel and wait for result to bubble out cancel
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
cancelSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
await handle.GetResultAsync();
}));
var inner = Assert.IsType<NexusOperationFailureException>(wfExc.InnerException);
Expand Down
48 changes: 40 additions & 8 deletions tests/Temporalio.Tests/Worker/WorkflowWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,14 @@ public enum Scenario
TaskWaitAsync,
// https://github.com/dotnet/runtime/issues/83159
DataflowReceiveAsync,
// https://github.com/dotnet/runtime/issues/87481
TaskWhenAnyWithResultThreeParam,
ListenerDisabledCreateCommand,

// Good
TaskFactoryStartNew,
TaskStart,
TaskContinueWith,
// https://github.com/dotnet/runtime/issues/87481
TaskWhenAnyWithResultTwoParam,
TaskWhenAnyWithResultThreeParam,
WorkflowWhenAnyWithResultThreeParam,
WorkflowWhenAll,
WorkflowRunTask,
Expand Down Expand Up @@ -333,9 +331,6 @@ await AssertScenarioFailsTask(
await AssertScenarioFailsTask(
StandardLibraryCallsWorkflow.Scenario.DataflowReceiveAsync,
"not scheduled on workflow scheduler");
await AssertScenarioFailsTask(
StandardLibraryCallsWorkflow.Scenario.TaskWhenAnyWithResultThreeParam,
"not scheduled on workflow scheduler");
await AssertScenarioFailsTask(
StandardLibraryCallsWorkflow.Scenario.ListenerDisabledCreateCommand,
"Function during tracing event listener disabling created workflow commands");
Expand All @@ -360,6 +355,8 @@ Task AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario scenario) =>
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.TaskStart);
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.TaskContinueWith);
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.TaskWhenAnyWithResultTwoParam);
// Starting in .NET 8, https://github.com/dotnet/runtime/issues/87481 is fixed
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.TaskWhenAnyWithResultThreeParam);
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.WorkflowWhenAnyWithResultThreeParam);
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.WorkflowWhenAll);
await AssertScenarioSucceeds(StandardLibraryCallsWorkflow.Scenario.WorkflowRunTask);
Expand Down Expand Up @@ -551,7 +548,12 @@ public async Task<string> RunAsync(Input input)
using var cancelSource = new CancellationTokenSource();
if (input.CancelBefore)
{
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
cancelSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}
else if (input.CancelAfterMS > 0)
{
Expand Down Expand Up @@ -1302,7 +1304,12 @@ public Task<bool> RunAsync(int timeoutMs) =>
public async Task ProceedAsync() => shouldProceed = true;

[WorkflowSignal]
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
public async Task CancelWaitAsync() => cancelSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}

[Fact]
Expand Down Expand Up @@ -2007,7 +2014,12 @@ public async Task RunAsync(Input input)
// Cancel before if desired
if (input.BeforeStart)
{
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
tokenSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}
Task activity;
if (input.Local)
Expand Down Expand Up @@ -2036,7 +2048,12 @@ public async Task RunAsync(Input input)
if (!input.BeforeStart)
{
await Workflow.DelayAsync(1);
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
tokenSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}
await activity;
}
Expand Down Expand Up @@ -2255,15 +2272,25 @@ public async Task RunAsync(bool beforeStart)
// Cancel before if desired
if (beforeStart)
{
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
tokenSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async method
}
var handle = await Workflow.StartChildWorkflowAsync(
(ChildWorkflow wf) => wf.RunAsync(),
new() { CancellationToken = tokenSource.Token });
// If not cancel before, cancel now
if (!beforeStart)
{
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
tokenSource.Cancel();
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore CA1849 // Call async methods when in an async methodßß
}
await handle.GetResultAsync();
}
Expand Down Expand Up @@ -4088,7 +4115,7 @@ await ExecuteWorkerAsync<UpdateWorkflow>(async worker =>
await AssertMore.EqualEventuallyAsync(true, () => handle.QueryAsync(wf => wf.Waiting));

// Cancel and confirm error
updateCancelSource.Cancel();
await updateCancelSource.CancelAsync();
await Assert.ThrowsAsync<WorkflowUpdateRpcTimeoutOrCanceledException>(() => updateTask);
});
}
Expand Down Expand Up @@ -5297,7 +5324,12 @@ await Workflow.ExecuteActivityAsync(
}

[WorkflowSignal]
#pragma warning disable CA1849 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// https://github.com/temporalio/sdk-dotnet/issues/327
public async Task CancelUpdateAsync(int number) => cancellations[number].Cancel();
#pragma warning restore VSTHRD103
#pragma warning restore CA1849

#pragma warning disable VSTHRD110 // Returning tasks is ok
private Task WaitAsync(CancellationToken? cancellationToken = null) =>
Expand Down Expand Up @@ -6512,7 +6544,7 @@ await AssertMore.EventuallyAsync(async () =>
});

// Now cancel token and confirm update cancellation results in proper cancellation
cancelSource.Cancel();
await cancelSource.CancelAsync();
await Assert.ThrowsAsync<WorkflowUpdateRpcTimeoutOrCanceledException>(
() => updateTask);
// Note, currently in this use case the handle isn't set either, the same exception
Expand Down