Table of Contents

Class JsonAttributes

Namespace
TypedRest.CodeGeneration.CSharp
Assembly
TypedRest.CodeGeneration.CSharp.dll

Supplies the attributes that carry wire names on generated DTOs, for one specific JSON serializer.

public abstract class JsonAttributes
Inheritance
object
JsonAttributes
Derived

Remarks

TypedRest for .NET serializes with Newtonsoft.Json out of the box; System.Text.Json is available through the TypedRest.SystemTextJson package. The two read entirely different attributes, so a DTO annotated for one silently falls back to its C# member names under the other.

Fields

Newtonsoft

Newtonsoft.Json, used by the TypedRest package by default.

public const string Newtonsoft = "newtonsoft"

Field Value

string

SystemTextJson

System.Text.Json, used through the TypedRest.SystemTextJson package.

public const string SystemTextJson = "system-text-json"

Field Value

string

Properties

Names

The serializer names For(string?) accepts, most preferred first.

public static IReadOnlyCollection<string> Names { get; }

Property Value

IReadOnlyCollection<string>

Serializer

The name of the serializer these attributes are for.

public abstract string Serializer { get; }

Property Value

string

Methods

EnumMemberName(string)

Carries the wire name of an enum value whose C# name differs from it.

public abstract CSharpAttribute EnumMemberName(string name)

Parameters

name string

Returns

CSharpAttribute

For(string?)

Returns the attributes for name, or the default serializer if it is null.

public static JsonAttributes For(string? name)

Parameters

name string

Returns

JsonAttributes

Exceptions

ArgumentException

name is not one of Names.

PropertyName(string)

Carries the wire name of a property whose C# name differs from it.

public abstract CSharpAttribute PropertyName(string name)

Parameters

name string

Returns

CSharpAttribute