Fix bug in XamlTypeInvoker.GetAddMethod if there is no such match#211
Merged
Conversation
stevenbrix
reviewed
Jan 4, 2019
stevenbrix
reviewed
Jan 4, 2019
stevenbrix
reviewed
Jan 4, 2019
stevenbrix
reviewed
Jan 4, 2019
Contributor
|
Thanks for this PR @hughbe! I also really appreciate you breaking up the commits the way you did so that we can see the bug fix vs. general code cleanup. I'm sorry that we've just left this sitting here, but there are few reasons why we are a bit hesitant on accepting these sorts of changes:
|
dipeshmsft
approved these changes
Apr 27, 2023
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
I might need to rebase this PR |
Member
|
@hughbe, let's wait for the CI build to finish. |
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fix 1: Use
Dictionary.TryAddinstead ofAddto prevent duplicatesExample code:
Use
Dictionary.TryAddto avoid throwing if there is more than one value. I opted to change this toTryAddrather than removingaddMethods.Add(_xamlType.ItemType, _xamlType.AddMethod);, as firstly a user can overrideLookupContentWrappersso removing this value could be breaking, and secondly becauseContentWrapperscould contain duplicate types which could throw anyway previouslyExpected: we return null
Actual: we throw an ArgumentException for duplicate value in a dictionary
Fixes #210
Fix 2: Bail out of
GetEnumeratorMethodif the type invoker is unknownExpected: returns null, matching behaviour with GetAddMethod()
Actual: throws NullReferenceException
Fixes #216