Skip to content

Commit

Permalink
Merge pull request #28 from youngcm2/release/27.2.1
Browse files Browse the repository at this point in the history
Release 27.2.1
  • Loading branch information
youngcm2 authored Jan 7, 2022
2 parents bf12797 + 936cb4a commit 0e3b333
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 247 deletions.
58 changes: 28 additions & 30 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@ name: .NET Publish

on:
push:
branches: [ main, release/* ]
branches: [main, release/*]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
- name: PushNuget
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate

- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
- name: PushNuget
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate
50 changes: 24 additions & 26 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
name: .NET CI

on:
on:
pull_request:
types: [opened]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .

- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
16 changes: 8 additions & 8 deletions src/CsvHelper.Excel.Specs/CsvHelper.Excel.Specs.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.95.4" />
<PackageReference Include="CsvHelper" Version="22.1.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.8.3" />
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
<PackageReference Include="CsvHelper" Version="27.2.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
<PackageReference Include="FluentAssertions" Version="6.3.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.0.0" />
<PackageReference Include="System.Linq.Async" Version="5.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
11 changes: 8 additions & 3 deletions src/CsvHelper.Excel.Specs/Parser/ExcelParserAsyncSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public ExcelParserAsyncSpec()

protected async Task RunAsync()
{
var csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture, shouldSkipRecord: record => record.All(string.IsNullOrEmpty));

var csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture)
{
ShouldSkipRecord = record => record.Record.All(string.IsNullOrEmpty)
};
using var parser = new ExcelParser(Path, WorksheetName, csvConfiguration);
using var reader = new CsvReader(parser);

Expand All @@ -108,7 +110,10 @@ public async void TheResultsAreCorrect()
[Fact]
public async void RowsHaveData()
{
var csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture, shouldSkipRecord: record => record.All(string.IsNullOrEmpty));
var csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture)
{
ShouldSkipRecord = record => record.Record.All(string.IsNullOrEmpty)
};
using var parser = new ExcelParser(Path, WorksheetName, csvConfiguration );
using var reader = new CsvReader(parser);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public ParseUsingPathSpecWithBlankRow() : base("parse_by_path_with_blank_row", i
{
var csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture)
{
ShouldSkipRecord = record => record.All(string.IsNullOrEmpty)
ShouldSkipRecord = record => record.Record.All(string.IsNullOrEmpty)
};
using var parser = new ExcelParser(Path, null, csvConfiguration);
Run(parser);
Expand Down
8 changes: 1 addition & 7 deletions src/CsvHelper.Excel.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=3329bce8_002D0c4a_002D484e_002D8490_002Dfdf9dd82f29b/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from &amp;lt;CsvHelper.Excel.Specs&amp;gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Project Location="/Users/chrisyoung/projects/CsvHelper.Excel/src/CsvHelper.Excel.Specs" Presentation="&amp;lt;CsvHelper.Excel.Specs&amp;gt;" /&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=d03634b0_002D4557_002D4e54_002Dbef6_002D75d15f706453/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from &amp;lt;CsvHelper.Excel.Specs&amp;gt; #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Project Location="/Users/chris.young/projects/CsvHelper.Excel/src/CsvHelper.Excel.Specs" Presentation="&amp;lt;CsvHelper.Excel.Specs&amp;gt;" /&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=dd2881e1_002D794f_002D4c08_002D9d09_002D25d7914949c2/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from ExcelSerializerSpecs.cs" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=9b0e05b3_002Dbdce_002D443a_002Db0a4_002D19f64dc80213/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &amp;lt;CsvHelper.Excel.Specs&amp;gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Project Location="/Users/chris.young/projects/CsvHelper.Excel/src/CsvHelper.Excel.Specs" Presentation="&amp;lt;CsvHelper.Excel.Specs&amp;gt;" /&gt;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
8 changes: 4 additions & 4 deletions src/CsvHelper.Excel/CsvHelper.Excel.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>An implementation of ICsvParser and ICsvSerializer from CsvHelper that reads and writes using the ClosedXml library.</Description>
<AssemblyTitle>CsvHelper for Excel</AssemblyTitle>
<VersionPrefix>22.1.1</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Authors>Chris Young</Authors>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<DebugType>portable</DebugType>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.95.4" />
<PackageReference Include="CsvHelper" Version="22.1.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.1" />
<PackageReference Include="CsvHelper" Version="27.2.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
</ItemGroup>
</Project>
11 changes: 8 additions & 3 deletions src/CsvHelper.Excel/ExcelParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ExcelParser : IParser
private readonly Stream _stream;
private int _rawRow = 1;
private string[] _currentRecord;
private int _lastRow;
private readonly int _lastRow;

/// <summary>
/// Initializes a new instance of the <see cref="ExcelParser"/> class.
Expand Down Expand Up @@ -83,7 +83,7 @@ public ExcelParser(Stream stream, CultureInfo culture, bool leaveOpen = false) :
/// <param name="culture">The culture.</param>
/// <param name="leaveOpen"><c>true</c> to leave the <see cref="TextWriter"/> open after the <see cref="ExcelParser"/> object is disposed, otherwise <c>false</c>.</param>
public ExcelParser(Stream stream, string sheetName, CultureInfo culture, bool leaveOpen = false) : this(stream,
sheetName, new CsvConfiguration(culture) {LeaveOpen = leaveOpen})
sheetName, new CsvConfiguration(culture) {LeaveOpen= leaveOpen})
{
}

Expand Down Expand Up @@ -195,6 +195,8 @@ public Task<bool> ReadAsync()
public string RawRecord => string.Join(Configuration.Delimiter, Record);
public int Row => _row;
public int RawRow => _rawRow;

public string Delimiter => Configuration.Delimiter;
public CsvContext Context { get; }
public IParserConfiguration Configuration { get; }

Expand All @@ -203,7 +205,10 @@ private string[] GetRecord()
{
var currentRow = _worksheet.Row(Row);
var cells = currentRow.Cells(1, Count);
var values = cells.Select(x => x.Value.ToString()).ToArray();
var values = Configuration.TrimOptions.HasFlag(TrimOptions.Trim)
? cells.Select(x => x.Value.ToString()?.Trim()).ToArray()
: cells.Select(x => x.Value.ToString()).ToArray();

return values;
}
}
Expand Down
Loading

0 comments on commit 0e3b333

Please sign in to comment.