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

upgrade/dotnet8 #94

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Even the focus of this library being data mapping to objects (classes, structs,

## RecordParser is a Zero Allocation Writer/Reader Parser for .NET Core

1. It supports .NET 6, 7 and .NET Standard 2.1
1. It supports .NET 6, 7, 8 and .NET Standard 2.1
2. It has minimal heap allocations because it does intense use of [Span](https://docs.microsoft.com/en-us/archive/msdn-magazine/2018/january/csharp-all-about-span-exploring-a-new-net-mainstay) type, a .NET type designed to have high-performance and reduce memory allocations [(see benchmark)](/Benchmark.md)
3. It is even more performant because the relevant code is generated using [expression trees](https://docs.microsoft.com/dotnet/csharp/expression-trees), which once compiled is fast as handwriting code
4. It supports parse for ANY type: classes, structs, records, arrays, tuples etc.
4. It supports parse for ANY type: classes, structs, records, arrays, tuples etc
5. It supports to map values for properties, fields, indexers, etc.
6. It does not do [boxing](https://docs.microsoft.com/dotnet/csharp/programming-guide/types/boxing-and-unboxing) for structs.
7. It is flexible: you can choose the most convenient way to configure each of your parsers: indexed or sequential configuration
Expand Down Expand Up @@ -58,6 +58,8 @@ Third Party Benchmarks

*ㅤyou can use a "string pool" to avoid creating multiple instances of strings with same content.

NOTE: MOST EXAMPLES USE TUPLES FOR SIMPLICITY. PARSER ACTUALLY WORKS FOR ANY TYPE (CLASSES, STRUCTS, RECORDS, ARRAYS, TUPLES, ETC)

## Fixed Length Reader
There are 2 flavors for mapping: indexed or sequential.

Expand Down
4 changes: 2 additions & 2 deletions RecordParser.Benchmark/RecordParser.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<!--<DefineConstants>TEST_ALL</DefineConstants>-->
</PropertyGroup>

Expand Down
9 changes: 1 addition & 8 deletions RecordParser.Test/FixedLengthWriterBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Given_value_using_standard_format_should_parse_without_extra_configu
[InlineData(48)]
[InlineData(01)]
[InlineData(00)]
public void Given_destination_shorter_than_max_position_especified_should_write_nothing(int destinationSize)
public void Given_destination_shorter_than_max_position_especified_then_chars_written_should_be_zero(int destinationSize)
{
// Arrange

Expand All @@ -88,7 +88,6 @@ public void Given_destination_shorter_than_max_position_especified_should_write_

success.Should().BeFalse();
charsWritten.Should().Be(0);
destination.ToString().Should().Be(new string(default, destinationSize));
}

[Fact]
Expand All @@ -115,11 +114,8 @@ public void Given_string_value_larger_than_designated_space_should_write_until_r
success.Should().BeFalse();

var result = destination.Slice(0, charsWritten);
var unwritted = destination.Slice(charsWritten);
var freeSpace = destination.Length - charsWritten;

result.Should().Be("2020.05.23");
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand All @@ -146,11 +142,8 @@ public void Given_non_string_value_larger_than_designated_space_should_write_unt
success.Should().BeFalse();

var result = destination.Slice(0, charsWritten);
var unwritted = destination.Slice(charsWritten);
var freeSpace = destination.Length - charsWritten;

result.Should().Be("foo bar baz----");
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand Down
9 changes: 1 addition & 8 deletions RecordParser.Test/FixedLengthWriterSequentialBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Given_value_using_standard_format_should_parse_without_extra_configu
[InlineData(48)]
[InlineData(01)]
[InlineData(00)]
public void Given_destination_shorter_than_max_position_especified_should_write_nothing(int destinationSize)
public void Given_destination_shorter_than_max_position_especified_then_chars_written_should_be_zero(int destinationSize)
{
// Arrange

Expand Down Expand Up @@ -92,7 +92,6 @@ public void Given_destination_shorter_than_max_position_especified_should_write_

success.Should().BeFalse();
charsWritten.Should().Be(0);
destination.ToString().Should().Be(new string(default, destinationSize));
}

[Fact]
Expand Down Expand Up @@ -120,11 +119,8 @@ public void Given_string_value_larger_than_designated_space_should_write_until_r
success.Should().BeFalse();

var result = destination.Slice(0, charsWritten);
var unwritted = destination.Slice(charsWritten);
var freeSpace = destination.Length - charsWritten;

result.Should().Be("2020.05.23");
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand Down Expand Up @@ -152,11 +148,8 @@ public void Given_non_string_value_larger_than_designated_space_should_write_unt
success.Should().BeFalse();

var result = destination.Slice(0, charsWritten);
var unwritted = destination.Slice(charsWritten);
var freeSpace = destination.Length - charsWritten;

result.Should().Be("foo bar baz----");
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions RecordParser.Test/RecordParser.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>11</LangVersion>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ public void Given_text_shorter_than_destination_should_not_write(string value, i
var freeSpace = destination.Length - charsWritten;

result.Should().Be(expected);
unwritted.Should().Be(new string(default, freeSpace));

if (success)
unwritted.Should().Be(new string(default, freeSpace));
}

public enum MapTextType
Expand Down
4 changes: 3 additions & 1 deletion RecordParser.Test/VariableLengthWriterBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ public void Given_too_short_destination_should_write_while_have_enough_space(int
var freeSpace = destination.Length - charsWritten;

result.Should().Be(expected);
unwritted.Should().Be(new string(default, freeSpace));

if (success)
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public void Given_too_short_destination_should_write_while_have_enough_space(int
var freeSpace = destination.Length - charsWritten;

result.Should().Be(expected);
unwritted.Should().Be(new string(default, freeSpace));

if (success)
unwritted.Should().Be(new string(default, freeSpace));
}

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions RecordParser/RecordParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<PackageId>RecordParser</PackageId>
<TargetFrameworks>netstandard2.1;net6.0;net7.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<TargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Leandro Fernandes Vieira (leandromoh)</Authors>
<Description>
RecordParser is a expression tree based parser that helps you to write maintainable parsers with high-performance and zero allocations, thanks to Span type.
Expand All @@ -14,7 +14,7 @@
<PackageProjectUrl>https://github.com/leandromoh/RecordParser</PackageProjectUrl>
<RepositoryUrl>https://github.com/leandromoh/RecordParser</RepositoryUrl>
<PackageTags>tsv parser performance csv mapper file flat reader dotnet-core span flatfile expression-tree delimited fixedlength</PackageTags>
<Version>2.2.1</Version>
<Version>2.3.0</Version>
<PackageReleaseNotes>
https://github.com/leandromoh/RecordParser/blob/master/release_notes.md
</PackageReleaseNotes>
Expand All @@ -38,7 +38,7 @@

<PropertyGroup Condition="
( '$(Configuration)' == 'Debug' OR '$(Configuration)' == 'Release') AND
( '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0') AND
( '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net8.0') AND
( '$(Platform)' == 'AnyCPU') ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Loading