-
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
When an interface inherits an interface, System.Text.Json.JsonSerializer.Serialize only encodes the properties of the current interface into the json #48768
Comments
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsThis issue has been moved from a ticket on Developer Community. The interface inherits the interface, and there should be content in the interface at the next level. Now System.Text.Json.JsonSerializer.Serialize encodes a string that contains only data for this level of interface, not the data for the interface's parent interface. Original CommentsFeedback Bot on 2/23/2021, 00:07 AM:We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps. Original Solutions(no solutions)
|
Should be by design - System.Text.Json uses variable/member type instead of object type, unless the variable type is |
In this example I would expect serialising as using System;
using System.Text.Json;
var fooBar = new FooBar{A="Foo", B="Bar"};
Console.WriteLine(JsonSerializer.Serialize(fooBar, typeof(FooBar)));
Console.WriteLine(JsonSerializer.Serialize(fooBar, typeof(IFooBar)));
Console.WriteLine(JsonSerializer.Serialize(fooBar, typeof(Foo)));
Console.WriteLine(JsonSerializer.Serialize(fooBar, typeof(IFoo)));
interface IFoo
{
string A {get;set;}
}
interface IFooBar: IFoo
{
string B {get;set;}
}
class Foo: IFoo {
public string A {get;set;}
}
class FooBar: Foo, IFooBar
{
public string B {get;set;}
}
|
Yes,this I would expect |
Well, in this case your expectation is reasonable. I don't know about the design here. |
Duplicate of #41749. |
This issue has been moved from a ticket on Developer Community.
The interface inherits the interface, and there should be content in the interface at the next level. Now System.Text.Json.JsonSerializer.Serialize encodes a string that contains only data for this level of interface, not the data for the interface's parent interface.
So I'm inglying back and hoping to get help.
Original Comments
Feedback Bot on 2/23/2021, 00:07 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: