You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An abstract property that has defined JsonPropertyName attribute is not inherited in a child class.
Reproduction Steps
public abstract class AbstractClass
{
[JsonPropertyName("propertyname")]
public abstract string PropertyName { get; }
}
public class Sample : AbstractClass
{
public override string PropertyName => "PropertyValue";
}
internal class Program
{
static void Main(string[] args)
{
var sample = new Sample();
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(sample));
}
}
In my opinion, the possible workaround produce unwanted that should be cover by .NET library and this should be fixed in the library itself and not by the workaround.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.
Issue Details
Description
An abstract property that has defined JsonPropertyName attribute is not inherited in a child class.
Reproduction Steps
public abstract class AbstractClass
{
[JsonPropertyName("propertyname")]
public abstract string PropertyName { get; }
}
public class Sample : AbstractClass
{
public override string PropertyName => "PropertyValue";
}
internal class Program
{
static void Main(string[] args)
{
var sample = new Sample();
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(sample));
}
}
In my opinion, the possible workaround produce unwanted that should be cover by .NET library and this should be fixed in the library itself and not by the workaround.
Description
An abstract property that has defined JsonPropertyName attribute is not inherited in a child class.
Reproduction Steps
Expected behavior
{"propertyname":"PropertyValue"}
Actual behavior
{"PropertyName":"PropertyValue","propertyname":"PropertyValue"}
Regression?
No response
Known Workarounds
Define JsonPropertyName on the derived class.
Configuration
Windows: 19045.3930
.NET: 8.0.2
Console application
System.Text.Json: 8.0.2
Other information
In my opinion, the possible workaround produce unwanted that should be cover by .NET library and this should be fixed in the library itself and not by the workaround.
The text was updated successfully, but these errors were encountered: