Open sfmskywalker opened 3 weeks ago
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 TypeName
to the overridden TypeName
. This mapping should be accessible during the workflow definition materialization process.
Update the IWorkflowBlueprintMaterializer
to use the new mapping mechanism to resolve the correct .NET type for an activity based on its TypeName
.
Ensure that the workflow builder API can handle dynamically provided activities, including those with overridden TypeName
attributes. This may involve extending the API to allow specifying a TypeName
when adding activities to the workflow programmatically.
Provide clear documentation and guidelines on how to use the TypeName
override feature to ensure that developers understand the implications and how to update their workflows accordingly.
Implement thorough testing to ensure that workflows with overridden TypeName
attributes 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.
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 theTypeName
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 theActivityAttribute.TypeName
or defaults to the activity's .NET type ifTypeName
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 theTypeName
of activity instances dynamically. This approach should ensure that any changes to theTypeName
through theIActivityDescriptorModifier
are accurately reflected.Expected Outcome:
TypeName
inIActivityDescriptorModifier
without 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.