Dameng.SepEx.Generator 0.2.10

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dameng.SepEx.Generator --version 0.2.10
                    
NuGet\Install-Package Dameng.SepEx.Generator -Version 0.2.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dameng.SepEx.Generator" Version="0.2.10">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dameng.SepEx.Generator" Version="0.2.10" />
                    
Directory.Packages.props
<PackageReference Include="Dameng.SepEx.Generator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dameng.SepEx.Generator --version 0.2.10
                    
#r "nuget: Dameng.SepEx.Generator, 0.2.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dameng.SepEx.Generator@0.2.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dameng.SepEx.Generator&version=0.2.10
                    
Install as a Cake Addin
#tool nuget:?package=Dameng.SepEx.Generator&version=0.2.10
                    
Install as a Cake Tool

Dameng.SepEx

A high-performance, Native AOT compatible source generator for working with separated values (CSV/TSV) files in C#. This library extends the excellent Sep library by providing compile-time code generation for strongly-typed reading and writing of CSV data.

Perfect for developers migrating from CSVHelper who need Native AOT support or want better performance through source generation.

Features

  • Source Generator: Automatically generates type-safe CSV readers and writers at compile time
  • High Performance: Built on top of the fast Sep library
  • Attribute-Based Configuration: Use attributes to configure column mapping, formatting, and behavior
  • Flexible Column Mapping: Support for column names, indexes, default values, and formatting
  • Type Safety: Compile-time type checking and IntelliSense support
  • NativeAOT Compatible: Full support for Native AOT compilation, unlike CSVHelper

Installation

Install the NuGet packages:

dotnet add package Dameng.SepEx
dotnet add package Dameng.SepEx.Generator

Usage & Migration

Basic Usage

Define your data model as a partial class with [GenSepParsable] and use attributes to configure column mapping:

[GenSepParsable]
public partial class Person
{
    [SepColumnName("FullName")]
    [SepColumnIndex(0)]
    public string Name { get; set; }
    
    [SepColumnName("Age")]
    public int Age { get; set; }
    
    [SepDefaultValue("Unknown")]
    public string City { get; set; }
    
    [SepColumnIgnore]
    public string InternalId { get; set; }
}

// Reading CSV
using var reader = Sep.Reader().FromFile("people.csv");
foreach (var person in reader.GetRecords<Person>())
{
    Console.WriteLine($"{person.Name} is {person.Age} years old");
}

// Writing CSV
var people = new List<Person> { /* ... */ };
using var writer = Sep.Writer().ToFile("output.csv");
writer.WriteRecords(people);

Migrating from CSVHelper

If you're migrating from CSVHelper, simply update your attributes and make classes partial:

CSVHelper Dameng.SepEx
[Name("column")] [SepColumnName("column")]
[Index(0)] [SepColumnIndex(0)]
[Ignore] [SepColumnIgnore]
[Default("value")] [SepDefaultValue("value")]
[Format("format")] [SepColumnFormat("format")]

Key changes:

  • Add [GenSepParsable] attribute and make class partial
  • Replace CSVHelper attributes with Dameng.SepEx equivalents
  • Use Sep.Reader() and Sep.Writer() instead of CSVHelper APIs

External Data Models

For classes you can't modify (e.g., from external libraries), use type info generation:

[GenSepTypeInfo<ExternalPerson>()]
public partial class ExternalPersonTypeInfo;

// Usage
using var reader = Sep.Reader().FromFile("people.csv");
foreach (var person in reader.GetRecords<ExternalPerson>(ExternalPersonTypeInfo.ExternalPerson))
{
    // Process person
}

Available Attributes

  • [GenSepTypeInfo<T>()]: Generate type info for the specified type
  • [SepColumnName(string name)]: Specify column name
  • [SepColumnIndex(int index)]: Specify column index for reading/writing order
  • [SepDefaultValue(object value)]: Set default value when column is missing
  • [SepColumnIgnore]: Ignore property/field during CSV operations
  • [SepColumnFormat(string format)]: Specify format for writing values

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.12 245 8/25/2025
0.2.10 245 8/25/2025
0.2.9 238 8/25/2025
0.2.7 246 8/25/2025
0.2.6 98 8/22/2025
0.2.5 92 8/22/2025
0.2.4 103 8/22/2025
0.2.3 100 8/22/2025
0.2.2 97 8/22/2025
0.2.1 107 8/22/2025
0.1.0 125 8/21/2025