Description
Minor breaking change introduced in .NET 6 Preview 1:
Applying JsonNumberHandlingAttribute on a collection of non-numbers e.g. List was previously (in 5.0) a no-op. Now, InvalidOperationException is thrown as it is not a valid configuration.
public class ClassWith_AttributeOnComplexListProperty
{
// Attribute not allowed here, previously ignored.
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public List<MyClass> MyList { get; set; }
// Attribute allowed here and will be honored.
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public List<int> MyOtherList { get; set; }
}
Version
Other (please put exact version in description textbox)
Previous behavior
Provided in description.
New behavior
Provided in description.
Type of breaking change
Reason for change
It was a side effect of a performance optimization for the number handling feature.
Recommended action
Remove the attribute on incompatible collection properties.
Feature area
Core .NET libraries
Affected APIs
All JsonSerializer (de)serialization methods.
Description
Minor breaking change introduced in .NET 6 Preview 1:
Applying
JsonNumberHandlingAttributeon a collection of non-numbers e.g. List was previously (in 5.0) a no-op. Now,InvalidOperationExceptionis thrown as it is not a valid configuration.Version
Other (please put exact version in description textbox)
Previous behavior
Provided in description.
New behavior
Provided in description.
Type of breaking change
Reason for change
It was a side effect of a performance optimization for the number handling feature.
Recommended action
Remove the attribute on incompatible collection properties.
Feature area
Core .NET libraries
Affected APIs
All
JsonSerializer(de)serialization methods.