From e568c71fc80f6bec1ac0886857c353e055d33f46 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 3 Mar 2017 16:13:51 +0000 Subject: [PATCH 01/18] Updating copyright notices to include the year 2017. --- src/StevenVolckaert.Core/project.json | 2 +- test/StevenVolckaert.Core.Tests/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StevenVolckaert.Core/project.json b/src/StevenVolckaert.Core/project.json index 5bcd835..03b8003 100644 --- a/src/StevenVolckaert.Core/project.json +++ b/src/StevenVolckaert.Core/project.json @@ -1,6 +1,6 @@ { "title": "Steven Volckaert's Enterprise Library - Core", - "copyright": "Copyright (c) 2016 Steven Volckaert", + "copyright": "Copyright (c) 2016, 2017 Steven Volckaert", "description": "Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code.\n\nSee https://github.com/stevenvolckaert/enterprise-library for more information.", "language": "en-US", "version": "1.0.0-*", diff --git a/test/StevenVolckaert.Core.Tests/project.json b/test/StevenVolckaert.Core.Tests/project.json index 4882276..3592052 100644 --- a/test/StevenVolckaert.Core.Tests/project.json +++ b/test/StevenVolckaert.Core.Tests/project.json @@ -1,6 +1,6 @@ { "title": "StevenVolckaert.Core.Tests", - "copyright": "Copyright (c) 2016 Steven Volckaert", + "copyright": "Copyright (c) 2016, 2017 Steven Volckaert", "description": "Unit test project for StevenVolckaert.Core.", "language": "en-US", "version": "1.0.0-*", From 423d467a8fd972fb365628ee92a15b1618fff2f7 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Thu, 16 Mar 2017 15:50:58 +0100 Subject: [PATCH 02/18] Upgrading from Visual Studio 2015 to Visual Studio 2017. --- StevenVolckaert.EnterpriseLibrary.sln | 33 +++++++++--------- global.json | 3 -- .../StevenVolckaert.Core.csproj | 34 +++++++++++++++++++ .../StevenVolckaert.Core.xproj | 19 ----------- .../StevenVolckaert.Core.Tests.csproj | 34 +++++++++++++++++++ .../StevenVolckaert.Core.Tests.xproj | 22 ------------ 6 files changed, 84 insertions(+), 61 deletions(-) delete mode 100644 global.json create mode 100644 src/StevenVolckaert.Core/StevenVolckaert.Core.csproj delete mode 100644 src/StevenVolckaert.Core/StevenVolckaert.Core.xproj create mode 100644 test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj delete mode 100644 test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.xproj diff --git a/StevenVolckaert.EnterpriseLibrary.sln b/StevenVolckaert.EnterpriseLibrary.sln index 9559677..8d9694f 100644 --- a/StevenVolckaert.EnterpriseLibrary.sln +++ b/StevenVolckaert.EnterpriseLibrary.sln @@ -1,46 +1,45 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StevenVolckaert.Core", "src\StevenVolckaert.Core\StevenVolckaert.Core.xproj", "{3E5DE170-18C8-4B09-90A6-7D158A6C54C5}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{00269925-9ABB-475F-A63B-B57C55E26CD3}" ProjectSection(SolutionItems) = preProject .gitattributes = .gitattributes .gitignore = .gitignore appveyor.yml = appveyor.yml - global.json = global.json LICENSE = LICENSE README.md = README.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{887100A5-003F-4148-85D8-9D9C9E7E5125}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.xproj", "{A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{54EC9438-05ED-4ACD-AEF6-B31B353069EA}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StevenVolckaert.Core", "src\StevenVolckaert.Core\StevenVolckaert.Core.csproj", "{9493EB60-BD91-426A-BDF1-4390456046E1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.csproj", "{B2222404-4375-458C-9F04-C5F1D279CBA6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3E5DE170-18C8-4B09-90A6-7D158A6C54C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E5DE170-18C8-4B09-90A6-7D158A6C54C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E5DE170-18C8-4B09-90A6-7D158A6C54C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E5DE170-18C8-4B09-90A6-7D158A6C54C5}.Release|Any CPU.Build.0 = Release|Any CPU - {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}.Release|Any CPU.Build.0 = Release|Any CPU + {9493EB60-BD91-426A-BDF1-4390456046E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9493EB60-BD91-426A-BDF1-4390456046E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9493EB60-BD91-426A-BDF1-4390456046E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9493EB60-BD91-426A-BDF1-4390456046E1}.Release|Any CPU.Build.0 = Release|Any CPU + {B2222404-4375-458C-9F04-C5F1D279CBA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2222404-4375-458C-9F04-C5F1D279CBA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2222404-4375-458C-9F04-C5F1D279CBA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2222404-4375-458C-9F04-C5F1D279CBA6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {3E5DE170-18C8-4B09-90A6-7D158A6C54C5} = {54EC9438-05ED-4ACD-AEF6-B31B353069EA} - {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2} = {887100A5-003F-4148-85D8-9D9C9E7E5125} + {9493EB60-BD91-426A-BDF1-4390456046E1} = {54EC9438-05ED-4ACD-AEF6-B31B353069EA} + {B2222404-4375-458C-9F04-C5F1D279CBA6} = {887100A5-003F-4148-85D8-9D9C9E7E5125} EndGlobalSection EndGlobal diff --git a/global.json b/global.json deleted file mode 100644 index 9a66d5e..0000000 --- a/global.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "projects": [ "src", "test" ] -} diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj new file mode 100644 index 0000000..de01bc0 --- /dev/null +++ b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj @@ -0,0 +1,34 @@ + + + + Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code. + +See https://github.com/stevenvolckaert/enterprise-library for more information. + Copyright (c) 2016, 2017 Steven Volckaert + Steven Volckaert's Enterprise Library - Core + en-US + Steven Volckaert + net35;net452;netstandard1.5 + true + StevenVolckaert.Core + StevenVolckaert.Core + https://github.com/stevenvolckaert/enterprise-library + https://github.com/stevenvolckaert/enterprise-library/blob/master/LICENSE + git + https://github.com/stevenvolckaert/enterprise-library + 1.6.1 + false + false + false + + + + + + + + + + + + diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.xproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.xproj deleted file mode 100644 index 6e51fd5..0000000 --- a/src/StevenVolckaert.Core/StevenVolckaert.Core.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 3e5de170-18c8-4b09-90a6-7d158a6c54c5 - StevenVolckaert - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - \ No newline at end of file diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj new file mode 100644 index 0000000..4583a46 --- /dev/null +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -0,0 +1,34 @@ + + + + Unit test project for StevenVolckaert.Core. + Copyright (c) 2016, 2017 Steven Volckaert + StevenVolckaert.Core.Tests + en-US + Steven Volckaert + netcoreapp1.0 + StevenVolckaert.Core.Tests + StevenVolckaert.Core.Tests + true + 1.0.4 + $(PackageTargetFallback);dnxcore50;portable-net45+win8 + false + false + false + + + + + + + + + + + + + + + + + diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.xproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.xproj deleted file mode 100644 index ec4bd4e..0000000 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a97f5579-7d70-4fd4-8d6b-dc12e4909ad2 - StevenVolckaert.Tests - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - - - - \ No newline at end of file From e475bda4fcbb432ff485b4d4d5acaff7aca4b0ec Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 17 Mar 2017 16:41:12 +0100 Subject: [PATCH 03/18] Removing project.json configuration files. They are no longer necessary. --- .../StevenVolckaert.Core.csproj | 1 + src/StevenVolckaert.Core/project.json | 29 ------------------- .../StevenVolckaert.Core.Tests.csproj | 8 ++--- test/StevenVolckaert.Core.Tests/project.json | 29 ------------------- 4 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 src/StevenVolckaert.Core/project.json delete mode 100644 test/StevenVolckaert.Core.Tests/project.json diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj index de01bc0..9807c7b 100644 --- a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj +++ b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj @@ -20,6 +20,7 @@ See https://github.com/stevenvolckaert/enterprise-library for more information.< false false false + StevenVolckaert diff --git a/src/StevenVolckaert.Core/project.json b/src/StevenVolckaert.Core/project.json deleted file mode 100644 index 03b8003..0000000 --- a/src/StevenVolckaert.Core/project.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "title": "Steven Volckaert's Enterprise Library - Core", - "copyright": "Copyright (c) 2016, 2017 Steven Volckaert", - "description": "Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code.\n\nSee https://github.com/stevenvolckaert/enterprise-library for more information.", - "language": "en-US", - "version": "1.0.0-*", - "authors": [ "Steven Volckaert" ], - "frameworks": { - "net35": {}, - "net452": {}, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.1" - } - } - }, - "buildOptions": { - "xmlDoc": true - }, - "packOptions": { - "projectUrl": "https://github.com/stevenvolckaert/enterprise-library", - "repository": { - "type": "git", - "url": "https://github.com/stevenvolckaert/enterprise-library" - }, - "licenseUrl": "https://github.com/stevenvolckaert/enterprise-library/blob/master/LICENSE", - "requireLicenseAcceptance": false - } -} diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj index 4583a46..f0df052 100644 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -18,13 +18,13 @@ - + + + - - - + diff --git a/test/StevenVolckaert.Core.Tests/project.json b/test/StevenVolckaert.Core.Tests/project.json deleted file mode 100644 index 3592052..0000000 --- a/test/StevenVolckaert.Core.Tests/project.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "title": "StevenVolckaert.Core.Tests", - "copyright": "Copyright (c) 2016, 2017 Steven Volckaert", - "description": "Unit test project for StevenVolckaert.Core.", - "language": "en-US", - "version": "1.0.0-*", - "authors": [ "Steven Volckaert" ], - - "testRunner": "mstest", - - "dependencies": { - "StevenVolckaert.Core": "0.1.1-*", - "dotnet-test-mstest": "1.1.2-preview", - "Microsoft.NETCore.App": { - "version": "1.0.1", - "type": "platform" - }, - "MSTest.TestFramework": "1.0.7-preview" - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - } -} From 6295bc90f14599e4c21fde0309a1fb38ddbea60c Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 17 Mar 2017 16:41:40 +0100 Subject: [PATCH 04/18] Ensuring the Visual Studio 2017 image is used when building. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 26c76a1..01bb93e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ configuration: - Release platform: Any CPU environment: + image: Visual Studio 2017 DOTNET_CLI_TELEMETRY_OPTOUT: 1 init: - ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") From c050d5b16a67e3e9e5e64be5ddf27d5333098bef Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sat, 18 Mar 2017 18:22:09 +0100 Subject: [PATCH 05/18] Temporarily dropping support for .NETFramework 3.5. The current version of the dotnet CLI tooling contains a bug causing the build of this target to fail, breaking CI builds. See https://github.com/Microsoft/msbuild/issues/1333 for more information. --- appveyor.yml | 6 +++--- .../StevenVolckaert.Core.csproj | 12 +++++++----- .../Properties/AssemblyInfo.cs | 15 --------------- .../StevenVolckaert.Core.Tests.csproj | 15 +-------------- 4 files changed, 11 insertions(+), 37 deletions(-) delete mode 100644 test/StevenVolckaert.Core.Tests/Properties/AssemblyInfo.cs diff --git a/appveyor.yml b/appveyor.yml index 01bb93e..d302312 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,12 +9,12 @@ environment: image: Visual Studio 2017 DOTNET_CLI_TELEMETRY_OPTOUT: 1 init: -- ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") +- ps: $Env:VERSION_SUFFIX = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") before_build: - appveyor-retry dotnet restore -v Minimal build_script: -- dotnet build "src\StevenVolckaert.Core" -c %CONFIGURATION% --no-dependencies --version-suffix %LABEL% +- dotnet build "src\StevenVolckaert.Core" -c %CONFIGURATION% --version-suffix %VERSION_SUFFIX% test_script: -- dotnet test "test\StevenVolckaert.Core.Tests" -c %CONFIGURATION% +- dotnet test "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.csproj" -c %CONFIGURATION% cache: - '%USERPROFILE%\.nuget\packages' diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj index 9807c7b..1d8e7b7 100644 --- a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj +++ b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj @@ -1,16 +1,18 @@  + StevenVolckaert.Core + Steven Volckaert's Enterprise Library - Core + en-US + 1.0.1 + alpha + Copyright (c) 2016, 2017 Steven Volckaert Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code. See https://github.com/stevenvolckaert/enterprise-library for more information. - Copyright (c) 2016, 2017 Steven Volckaert - Steven Volckaert's Enterprise Library - Core - en-US Steven Volckaert - net35;net452;netstandard1.5 + net452;netstandard1.5 true - StevenVolckaert.Core StevenVolckaert.Core https://github.com/stevenvolckaert/enterprise-library https://github.com/stevenvolckaert/enterprise-library/blob/master/LICENSE diff --git a/test/StevenVolckaert.Core.Tests/Properties/AssemblyInfo.cs b/test/StevenVolckaert.Core.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 8a72bfd..0000000 --- a/test/StevenVolckaert.Core.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -#if DEBUG -[assembly: AssemblyConfiguration("Debug")] -#else -[assembly: AssemblyConfiguration("Release")] -#endif - -[assembly: AssemblyCompany("Steven Volckaert")] -[assembly: AssemblyProduct("StevenVolckaert.Core.Tests")] -[assembly: AssemblyTrademark("")] - -[assembly: ComVisible(false)] -[assembly: Guid("a97f5579-7d70-4fd4-8d6b-dc12e4909ad2")] diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj index f0df052..267c7d4 100644 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -1,20 +1,7 @@  - Unit test project for StevenVolckaert.Core. - Copyright (c) 2016, 2017 Steven Volckaert - StevenVolckaert.Core.Tests - en-US - Steven Volckaert - netcoreapp1.0 - StevenVolckaert.Core.Tests - StevenVolckaert.Core.Tests - true - 1.0.4 - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - false - false - false + netcoreapp1.1 From 6ede5eba2c5af2c129f78e48bbed002d7628b5a0 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sat, 18 Mar 2017 18:27:26 +0100 Subject: [PATCH 06/18] Removing AssemblyInfo; this seems to be redundant for .NET Core class libraries. --- .../Properties/AssemblyInfo.cs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/StevenVolckaert.Core/Properties/AssemblyInfo.cs diff --git a/src/StevenVolckaert.Core/Properties/AssemblyInfo.cs b/src/StevenVolckaert.Core/Properties/AssemblyInfo.cs deleted file mode 100644 index 78bab0d..0000000 --- a/src/StevenVolckaert.Core/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -#if DEBUG -[assembly: AssemblyConfiguration("Debug")] -#else -[assembly: AssemblyConfiguration("Release")] -#endif - -[assembly: AssemblyCompany("Steven Volckaert")] -[assembly: AssemblyProduct("StevenVolckaert.Core")] -[assembly: AssemblyTrademark("")] - -[assembly: ComVisible(false)] -[assembly: Guid("3e5de170-18c8-4b09-90a6-7d158a6c54c5")] From 07688528b8bf29d40969fefe5ba52dd8d4423d4f Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 5 Apr 2017 16:43:53 +0100 Subject: [PATCH 07/18] Overloading the ICollection.AddRange(IEnumerable) method with a version that accepts a boolean 'isDistinct' parameter. Also adding unit tests. --- .../ICollectionExtensions.cs | 44 ++++++++++++++++-- .../IEnumerableExtensions.cs | 14 +++--- .../ICollectionExtensionsTests.cs | 45 +++++++++++++++++++ .../StevenVolckaert.Core.Tests.csproj | 1 + 4 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 test/StevenVolckaert.Core.Tests/ICollectionExtensionsTests.cs diff --git a/src/StevenVolckaert.Core/ICollectionExtensions.cs b/src/StevenVolckaert.Core/ICollectionExtensions.cs index 6a804fd..b0ce69b 100644 --- a/src/StevenVolckaert.Core/ICollectionExtensions.cs +++ b/src/StevenVolckaert.Core/ICollectionExtensions.cs @@ -5,7 +5,8 @@ using System.Linq; /// - /// Provides extension methods for instances that implement the interface. + /// Provides extension methods for instances that implement the + /// interface. /// public static class ICollectionExtensions { @@ -27,8 +28,40 @@ IEnumerable sourceCollection if (source == null) throw new ArgumentNullException(nameof(source)); - if (sourceCollection != null) - foreach (TSource value in sourceCollection) + source.AddRange(sourceCollection, isDistinct: false); + } + + /// + /// Adds the elements of the specified collection to the end of the + /// instance. + /// + /// The type of elements of . + /// The target data collection. + /// + /// A value that indicates whether to skip adding elements from + /// that already contains, + /// using the default equality comparer. + /// + /// + /// The collection whose elements should be added to the instance. + /// + /// is null. + public static void AddRange( + this ICollection source, + IEnumerable sourceCollection, + bool isDistinct + ) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (sourceCollection == null) + return; + + foreach (TSource value in sourceCollection) + if (isDistinct && source.Contains(value)) + continue; + else source.Add(value); } @@ -42,7 +75,10 @@ IEnumerable sourceCollection /// /// or is null. /// - public static void RemoveFirst(this ICollection source, Func predicate) + public static void RemoveFirst( + this ICollection source, + Func predicate + ) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/src/StevenVolckaert.Core/IEnumerableExtensions.cs b/src/StevenVolckaert.Core/IEnumerableExtensions.cs index 04e817c..a35797e 100644 --- a/src/StevenVolckaert.Core/IEnumerableExtensions.cs +++ b/src/StevenVolckaert.Core/IEnumerableExtensions.cs @@ -8,7 +8,8 @@ #endif /// - /// Provides extension methods for instances that implement the interface. + /// Provides extension methods for instances that implement the + /// interface. /// public static class IEnumerableExtensions { @@ -17,7 +18,9 @@ public static class IEnumerableExtensions /// /// The type of the elements of . /// The instance to check for emptiness. - /// true if the source sequence contains no elements; otherwise, false. + /// + /// true if the source sequence contains no elements; otherwise, false. + /// /// is null. public static bool Empty(this IEnumerable source) { @@ -253,8 +256,8 @@ public static IEnumerable SkipLast(this IEnumerable source) /// The sequence to remove elements from. /// The number of elements to remove. /// - /// An instance that doesn't contain the specified number of elements at - /// the end of the input sequence. + /// An instance that doesn't contain the specified number of elements + /// at the end of the input sequence. /// /// /// is null. @@ -285,7 +288,8 @@ public static IEnumerable SkipLast(this IEnumerable source, int count) /// The type of the elements of . /// The sequence to create an from. /// - /// An instance that contains elements from the input sequence. + /// An instance that contains elements from the input + /// sequence. /// /// /// is null. diff --git a/test/StevenVolckaert.Core.Tests/ICollectionExtensionsTests.cs b/test/StevenVolckaert.Core.Tests/ICollectionExtensionsTests.cs new file mode 100644 index 0000000..c0053ac --- /dev/null +++ b/test/StevenVolckaert.Core.Tests/ICollectionExtensionsTests.cs @@ -0,0 +1,45 @@ +namespace StevenVolckaert.Tests +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class ICollectionExtensionsTests + { + [TestMethod] + public void AddRangeTest() + { + var source = new List { "foo", "bar", "baz" }; + var other = new List { "bar", "foo", "qux" }; + var expected = new List { "foo", "bar", "baz", "bar", "foo", "qux" }; + + source.AddRange(other); + + CollectionAssert.AreEqual(expected, source); + } + + [TestMethod] + public void AddRangeIndistinctTest() + { + var source = new List { "foo", "bar", "baz" }; + var other = new List { "bar", "foo", "qux" }; + var expected = new List { "foo", "bar", "baz", "bar", "foo", "qux" }; + + source.AddRange(other, isDistinct: false); + + CollectionAssert.AreEqual(expected, source); + } + + [TestMethod] + public void AddRangeDistinctTest() + { + var source = new List { "foo", "bar", "baz" }; + var other = new List { "bar", "foo", "qux" }; + var expected = new List { "foo", "bar", "baz", "qux" }; + + source.AddRange(other, isDistinct: true); + + CollectionAssert.AreEqual(expected, source); + } + } +} diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj index 267c7d4..be93756 100644 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -2,6 +2,7 @@ netcoreapp1.1 + StevenVolckaert.Tests From 5cb004ad431725e83fd80c0bee959d6a657c83aa Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 21 Apr 2017 17:08:20 +0200 Subject: [PATCH 08/18] Renaming string.DefaultIfNullOrEmpty(string) and string.DefaultIfNullOrWhiteSpace(string) to string.FallbackIfNullOrEmpty(string) and string.FallbackIfNullOrWhiteSpace(string), respectively. --- .../IDictionaryExtensions.cs | 21 ++++++------ src/StevenVolckaert.Core/StringExtensions.cs | 34 +++++++++++++++++-- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/StevenVolckaert.Core/IDictionaryExtensions.cs b/src/StevenVolckaert.Core/IDictionaryExtensions.cs index f78514f..da46fb9 100644 --- a/src/StevenVolckaert.Core/IDictionaryExtensions.cs +++ b/src/StevenVolckaert.Core/IDictionaryExtensions.cs @@ -7,8 +7,8 @@ #endif /// - /// Provides extension methods for instances that implement the - /// interface. + /// Provides extension methods for instances that implement the + /// interface. /// public static class IDictionaryExtensions { @@ -34,8 +34,8 @@ this IDictionary dictionary #endif /// - /// Gets the value associated with the specified key, or the type's default value if the key - /// doesn't exist. + /// Gets the value associated with the specified key, + /// or the type's default value if the key doesn't exist. /// /// The type of keys in the dictionary. /// The type of values in the dictionary. @@ -55,11 +55,12 @@ public static TValue TryGetValue(this IDictionary di if (key == null) throw new ArgumentNullException(nameof(key)); - return dictionary.TryGetValue(key, defaultValue: default(TValue)); + return dictionary.TryGetValue(key, fallbackValue: default(TValue)); } /// - /// Gets the value associated with the specified key, or a default value if the key doesn't exist. + /// Gets the value associated with the specified key, + /// or a specified fallback value if the key doesn't exist. /// /// The type of keys in the dictionary. /// The type of values in the dictionary. @@ -67,15 +68,15 @@ public static TValue TryGetValue(this IDictionary di /// The instance this extension method affects. /// /// The key whose value to get. - /// The default value. + /// The default value. /// - /// The value associated with the specified key, or if + /// The value associated with the specified key, or if /// doesn't exist. /// public static TValue TryGetValue( this IDictionary dictionary, TKey key, - TValue defaultValue + TValue fallbackValue ) { if (dictionary == null) @@ -84,7 +85,7 @@ TValue defaultValue if (key == null) throw new ArgumentNullException(nameof(key)); - return dictionary.ContainsKey(key) ? dictionary[key] : defaultValue; + return dictionary.ContainsKey(key) ? dictionary[key] : fallbackValue; } } } diff --git a/src/StevenVolckaert.Core/StringExtensions.cs b/src/StevenVolckaert.Core/StringExtensions.cs index 8edda45..4cbed9a 100644 --- a/src/StevenVolckaert.Core/StringExtensions.cs +++ b/src/StevenVolckaert.Core/StringExtensions.cs @@ -57,9 +57,23 @@ public static bool IsNullOrWhiteSpace(this string value) /// /// The string, or the default value if the string is null or empty. /// + [Obsolete("Use of this method is deprecated. Use string.FallbackIfNullOrEmpty(string) instead.")] public static string DefaultIfNullOrEmpty(this string value, string defaultValue) { - return string.IsNullOrEmpty(value) ? defaultValue : value; + return value.FallbackIfNullOrWhiteSpace(defaultValue); + } + + /// + /// Returns the string, or a specified fallback value if the string is null or empty. + /// + /// The value this extension method affects. + /// The default value. + /// + /// The string, or if the string is null or empty. + /// + public static string FallbackIfNullOrEmpty(this string value, string fallbackValue) + { + return string.IsNullOrEmpty(value) ? fallbackValue : value; } /// @@ -70,9 +84,25 @@ public static string DefaultIfNullOrEmpty(this string value, string defaultValue /// /// The string, or the default value if the string is null, empty, or white space. /// + [Obsolete("Use of this method is deprecated. Use string.FallbackIfNullOrWhiteSpace(string) instead.")] public static string DefaultIfNullOrWhiteSpace(this string value, string defaultValue) { - return value.IsNullOrWhiteSpace() ? defaultValue : value; + return value.FallbackIfNullOrWhiteSpace(defaultValue); + } + + /// + /// Returns the string, + /// or a specified fallback value if the string is null, empty, or white space. + /// + /// The value this extension method affects. + /// The default value. + /// + /// The string, or if the string is null, empty, + /// or white space. + /// + public static string FallbackIfNullOrWhiteSpace(this string value, string fallbackValue) + { + return value.IsNullOrWhiteSpace() ? fallbackValue : value; } /// From ebf8fd74d7dfa8851ee74d1f7e9085ca6a94c3ae Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 28 Apr 2017 08:57:23 +0200 Subject: [PATCH 09/18] Renaming extension method IEnumerable.Empty() to IsEmpty(). --- .../IEnumerableExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/StevenVolckaert.Core/IEnumerableExtensions.cs b/src/StevenVolckaert.Core/IEnumerableExtensions.cs index a35797e..5f9d70a 100644 --- a/src/StevenVolckaert.Core/IEnumerableExtensions.cs +++ b/src/StevenVolckaert.Core/IEnumerableExtensions.cs @@ -22,6 +22,24 @@ public static class IEnumerableExtensions /// true if the source sequence contains no elements; otherwise, false. /// /// is null. + public static bool IsEmpty(this IEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return !source.Any(); + } + + /// + /// Determines whether a sequence contains no elements. + /// + /// The type of the elements of . + /// The instance to check for emptiness. + /// + /// true if the source sequence contains no elements; otherwise, false. + /// + /// is null. + [Obsolete("Use of this method is deprecated. Use IEnumerable.IsEmpty() instead.")] public static bool Empty(this IEnumerable source) { if (source == null) From 196b3bd7ce578ce5cc931bdfca6b39b791e6e1a8 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 12 May 2017 08:38:53 +0200 Subject: [PATCH 10/18] Removing .ToList() operation: Transforming into a list is not necessary here. --- src/StevenVolckaert.Core/StringExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/StevenVolckaert.Core/StringExtensions.cs b/src/StevenVolckaert.Core/StringExtensions.cs index 4cbed9a..a36154d 100644 --- a/src/StevenVolckaert.Core/StringExtensions.cs +++ b/src/StevenVolckaert.Core/StringExtensions.cs @@ -119,8 +119,7 @@ public static string FirstFromSplit(this string value, params string[] separator if (string.IsNullOrEmpty(value)) return null; - var values = value.Split(separators, StringSplitOptions.RemoveEmptyEntries).ToList(); - return values.FirstOrDefault(); + return value.Split(separators, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); } /// From 1ef427a49a8497eb53c1b737ef588fe389635968 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 2 Jun 2017 17:19:43 +0200 Subject: [PATCH 11/18] Updating naming of 'meter' to its plural form 'meters', where appropriate. --- src/StevenVolckaert.Core/UnitConvert.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/StevenVolckaert.Core/UnitConvert.cs b/src/StevenVolckaert.Core/UnitConvert.cs index a067203..1aec7ad 100644 --- a/src/StevenVolckaert.Core/UnitConvert.cs +++ b/src/StevenVolckaert.Core/UnitConvert.cs @@ -52,41 +52,41 @@ public static int FromFahrenheitToCelsius(double value) } /// - /// Converts a value in feet to its equivalent in meter. + /// Converts a value in feet to its equivalent in meters. /// /// The value to convert. - /// The value in meter. - public static double FromFeetToMeter(int value) + /// The value in meters. + public static double FromFeetToMeters(int value) { - return FromFeetToMeter((double)value); + return FromFeetToMeters((double)value); } /// - /// Converts a value in feet to its equivalent in meter. + /// Converts a value in feet to its equivalent in meters. /// /// The value to convert. - /// The value in meter. - public static double FromFeetToMeter(double value) + /// The value in meters. + public static double FromFeetToMeters(double value) { return value / FeetPerMeter; } /// - /// Converts a value in meter to its equivalent in feet. + /// Converts a value in meters to its equivalent in feet. /// /// The value to convert. /// The value in feet. - public static double FromMeterToFeet(int value) + public static double FromMetersToFeet(int value) { - return FromMeterToFeet((double)value); + return FromMetersToFeet((double)value); } /// - /// Converts a value in meter to its equivalent in feet. + /// Converts a value in meters to its equivalent in feet. /// /// The value to convert. /// The value in feet. - public static double FromMeterToFeet(double value) + public static double FromMetersToFeet(double value) { return value * FeetPerMeter; } From 715b217dd392937204f4cbb6e93be9bc92d19afa Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 2 Jun 2017 17:33:34 +0200 Subject: [PATCH 12/18] Replacing Constant FeetPerMeter with MetersPerFoot. --- src/StevenVolckaert.Core/UnitConvert.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/StevenVolckaert.Core/UnitConvert.cs b/src/StevenVolckaert.Core/UnitConvert.cs index 1aec7ad..a686fd5 100644 --- a/src/StevenVolckaert.Core/UnitConvert.cs +++ b/src/StevenVolckaert.Core/UnitConvert.cs @@ -7,7 +7,11 @@ /// public static class UnitConvert { - private const double FeetPerMeter = 3.280839895; + private const double MillimetersPerInch = 25.4; + private const double MillimetersPerFoot = MillimetersPerInch * 12; + private const double MillimetersPerYard = MillimetersPerFoot * 3; + private const double MetersPerFoot = MillimetersPerFoot / 1000; + private const double MetersPerYard = MillimetersPerYard / 1000; /// /// Converts a value in degrees Celsius (°C) to its equivalent in degrees Fahrenheit (°F). @@ -68,7 +72,7 @@ public static double FromFeetToMeters(int value) /// The value in meters. public static double FromFeetToMeters(double value) { - return value / FeetPerMeter; + return value * MetersPerFoot; } /// @@ -88,7 +92,7 @@ public static double FromMetersToFeet(int value) /// The value in feet. public static double FromMetersToFeet(double value) { - return value * FeetPerMeter; + return value / MetersPerFoot; } } } From 29a09fff6c6faff8a3b056316a523733ac3d8fee Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 2 Jun 2017 17:34:20 +0200 Subject: [PATCH 13/18] Removing test methods FromFeetToMeterTest and FromMeterToFeetTest. Given the precision, it is difficult to create a list that is accurate enough. --- .../UnitConvertTests.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs b/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs index a9e3db9..b19ea9b 100644 --- a/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs +++ b/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs @@ -8,8 +8,8 @@ public class UnitConvertTests { /// - /// A list of tuples that links degrees Celsius to degrees Fahrenheit. - /// Source http://www.rapidtables.com/convert/temperature/celsius-to-fahrenheit.htm + /// A list of tuples that links degrees Celsius to degrees Fahrenheit. + /// Source http://www.rapidtables.com/convert/temperature/celsius-to-fahrenheit.htm /// private static readonly List> _temperatureTuples = new List> @@ -69,17 +69,5 @@ public void FromFahrenheitToCelsiusTest() x => Assert.AreEqual(x.Item1, UnitConvert.FromFahrenheitToCelsius(x.Item2)) ); } - - //[TestMethod] - public void FromFeetToMeterTest() - { - throw new NotImplementedException(); - } - - //[TestMethod] - public void FromMeterToFeetTest() - { - throw new NotImplementedException(); - } } } From 0f016371f21b04408a3d80f0b5d6817d899c6590 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Fri, 2 Jun 2017 17:35:18 +0200 Subject: [PATCH 14/18] Using Tuple.Create(T1, T2) method to initialize the tuples. --- .../UnitConvertTests.cs | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs b/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs index b19ea9b..8fbb1b7 100644 --- a/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs +++ b/test/StevenVolckaert.Core.Tests/UnitConvertTests.cs @@ -14,44 +14,44 @@ public class UnitConvertTests private static readonly List> _temperatureTuples = new List> { - new Tuple(-50, -58), - new Tuple(-40, -40), - new Tuple(-30, -22), - new Tuple(-20, -4), - new Tuple(-10, 14), - new Tuple(-9, 16), - new Tuple(-8, 18), - new Tuple(-7, 19), - new Tuple(-6, 21), - new Tuple(-5, 23), - new Tuple(-4, 25), - new Tuple(-3, 27), - new Tuple(-2, 28), - new Tuple(-1, 30), - new Tuple(0, 32), - new Tuple(1, 34), - new Tuple(2, 36), - new Tuple(3, 37), - new Tuple(4, 39), - new Tuple(5, 41), - new Tuple(6, 43), - new Tuple(7, 45), - new Tuple(8, 46), - new Tuple(9, 48), - new Tuple(10, 50), - new Tuple(20, 68), - new Tuple(21, 70), - new Tuple(30, 86), - new Tuple(37, 99), - new Tuple(40, 104), - new Tuple(50, 122), - new Tuple(60, 140), - new Tuple(70, 158), - new Tuple(80, 176), - new Tuple(90, 194), - new Tuple(100, 212), - new Tuple(200, 392), - new Tuple(300, 572), + Tuple.Create(-50, -58), + Tuple.Create(-40, -40), + Tuple.Create(-30, -22), + Tuple.Create(-20, -4), + Tuple.Create(-10, 14), + Tuple.Create(-9, 16), + Tuple.Create(-8, 18), + Tuple.Create(-7, 19), + Tuple.Create(-6, 21), + Tuple.Create(-5, 23), + Tuple.Create(-4, 25), + Tuple.Create(-3, 27), + Tuple.Create(-2, 28), + Tuple.Create(-1, 30), + Tuple.Create(0, 32), + Tuple.Create(1, 34), + Tuple.Create(2, 36), + Tuple.Create(3, 37), + Tuple.Create(4, 39), + Tuple.Create(5, 41), + Tuple.Create(6, 43), + Tuple.Create(7, 45), + Tuple.Create(8, 46), + Tuple.Create(9, 48), + Tuple.Create(10, 50), + Tuple.Create(20, 68), + Tuple.Create(21, 70), + Tuple.Create(30, 86), + Tuple.Create(37, 99), + Tuple.Create(40, 104), + Tuple.Create(50, 122), + Tuple.Create(60, 140), + Tuple.Create(70, 158), + Tuple.Create(80, 176), + Tuple.Create(90, 194), + Tuple.Create(100, 212), + Tuple.Create(200, 392), + Tuple.Create(300, 572), }; [TestMethod] From 4079cf8ba9459e06dc27767ab224ee5c66d4356c Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sun, 4 Jun 2017 13:39:22 +0200 Subject: [PATCH 15/18] Adding unit conversion methods FromMillimetersToPoints(double), FromPointsToMillimeters(double), FromInchesToMillimeters(double), FromMillimetersToInches(double). --- src/StevenVolckaert.Core/UnitConvert.cs | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/StevenVolckaert.Core/UnitConvert.cs b/src/StevenVolckaert.Core/UnitConvert.cs index a686fd5..1bad77d 100644 --- a/src/StevenVolckaert.Core/UnitConvert.cs +++ b/src/StevenVolckaert.Core/UnitConvert.cs @@ -10,6 +10,16 @@ public static class UnitConvert private const double MillimetersPerInch = 25.4; private const double MillimetersPerFoot = MillimetersPerInch * 12; private const double MillimetersPerYard = MillimetersPerFoot * 3; + + /// + /// The millimeters per DTP point. The DTP is defined as 1⁄72 of an international inch + /// (exactly 25.4 mm). + /// + /// + /// See https://en.wikipedia.org/wiki/Point_(typography) for more information. + /// + private const double MillimetersPerPoint = MillimetersPerInch / 72; + private const double MetersPerFoot = MillimetersPerFoot / 1000; private const double MetersPerYard = MillimetersPerYard / 1000; @@ -75,6 +85,16 @@ public static double FromFeetToMeters(double value) return value * MetersPerFoot; } + /// + /// Converts a value in international inches to its equivalent in millimeters. + /// + /// The value to convert. + /// The value in millimeters. + public static double FromInchesToMillimeters(double value) + { + return value * MillimetersPerInch; + } + /// /// Converts a value in meters to its equivalent in feet. /// @@ -94,5 +114,35 @@ public static double FromMetersToFeet(double value) { return value / MetersPerFoot; } + + /// + /// Converts a value in millimeters to its equivalent in international inches. + /// + /// The value to convert. + /// The value in international inches. + public static double FromMillimetersToInches(double value) + { + return value / MillimetersPerInch; + } + + /// + /// Converts a value in millimeters to its equivalent in DTPs (Desktop Publishing Points). + /// + /// The value to convert. + /// The value in DTPs (Desktop Publishing Points). + public static double FromMillimetersToPoints(double value) + { + return value / MillimetersPerPoint; + } + + /// + /// Converts a value in DTPs (Desktop Publishing Points) to its equivalent in millimeters. + /// + /// The value to convert. + /// The value in millimeters. + public static double FromPointsToMillimeters(double value) + { + return value * MillimetersPerPoint; + } } } From c06f6a35ea17d2d9c5bc643f4c1a9e13b98fa8ee Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sun, 4 Jun 2017 14:22:02 +0200 Subject: [PATCH 16/18] Adding extension methods Append(T) and Prepend(T). --- .../IEnumerableExtensions.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/StevenVolckaert.Core/IEnumerableExtensions.cs b/src/StevenVolckaert.Core/IEnumerableExtensions.cs index 5f9d70a..31dfb48 100644 --- a/src/StevenVolckaert.Core/IEnumerableExtensions.cs +++ b/src/StevenVolckaert.Core/IEnumerableExtensions.cs @@ -13,6 +13,58 @@ /// public static class IEnumerableExtensions { + /// + /// Adds a specified element to the end of the sequence. + /// + /// The type of the elements of . + /// + /// The instance this extension method affects. + /// + /// The element to add. + /// + /// An instance containing all elements of , + /// followed by . + /// + /// + /// is null. + /// + public static IEnumerable Append(this IEnumerable source, T element) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + foreach (var sourceElement in source) + yield return sourceElement; + + yield return element; + } + + /// + /// Adds a specified element to the beginning of the sequence. + /// + /// The type of the elements of . + /// + /// The instance this extenion method affects. + /// + /// The element to add. + /// + /// An instance containing , + /// followed by all elements of . + /// + /// + /// is null. + /// + public static IEnumerable Prepend(this IEnumerable source, T element) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + yield return element; + + foreach (var sourceElement in source) + yield return sourceElement; + } + /// /// Determines whether a sequence contains no elements. /// From cefc32dc029fdb1933adf61e8ec7d6d511fdad88 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sun, 4 Jun 2017 14:22:43 +0200 Subject: [PATCH 17/18] Adding unit tests for extension methods Append(T) and Prepend(T). --- .../IEnumerableExtensionsTests.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs b/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs index 596aa04..671e4b0 100644 --- a/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs +++ b/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs @@ -1,12 +1,32 @@ namespace StevenVolckaert.Tests { + using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Linq; - using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class IEnumerableExtensionsTests { + [TestMethod] + public void AppendTest() + { + var source = new string[] { "foo", "bar" }; + var expected = new string[] { "foo", "bar", "baz" }; + var actual = source.Append("baz").ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + + [TestMethod] + public void PrependTest() + { + var source = new string[] { "bar", "baz" }; + var expected = new string[] { "foo", "bar", "baz" }; + var actual = source.Prepend("foo").ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + [TestMethod] public void ExceptTest() { From dcb0d65e906d2e12fbb858f7c5866e861dae98af Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Tue, 6 Jun 2017 17:08:12 +0200 Subject: [PATCH 18/18] Updating project versions to 1.1.0. --- appveyor.yml | 2 +- src/StevenVolckaert.Core/StevenVolckaert.Core.csproj | 3 +++ .../StevenVolckaert.Core.Tests.csproj | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d302312..0f25904 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.0.0-{build} +version: 1.1.0-{build} build: verbosity: minimal configuration: diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj index 1d8e7b7..945dc9c 100644 --- a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj +++ b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj @@ -23,6 +23,9 @@ See https://github.com/stevenvolckaert/enterprise-library for more information.< false false StevenVolckaert + 1.1.0.0 + 1.1.0.0 + 1.1.0 diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj index be93756..ec8e296 100644 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -3,6 +3,7 @@ netcoreapp1.1 StevenVolckaert.Tests + 1.1.0