Skip to content
Merged
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
19 changes: 18 additions & 1 deletion src/Temporalio/Activities/ActivityDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,30 @@ public static ActivityDefinition Create(MethodInfo method, Func<object?[], objec
{
var attr = method.GetCustomAttribute<ActivityAttribute>(false) ??
throw new ArgumentException($"{method} missing Activity attribute");
return CreateWithoutAttribute(
NameFromAttributed(method, attr), method, invoker);
}

/// <summary>
/// Create an activity definition with a name, a method, and a custom invoker. This does not
/// require/check the activity attribute. This is a helper for
/// <see cref="Create(string?, Type, IReadOnlyCollection{Type}, int, Func{object?[], object?}, MethodInfo?)"/>
/// that collects parameters and handles parameter defaults.
/// </summary>
/// <param name="name">Name to use for the activity or null for dynamic.</param>
/// <param name="method">Activity method.</param>
/// <param name="invoker">Invoker.</param>
/// <returns>Definition for the activity.</returns>
public static ActivityDefinition CreateWithoutAttribute(
string? name, MethodInfo method, Func<object?[], object?> invoker)
{
if (method.ContainsGenericParameters)
{
throw new ArgumentException($"{method} contains generic parameters");
}
var parms = method.GetParameters();
return Create(
NameFromAttributed(method, attr),
name,
method.ReturnType,
parms.Select(p => p.ParameterType).ToArray(),
parms.Count(p => !p.HasDefaultValue),
Expand Down
Loading