Skip to content

Fix issue where IReadOnlyList<T> wasn't a valid binding type.#2174

Merged
jviau merged 4 commits intoAzure:mainfrom
savagemonitor:user/mahay/try_fix_for_issue_2173
Jan 9, 2024
Merged

Fix issue where IReadOnlyList<T> wasn't a valid binding type.#2174
jviau merged 4 commits intoAzure:mainfrom
savagemonitor:user/mahay/try_fix_for_issue_2173

Conversation

@savagemonitor
Copy link
Copy Markdown
Contributor

Issue describing the changes in this PR

resolves #2173

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Additional information

I leveraged Linq to give what I felt was a "cleaner" approach where the IsListInterface can succinctly look at the value of the Type as well as the value of all of the Interfaces of the type to see if it's valid. I think this should cover every situation where the passed in interface type inherits from one of the valid types.

I know this isn't an optimal runtime solution since LINQ can be slower but since we're talking reflection I figured it was a good tradeoff. If there are performance issues with this approach I'd love to learn more.

Matthew J. Hayward added 2 commits December 29, 2023 15:04
…he valid types or if any of the types available on the input type is one of the valid types.
@savagemonitor
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@jviau jviau self-requested a review January 4, 2024 18:09
Copy link
Copy Markdown
Contributor

@jviau jviau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! I agree supporting IReadOnlyList<T> (and IReadOnlyCollection<T>) would be nice. Some comments on how to go about that.

Comment thread extensions/Worker.Extensions.Shared/Reflection/ParameterBinder.cs Outdated
… List type instead of checking the inheritance hierarchy.
Comment thread extensions/Worker.Extensions.Shared/Reflection/ParameterBinder.cs Outdated
@jviau jviau merged commit b481535 into Azure:main Jan 9, 2024
@jviau
Copy link
Copy Markdown
Contributor

jviau commented Jan 9, 2024

Thank you for the contribution!

@savagemonitor savagemonitor deleted the user/mahay/try_fix_for_issue_2173 branch January 13, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CosmosDB Extension throws exception when Input is of type IReadOnlyList.

2 participants