-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JsonTypeInfoResolver
doesn't populate inherited properties in interface hierarchy
#77276
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionUsing the Reproduction Stepsusing System.Text.Json;
using System.Text.Json.Serialization.Metadata;
GetPropertiesFromType(typeof(IBaseInterface));
GetPropertiesFromType(typeof(ISubInterface1));
GetPropertiesFromType(typeof(ISubInterface2));
GetPropertiesFromType(typeof(IMultiSubInterface));
static void GetPropertiesFromType(Type type)
{
var typeInfoResolver = new DefaultJsonTypeInfoResolver();
var jsonType = typeInfoResolver.GetTypeInfo(type, JsonSerializerOptions.Default);
if (jsonType.Kind == JsonTypeInfoKind.Object)
{
Console.WriteLine(string.Join(", ", jsonType.Properties.Select(property => property.Name)));
}
}
interface IBaseInterface
{
string BaseProperty { get; set; }
}
interface ISubInterface1 : IBaseInterface
{
int Property1 { get; set; }
}
interface ISubInterface2 : IBaseInterface
{
int Property2 { get; set; }
}
interface IMultiSubInterface : ISubInterface1, ISubInterface2
{
int Property3 { get; set; }
} Expected behavior
Actual behavior
Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
Duplicate of #41749. We were hoping to address this in .NET 7 but ran into design questions regarding handling of diamond ambiguities that arise in interface hierarchies. |
Description
Using the
DefaultJsonTypeInfoResolver
API to identify the properties for an interface in a type hierarchy does not populate inherited properties inJsonTypeInfo.Properties
.Reproduction Steps
Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: