Skip to content

Commit 2433560

Browse files
committed
Merge remote-tracking branch 'upstream/master' into docs
2 parents 481268b + 33970e5 commit 2433560

File tree

23 files changed

+443
-57
lines changed

23 files changed

+443
-57
lines changed

CsvHelper.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CsvHelper.Tests", "tests\Cs
2020
EndProject
2121
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CsvHelper.Website", "src\CsvHelper.Website\CsvHelper.Website.csproj", "{3E59CA52-D248-4CBB-BB06-270FA942C4B8}"
2222
EndProject
23+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvHelper.Benchmarks", "performance\CsvHelper.Benchmarks\CsvHelper.Benchmarks.csproj", "{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}"
24+
EndProject
2325
Global
2426
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2527
Debug|Any CPU = Debug|Any CPU
@@ -94,6 +96,26 @@ Global
9496
{3E59CA52-D248-4CBB-BB06-270FA942C4B8}.Release|x64.Build.0 = Release|Any CPU
9597
{3E59CA52-D248-4CBB-BB06-270FA942C4B8}.Release|x86.ActiveCfg = Release|Any CPU
9698
{3E59CA52-D248-4CBB-BB06-270FA942C4B8}.Release|x86.Build.0 = Release|Any CPU
99+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
100+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
101+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|ARM.ActiveCfg = Debug|Any CPU
102+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|ARM.Build.0 = Debug|Any CPU
103+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
104+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
105+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|x64.ActiveCfg = Debug|Any CPU
106+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|x64.Build.0 = Debug|Any CPU
107+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|x86.ActiveCfg = Debug|Any CPU
108+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Debug|x86.Build.0 = Debug|Any CPU
109+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
110+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|Any CPU.Build.0 = Release|Any CPU
111+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|ARM.ActiveCfg = Release|Any CPU
112+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|ARM.Build.0 = Release|Any CPU
113+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
114+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
115+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|x64.ActiveCfg = Release|Any CPU
116+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|x64.Build.0 = Release|Any CPU
117+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|x86.ActiveCfg = Release|Any CPU
118+
{4DAB88D4-56B0-C42A-25BB-3E5BBCBB5F1B}.Release|x86.Build.0 = Release|Any CPU
97119
EndGlobalSection
98120
GlobalSection(SolutionProperties) = preSolution
99121
HideSolutionNode = FALSE

CsvHelper.v3.ncrunchsolution

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Settings>
33
<AllowParallelTestExecution>True</AllowParallelTestExecution>
44
<InstrumentationMode>Optimised</InstrumentationMode>
5+
<RdiConfigured>True</RdiConfigured>
56
<SolutionConfigured>True</SolutionConfigured>
67
</Settings>
78
</SolutionConfiguration>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Globalization;
3+
using System.IO;
4+
5+
using BenchmarkDotNet.Attributes;
6+
7+
namespace CsvHelper.Benchmarks;
8+
9+
[MemoryDiagnoser]
10+
public class BenchmarkEnumerateRecords
11+
{
12+
private const int entryCount = 10000;
13+
private readonly MemoryStream stream = new();
14+
15+
public class Simple
16+
{
17+
public int Id { get; set; }
18+
public string Name { get; set; }
19+
}
20+
21+
[GlobalSetup]
22+
public void GlobalSetup()
23+
{
24+
using var streamWriter = new StreamWriter(this.stream, null, -1, true);
25+
using var writer = new CsvWriter(streamWriter, CultureInfo.InvariantCulture, true);
26+
var random = new Random(42); // Pick a known seed to keep things consistent
27+
28+
var chars = new char[10];
29+
string getRandomString()
30+
{
31+
for (int i = 0; i < 10; ++i)
32+
chars[i] = (char)random.Next('a', 'z' + 1);
33+
return new string(chars);
34+
}
35+
36+
writer.WriteHeader(typeof(Simple));
37+
writer.NextRecord();
38+
for (int i = 0; i < BenchmarkEnumerateRecords.entryCount; ++i)
39+
{
40+
writer.WriteRecord(new Simple()
41+
{
42+
Id = random.Next(),
43+
Name = getRandomString()
44+
});
45+
writer.NextRecord();
46+
}
47+
}
48+
49+
[GlobalCleanup]
50+
public void GlobalCleanup()
51+
{
52+
this.stream.Dispose();
53+
}
54+
55+
[Benchmark]
56+
public void EnumerateRecords()
57+
{
58+
this.stream.Position = 0;
59+
using var streamReader = new StreamReader(this.stream, null, true, -1, true);
60+
using var csv = new CsvReader(streamReader, CultureInfo.InvariantCulture, true);
61+
foreach (var record in csv.GetRecords<Simple>())
62+
{
63+
_ = record;
64+
}
65+
}
66+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using BenchmarkDotNet.Running;
2+
3+
namespace CsvHelper.Benchmarks;
4+
5+
internal class BenchmarkMain
6+
{
7+
static void Main(string[] args)
8+
{
9+
_ = BenchmarkRunner.Run<BenchmarkEnumerateRecords>();
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="BenchmarkDotNet" Version="0.15.0" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\src\CsvHelper\CsvHelper.csproj" />
14+
</ItemGroup>
15+
16+
</Project>

src/CsvHelper.Website/input/change-log/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Change Log
22

3+
### 33.1.0
4+
5+
#### Features
6+
7+
- Use `Attributes.IsDefined` instead of `Attributes.GetCustomAttributes` to check for attributes on a type. This is more performant.
8+
- Removed out of support frameworks `net6.0` and `net7.0` and added `net9.0`.
9+
- Use CacheKey struct for ObjectCreator cache key.
10+
- Early exit in ObjectCreator when there are no args. This reduces allocations.
11+
12+
#### Bug Fixes
13+
14+
- Add `Dispose` and `DisposeAsync` to writer write async methods.
15+
- Fixed issue with setting `UseDefaultOnConversionFailure` to `true` when the default value is `null`.
16+
317
### 33.0.1
418

519
#### Bug Fixes

src/CsvHelper.Website/input/examples/configuration/class-maps/validation/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class FooMap : ClassMap<Foo>
3434
public FooMap()
3535
{
3636
Map(m => m.Id);
37-
Map(m => m.Name).Validate(field => !field.Contains("-"));
37+
Map(m => m.Name).Validate(args => !args.Field.Contains("-"));
3838
}
3939
}
4040
```

src/CsvHelper.Website/input/examples/type-conversion/custom-type-converter/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Id,Name,Json
1818
```cs
1919
void Main()
2020
{
21-
using (var reader = new new StreamReader("path\\to\\file.csv"))
21+
using (var reader = new StreamReader("path\\to\\file.csv"))
2222
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
2323
{
2424
// Register globally.

src/CsvHelper.Website/input/examples/type-conversion/type-converter-options/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Any option for these methods should be available through configuration.
77
###### Mapping Example
88

99
```cs
10-
public sealed class FooMap : ClassMap\<Foo\>
10+
public sealed class FooMap : ClassMap<Foo>
1111
{
1212
public FooMap()
1313
{

src/CsvHelper.Website/input/getting-started/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ is done against the property name. Both the header and the property name are ran
105105
header, they will now match. You can use this function to do other things such as remove
106106
whitespace or other characters.
107107

108-
Let's say out CSV file doesn't have a header at all.
108+
Let's say our CSV file doesn't have a header at all.
109109

110110
```
111111
1,one

0 commit comments

Comments
 (0)