CsvMetadataServices Class

Creates serialization metadata. The code generated for a CsvSerializerContext calls these methods.

public static class CsvMetadataServices

Methods

NameDescription
CreateObjectInfo<T>(CsvSerializerOptions, CsvObjectInfoValues<T>)Creates the metadata of a type.
CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions, CsvPropertyInfoValues<TDeclaring, TValue>)Creates the metadata of a column.
GetConverter<T>(CsvSerializerOptions)Gets the converter of T: a converter of CsvSerializerOptions.Converters, or a built-in converter.
GetConverter<T>(CsvSerializerOptions, CsvConverter<T>?)Gets the converter of T: a converter of CsvSerializerOptions.Converters, defaultConverter, or a built-in converter.
GetEnumConverter<TEnum>()Gets a converter that reads the names and the numbers of the members of an enumeration, ignoring case, and writes their names.
GetNullableConverter<T>(CsvConverter<T>)Gets a converter of Nullable<T>: an empty value is null, other values are converted by converter.
GetSpanParsableConverter<T>()Gets a converter that parses and formats values with the ISpanParsable<TSelf> and ISpanFormattable implementations of T.

CreateObjectInfo<T>(CsvSerializerOptions, CsvObjectInfoValues<T>)

CsvMetadataServices.cs

Creates the metadata of a type.

public static CsvTypeInfo<T> CreateObjectInfo<T>(CsvSerializerOptions options, CsvObjectInfoValues<T> values)

Type parameters

T
The type described.

Parameters

options CsvSerializerOptions
The options the metadata is created for.
values CsvObjectInfoValues<T>
The description of the type.

Returns

CsvTypeInfo<T> The metadata of the type.

CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions, CsvPropertyInfoValues<TDeclaring, TValue>)

CsvMetadataServices.cs

Creates the metadata of a column.

public static CsvPropertyInfo CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions options, CsvPropertyInfoValues<TDeclaring, TValue> values)

Type parameters

TDeclaring
The type that declares the member.
TValue
The type of the member.

Parameters

options CsvSerializerOptions
The options the metadata is created for.
values CsvPropertyInfoValues<TDeclaring, TValue>
The description of the column.

Returns

CsvPropertyInfo The metadata of the column.

Exceptions

NotSupportedException
No converter converts TValue.

GetConverter overloads

GetConverter<T>(CsvSerializerOptions)

CsvMetadataServices.cs

Gets the converter of T: a converter of CsvSerializerOptions.Converters, or a built-in converter.

public static CsvConverter<T> GetConverter<T>(CsvSerializerOptions options)
Type parameters
T
The type of the values.
Parameters
options CsvSerializerOptions
The options.
Returns

CsvConverter<T> The converter.

Exceptions
NotSupportedException
No converter converts T.

GetConverter<T>(CsvSerializerOptions, CsvConverter<T>?)

CsvMetadataServices.cs

Gets the converter of T: a converter of CsvSerializerOptions.Converters, defaultConverter, or a built-in converter.

public static CsvConverter<T> GetConverter<T>(CsvSerializerOptions options, CsvConverter<T>? defaultConverter)
Type parameters
T
The type of the values.
Parameters
options CsvSerializerOptions
The options.
defaultConverter CsvConverter<T>?
The converter to use when no converter of the options converts T, or null for the built-in converters.
Returns

CsvConverter<T> The converter.

Exceptions
NotSupportedException
No converter converts T.

GetEnumConverter<TEnum>()

CsvMetadataServices.cs

Gets a converter that reads the names and the numbers of the members of an enumeration, ignoring case, and writes their names.

public static CsvConverter<TEnum> GetEnumConverter<TEnum>() where TEnum : struct, Enum

Type parameters

TEnum
The type of the enumeration.

Returns

CsvConverter<TEnum> The converter.

GetNullableConverter<T>(CsvConverter<T>)

CsvMetadataServices.cs

Gets a converter of Nullable<T>: an empty value is null, other values are converted by converter.

public static CsvConverter<T?> GetNullableConverter<T>(CsvConverter<T> converter) where T : struct

Type parameters

T
The underlying type.

Parameters

converter CsvConverter<T>
The converter of T.

Returns

CsvConverter<T?> The converter.

GetSpanParsableConverter<T>()

CsvMetadataServices.cs

Gets a converter that parses and formats values with the ISpanParsable<TSelf> and ISpanFormattable implementations of T.

public static CsvConverter<T> GetSpanParsableConverter<T>() where T : ISpanFormattable, ISpanParsable<T>

Type parameters

T
The type of the values.

Returns

CsvConverter<T> The converter.