CsvSourceGeneration 0.0.4

dotnet add package CsvSourceGeneration --version 0.0.4                
NuGet\Install-Package CsvSourceGeneration -Version 0.0.4                
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="CsvSourceGeneration" Version="0.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsvSourceGeneration --version 0.0.4                
#r "nuget: CsvSourceGeneration, 0.0.4"                
#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.
// Install CsvSourceGeneration as a Cake Addin
#addin nuget:?package=CsvSourceGeneration&version=0.0.4

// Install CsvSourceGeneration as a Cake Tool
#tool nuget:?package=CsvSourceGeneration&version=0.0.4                

Static CSV Source Generator NuGet GitHub

This package allows for generating static C# classes allowing for easy, type safe and performant row-wise access to the data.

Usage

Add a package reference to your project:

    <ItemGroup>
        <PackageReference Include="CsvSourceGeneration" Version="0.0.2" />
    </ItemGroup>

Then include a file with the .csv extension:

    <ItemGroup>
        <AdditionalFiles Include="CsvFiles\MyFile.csv" />
    </ItemGroup>
Entry,Message
First,Hello World!

When the project is built next, the data contained in the csv is available through a static class with the same name as the csv file:

Console.WriteLine($"Some data from the csv file: {MyFile.First.Message}");
// Some data from the csv file: Hello World!

Data types

Several field types (FieldType enumerable) are supported.

The data type of a column is deduced from the first row based on the following rules:

  1. If the column name is id (ignoring case), values are parsed into IdString
  2. If the cell value ends with s, values are parsed into TimeSpan using TimeSpan.FromSeconds
  3. If the cell value can be parsed with bool.TryParse, values are parsed into bool
  4. If the cell value can be parsed with int.TryParse, values are parsed into int
  5. If the cell value can be parsed with float.TryParse, values are parsed into float
  6. If the cell value can be parsed with double.TryParse, values are parsed into double
  7. Otherwise, values are assumed to be strings.

Example CSV content with each field type:

Example Id TimeSpan Bool Int Float Double String
First first 1.0s true 10 10.0 10.0d Hello World!
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • 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.0.4 100 11/2/2024
0.0.3 83 11/2/2024
0.0.2 94 10/26/2024
0.0.1 96 10/26/2024