[ENH] Support TypeName Overriding in IActivityDescriptorModifier Without Breaking Workflow Builder API
Currently, the IActivityDescriptorModifier interface allows overriding various activity descriptor attributes such as Display Name, Description, Inputs, and Outputs. This is implemented before the activities are registered in the activity registry. However, attempts to override the TypeName attribute can disrupt the functioning of programmatically created workflows using the workflow builder API. This occurs because the instantiation of an activity directly relies on the ActivityAttribute.TypeName or defaults to the activity's .NET type if TypeName is not set.
To address this, we propose enhancing the handling of TypeName overrides. Specifically, we need to implement a mechanism that checks and updates the TypeName of activity instances dynamically. This approach should ensure that any changes to the TypeName through the IActivityDescriptorModifier are accurately reflected.
Expected Outcome:
- Allow dynamic overriding of
TypeNameinIActivityDescriptorModifierwithout breaking the integrity and functionality of workflows constructed using the workflow builder API.
This enhancement will contribute to greater flexibility in modifying and extending activities without risking the stability of programmatically created workflows.
To address the proposed enhancement, it's important to consider the current behavior of Elsa Workflows as described in the provided context. The TypeName attribute of an activity is crucial for the correct serialization and deserialization of workflow definitions, as well as for the materialization of workflow blueprints. As such, any changes to the TypeName must be handled with care to avoid disrupting existing workflows.
The IActivityDescriptorModifier interface allows for modifications to activity descriptors, which are used by the designer to present activities to the user. However, changing the TypeName through this interface could lead to inconsistencies between the descriptors and the actual .NET types used in programmatic workflows.
To implement the proposed enhancement, the following steps could be considered:
-
Introduce a new mechanism that maps the original
TypeNameto the overriddenTypeName. This mapping should be accessible during the workflow definition materialization process. -
Update the
IWorkflowBlueprintMaterializerto use the new mapping mechanism to resolve the correct .NET type for an activity based on itsTypeName. -
Ensure that the workflow builder API can handle dynamically provided activities, including those with overridden
TypeNameattributes. This may involve extending the API to allow specifying aTypeNamewhen adding activities to the workflow programmatically. -
Provide clear documentation and guidelines on how to use the
TypeNameoverride feature to ensure that developers understand the implications and how to update their workflows accordingly. -
Implement thorough testing to ensure that workflows with overridden
TypeNameattributes function correctly and that existing workflows are not adversely affected by these changes.
By following these steps, it should be possible to allow dynamic overriding of TypeName in IActivityDescriptorModifier without breaking the integrity and functionality of workflows constructed using the workflow builder API. This enhancement would indeed contribute to greater flexibility in modifying and extending activities.
This comment was generated by Glime.