dapr / dapr/dotnet-sdk

Improve type safety on Workflows and Activities

Open
#1,399 1 comment 1 reaction 0 assignees View on GitHub
area/workflow kind/enhancement
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
2d 1h
Merged PRs (30d)
6

Description

## Describe the feature

I'd like to explore an improvement to the .NET SDK that makes it easier to build out workflows and their activities in a way that ensures that the inputs and outputs align with expectations.

I can see two ways of going about this:
1) In the SDK, add an overload that supports generic typing. If developers wish to invoke workflows or activities created in a different language, they're welcome to do so using the method already provided, but this overload would provide the developer some piece of mind that if a refactoring changes the expected input or output type of a workflow or activity, that the issue will be caught at development/compile time instead of runtime when the object fails to map properly.

2) Offer a source generator that introduces a static method for each workflow and activity that's appropriately typed. For example, rather than having `context.CallActivityAsync(nameof(MyActivity), "test value");` a static extension method would be introduced that provides `static Task CallMyActivityAsync(string value, DaprActivityOptions? options = null);`

## Release Note
RELEASE NOTE: **ADD** Stronger type safety validation in workflows and workflow activities

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.