-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Guard against invalid TypeToConvert args to read methods of object and collection converter #36605
Comments
Moving this to 6.0 since this is not a regression and will not be experienced if a compatible |
Hi, @layomia So, in this should we throw an exception like stating that type mismatched or just return |
@MCCshreyas I believe an |
OK @layomia, thanks for clarification! I will get that implemented! |
Moving to Future, as we won't have time to work on this in the .NET 7 timeframe. |
Added guard to throw InvalidOperrationException if the argument typeToConvert and Converter are incompatible. The exception message is "Type 'NameOfType' is not compatible with converter 'ConverterName'." and "Type 'NameOfType' is not compatible with converter 'ConverterName'. NOTES: The test threw a NotSupportedException on the following line and could not reproduce this issue, so the JsonSerializerOptions instantiation was changed. OptionsTests.ConverterRead_VerifyInvalidTypeToConvertFails() lineno 1432 KeyValuePair<int, int> kvp = converter.Read(ref reader, typeToConvert, options); Fix dotnet#36605
Depending on the scenario, we could fail with a NRE:
Validation should take place in this method:runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonResumableConverterOfT.cs
Line 17 in ce1123f
The ReadStackInitialize
method called downstream may also need some validation logic.EDIT: the validation may need to take place in the individual object/collection converters.
The text was updated successfully, but these errors were encountered: