Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add max buffer sizes and if should process bad field flag #2188

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/CsvHelper/Configuration/CsvConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public record CsvConfiguration : IReaderConfiguration, IWriterConfiguration
/// <inheritdoc/>
public virtual BadDataFound BadDataFound { get; set; } = ConfigurationFunctions.BadDataFound;

public virtual bool ProcessBadDataFields { get; set; } = true;
Copy link

@nicemanman nicemanman Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other properties (not only properties) have /// <inheritdoc/> above them, you forgot to add it above this line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been added.


/// <inheritdoc/>
public virtual int BufferSize { get; set; } = 0x1000;

Expand All @@ -37,6 +39,9 @@ public record CsvConfiguration : IReaderConfiguration, IWriterConfiguration
/// <inheritdoc/>
public virtual char Comment { get; set; } = '#';

/// <inheritdoc/>
public virtual int? MaxProcessFieldBufferSize { get; set; }

/// <inheritdoc/>
public virtual bool CountBytes { get; set; }

Expand Down Expand Up @@ -135,6 +140,9 @@ public virtual string NewLine
/// <inheritdoc/>
public virtual int ProcessFieldBufferSize { get; set; } = 1024;

/// <inheritdoc/>
public virtual int? MaxBufferSize { get; set; }

/// <inheritdoc/>
public virtual char Quote { get; set; } = '"';

Expand Down
19 changes: 19 additions & 0 deletions src/CsvHelper/Configuration/IParserConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ public interface IParserConfiguration
/// </summary>
int ProcessFieldBufferSize { get; }

/// <summary>
/// Gets the maximum allowed size of the buffer which must not be increased above that value.
/// No limit if not defined.
/// </summary>
int? MaxBufferSize { get; }

/// <summary>
/// Gets the maximum allowed size of the process field buffer which must not be increased above that value.
/// If field is longer value is truncated what leads to data loss.
/// No limit if not defined.
/// WARNING: setting too low value can lead to field truncation if length bigger than this value
/// </summary>
int? MaxProcessFieldBufferSize { get; }

/// <summary>
/// Gets a value indicating whether the number of bytes should
/// be counted while parsing. Default is false. This will slow down parsing
Expand All @@ -82,6 +96,11 @@ public interface IParserConfiguration
/// </summary>
BadDataFound BadDataFound { get; }

/// <summary>
/// If set bad data fields are not processed and empty array allocated for them
/// </summary>
bool ProcessBadDataFields { get; }

/// <summary>
/// Gets or sets the maximum size of a field.
/// Defaults to 0, indicating maximum field size is not checked.
Expand Down
Loading