CsvOptionsAttribute()
public CsvOptionsAttribute()Initializes a new instance of CsvOptionsAttribute.
Attribute in CsvHelper
Keeps the dialect of a CsvRecordAttribute type's files next to the type: the settings that CsvReaderOptions.For and CsvWriterOptions.For put in the options they return, such as [CsvOptions(Separator = ';', HasHeader = false)].
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
public sealed class CsvOptionsAttribute : AttributeCsvHelperCsvHelper.dllOnly the properties that are set change the options; the others keep the defaults. The source generator turns the attribute into code, so no reflection is involved. A CsvMode.FixedWidth mode also sets the options' field widths to the type's layout (CsvRecordMapper.GetFieldWidths). The options are checked when a reader or writer is created with them.
public CsvOptionsAttribute()Initializes a new instance of CsvOptionsAttribute.
public char CommentPrefix { get; set; }The character that starts comment lines (CsvReaderOptions.CommentPrefix, CsvWriterOptions.CommentPrefix).
public string? Culture { get; set; }The name of the culture that numbers and dates are read and written with, such as "de-DE" (CsvReaderOptions.FormatProvider, CsvWriterOptions.FormatProvider); "" is the invariant culture. It is looked up when the options are created.
public char Escape { get; set; }The escape character of CsvMode.Escape mode (CsvReaderOptions.Escape, CsvWriterOptions.Escape).
public string[]? FalseValues { get; set; }The values that read as false (CsvReaderOptions.FalseValues); the writer writes the first (CsvWriterOptions.FalseValue).
public bool HasHeader { get; set; }Whether the files have a header (CsvReaderOptions.HasHeader, CsvWriterOptions.HasHeader).
public CsvMode Mode { get; set; }How fields are delimited and escaped (CsvReaderOptions.Mode, CsvWriterOptions.Mode).
public string? NewLine { get; set; }The line ending written after each record (CsvWriterOptions.NewLine).
public string[]? NullValues { get; set; }The field values that mean null (CsvReaderOptions.NullValues); the record writer writes the first (CsvWriterOptions.NullValue).
public char Separator { get; set; }The field separator (CsvReaderOptions.Separator, CsvWriterOptions.Separator).
public bool TrimWhitespace { get; set; }Whether spaces and tabs around values are removed when reading (CsvReaderOptions.TrimWhitespace).
public string[]? TrueValues { get; set; }The values that read as true (CsvReaderOptions.TrueValues); the writer writes the first (CsvWriterOptions.TrueValue).