-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue when adding a new complex value to a generic dictionary #29
Conversation
…ctionary with a given value type
One thing that I would like to change but that could be breaking is to not find the public Type PropertyType => typeof(TValue);
{
get
{
_dictionary.TryGetValue(_propertyName, out var val);
if (val == null)
{
return typeof(TValue);
}
return val.GetType();
}
} This should instead be |
Hi, Thanks for the PR.
That type is not considered public, so it should be safe to change as long as it works as expected |
SystemTextJsonPatch/Internal/Proxies/DictionaryTypedPropertyProxy.cs
Outdated
Show resolved
Hide resolved
The compatibility problem if we chose to have Old behavior: The result, we try and convert to New behavor: The problem with the old behavior is if we want to replace the entry to some other type, e.g. |
I have included the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the contribution!
This is now available in Nuget v3.2.0 |
This pr fixes an issue that it shown by the added test where it is not possible to add a complex object to a typed dictionary.
The fix prefers to use the
IDictionary<TKey, TValue>
proxy over theIDictionary
proxy as e.g.Dictionary<TKey, TValue>
implements both.