Skip to content

[Feature Request] .NET Analyzer for Checking Workflows #576

@cretz

Description

@cretz

Describe the solution you'd like

Like we built for Go and built for Java, there is a desire for a "workflow check" analyzer for .NET.

Initial notes/thoughts:

  • Should be a diagnostic/Roslyn analyzer called "workflow check" to match Go and Java equivalents
  • Should transitively check known-yet-configurable invalid actions occurring in a workflow
    • Transitive is the key/hard part
      • This requires coloring methods as "Temporal invalid" or not, and any method that invokes an invalid method is itself invalid, so this is basically call graph building
      • For Go, diagnostic checks support "facts" which are effectively serializable metadata that can be attached to typed AST, so that was used to mark a method as invalid (including transitively)
      • For Java, no such thing exists, so we had to completely write an analyzer from scratch
      • Like Java, .NET analyzer can ideally work from workflow method out and not have to eagerly color all methods
      • The error needs to show the call graph stack since many times the issue is several calls deep from the workflow itself
    • Understood that this will miss some things, e.g. reflection
    • See https://github.com/temporalio/sdk-dotnet#workflow-logic-constraints and https://github.com/temporalio/sdk-dotnet?tab=readme-ov-file#net-task-determinism for what constitutes an invalid action
  • Ideally, should disable or invert certain existing analyzer/diagnostic warnings that are not applicable to workflows
  • If analyzer is cheap enough performance-wise to enable by default when using the Temporalio NuGet package, should do so
  • Ideally, if the rules are not too granular, we can create entries at https://github.com/temporalio/rules for each one (so we should prefix with TMPRL)
    • Even if they are fairly granular, it is something we may want
  • https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-roslyn-analyzer already exists for those curious

Admittedly research has not been done to confirm that all of these features are possible with .NET code analyzers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions