Skip to content
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

Deserializing Dictionary<int, AnyThing> fails #7

Open
NeilNewmanAlways opened this issue Jun 29, 2022 · 0 comments
Open

Deserializing Dictionary<int, AnyThing> fails #7

NeilNewmanAlways opened this issue Jun 29, 2022 · 0 comments

Comments

@NeilNewmanAlways
Copy link

Hi,
In VS2022 I have opened the main code project and got the tests running. All looked good until I tried Dictionary<int, SortedList>

this deserialized the integer keys, but all reference values were null.

A Dictionary where the key is string seems to work fine, but most other type fail due to the generic comparers not implementing IConvertible

for my production code GenericEqualityComparer<T> is the type in the XML which does not match the expected type IEqualityComparer so in System.Private.CoreLib\src\System\Convert.cs an InvalidCastException is raised, not sure why no exception in the package test code, but it results in the same thing...

            if (!(value is IConvertible ic))
            {
                if (value.GetType() == conversionType)
                {
                    return value;
                }
                throw new InvalidCastException(SR.InvalidCast_IConvertible);
            }

The code look wrong, in the sense that GenericEqualityComparer<T> implements the expected type IEqualityComparer, so should probably just cast it and everything would be fine.

If you know of a good work around, that would be great.

This is probably an issue with .NET code, so maybe listing the limitation is all you can do

Cheers Neil

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

No branches or pull requests

1 participant