diff --git a/README.md b/README.md index f59277c..9450445 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Cake Addin for working with CSV files using the CSVHelper library. [![License](http://img.shields.io/:license-apache-blue.svg)](https://github.com/RadioSystems/Cake.CsvHelper/blob/master/LICENSE) +## Give a Star! :star: + +If you like or are using this project please give it a star. Thanks! + ## Information | | Stable | Pre-release | @@ -41,3 +45,13 @@ On Windows PowerShell run: ```powershell ./build ``` + +## Discussion + +For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category. + +[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions) + +## Release History + +Click on the [Releases](https://github.com/cake-contrib/Cake.ISO/releases) tab on GitHub. diff --git a/nuspec/nuget/Cake.CsvHelper.nuspec b/nuspec/nuget/Cake.CsvHelper.nuspec index d781083..b23f525 100644 --- a/nuspec/nuget/Cake.CsvHelper.nuspec +++ b/nuspec/nuget/Cake.CsvHelper.nuspec @@ -1,5 +1,6 @@ - + Cake.CsvHelper 0.0.0 @@ -9,16 +10,25 @@ A set of aliases for Cake to help with running Gulp scripts as part of a build. https://github.com/RadioSystems/Cake.CsvHelper/blob/master/LICENSE https://github.com/RadioSystems/Cake.CsvHelper - https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png + https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/addin/cake-contrib-addin-medium.png false Copyright (c) Radio Systems Corporation 2017 - Present - Cake, Script, Build, CsvHelper, CSV, Addin + + + + cake csv-helper csvhelper csv cake-addin cake-build cake-contrib addin script build - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.CsvHelper.Tests/Cake.CsvHelper.Tests.csproj b/src/Cake.CsvHelper.Tests/Cake.CsvHelper.Tests.csproj index 3188e97..1baa3c3 100644 --- a/src/Cake.CsvHelper.Tests/Cake.CsvHelper.Tests.csproj +++ b/src/Cake.CsvHelper.Tests/Cake.CsvHelper.Tests.csproj @@ -1,157 +1,27 @@ - - - - + + - Debug - AnyCPU - {1691864A-29DA-4ED9-A2C1-3EE39D006F51} - Library - Properties - Cake.CsvHelper.Tests - Cake.CsvHelper.Tests - v4.6.1 - 512 - - - + net461;netcoreapp3.1;net5.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Cake.Core.0.23.0\lib\net46\Cake.Core.dll - - - ..\packages\Cake.Testing.0.23.0\lib\net46\Cake.Testing.dll - - - ..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll - - - ..\packages\CsvHelper.6.0.0\lib\net45\CsvHelper.dll - - - ..\packages\NSubstitute.3.1.0\lib\net46\NSubstitute.dll - - - ..\packages\Should.1.1.20\lib\Should.dll - True - - - - - - - ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll - True - - - ..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll - - - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - - - ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net461\System.Security.Cryptography.Algorithms.dll - - - ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - - - ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - - - ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - - - - - - ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll - - - ..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll - - - - - - - - - True - True - Resources.resx - - - - - {85c3e531-f53b-4344-9456-1b0176e547da} - Cake.CsvHelper - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - + - - + + - + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - + \ No newline at end of file diff --git a/src/Cake.CsvHelper.Tests/CsvHelperAliasesTests.cs b/src/Cake.CsvHelper.Tests/CsvHelperAliasesTests.cs index 76bdd96..02f39b5 100644 --- a/src/Cake.CsvHelper.Tests/CsvHelperAliasesTests.cs +++ b/src/Cake.CsvHelper.Tests/CsvHelperAliasesTests.cs @@ -4,7 +4,7 @@ using Cake.Core.IO; using Cake.CsvHelper.Tests.Fixtures; using NSubstitute; -using Should; +using Shouldly; using Xunit; namespace Cake.CsvHelper.Tests { @@ -19,7 +19,7 @@ public void Should_Throw_If_Context_Is_Null() { var result = Record.Exception(() => CsvHelperAliases.ReadCsv(null, file.Path)); // Then - result.ShouldBeType().ParamName.ShouldEqual("context"); + result.ShouldBeOfType().ParamName.ShouldBe("context"); } [Fact] @@ -33,7 +33,7 @@ public void Should_Throw_If_CSV_File_Is_Null() { var result = Record.Exception(() => CsvHelperAliases.ReadCsv(context, null)); // Then - result.ShouldBeType().ParamName.ShouldEqual("csvFile"); + result.ShouldBeOfType().ParamName.ShouldBe("csvFile"); } } @@ -47,7 +47,7 @@ public void Should_Throw_If_Context_Is_Null() { var result = Record.Exception(() => CsvHelperAliases.WriteCsv(null, file.Path, new List())); // Then - result.ShouldBeType().ParamName.ShouldEqual("context"); + result.ShouldBeOfType().ParamName.ShouldBe("context"); } } } diff --git a/src/Cake.CsvHelper.Tests/CsvHelperTests.cs b/src/Cake.CsvHelper.Tests/CsvHelperTests.cs index a3dc40b..16b3092 100644 --- a/src/Cake.CsvHelper.Tests/CsvHelperTests.cs +++ b/src/Cake.CsvHelper.Tests/CsvHelperTests.cs @@ -4,9 +4,8 @@ using Cake.Core.IO; using Cake.CsvHelper.Tests.Fixtures; using Cake.CsvHelper.Tests.Properties; -using Should; +using Shouldly; using Xunit; -using Xunit.Sdk; namespace Cake.CsvHelper.Tests { public sealed class CsvHelperTests { @@ -20,20 +19,20 @@ public void Should_Throw_If_CsvFile_Is_Null() { var result = Record.Exception(() => fixture.Read()); // Then - result.ShouldBeType().ParamName.ShouldEqual("csvFile"); + result.ShouldBeOfType().ParamName.ShouldBe("csvFile"); } [Fact] public void Should_Throw_If_Settings_Are_Null() { // Given var fixture = new CsvHelpersFixture(); - fixture.Settings = null; + fixture.Configuration = null; // When var result = Record.Exception(() => fixture.Read()); // Then - result.ShouldBeType().ParamName.ShouldEqual("settings"); + result.ShouldBeOfType().ParamName.ShouldBe("configuration"); } [Fact] @@ -46,7 +45,7 @@ public void Should_Throw_If_File_Does_Not_Exist() { var result = Record.Exception(() => fixture.Read()); // Then - result.ShouldBeType(); + result.ShouldBeOfType(); } } @@ -61,7 +60,7 @@ public void Should_Throw_If_CsvFile_Is_Null() { var result = Record.Exception(() => fixture.WriteNoMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("csvFile"); + result.ShouldBeOfType().ParamName.ShouldBe("csvFile"); } [Fact] @@ -73,20 +72,20 @@ public void Should_Throw_If_Records_Are_Null() { var result = Record.Exception(() => fixture.WriteNoMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("records"); + result.ShouldBeOfType().ParamName.ShouldBe("records"); } [Fact] public void Should_Throw_If_Settings_Are_Null() { // Given var fixture = new CsvHelpersFixture(); - fixture.Settings = null; + fixture.Configuration = null; // When var result = Record.Exception(() => fixture.WriteNoMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("settings"); + result.ShouldBeOfType().ParamName.ShouldBe("configuration"); } [Fact(Skip = "Experimental")] @@ -99,12 +98,12 @@ public void Should_Write_Records_To_CsvFile_With_No_Map() { // Then var resultFile = fixture.FileSystem.GetFile(fixture.ResultPath); - resultFile.Exists.ShouldEqual(true); + resultFile.Exists.ShouldBeTrue(); string resultString; using(var resultStream = resultFile.OpenRead()) using (var streamReader = new StreamReader(resultStream, Encoding.UTF8)) { resultString = streamReader.ReadToEnd(); - resultString.Trim().ShouldEqual(Resources.CsvHelper_CsvFile.Trim()); + resultString.Trim().ShouldBe(Resources.CsvHelper_CsvFile.Trim()); } } } @@ -120,7 +119,7 @@ public void Should_Throw_If_CsvFile_Is_Null() { var result = Record.Exception(() => fixture.WriteWithMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("csvFile"); + result.ShouldBeOfType().ParamName.ShouldBe("csvFile"); } [Fact] @@ -132,7 +131,7 @@ public void Should_Throw_If_Records_Are_Null() { var result = Record.Exception(() => fixture.WriteWithMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("records"); + result.ShouldBeOfType().ParamName.ShouldBe("records"); } [Fact] @@ -144,7 +143,7 @@ public void Should_Throw_If_ClassMap_Is_Null() { var result = Record.Exception(() => fixture.WriteWithMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("classMap"); + result.ShouldBeOfType().ParamName.ShouldBe("classMap"); } [Fact] @@ -156,20 +155,20 @@ public void Should_Throw_If_Mapping_Is_Null() { var result = Record.Exception(() => fixture.WriteWithMapping(true)); // Then - result.ShouldBeType().ParamName.ShouldEqual("mapping"); + result.ShouldBeOfType().ParamName.ShouldBe("mapping"); } [Fact] public void Should_Throw_If_Settings_Are_Null() { // Given var fixture = new CsvHelpersFixture(); - fixture.Settings = null; + fixture.Configuration = null; // When var result = Record.Exception(() => fixture.WriteWithMapping()); // Then - result.ShouldBeType().ParamName.ShouldEqual("settings"); + result.ShouldBeOfType().ParamName.ShouldBe("configuration"); } [Fact(Skip = "Experimental")] @@ -182,13 +181,13 @@ public void Should_Write_Records_To_CsvFile_With_Class_Map() { // Then var resultFile = fixture.FileSystem.GetFile(fixture.ResultPath); - resultFile.Exists.ShouldEqual(true); + resultFile.Exists.ShouldBeTrue(); string resultString; using (var resultStream = resultFile.OpenRead()) using (var streamReader = new StreamReader(resultStream, Encoding.UTF8)) { resultString = streamReader.ReadToEnd(); } - resultString.Trim().ShouldEqual(Resources.CsvHelper_MappedFile.Trim()); + resultString.Trim().ShouldBe(Resources.CsvHelper_MappedFile.Trim()); } [Fact(Skip = "Experimental")] @@ -201,13 +200,13 @@ public void Should_Write_Records_To_CsvFile_With_Dictionary_Map() { // Then var resultFile = fixture.FileSystem.GetFile(fixture.ResultPath); - resultFile.Exists.ShouldEqual(true); + resultFile.Exists.ShouldBeTrue(); string resultString; using (var resultStream = resultFile.OpenRead()) using (var streamReader = new StreamReader(resultStream, Encoding.UTF8)) { resultString = streamReader.ReadToEnd(); } - resultString.Trim().ShouldEqual(Resources.CsvHelper_MappedFile.Trim()); + resultString.Trim().ShouldBe(Resources.CsvHelper_MappedFile.Trim()); } } } diff --git a/src/Cake.CsvHelper.Tests/Fixtures/CsvHelpersFixture.cs b/src/Cake.CsvHelper.Tests/Fixtures/CsvHelpersFixture.cs index 1d99a20..5637ee7 100644 --- a/src/Cake.CsvHelper.Tests/Fixtures/CsvHelpersFixture.cs +++ b/src/Cake.CsvHelper.Tests/Fixtures/CsvHelpersFixture.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Globalization; using Cake.Core; using Cake.Core.IO; using Cake.CsvHelper.Tests.Properties; @@ -12,13 +13,13 @@ internal sealed class CsvHelpersFixture { public ICakeContext Context { get; set; } public FilePath CsvFilePath { get; set; } public FilePath ResultPath { get; set; } - public CsvHelperSettings Settings { get; set; } + public CsvConfiguration Configuration { get; set; } public List People { get; set; } public Dictionary DictionaryMap { get; set; } public ClassMap ClassMap { get; set; } public CsvHelpersFixture(bool csvFileExists = true, bool peopleExists = true) { - Settings = new CsvHelperSettings(); + Configuration = new CsvConfiguration(CultureInfo.InvariantCulture); ClassMap = new PersonMap(); @@ -54,21 +55,21 @@ public CsvHelpersFixture(bool csvFileExists = true, bool peopleExists = true) { public void Read() { var csvHelper = new CsvHelpers(Context.FileSystem, Context.Environment); - csvHelper.ReadRecords(CsvFilePath, null, Settings); + csvHelper.ReadRecords(CsvFilePath, null, Configuration); } public void WriteNoMapping() { var csvHelper = new CsvHelpers(Context.FileSystem, Context.Environment); - csvHelper.WriteRecords(ResultPath, People, Settings); + csvHelper.WriteRecords(ResultPath, People, Configuration); } public void WriteWithMapping(bool useDictionaryMapping = false) { var csvHelper = new CsvHelpers(Context.FileSystem, Context.Environment); if (useDictionaryMapping) { - csvHelper.WriteRecords(ResultPath, People, DictionaryMap, Settings); + csvHelper.WriteRecords(ResultPath, People, DictionaryMap, Configuration); } else { - csvHelper.WriteRecords(ResultPath, People, ClassMap, Settings); + csvHelper.WriteRecords(ResultPath, People, ClassMap, Configuration); } } } diff --git a/src/Cake.CsvHelper.Tests/Properties/AssemblyInfo.cs b/src/Cake.CsvHelper.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index cf8c6fd..0000000 --- a/src/Cake.CsvHelper.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Cake.CsvHelper.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cake.CsvHelper.Tests")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1691864a-29da-4ed9-a2c1-3ee39d006f51")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Cake.CsvHelper.Tests/app.config b/src/Cake.CsvHelper.Tests/app.config deleted file mode 100644 index 7d8c922..0000000 --- a/src/Cake.CsvHelper.Tests/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.CsvHelper.Tests/packages.config b/src/Cake.CsvHelper.Tests/packages.config deleted file mode 100644 index ccf02bd..0000000 --- a/src/Cake.CsvHelper.Tests/packages.config +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.CsvHelper/Cake.CsvHelper.csproj b/src/Cake.CsvHelper/Cake.CsvHelper.csproj index 1152c16..9c0ba45 100644 --- a/src/Cake.CsvHelper/Cake.CsvHelper.csproj +++ b/src/Cake.CsvHelper/Cake.CsvHelper.csproj @@ -1,68 +1,13 @@ - - - + + - Debug - AnyCPU - {85C3E531-F53B-4344-9456-1B0176E547DA} - Library - Properties - Cake.CsvHelper - Cake.CsvHelper - v4.6.1 - 512 - + net461;netstandard2.0;net5.0 + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Cake.CsvHelper.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Cake.CsvHelper.XML - - - - ..\packages\Cake.Core.0.23.0\lib\net46\Cake.Core.dll - - - ..\packages\CsvHelper.6.0.0\lib\net45\CsvHelper.dll - - - - - - - - - - - - - - - - - - + + + + - - + \ No newline at end of file diff --git a/src/Cake.CsvHelper/CsvHelperAliases.cs b/src/Cake.CsvHelper/CsvHelperAliases.cs index abcc2c2..2e4daa8 100644 --- a/src/Cake.CsvHelper/CsvHelperAliases.cs +++ b/src/Cake.CsvHelper/CsvHelperAliases.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using Cake.Core; using Cake.Core.Annotations; using Cake.Core.IO; @@ -8,7 +9,7 @@ namespace Cake.CsvHelper { /// - /// Contians functionality related to reading and writing CSV files. + /// Contains functionality related to reading and writing CSV files. /// [CakeAliasCategory("CsvHelper")] public static class CsvHelperAliases @@ -28,8 +29,8 @@ public static class CsvHelperAliases [CakeMethodAlias] [CakeAliasCategory("ReadCsv")] public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile) { - var settings = new CsvHelperSettings(); - return ReadCsv(context, csvFile, null, settings); + var configuration = new CsvConfiguration(CultureInfo.InvariantCulture); + return ReadCsv(context, csvFile, null, configuration); } /// @@ -38,7 +39,7 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF /// The type. /// The context. /// The CSV to read. - /// The settings. + /// The configuration. /// List objects as defined by type. /// /// @@ -47,8 +48,8 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF /// [CakeMethodAlias] [CakeAliasCategory("ReadCsv")] - public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile, CsvHelperSettings settings) { - return ReadCsv(context, csvFile, null, settings); + public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile, CsvConfiguration configuration) { + return ReadCsv(context, csvFile, null, configuration); } /// @@ -69,8 +70,8 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF [CakeNamespaceImport("CsvHelper.Configuration.CsvClassMap")] public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile, ClassMap classMap) { - var settings = new CsvHelperSettings(); - return ReadCsv(context, csvFile, classMap, settings); + var configuration = new CsvConfiguration(CultureInfo.InvariantCulture); + return ReadCsv(context, csvFile, classMap, configuration); } /// @@ -80,7 +81,7 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF /// The context. /// The CSV to read. /// The CSV class map. - /// The settings. + /// The configuration. /// List objects as defined by type. /// /// @@ -90,18 +91,18 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF [CakeMethodAlias] [CakeAliasCategory("ReadCsv")] [CakeNamespaceImport("CsvHelper.Configuration.CsvClassMap")] - public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile, ClassMap classMap, CsvHelperSettings settings) + public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvFile, ClassMap classMap, CsvConfiguration configuration) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var csvHelpers = new CsvHelpers(context.FileSystem, context.Environment); - return csvHelpers.ReadRecords(csvFile, classMap, settings); + return csvHelpers.ReadRecords(csvFile, classMap, configuration); } /// - /// Writes the records to the speficed file using the specified class mapp and settings. + /// Writes the records to the specified file using the specified class map and settings. /// /// The type. /// The context. @@ -117,18 +118,18 @@ public static IEnumerable ReadCsv(this ICakeContext context, FilePath csvF [CakeAliasCategory("WriteCsv")] public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records) { - var settings = new CsvHelperSettings(); - WriteCsv(context, csvFile, records, settings); + var configuration = new CsvConfiguration(CultureInfo.InvariantCulture); + WriteCsv(context, csvFile, records, configuration); } /// - /// Writes the records to the speficed file using the specified class mapp and settings. + /// Writes the records to the specified file using the specified class map and settings. /// /// The type. /// The context. /// The CSV to file to write. /// The list objects you want to write to a csv. - /// The settings. + /// The configuration. /// List objects as defined by type. /// /// @@ -137,25 +138,25 @@ public static void WriteCsv(this ICakeContext context, FilePath csvFile, List /// [CakeMethodAlias] [CakeAliasCategory("WriteCsv")] - public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, CsvHelperSettings settings) + public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, CsvConfiguration configuration) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var csvHelpers = new CsvHelpers(context.FileSystem, context.Environment); - csvHelpers.WriteRecords(csvFile, records, settings); + csvHelpers.WriteRecords(csvFile, records, configuration); } /// - /// Writes the records to the speficed file using the specified class mapp and settings. + /// Writes the records to the specified file using the specified class map and settings. /// /// The type. /// The context. /// The CSV to file to write. /// The list objects you want to write to a csv. /// The property column mapping. - /// The settings. + /// The configuration. /// List objects as defined by type. /// /// @@ -168,25 +169,27 @@ public static void WriteCsv(this ICakeContext context, FilePath csvFile, List /// [CakeMethodAlias] [CakeAliasCategory("WriteCsv")] - public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, Dictionary mapping, CsvHelperSettings settings) + public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, + Dictionary mapping, CsvConfiguration configuration) { if (context == null) { throw new ArgumentNullException(nameof(context)); } + var csvHelpers = new CsvHelpers(context.FileSystem, context.Environment); - csvHelpers.WriteRecords(csvFile, records, mapping, settings); + csvHelpers.WriteRecords(csvFile, records, mapping, configuration); } /// - /// Writes the records to the speficed file using the specified class mapp and settings. + /// Writes the records to the specified file using the specified class map and settings. /// /// The type. /// The context. /// The CSV to file to write. /// The list objects you want to write to a csv. /// The CSV Helper Class Map. - /// The settings. + /// The configuration. /// List objects as defined by type. /// /// @@ -204,14 +207,14 @@ public static void WriteCsv(this ICakeContext context, FilePath csvFile, List [CakeMethodAlias] [CakeAliasCategory("WriteCsv")] [CakeNamespaceImport("CsvHelper.Configuration.CsvClassMap")] - public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, ClassMap classMap, CsvHelperSettings settings) + public static void WriteCsv(this ICakeContext context, FilePath csvFile, List records, ClassMap classMap, CsvConfiguration configuration) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var csvHelpers = new CsvHelpers(context.FileSystem, context.Environment); - csvHelpers.WriteRecords(csvFile,records, classMap, settings); + csvHelpers.WriteRecords(csvFile,records, classMap, configuration); } } } diff --git a/src/Cake.CsvHelper/CsvHelpers.cs b/src/Cake.CsvHelper/CsvHelpers.cs index cc066d1..1691820 100644 --- a/src/Cake.CsvHelper/CsvHelpers.cs +++ b/src/Cake.CsvHelper/CsvHelpers.cs @@ -31,34 +31,34 @@ public CsvHelpers(IFileSystem fileSystem, ICakeEnvironment environment) { /// The record type. /// The CSV file to read. /// The class map to use, null if not needed. - /// The settings. + /// The configuration. /// List of defined type. - public IEnumerable ReadRecords(FilePath csvFile, ClassMap classMap, CsvHelperSettings settings) { + public IEnumerable ReadRecords(FilePath csvFile, ClassMap classMap, CsvConfiguration configuration) { if (csvFile == null) { throw new ArgumentNullException(nameof(csvFile)); } - if (settings == null) { - throw new ArgumentNullException(nameof(settings)); + if (configuration == null) { + throw new ArgumentNullException(nameof(configuration)); } var file = GetFile(csvFile); using (var textReader = new StreamReader(file.OpenRead())) - using (var csvReader = new CsvReader(textReader)) { + using (var csvReader = new CsvReader(textReader, configuration)) { if (classMap != null) { - csvReader.Configuration.RegisterClassMap(classMap); + csvReader.Context.RegisterClassMap(classMap); } return csvReader.GetRecords().ToList(); } } /// - /// Writes the records to the speficed file using the specified class mapp and settings. + /// Writes the records to the specified file using the specified class map and settings. /// /// The record type. /// The CSV file to write. /// The records to write. /// The class map. - /// The settings. - public void WriteRecords(FilePath csvFile, List records, ClassMap classMap, CsvHelperSettings settings) { + /// The configuration. + public void WriteRecords(FilePath csvFile, List records, ClassMap classMap, CsvConfiguration configuration) { if (csvFile == null) { throw new ArgumentNullException(nameof(csvFile)); } @@ -68,15 +68,15 @@ public void WriteRecords(FilePath csvFile, List records, ClassMap classMap if (classMap == null) { throw new ArgumentNullException(nameof(classMap)); } - if (settings == null) { - throw new ArgumentNullException(nameof(settings)); + if (configuration == null) { + throw new ArgumentNullException(nameof(configuration)); } var file = GetFile(csvFile); using (var stream = file.OpenWrite()) - using (var textWriter = new StreamWriter(stream, settings.Encoding)) - using (var csvWriter = new CsvWriter(textWriter)) { - csvWriter.Configuration.RegisterClassMap(classMap); + using (var textWriter = new StreamWriter(stream, configuration.Encoding)) + using (var csvWriter = new CsvWriter(textWriter, configuration)) { + csvWriter.Context.RegisterClassMap(classMap); csvWriter.WriteHeader(); foreach (var record in records) { csvWriter.WriteRecord(record); @@ -86,46 +86,46 @@ public void WriteRecords(FilePath csvFile, List records, ClassMap classMap } /// - /// Writes the records to the speficed file using the specified mapping and settings. + /// Writes the records to the specified file using the specified mapping and settings. /// /// The record type. /// The CSV file to write. /// The records to write. /// The property column mapping. - /// The settings. + /// The configuration. public void WriteRecords(FilePath csvFile, List records, Dictionary mapping, - CsvHelperSettings settings) { + CsvConfiguration configuration) { if (mapping == null) { throw new ArgumentNullException(nameof(mapping)); } var customMap = new DefaultClassMap(); - customMap.AutoMap(); - WriteRecords(csvFile, records, customMap, settings); + customMap.AutoMap(configuration); + WriteRecords(csvFile, records, customMap, configuration); } /// - /// Writes the records to the speficed file using automap and settings. + /// Writes the records to the specified file using automap and settings. /// /// The record type. /// The CSV file to write. /// The records to write. - /// The settings. - public void WriteRecords(FilePath csvFile, List records, CsvHelperSettings settings) { + /// The configuration. + public void WriteRecords(FilePath csvFile, List records, CsvConfiguration configuration) { if (csvFile == null) { throw new ArgumentNullException(nameof(csvFile)); } if (records == null) { throw new ArgumentNullException(nameof(records)); } - if (settings == null) { - throw new ArgumentNullException(nameof(settings)); + if (configuration == null) { + throw new ArgumentNullException(nameof(configuration)); } // Make the path absolute if necessary. var file = GetFile(csvFile); using (var stream = file.OpenWrite()) - using (var textWriter = new StreamWriter(stream, settings.Encoding)) - using (var csvWriter = new CsvWriter(textWriter)) { + using (var textWriter = new StreamWriter(stream, configuration.Encoding)) + using (var csvWriter = new CsvWriter(textWriter, configuration)) { csvWriter.WriteHeader(); foreach (var record in records) { csvWriter.WriteRecord(record); diff --git a/src/Cake.CsvHelper/Properties/AssemblyInfo.cs b/src/Cake.CsvHelper/Properties/AssemblyInfo.cs deleted file mode 100644 index 123232e..0000000 --- a/src/Cake.CsvHelper/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Cake.CsvHelper")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cake.CsvHelper")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("85c3e531-f53b-4344-9456-1b0176e547da")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Cake.CsvHelper/packages.config b/src/Cake.CsvHelper/packages.config deleted file mode 100644 index 4772a52..0000000 --- a/src/Cake.CsvHelper/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file