Relax type check in OrchestrationInputConverter
#3061
+76
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OrchestrationInputConverter
responsible for processing orchestration inputs in isolated model has a strict type check that verifies that deserialized value's type equals exactly to the target type in the function prototype. While it is correct for the majority of cases, it is not so when the target type is a collection interface. Standard behavior of, e.g.,System.Text.Json
serializer to produce aList<T>
when target deserialization type is, e.g.,IEnumerable<T>
. Now,List<T>
implementsIEnumerable<T>
and this can safely be passed to the orchestration, however sincetypeof(List<T>) != typeof(IEnumerable<T>)
, the check fails and orchestration receives anull
input.This PR addresses this issue by slightly relaxing the type check, reporting a successful conversion of actual deserialized value can be assigned to target type due to inheritance or interface implementation. This unblocks collection interfaces and custom json serializers that might return a more concrete type than target deserialization type (i.e. custom polymorphic deserialization).
Issue describing the changes in this PR
resolves #3035
Pull request checklist
pending_docs.md
release_notes.md
/src/Worker.Extensions.DurableTask/AssemblyInfo.cs
dev
andmain
branches and will not be merged into thev2.x
branch.