Motivation
There's a substantial amount of duplication in the following code:
class MyPoco
{
[JsonIgnore(JsonIgnoreCondition.WhenWritingNull)]
public string? PropA { get; set; }
[JsonIgnore(JsonIgnoreCondition.WhenWritingNull)]
public string? PropB { get; set; }
[JsonIgnore(JsonIgnoreCondition.WhenWritingNull)]
public string? PropC { get; set; }
}
that could be eliminated using a type-level declaration:
[JsonIgnore(JsonIgnoreCondition.WhenWritingNull)]
class MyPoco
{
public string? PropA { get; set; }
public string? PropB { get; set; }
public string? PropC { get; set; }
}
API Proposal
namespace System.Text.Json.Serialization;
-[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public partial class JsonIgnoreAttribute;
cc @stephentoub
Motivation
There's a substantial amount of duplication in the following code:
that could be eliminated using a type-level declaration:
API Proposal
cc @stephentoub