Closed
Description
Description
Happens for source generator based serialization as well (tested only with .NET 8).
Reproduction Steps
using System.Text.Json;
using System.Text.Json.Serialization;
JsonSerializer.Serialize(Console.OpenStandardOutput(), new B());
abstract class A
{
[JsonPropertyName("x")]
public abstract int I { get; }
}
class B : A
{
public override int I => 10;
}
Expected behavior
{"x":10}
Actual behavior
{"I":10,"x":10}
Regression?
No response
Known Workarounds
Using the JsonPropertyNameAttribute
on the overriding member.
Configuration
.NET 8 and 9
Other information
No response