Skip to content

Commit

Permalink
Merge pull request #77 from pjoiner/v0.8.0
Browse files Browse the repository at this point in the history
V0.8.0
  • Loading branch information
pjoiner authored Nov 22, 2023
2 parents 1902523 + 0c43dbf commit 05c6de8
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
<Configurations>Debug;Release;LocalRelease</Configurations>
</PropertyGroup>

Expand Down Expand Up @@ -67,7 +67,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
<PackageReference Condition="'$(LOCALBUILD)' == ''" Include="DwC-A_dotnet" Version="0.5.2" />
</ItemGroup>

Expand Down
19 changes: 14 additions & 5 deletions Benchmarks/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,32 @@ public Config()
{
var baseJob = Job.ShortRun;
#if LOCALBUILD
var package_0_7_0 = baseJob.WithId("0.7.0");
AddJob(package_0_7_0.WithRuntime(ClrRuntime.Net48));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core50));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core60));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core70));
var package_0_8_0 = baseJob.WithId("0.8.0");
AddJob(package_0_8_0.WithRuntime(ClrRuntime.Net48));
AddJob(package_0_8_0.WithRuntime(CoreRuntime.Core50));
AddJob(package_0_8_0.WithRuntime(CoreRuntime.Core60));
AddJob(package_0_8_0.WithRuntime(CoreRuntime.Core70));
AddJob(package_0_8_0.WithRuntime(CoreRuntime.Core80));
#else
var package_0_5_2 = baseJob.WithNuGet("DwC-A_dotnet", "0.5.2").WithId("0.5.2");
var package_0_6_2 = baseJob.WithNuGet("DwC-A_dotnet", "0.6.2").WithId("0.6.2");
var package_0_7_0 = baseJob.WithNuGet("DwC-A_dotnet", "0.7.0").WithId("0.7.0");

AddJob(package_0_5_2.WithRuntime(ClrRuntime.Net48));
AddJob(package_0_5_2.WithRuntime(CoreRuntime.Core50));
AddJob(package_0_5_2.WithRuntime(CoreRuntime.Core60));
AddJob(package_0_5_2.WithRuntime(CoreRuntime.Core70));
AddJob(package_0_5_2.WithRuntime(CoreRuntime.Core80));
AddJob(package_0_6_2.WithRuntime(ClrRuntime.Net48));
AddJob(package_0_6_2.WithRuntime(CoreRuntime.Core50));
AddJob(package_0_6_2.WithRuntime(CoreRuntime.Core60));
AddJob(package_0_6_2.WithRuntime(CoreRuntime.Core70));
AddJob(package_0_6_2.WithRuntime(CoreRuntime.Core80));
AddJob(package_0_7_0.WithRuntime(ClrRuntime.Net48));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core50));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core60));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core70));
AddJob(package_0_7_0.WithRuntime(CoreRuntime.Core80));
#endif
}
}
Expand Down
4 changes: 2 additions & 2 deletions Benchmarks/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
To run benchmarks for the current release from the command line and save logs/results use the following command line.

```
dotnet run -c LocalRelease --framework net48 net50 net60 net70
dotnet run -c LocalRelease --framework net48 net50 net60 net70 net80
```
To run benchmarks for the previous releases use the following command line.

