-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Closed
Copy link
Labels
🏁 Release: .NET 6Issues and PRs for the .NET 6 releaseIssues and PRs for the .NET 6 releasebinary incompatibleExisting binaries may encounter a breaking change in behavior.Existing binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changeIndicates a .NET Core breaking change
Description
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
- Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
- Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
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.
Metadata
Metadata
Assignees
Labels
🏁 Release: .NET 6Issues and PRs for the .NET 6 releaseIssues and PRs for the .NET 6 releasebinary incompatibleExisting binaries may encounter a breaking change in behavior.Existing binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changeIndicates a .NET Core breaking change