Table of Contents

Class CsvConfiguration

Namespace
CsvHelper.Configuration
Assembly
CsvHelper.dll

Configuration used for reading and writing CSV data.

public record CsvConfiguration : IReaderConfiguration, IParserConfiguration, IWriterConfiguration, IEquatable<CsvConfiguration>
Inheritance
CsvConfiguration
Implements
Inherited Members

Constructors

CsvConfiguration(CsvConfiguration)

protected CsvConfiguration(CsvConfiguration original)

Parameters

original CsvConfiguration

CsvConfiguration(CultureInfo)

Initializes a new instance of the CsvConfiguration class using the given CultureInfo. Since Delimiter uses CultureInfo for its default, the given CultureInfo will be used instead.

public CsvConfiguration(CultureInfo cultureInfo)

Parameters

cultureInfo CultureInfo

The culture information.

CsvConfiguration(CultureInfo, Type)

Initializes a new instance of the CsvConfiguration class using the given CultureInfo. Since Delimiter uses CultureInfo for its default, the given CultureInfo will be used instead.

[Obsolete("This constructor is deprecated and will be removed in the next major release. Use CsvConfiguration(CultureInfo) instead.", false)]
public CsvConfiguration(CultureInfo cultureInfo, Type attributesType)

Parameters

cultureInfo CultureInfo

The culture information.

attributesType Type

The type that contains the configuration attributes. This will call ApplyAttributes(Type) automatically.

Properties

AllowComments

public virtual bool AllowComments { get; set; }

Property Value

bool

BadDataFound

public virtual BadDataFound? BadDataFound { get; set; }

Property Value

BadDataFound

BufferSize

public virtual int BufferSize { get; set; }

Property Value

int

CacheFields

public virtual bool CacheFields { get; set; }

Property Value

bool

Comment

public virtual char Comment { get; set; }

Property Value

char

CountBytes

public virtual bool CountBytes { get; set; }

Property Value

bool

CultureInfo

public virtual CultureInfo CultureInfo { get; protected set; }

Property Value

CultureInfo

Delimiter

public virtual string Delimiter { get; set; }

Property Value

string

DetectColumnCountChanges

public virtual bool DetectColumnCountChanges { get; set; }

Property Value

bool

DetectDelimiter

public virtual bool DetectDelimiter { get; set; }

Property Value

bool

DetectDelimiterValues

public virtual string[] DetectDelimiterValues { get; set; }

Property Value

string[]

DynamicPropertySort

public virtual IComparer<string>? DynamicPropertySort { get; set; }

Property Value

IComparer<string>

Encoding

public virtual Encoding Encoding { get; set; }

Property Value

Encoding

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

Escape

public virtual char Escape { get; set; }

Property Value

char

ExceptionMessagesContainRawData

public virtual bool ExceptionMessagesContainRawData { get; set; }

Property Value

bool

GetConstructor

public virtual GetConstructor GetConstructor { get; set; }

Property Value

GetConstructor

GetDelimiter

public virtual GetDelimiter GetDelimiter { get; set; }

Property Value

GetDelimiter

GetDynamicPropertyName

public virtual GetDynamicPropertyName GetDynamicPropertyName { get; set; }

Property Value

GetDynamicPropertyName

HasHeaderRecord

public virtual bool HasHeaderRecord { get; set; }

Property Value

bool

HeaderValidated

public virtual HeaderValidated? HeaderValidated { get; set; }

Property Value

HeaderValidated

IgnoreBlankLines

public virtual bool IgnoreBlankLines { get; set; }

Property Value

bool

IgnoreReferences

public virtual bool IgnoreReferences { get; set; }

Property Value

bool

IncludePrivateMembers

public virtual bool IncludePrivateMembers { get; set; }

Property Value

bool

InjectionCharacters

public virtual char[] InjectionCharacters { get; set; }

Property Value

char[]

InjectionEscapeCharacter

public virtual char InjectionEscapeCharacter { get; set; }

Property Value

char

InjectionOptions

public virtual InjectionOptions InjectionOptions { get; set; }

Property Value

InjectionOptions

IsNewLineSet

public bool IsNewLineSet { get; }

Property Value

bool

LineBreakInQuotedFieldIsBadData

public virtual bool LineBreakInQuotedFieldIsBadData { get; set; }

Property Value

bool

MaxFieldSize

public double MaxFieldSize { get; set; }

Property Value

double

MemberTypes

public virtual MemberTypes MemberTypes { get; set; }

Property Value

MemberTypes

MissingFieldFound

public virtual MissingFieldFound? MissingFieldFound { get; set; }

Property Value

MissingFieldFound

Mode

public virtual CsvMode Mode { get; set; }

Property Value

CsvMode

NewLine

public virtual string NewLine { get; set; }

Property Value

string

PrepareHeaderForMatch

public virtual PrepareHeaderForMatch PrepareHeaderForMatch { get; set; }

Property Value

PrepareHeaderForMatch

ProcessFieldBufferSize

public virtual int ProcessFieldBufferSize { get; set; }

Property Value

int

Quote

public virtual char Quote { get; set; }

Property Value

char

ReadingExceptionOccurred

public virtual ReadingExceptionOccurred? ReadingExceptionOccurred { get; set; }

Property Value

ReadingExceptionOccurred

ReferenceHeaderPrefix

public virtual ReferenceHeaderPrefix? ReferenceHeaderPrefix { get; set; }

Property Value

ReferenceHeaderPrefix

ShouldQuote

public ShouldQuote ShouldQuote { get; set; }

Property Value

ShouldQuote

ShouldSkipRecord

public virtual ShouldSkipRecord? ShouldSkipRecord { get; set; }

Property Value

ShouldSkipRecord

ShouldUseConstructorParameters

public virtual ShouldUseConstructorParameters ShouldUseConstructorParameters { get; set; }

Property Value

ShouldUseConstructorParameters

TrimOptions

public virtual TrimOptions TrimOptions { get; set; }

Property Value

TrimOptions

UseNewObjectForNullReferenceMembers

public virtual bool UseNewObjectForNullReferenceMembers { get; set; }

Property Value

bool

WhiteSpaceChars

public virtual char[] WhiteSpaceChars { get; set; }

Property Value

char[]

Methods

ApplyAttributes(Type)

Applies class level attribute to configuration.

public CsvConfiguration ApplyAttributes(Type type)

Parameters

type Type

Type with attributes.

Returns

CsvConfiguration

ApplyAttributes<T>()

Applies class level attribute to configuration.

public CsvConfiguration ApplyAttributes<T>()

Returns

CsvConfiguration

Type Parameters

T

Type with attributes.

Equals(CsvConfiguration?)

public virtual bool Equals(CsvConfiguration? other)

Parameters

other CsvConfiguration

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromAttributes(Type)

Creates a CsvConfiguration instance configured using CsvHelper attributes applied to type at the type-level. This method requires type to be annotated with CultureInfoAttribute (or to sub-class a type which is).

public static CsvConfiguration FromAttributes(Type type)

Parameters

type Type

Returns

CsvConfiguration

A new CsvConfiguration instance configured with attributes applied to type.

Remarks

CsvHelper attributes applied to members and parameters do not influence the return value of this method. Such attributes do not define values which are used in CsvConfiguration and instead influence the maps which are built and used during reading and writing. See MemberMap and ParameterMap.

Exceptions

ConfigurationException

If type is not annotated with CultureInfoAttribute.

ArgumentNullException

If the argument to the CultureInfoAttribute is null.

CultureNotFoundException

If the argument to the CultureInfoAttribute does not specify a supported culture.

FromAttributes(Type, CultureInfo)

Creates a CsvConfiguration instance configured using cultureInfo and CsvHelper attributes applied to type at the type-level. This method ignores any CultureInfoAttribute applied to type.

public static CsvConfiguration FromAttributes(Type type, CultureInfo cultureInfo)

Parameters

type Type

cultureInfo CultureInfo

Returns

CsvConfiguration

A new CsvConfiguration instance configured with cultureInfo and attributes applied to type

Remarks

FromAttributes<T>()

Creates a CsvConfiguration instance configured using CsvHelper attributes applied to T at the type-level. This method requires T to be annotated with CultureInfoAttribute (or to sub-class a type which is).

public static CsvConfiguration FromAttributes<T>()

Returns

CsvConfiguration

A new CsvConfiguration instance configured with attributes applied to T.

Type Parameters

T

The type whose attributes should be used to configure the CsvConfiguration instance. This is normally the type you are intending to map for reading and writing.

Remarks

CsvHelper attributes applied to members and parameters do not influence the return value of this method. Such attributes do not define values which are used in CsvConfiguration and instead influence the maps which are built and used during reading and writing. See MemberMap and ParameterMap.

Exceptions

ConfigurationException

If T is not annotated with CultureInfoAttribute.

ArgumentNullException

If the argument to the CultureInfoAttribute is null.

CultureNotFoundException

If the argument to the CultureInfoAttribute does not specify a supported culture.

FromAttributes<T>(CultureInfo)

Creates a CsvConfiguration instance configured using cultureInfo and CsvHelper attributes applied to T at the type-level. This method ignores any CultureInfoAttribute applied to T.

public static CsvConfiguration FromAttributes<T>(CultureInfo cultureInfo)

Parameters

cultureInfo CultureInfo

The CultureInfo to configure the returned CsvConfiguration with.

Returns

CsvConfiguration

A new CsvConfiguration instance configured with cultureInfo and attributes applied to T.

Type Parameters

T

Remarks

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Validate()

Validates the configuration.

public void Validate()

<Clone>$()

public virtual CsvConfiguration <Clone>$()

Returns

CsvConfiguration

Operators

operator ==(CsvConfiguration?, CsvConfiguration?)

public static bool operator ==(CsvConfiguration? left, CsvConfiguration? right)

Parameters

left CsvConfiguration
right CsvConfiguration

Returns

bool

operator !=(CsvConfiguration?, CsvConfiguration?)

public static bool operator !=(CsvConfiguration? left, CsvConfiguration? right)

Parameters

left CsvConfiguration
right CsvConfiguration

Returns

bool