diff --git a/README.md b/README.md index 0d68336..cb04da4 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/RecordParser.Benchmark/RecordParser.Benchmark.csproj b/RecordParser.Benchmark/RecordParser.Benchmark.csproj index 7676601..b85a32f 100644 --- a/RecordParser.Benchmark/RecordParser.Benchmark.csproj +++ b/RecordParser.Benchmark/RecordParser.Benchmark.csproj @@ -2,8 +2,8 @@ Exe - net7.0 - 10 + net8.0 + latest diff --git a/RecordParser.Test/FixedLengthWriterBuilderTest.cs b/RecordParser.Test/FixedLengthWriterBuilderTest.cs index 8014be2..8d0b9c2 100644 --- a/RecordParser.Test/FixedLengthWriterBuilderTest.cs +++ b/RecordParser.Test/FixedLengthWriterBuilderTest.cs @@ -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 @@ -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] @@ -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] @@ -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] diff --git a/RecordParser.Test/FixedLengthWriterSequentialBuilderTest.cs b/RecordParser.Test/FixedLengthWriterSequentialBuilderTest.cs index 98e28ec..2927cf0 100644 --- a/RecordParser.Test/FixedLengthWriterSequentialBuilderTest.cs +++ b/RecordParser.Test/FixedLengthWriterSequentialBuilderTest.cs @@ -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 @@ -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] @@ -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] @@ -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] diff --git a/RecordParser.Test/RecordParser.Test.csproj b/RecordParser.Test/RecordParser.Test.csproj index 425cf63..4cd1565 100644 --- a/RecordParser.Test/RecordParser.Test.csproj +++ b/RecordParser.Test/RecordParser.Test.csproj @@ -1,8 +1,8 @@  - net7.0 - 11 + net8.0 + latest false diff --git a/RecordParser.Test/VariableLengthWriterBuilderQuotedFieldTest.cs b/RecordParser.Test/VariableLengthWriterBuilderQuotedFieldTest.cs index 3e6f12a..1f2550f 100644 --- a/RecordParser.Test/VariableLengthWriterBuilderQuotedFieldTest.cs +++ b/RecordParser.Test/VariableLengthWriterBuilderQuotedFieldTest.cs @@ -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 diff --git a/RecordParser.Test/VariableLengthWriterBuilderTest.cs b/RecordParser.Test/VariableLengthWriterBuilderTest.cs index 5f04c61..fe82648 100644 --- a/RecordParser.Test/VariableLengthWriterBuilderTest.cs +++ b/RecordParser.Test/VariableLengthWriterBuilderTest.cs @@ -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] diff --git a/RecordParser.Test/VariableLengthWriterSequentialBuilderTest.cs b/RecordParser.Test/VariableLengthWriterSequentialBuilderTest.cs index cdd7940..3b37805 100644 --- a/RecordParser.Test/VariableLengthWriterSequentialBuilderTest.cs +++ b/RecordParser.Test/VariableLengthWriterSequentialBuilderTest.cs @@ -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] diff --git a/RecordParser/RecordParser.csproj b/RecordParser/RecordParser.csproj index a28ea71..9e00fba 100644 --- a/RecordParser/RecordParser.csproj +++ b/RecordParser/RecordParser.csproj @@ -2,8 +2,8 @@ RecordParser - netstandard2.1;net6.0;net7.0 - 10 + netstandard2.1;net6.0;net7.0;net8.0 + latest Leandro Fernandes Vieira (leandromoh) RecordParser is a expression tree based parser that helps you to write maintainable parsers with high-performance and zero allocations, thanks to Span type. @@ -14,7 +14,7 @@ https://github.com/leandromoh/RecordParser https://github.com/leandromoh/RecordParser tsv parser performance csv mapper file flat reader dotnet-core span flatfile expression-tree delimited fixedlength - 2.2.1 + 2.3.0 https://github.com/leandromoh/RecordParser/blob/master/release_notes.md @@ -38,7 +38,7 @@ true