Azure / Azure/azure-functions-dotnet-worker
Inheriting FunctionAttribute not supported?
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
I'm trying to inherit the `FunctionAttribute` but it's not working like I expect it would..
Is this something that isn't supported or am I missing something?
This is my attribute:
```csharp
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public class WorkflowAttribute(string name) : FunctionAttribute(name)
{
private Type[] _triggers = [];
public Type[] Triggers
{
get => _triggers;
set
{
if (value.Any(t => !typeof(IWorkflowTrigger).IsAssignableFrom(t)))
{
throw new ArgumentException("All types must implement IWorkflowTrigger interface");
}
_triggers = value;
}
}
public string? Description { get; set; }
}
```
Implementation should just be as simple as replacing the `Function` attribute:
```csharp
[Workflow(nameof(StartSalesOrderWorkflowsAsync), Triggers = [typeof(SalesOrderCompletedMessage)])]
public static async Task StartSalesOrderWorkflowsAsync(
[OrchestrationTrigger] TaskOrchestrationContext context, ...
```
It doesn't matter where the custom attribute resides, same assembly or not.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how FunctionAttribute and OrchestrationTrigger are discovered for the provided WorkflowAttribute example. Compare behavior when the custom attribute is in the same assembly and a different assembly. Done means the issue clearly documents whether inheriting FunctionAttribute is supported and, if supported, the replacement attribute works as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100