CsvSourceGeneration 0.0.4
dotnet add package CsvSourceGeneration --version 0.0.4
NuGet\Install-Package CsvSourceGeneration -Version 0.0.4
<PackageReference Include="CsvSourceGeneration" Version="0.0.4" />
paket add CsvSourceGeneration --version 0.0.4
#r "nuget: CsvSourceGeneration, 0.0.4"
// 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
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:
- If the column name is
id
(ignoring case), values are parsed intoIdString
- If the cell value ends with
s
, values are parsed intoTimeSpan
usingTimeSpan.FromSeconds
- If the cell value can be parsed with
bool.TryParse
, values are parsed intobool
- If the cell value can be parsed with
int.TryParse
, values are parsed intoint
- If the cell value can be parsed with
float.TryParse
, values are parsed intofloat
- If the cell value can be parsed with
double.TryParse
, values are parsed intodouble
- 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 | Versions 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. |
-
.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.