```
dotnet run -c Release --framework net48 net50 net60 net70
dotnet run -c Release --framework net48 net50 net60 net70 net80
```
1 change: 0 additions & 1 deletion src/DWC_A/ArchiveWriter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DwC_A.Builders;
using DwC_A.Meta;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
Expand Down
7 changes: 4 additions & 3 deletions src/DWC_A/AsyncEnumerable/FileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace DwC_A
{
Expand All @@ -13,7 +14,7 @@ public async IAsyncEnumerable<IRow> GetRowsAsync([EnumeratorCancellation] Cancel
using (var stream = new FileStream(FileName,
FileMode.Open, FileAccess.Read, FileShare.Read, config.BufferSize, true))
{
await foreach (var row in streamReader.ReadRowsAsync(stream, ct))
await foreach (var row in streamReader.ReadRowsAsync(stream, ct).ConfigureAwait(false))
{
yield return row;
}
Expand All @@ -23,7 +24,7 @@ public async IAsyncEnumerable<IRow> GetRowsAsync([EnumeratorCancellation] Cancel
public async IAsyncEnumerable<IRow> GetHeaderRowsAsync([EnumeratorCancellation] CancellationToken ct = default)
{
int count = 0;
await foreach (var row in GetRowsAsync(ct))
await foreach (var row in GetRowsAsync(ct).ConfigureAwait(false))
{
if (count < FileMetaData.HeaderRowCount)
{
Expand All @@ -40,7 +41,7 @@ public async IAsyncEnumerable<IRow> GetHeaderRowsAsync([EnumeratorCancellation]
public async IAsyncEnumerable<IRow> GetDataRowsAsync([EnumeratorCancellation] CancellationToken ct = default)
{
int count = 0;
await foreach (var row in GetRowsAsync(ct))
await foreach (var row in GetRowsAsync(ct).ConfigureAwait(false))
{
if (count >= FileMetaData.HeaderRowCount)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DWC_A/AsyncEnumerable/StreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async IAsyncEnumerable<IRow> ReadRowsAsync(Stream stream,
using (var reader = new System.IO.StreamReader(stream, fileMetaData.Encoding))
{
string line;
while ((line = await reader.ReadRowAsync(fileMetaData)) != null)
while ((line = await reader.ReadRowAsync(fileMetaData).ConfigureAwait(false)) != null)
{
ct.ThrowIfCancellationRequested();
yield return rowFactory.CreateRow(tokenizer.Split(line), fileMetaData.Fields);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using DwC_A.Builders;
using DwC_A.Meta;
using System.IO;
using System.Xml.Serialization;

namespace DwC_A.Meta
namespace DwC_A.Builders
{
public class ArchiveMetaDataBuilder
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public Archive Build()
public string Serialize()
{
var path = GetPath();
var metaDataFileName = System.IO.Path.Combine(path, fileName);
var metaDataFileName = Path.Combine(path, fileName);
var overrides = GetXmlAttributeOverrides();
XmlSerializer serializer = new XmlSerializer(typeof(Archive), overrides);
using (Stream stream = new FileStream(metaDataFileName, FileMode.Create))
Expand All @@ -60,7 +60,7 @@ public string Serialize()

private string GetPath()
{
if(context == null)
if (context == null)
{
return BuilderContext.Default.Path;
}
Expand All @@ -80,14 +80,14 @@ private XmlAttributeOverrides GetXmlAttributeOverrides()
"dateFormat"
};
var overrides = new XmlAttributeOverrides();
foreach(var attributeName in attributeNames)
foreach (var attributeName in attributeNames)
{
var attribute = new XmlAttributes()
{
XmlDefaultValue = null,
XmlAttribute = new XmlAttributeAttribute()
{
AttributeName = attributeName
{
AttributeName = attributeName
}
};
var memberName = Capitalize(attributeName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using DwC_A.Meta;

namespace DwC_A.Meta
namespace DwC_A.Builders
{
public class CoreFileMetaDataBuilder
{
Expand Down Expand Up @@ -83,7 +84,7 @@ public CoreFileMetaDataBuilder AddField(FieldMetaDataBuilder field)

public CoreFileMetaDataBuilder AddFields(FieldsMetaDataBuilder fields)
{
foreach(var field in fields.Build())
foreach (var field in fields.Build())
{
AddField(field);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using DwC_A.Meta;

namespace DwC_A.Meta
namespace DwC_A.Builders
{
public class ExtensionFileMetaDataBuilder
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace DwC_A.Meta
using DwC_A.Meta;

namespace DwC_A.Builders
{
/// <summary>
/// Builds field metadata definitions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DwC_A.Meta;

namespace DwC_A.Meta
namespace DwC_A.Builders
{
/// <summary>
/// Creates a collection of field metadata
Expand Down Expand Up @@ -41,10 +42,10 @@ public FieldsMetaDataBuilder AutomaticallyIndex()
/// </summary>
/// <param name="fieldMetaData">This method will create a FieldMetaDataBuilder and pass it to a lamba defined to fill in the field metadat</param>
/// <returns>this</returns>
public FieldsMetaDataBuilder AddField( Func<FieldMetaDataBuilder, FieldMetaDataBuilder> fieldMetaData )
public FieldsMetaDataBuilder AddField(Func<FieldMetaDataBuilder, FieldMetaDataBuilder> fieldMetaData)
{
var fieldMetaDataBuilder = FieldMetaDataBuilder.Field();
if(automaticallyIndex)
if (automaticallyIndex)
{
fieldMetaDataBuilder.Index(index++);
}
Expand Down
18 changes: 12 additions & 6 deletions src/DWC_A/DwC-A_dotnet.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<RootNamespace>DwC_A</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Configurations>Debug;Release;LocalRelease</Configurations>
Expand All @@ -12,12 +12,12 @@
<RepositoryUrl>https://github.com/pjoiner/DwC-A_dotnet</RepositoryUrl>
<Authors>Paul Joiner</Authors>
<Company />
<Copyright>Copyright © Paul Joiner 2022</Copyright>
<Copyright>Copyright © Paul Joiner 2023</Copyright>
<license>https://github.com/pjoiner/DwC-A_dotnet/blob/master/LICENSE</license>
<RepositoryType>git</RepositoryType>
<Description>A simple Darwin Core Archive Reader for dotnet</Description>
<PackageTags>DwC-A darwin-core Biodiversity</PackageTags>
<Version>0.7.0</Version>
<Version>0.8.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
Expand All @@ -26,10 +26,12 @@
<PropertyGroup>
<DocumentationFile>DwC-A_dotnet.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
<AssemblyVersion>0.7.0.0</AssemblyVersion>
<FileVersion>0.7.0.0</FileVersion>
<AssemblyVersion>0.8.0.0</AssemblyVersion>
<FileVersion>0.8.0.0</FileVersion>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -47,7 +49,11 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Linq.Async" Version="5.0.0" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Linq.Async" Version="6.0.1" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
</ItemGroup>

</Project>
10 changes: 2 additions & 8 deletions src/DWC_A/Exceptions/FileReaderNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace DwC_A.Exceptions
{
Expand All @@ -14,19 +13,14 @@ public FileReaderNotFoundException()
{
}

public FileReaderNotFoundException(string fileName) :
public FileReaderNotFoundException(string fileName) :
base(BuildMessage(fileName))
{
}

public FileReaderNotFoundException(string fileName, Exception innerException) :
public FileReaderNotFoundException(string fileName, Exception innerException) :
base(BuildMessage(fileName), innerException)
{
}

protected FileReaderNotFoundException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
}
}
10 changes: 2 additions & 8 deletions src/DWC_A/Exceptions/InvalidArchiveException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace DwC_A.Exceptions
{
Expand All @@ -14,19 +13,14 @@ public InvalidArchiveException()
{
}

public InvalidArchiveException(string path) :
public InvalidArchiveException(string path) :
base(BuildMessage(path))
{
}

public InvalidArchiveException(string path, Exception innerException) :
public InvalidArchiveException(string path, Exception innerException) :
base(BuildMessage(path), innerException)
{
}

protected InvalidArchiveException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
}
}
7 changes: 1 addition & 6 deletions src/DWC_A/Exceptions/TermNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace DwC_A.Exceptions
{
Expand All @@ -15,13 +14,9 @@ public TermNotFoundException(string term) :
{
}

public TermNotFoundException(string term, Exception innerException) :
public TermNotFoundException(string term, Exception innerException) :
base(BuildMessage(term), innerException)
{
}

protected TermNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
10 changes: 5 additions & 5 deletions src/DWC_A/Extensions/StreamReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public static string ReadRow(this System.IO.StreamReader reader, IFileMetaData f
char terminatorStart = fileMetaData.LinesTerminatedBy.FirstOrDefault();
bool inQuotes = false;
char[] c = new char[1];
while(reader.Peek() != -1)
while (reader.Peek() != -1)
{
reader.Read(c,0,1);
reader.Read(c, 0, 1);
if (!inQuotes && c[0] == terminatorStart)
{
for (int i = 1; i < fileMetaData.LineTerminatorLength; i++)
Expand Down Expand Up @@ -61,20 +61,20 @@ public async static Task<string> ReadRowAsync(this System.IO.StreamReader reader
char Quotes = fileMetaData.FieldsEnclosedBy.FirstOrDefault();
if (Quotes == '\0')
{
line.Append(await reader.ReadLineAsync());
line.Append(await reader.ReadLineAsync().ConfigureAwait(false));
return line.Flush();
}
char terminatorStart = fileMetaData.LinesTerminatedBy.FirstOrDefault();
bool inQuotes = false;
char[] c = new char[1];
while (reader.Peek() != -1)
{
await reader.ReadAsync(c, 0, 1);
await reader.ReadAsync(c, 0, 1).ConfigureAwait(false);
if (!inQuotes && c[0] == terminatorStart)
{
for (int i = 1; i < fileMetaData.LineTerminatorLength; i++)
{
await reader.ReadAsync(c, 0, 1);
await reader.ReadAsync(c, 0, 1).ConfigureAwait(false);
}
return line.Flush();
}
Expand Down
Binary file modified src/DWC_A/Terms/Terms.cs
Binary file not shown.
Loading

0 comments on commit 05c6de8

Please sign in to comment.