Skip to content

Commit 070c63c

Browse files
author
Sophia Tevosyan
committed
Merge branch 'main' into stevosyan/add-tags-to-create-sub-proto
2 parents fb8ab55 + ad96233 commit 070c63c

File tree

19 files changed

+1194
-43
lines changed

19 files changed

+1194
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## v1.17.2
3+
## v1.18.0
44
- Add taskentity support to durabletasksourcegenerator by Copilot ([#517](https://github.com/microsoft/durabletask-dotnet/pull/517))
55
- Bump azure.identity by dependabot[bot] ([#525](https://github.com/microsoft/durabletask-dotnet/pull/525))
66
- Bump google.protobuf by dependabot[bot] ([#529](https://github.com/microsoft/durabletask-dotnet/pull/529))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To get started, add the [Microsoft.Azure.Functions.Worker.Extensions.DurableTask
3535
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.2.2" />
3636
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
3737
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" OutputItemType="Analyzer" />
38-
<PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0-preview.1" OutputItemType="Analyzer" />
38+
<PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0" OutputItemType="Analyzer" />
3939
</ItemGroup>
4040
```
4141

eng/targets/Release.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<PropertyGroup>
20-
<VersionPrefix>1.17.2</VersionPrefix>
20+
<VersionPrefix>1.18.0</VersionPrefix>
2121
<VersionSuffix></VersionSuffix>
2222
</PropertyGroup>
2323

samples/AzureFunctionsApp/AzureFunctionsApp.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
66
<OutputType>Exe</OutputType>
77
<Nullable>enable</Nullable>
8+
<!-- Disable SDK's source generation to allow reflection-based discovery of source-generated functions -->
9+
<FunctionsEnableExecutorSourceGen>false</FunctionsEnableExecutorSourceGen>
10+
<FunctionsEnableWorkerIndexing>false</FunctionsEnableWorkerIndexing>
811
</PropertyGroup>
912

1013
<ItemGroup>
1114
<PackageReference Include="Microsoft.Azure.Functions.Worker" />
1215
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" />
1316
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" />
1417
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" OutputItemType="Analyzer" />
15-
<PackageReference Include="Microsoft.DurableTask.Generators" OutputItemType="Analyzer" />
18+
<!-- Reference the source generator project directly for local development -->
19+
<ProjectReference Include="..\..\src\Generators\Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
1620
</ItemGroup>
1721

1822
<ItemGroup>

samples/AzureFunctionsApp/Entities/Counter.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ namespace AzureFunctionsApp.Entities;
2929
/// Example on how to dispatch to an entity which directly implements TaskEntity<TState>. Using TaskEntity<TState> gives
3030
/// the added benefit of being able to use DI. When using TaskEntity<TState>, state is deserialized to the "State"
3131
/// property. No other properties on this type will be serialized/deserialized.
32+
///
33+
/// Source generators are used to generate the [Function] method with [EntityTrigger] binding automatically.
34+
/// The generated function will be named "Counter" (based on the class name or the DurableTask attribute value).
3235
/// </summary>
36+
[DurableTask(nameof(Counter))]
3337
public class Counter : TaskEntity<int>
3438
{
3539
readonly ILogger logger;
@@ -49,19 +53,21 @@ public int Add(int input)
4953

5054
public void Reset() => this.State = 0;
5155

52-
[Function("Counter")]
53-
public Task DispatchAsync([EntityTrigger] TaskEntityDispatcher dispatcher)
54-
{
55-
// Can dispatch to a TaskEntity<TState> by passing a instance.
56-
return dispatcher.DispatchAsync(this);
57-
}
56+
// Note: The [Function("Counter")] method is now auto-generated by the source generator.
57+
// The generated code will look like:
58+
// [Function(nameof(Counter))]
59+
// public static Task Counter([EntityTrigger] TaskEntityDispatcher dispatcher)
60+
// {
61+
// return dispatcher.DispatchAsync<Counter>();
62+
// }
5863

5964
[Function("Counter_Alt")]
6065
public static Task DispatchStaticAsync([EntityTrigger] TaskEntityDispatcher dispatcher)
6166
{
62-
// Can also dispatch to a TaskEntity<TState> by using a static method.
63-
// However, this is a different entity ID - "counter_alt" and not "counter". Even though it uses the same
64-
// entity implementation, the function attribute has a different name, which determines the entity ID.
67+
// This is kept as a manual example showing how to create an alternative entity function
68+
// with a different name. This creates a separate entity ID "counter_alt" vs "counter".
69+
// Even though it uses the same entity implementation, the function attribute has a different name,
70+
// which determines the entity ID.
6571
return dispatcher.DispatchAsync<Counter>();
6672
}
6773
}

samples/AzureFunctionsApp/Entities/Lifetime.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net;
55
using Microsoft.Azure.Functions.Worker;
66
using Microsoft.Azure.Functions.Worker.Http;
7+
using Microsoft.DurableTask;
78
using Microsoft.DurableTask.Client;
89
using Microsoft.DurableTask.Client.Entities;
910
using Microsoft.DurableTask.Entities;
@@ -16,7 +17,10 @@ namespace AzureFunctionsApp.Entities;
1617
/// is considered deleted when <see cref="TaskEntity{TState}.State"/> is <c>null</c> at the end of an operation. It
1718
/// is also possible to design an entity which remains stateless by always returning <c>null</c> from
1819
/// <see cref="InitializeState"/> and never assigning a non-null state.
20+
///
21+
/// Source generators are used to generate the [Function] method with [EntityTrigger] binding automatically.
1922
/// </summary>
23+
[DurableTask(nameof(Lifetime))]
2024
public class Lifetime : TaskEntity<MyState>
2125
{
2226
readonly ILogger logger;
@@ -34,14 +38,13 @@ public Lifetime(ILogger<Lifetime> logger)
3438
/// </summary>
3539
protected override bool AllowStateDispatch => base.AllowStateDispatch;
3640

37-
// NOTE: when using TaskEntity<TState>, you cannot use "RunAsync" as the entity trigger name as this conflicts
38-
// with the base class method 'RunAsync'.
39-
[Function(nameof(Lifetime))]
40-
public Task DispatchAsync([EntityTrigger] TaskEntityDispatcher dispatcher)
41-
{
42-
this.logger.LogInformation("Dispatching entity");
43-
return dispatcher.DispatchAsync(this);
44-
}
41+
// Note: The [Function(nameof(Lifetime))] method is now auto-generated by the source generator.
42+
// The generated code will look like:
43+
// [Function(nameof(Lifetime))]
44+
// public static Task Lifetime([EntityTrigger] TaskEntityDispatcher dispatcher)
45+
// {
46+
// return dispatcher.DispatchAsync<Lifetime>();
47+
// }
4548

4649
public MyState Get() => this.State;
4750

samples/AzureFunctionsApp/Entities/User.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public record UserUpdate(string? Name, int? Age);
1818

1919
/// <summary>
2020
/// This sample demonstrates how to bind to <see cref="TaskEntityContext"/> as well as dispatch to orchestrations.
21+
///
22+
/// Source generators are used to generate the [Function] method with [EntityTrigger] binding automatically.
23+
/// The generated function will be named "User" (based on the class name or the DurableTask attribute value).
2124
/// </summary>
25+
[DurableTask(nameof(User))]
2226
public class UserEntity : TaskEntity<User>
2327
{
2428
readonly ILogger logger;
@@ -68,12 +72,13 @@ public void Greet(TaskEntityContext context, string? message = null)
6872
// this.Context.ScheduleNewOrchestration(nameof(Greeting.GreetingOrchestration), input);
6973
}
7074

71-
[Function(nameof(User))]
72-
public Task DispatchAsync([EntityTrigger] TaskEntityDispatcher dispatcher)
73-
{
74-
// Can dispatch to a TaskEntity<TState> by passing a instance.
75-
return dispatcher.DispatchAsync(this);
76-
}
75+
// Note: The [Function(nameof(User))] method is now auto-generated by the source generator.
76+
// The generated code will look like:
77+
// [Function(nameof(User))]
78+
// public static Task User([EntityTrigger] TaskEntityDispatcher dispatcher)
79+
// {
80+
// return dispatcher.DispatchAsync<UserEntity>();
81+
// }
7782

7883
protected override User InitializeState(TaskEntityOperation entityOperation)
7984
{

0 commit comments

Comments
 (0)