From 069e1036fc8624aa2d15d1ea62de4a5ef12e5b94 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sat, 1 Jan 2022 23:52:02 -0600 Subject: [PATCH 01/12] Feature completed --- src/.config/dotnet-tools.json | 14 +++++ .../ByteDecoder.Common.Tests.csproj | 44 +++++++-------- src/ByteDecoder.Common.Tests/GuardTests.cs | 4 +- src/ByteDecoder.Common.sln | 6 +- src/ByteDecoder.Common/ByteDecoder.Common.cs | 6 ++ .../ByteDecoder.Common.csproj | 47 ++++++++++------ src/ByteDecoder.Common/EnumExtensions.cs | 55 +++++++++---------- src/ByteDecoder.Common/GuardClauses/Guard.cs | 14 +++-- .../GuardClauses/IGuardClause.cs | 14 +++-- src/ByteDecoder.Common/NuGetDefense.json | 33 +++++++++++ src/_stylecop/TestProjStyleCopRules.ruleset | 1 + src/global.json | 2 +- src/run-dotnet-format.sh | 4 +- src/win-run-dotnet-format.bat | 4 +- src/win-security-code-scan.bat | 2 + 15 files changed, 159 insertions(+), 91 deletions(-) create mode 100644 src/.config/dotnet-tools.json create mode 100644 src/ByteDecoder.Common/ByteDecoder.Common.cs create mode 100644 src/ByteDecoder.Common/NuGetDefense.json create mode 100644 src/win-security-code-scan.bat diff --git a/src/.config/dotnet-tools.json b/src/.config/dotnet-tools.json new file mode 100644 index 0000000..06c34e9 --- /dev/null +++ b/src/.config/dotnet-tools.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "security-scan": { + "version": "5.6.0", + "commands": ["security-scan"] + }, + "dotnet-format": { + "version": "5.1.250801", + "commands": ["dotnet-format"] + } + } +} diff --git a/src/ByteDecoder.Common.Tests/ByteDecoder.Common.Tests.csproj b/src/ByteDecoder.Common.Tests/ByteDecoder.Common.Tests.csproj index 5a468d1..52087ed 100644 --- a/src/ByteDecoder.Common.Tests/ByteDecoder.Common.Tests.csproj +++ b/src/ByteDecoder.Common.Tests/ByteDecoder.Common.Tests.csproj @@ -1,44 +1,42 @@ - + - netcoreapp3.1 + net6.0 + enable false + + $(SolutionDir)\_stylecop\TestProjStyleCopRules.ruleset + + + True + + 1701;1702;1705 + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + - + - - + - - - $(SolutionDir)\_stylecop\TestProjStyleCopRules.ruleset - - - - True - - 1701;1702;1705 + + AllEnabledByDefault - \ No newline at end of file diff --git a/src/ByteDecoder.Common.Tests/GuardTests.cs b/src/ByteDecoder.Common.Tests/GuardTests.cs index 14fd8ac..5b70c1c 100644 --- a/src/ByteDecoder.Common.Tests/GuardTests.cs +++ b/src/ByteDecoder.Common.Tests/GuardTests.cs @@ -21,7 +21,7 @@ public void ThrowIfArgumentIsNull_ThrowsNullArgumentException_WhenSourceIsNull() // Act var exception = Record.Exception(() => { - Guard.Break.IfArgumentIsNull((IEnumerable)null, "collection"); + Guard.Break.IfArgumentIsNull?>(null, "collection"); }); // Assert @@ -49,7 +49,7 @@ public void ThrowIfArgumentIsNullWithMessage_ThrowsNullArgumentException_WhenSou // Act var exception = Record.Exception(() => { - Guard.Break.IfArgumentIsNull((IEnumerable)null, "collection", "An error occurred"); + Guard.Break.IfArgumentIsNull((IEnumerable?)null, "collection", "An error occurred"); }); // Assert diff --git a/src/ByteDecoder.Common.sln b/src/ByteDecoder.Common.sln index 1f23616..ed08026 100644 --- a/src/ByteDecoder.Common.sln +++ b/src/ByteDecoder.Common.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ByteDecoder.Common", "ByteDecoder.Common\ByteDecoder.Common.csproj", "{8E47AA9F-A9AE-4104-B3EF-DDEC366C9D94}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ByteDecoder.Common.Tests", "ByteDecoder.Common.Tests\ByteDecoder.Common.Tests.csproj", "{127AD73D-0572-4D6E-9EF2-23909C5A84E3}" diff --git a/src/ByteDecoder.Common/ByteDecoder.Common.cs b/src/ByteDecoder.Common/ByteDecoder.Common.cs new file mode 100644 index 0000000..5de3ebe --- /dev/null +++ b/src/ByteDecoder.Common/ByteDecoder.Common.cs @@ -0,0 +1,6 @@ +#pragma warning disable SA1516 + +[assembly: CLSCompliant(true)] +namespace ByteDecoder.Common; + +#pragma warning restore SA1516 diff --git a/src/ByteDecoder.Common/ByteDecoder.Common.csproj b/src/ByteDecoder.Common/ByteDecoder.Common.csproj index 45ac444..a1e99ac 100644 --- a/src/ByteDecoder.Common/ByteDecoder.Common.csproj +++ b/src/ByteDecoder.Common/ByteDecoder.Common.csproj @@ -1,12 +1,15 @@ - + - netstandard2.0 + net6.0 + enable + enable + - netstandard2.0 + net6.0 ByteDecoder.Common ByteDecoder - + ByteDecoder.Common ByteDecoder.Common Common utility classes @@ -24,39 +27,49 @@ Common utility classes $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + TRACE;JETBRAINS_ANNOTATIONS - True - + 1701;1702;1705 bin\Debug\netstandard2.0\ByteDecoder.Common.xml + + + $(SolutionDir)\_stylecop\LibraryStyleCopRules.ruleset + + True - + + - - + + all - + all + + all + + + + + AllEnabledByDefault + + - + - + - - - $(SolutionDir)\_stylecop\LibraryStyleCopRules.ruleset - - \ No newline at end of file diff --git a/src/ByteDecoder.Common/EnumExtensions.cs b/src/ByteDecoder.Common/EnumExtensions.cs index e15cecd..6ab10b7 100644 --- a/src/ByteDecoder.Common/EnumExtensions.cs +++ b/src/ByteDecoder.Common/EnumExtensions.cs @@ -1,38 +1,35 @@ -using System; +namespace ByteDecoder.Common; -namespace ByteDecoder.Common +/// +/// Enum type extensions. +/// +public static class EnumExtensions { /// - /// Enum type extensions. + /// Converts a string value to an Enum value. /// - public static class EnumExtensions + /// Enum type. + /// Value to convert. + /// Enum value. + public static T ToEnum(this string value) where T : struct { - /// - /// Converts a string value to an Enum value. - /// - /// Enum type. - /// Value to convert. - /// Enum value. - public static T ToEnum(this string value) where T : struct, IConvertible - { - return (T)Enum.Parse(typeof(T), value, true); - } + return (T)Enum.Parse(typeof(T), value, true); + } - /// - /// Converts a string value to an Enum value, if fails returns the default value - /// specified. - /// - /// Enum type. - /// Value to convert. - /// Default enum value. - /// Enum value. - public static T ToEnum(this string value, T defaultValue) where T : struct, IConvertible - { - if (string.IsNullOrWhiteSpace(value)) - return defaultValue; + /// + /// Converts a string value to an Enum value, if fails returns the default value + /// specified. + /// + /// Enum type. + /// Value to convert. + /// Default enum value. + /// Enum value. + public static T ToEnum(this string value, T defaultValue) where T : struct + { + if (string.IsNullOrWhiteSpace(value)) + return defaultValue; - T result; - return Enum.TryParse(value, true, out result) ? result : defaultValue; - } + T result; + return Enum.TryParse(value, true, out result) ? result : defaultValue; } } diff --git a/src/ByteDecoder.Common/GuardClauses/Guard.cs b/src/ByteDecoder.Common/GuardClauses/Guard.cs index e5e3950..4f13500 100644 --- a/src/ByteDecoder.Common/GuardClauses/Guard.cs +++ b/src/ByteDecoder.Common/GuardClauses/Guard.cs @@ -1,5 +1,4 @@ -using System; -using JetBrains.Annotations; +using JetBrains.Annotations; namespace ByteDecoder.Common.GuardClauses { @@ -22,7 +21,7 @@ private Guard() { } /// Generic type for the guard. /// Instance source. /// Param name. - public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName) where T : class + public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName) { if (source == null) throw new ArgumentNullException(paramName); @@ -35,7 +34,10 @@ public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, stri /// Instance source. /// Param name. /// Message if guard clause breaks. - public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName, string message) where T : class + public void IfArgumentIsNull( + [NoEnumeration][ValidatedNotNull] T source, + string paramName, + string message) { if (source == null) throw new ArgumentNullException(paramName, message); @@ -46,7 +48,7 @@ public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, stri /// /// Instance source. /// Param name. - public void IfArgumentIsNullOrEmpty(string source, string paramName) + public void IfArgumentIsNullOrEmpty(string? source, string paramName) { if (string.IsNullOrEmpty(source)) throw new ArgumentNullException(paramName); @@ -58,7 +60,7 @@ public void IfArgumentIsNullOrEmpty(string source, string paramName) /// Instance source. /// Param name. /// Message if guard clause breaks. - public void IfArgumentIsNullOrEmpty(string source, string paramName, string message) + public void IfArgumentIsNullOrEmpty(string? source, string paramName, string message) { if (string.IsNullOrEmpty(source)) throw new ArgumentNullException(paramName, message); diff --git a/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs b/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs index 8f0f544..6726fce 100644 --- a/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs +++ b/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs @@ -1,5 +1,4 @@ -using System; -using JetBrains.Annotations; +using JetBrains.Annotations; namespace ByteDecoder.Common.GuardClauses { @@ -14,7 +13,7 @@ public interface IGuardClause /// Generic type for the guard. /// Instance source. /// Param name. - void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName) where T : class; + void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName); /// /// Guard and check a value if is not null. @@ -23,14 +22,17 @@ public interface IGuardClause /// Instance source. /// Param name. /// Message if guard clause breaks. - void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName, string message) where T : class; + void IfArgumentIsNull( + [NoEnumeration][ValidatedNotNull] T source, + string paramName, + string message); /// /// Guard and check a value if is not null or neither empty. /// /// Instance source. /// Param name. - void IfArgumentIsNullOrEmpty(string source, string paramName); + void IfArgumentIsNullOrEmpty(string? source, string paramName); /// /// Guard and check a value if is not null or neither empty. @@ -38,7 +40,7 @@ public interface IGuardClause /// Instance source. /// Param name. /// Message if guard clause breaks. - void IfArgumentIsNullOrEmpty(string source, string paramName, string message); + void IfArgumentIsNullOrEmpty(string? source, string paramName, string message); /// /// Guard and check a value if is in a range. diff --git a/src/ByteDecoder.Common/NuGetDefense.json b/src/ByteDecoder.Common/NuGetDefense.json new file mode 100644 index 0000000..0df7264 --- /dev/null +++ b/src/ByteDecoder.Common/NuGetDefense.json @@ -0,0 +1,33 @@ +{ + "WarnOnly": false, + "VulnerabilityReports": { + "OutputTextReport": true + }, + "CheckTransitiveDependencies": true, + "CheckReferencedProjects": false, + "ErrorSettings": { + "ErrorSeverityThreshold": "any", + "Cvss3Threshold": -1, + "IgnoredPackages": [ + { + "Id": "NugetDefense" + } + ], + "IgnoredCvEs": [], + "AllowedPackages": [], + "BlockedPackages": [] + }, + "OssIndex": { + "ApiToken": "", + "Username": "", + "Enabled": true, + "BreakIfCannotRun": true + }, + "NVD": { + "SelfUpdate": false, + "TimeoutInSeconds": 15, + "Enabled": true, + "BreakIfCannotRun": true + }, + "SensitivePackages": [] +} \ No newline at end of file diff --git a/src/_stylecop/TestProjStyleCopRules.ruleset b/src/_stylecop/TestProjStyleCopRules.ruleset index 2c87ffc..493e6c9 100644 --- a/src/_stylecop/TestProjStyleCopRules.ruleset +++ b/src/_stylecop/TestProjStyleCopRules.ruleset @@ -3,6 +3,7 @@ + diff --git a/src/global.json b/src/global.json index d82f13f..e52d340 100644 --- a/src/global.json +++ b/src/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.405" + "version": "6.0.101" } } diff --git a/src/run-dotnet-format.sh b/src/run-dotnet-format.sh index 9a62db9..0bb0c78 100755 --- a/src/run-dotnet-format.sh +++ b/src/run-dotnet-format.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -dotnet tool update -g dotnet-format -dotnet format --check --verbosity diagnostic +dotnet tool update dotnet-format +dotnet format --verbosity diagnostic diff --git a/src/win-run-dotnet-format.bat b/src/win-run-dotnet-format.bat index d2d3028..4cfd13d 100644 --- a/src/win-run-dotnet-format.bat +++ b/src/win-run-dotnet-format.bat @@ -4,5 +4,5 @@ cls echo Legion awaits -dotnet tool update -g dotnet-format -dotnet format --check --verbosity diagnostic \ No newline at end of file +dotnet tool update dotnet-format +dotnet format --verbosity diagnostic \ No newline at end of file diff --git a/src/win-security-code-scan.bat b/src/win-security-code-scan.bat new file mode 100644 index 0000000..16083e3 --- /dev/null +++ b/src/win-security-code-scan.bat @@ -0,0 +1,2 @@ +dotnet tool update security-scan +dotnet security-scan .\ByteDecoder.Common.sln \ No newline at end of file From f361a3c84db1a26c8966f57045758c2dfaca09c1 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sat, 1 Jan 2022 23:58:17 -0600 Subject: [PATCH 02/12] github actions updated --- .github/workflows/dotnet-core.yml | 67 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 9c61039..e0c3455 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -2,45 +2,42 @@ name: .NET Core on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.405 - - - name: Install dependencies - run: cd src && dotnet restore - - - name: Build - run: cd src && dotnet build --configuration Release --no-restore - - - name: Linting code with dotnet-format - run: cd src && ./run-dotnet-format.sh - - - name: Test - run: cd src && ./codeclimate_code_coverage.sh - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - - - name: docfx-action - uses: nikeee/docfx-action@v1.0.0 - with: - args: docs/docfx.json - - - name: Update Library DocFx documentation - run: cd src && ./release-docfx-github.sh - env: - BYTEDECODER_COMMON_GITHUB_CI_ACTIONS: ${{ secrets.BYTEDECODER_COMMON_GITHUB_CI_ACTIONS }} - DOCFX_GITHUB_EMAIL: ${{ secrets.DOCFX_GITHUB_EMAIL }} - - + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.101 + + - name: Install dependencies + run: cd src && dotnet restore + + - name: Build + run: cd src && dotnet build --configuration Release --no-restore + + - name: Linting code with dotnet-format + run: cd src && ./run-dotnet-format.sh + + - name: Test + run: cd src && ./codeclimate_code_coverage.sh + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + + - name: docfx-action + uses: nikeee/docfx-action@v1.0.0 + with: + args: docs/docfx.json + + - name: Update Library DocFx documentation + run: cd src && ./release-docfx-github.sh + env: + BYTEDECODER_COMMON_GITHUB_CI_ACTIONS: ${{ secrets.BYTEDECODER_COMMON_GITHUB_CI_ACTIONS }} + DOCFX_GITHUB_EMAIL: ${{ secrets.DOCFX_GITHUB_EMAIL }} From 4b1480d4664607b3e94ff8a2335d3f4344ea2d08 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 00:00:32 -0600 Subject: [PATCH 03/12] github action .bet version updated --- .github/workflows/dotnet-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index e0c3455..491bbd6 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.101 + dotnet-version: 6.0.1 - name: Install dependencies run: cd src && dotnet restore From a785a4dcb4da6c91360b69677488fb5813e03f55 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 13:54:42 -0600 Subject: [PATCH 04/12] github action cfg updates --- .github/workflows/dotnet-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 491bbd6..e0c3455 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.1 + dotnet-version: 6.0.101 - name: Install dependencies run: cd src && dotnet restore From f8771ec4b75e2c56a36c96450edf43e3f94d8779 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 14:14:36 -0600 Subject: [PATCH 05/12] Github actions cfg updates --- .github/workflows/dotnet-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index e0c3455..bca2038 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.101 + dotnet-version: 6.0.x - name: Install dependencies run: cd src && dotnet restore From b17acf7a83ebe06de889e8c8e4174c86dc75f3ff Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 14:19:11 -0600 Subject: [PATCH 06/12] Github actions cfg updates --- .github/workflows/dotnet-core.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index bca2038..51a5f80 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -20,6 +20,9 @@ jobs: - name: Install dependencies run: cd src && dotnet restore + - name: .Net Version + run: cd src && dotnet --version + - name: Build run: cd src && dotnet build --configuration Release --no-restore From 5bbee448b8f7048649aef87e849a4d06b4c2aa92 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 14:30:45 -0600 Subject: [PATCH 07/12] Added .Net5 into the github action pipeline per NugetDefense requiriment --- .github/workflows/dotnet-core.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 51a5f80..1dc9e1f 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -12,7 +12,13 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET Core + + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + - name: Setup .NET 6 uses: actions/setup-dotnet@v1 with: dotnet-version: 6.0.x From 8a9e128295ca1f1fb8515816f69d6d9886c1989b Mon Sep 17 00:00:00 2001 From: Rodrigo Reyes Date: Sun, 2 Jan 2022 14:41:56 -0600 Subject: [PATCH 08/12] Added CodeSecurityScan into the gihub actions CI pipeline --- .github/workflows/dotnet-core.yml | 3 +++ src/run-security-code-scan.sh | 5 +++++ 2 files changed, 8 insertions(+) create mode 100755 src/run-security-code-scan.sh diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 1dc9e1f..ce3685d 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -32,6 +32,9 @@ jobs: - name: Build run: cd src && dotnet build --configuration Release --no-restore + - name: Security Code Scan + run: cd src && ./run-security-code-scan.sh + - name: Linting code with dotnet-format run: cd src && ./run-dotnet-format.sh diff --git a/src/run-security-code-scan.sh b/src/run-security-code-scan.sh new file mode 100755 index 0000000..4e3b2f0 --- /dev/null +++ b/src/run-security-code-scan.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +dotnet tool update security-scan +dotnet security-scan ./ByteDecoder.Common.sln \ No newline at end of file From 95e29f87213190addd5ed9d80461329eda623086 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 14:57:28 -0600 Subject: [PATCH 09/12] Updating QL github action cfg --- .github/workflows/codeql-analysis.yml | 76 +++++++++++++++------------ 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 58753a8..e59c621 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,7 +7,7 @@ on: # The branches below must be a subset of the branches above branches: [master] schedule: - - cron: '0 9 * * 5' + - cron: "0 9 * * 5" jobs: analyze: @@ -19,39 +19,49 @@ jobs: matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['csharp'] + language: ["csharp"] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 9d78e0b2f24df6950be3ae5463cf601e8ebd0d77 Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 15:09:02 -0600 Subject: [PATCH 10/12] Code updated to C# 10 syntax --- CHANGELOG | 53 ++++--- .../DateTimeOffsetExtensions.cs | 35 ++--- src/ByteDecoder.Common/GuardClauses/Guard.cs | 139 +++++++++--------- .../GuardClauses/IGuardClause.cs | 85 ++++++----- .../GuardClauses/ValidatedNotNullAttribute.cs | 17 +-- .../MathComparisonExtensions.cs | 93 ++++++------ src/ByteDecoder.Common/StringExtensions.cs | 76 +++++----- 7 files changed, 251 insertions(+), 247 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6bcc438..c200bad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,38 +1,53 @@ +# Changelog + +## Version Changes + ### 0.3.6 - 2021-01-25 - * Added ToCamelCase string extension methods. + +- Added ToCamelCase string extension methods. ### 0.3.5 - 2021-01-20 - * Added ToEnum string extension methods. - * Added DateTimeOffset extensions methods. + +- Added ToEnum string extension methods. +- Added DateTimeOffset extensions methods. ### 0.3.4 - 2020-08-19 - * Transparent favicon added + +- Transparent favicon added ### 0.3.3 - 2020-08-19 - * Library logos added in the DocFX documentation - + +- Library logos added in the DocFX documentation + ### 0.3.2 - 2020-08-18 - * DocFX documentation completed - * Official documentation url https://bytedecoder.me/ByteDecoder.Common/ - + +- DocFX documentation completed +- Official documentation url + ### 0.3.1 - 2020-08-13 - * Guard interface implementation refactored - * StyleCop and FxCop analyzers added as part of the development workflow - * Violating the analyzers rules will throw errors on compile, until they are fix - * All methods, classes and interfaces consumables for third parties in the Library has now documentation + +- Guard interface implementation refactored +- StyleCop and FxCop analyzers added as part of the development workflow +- Violating the analyzers rules will throw errors on compile, until they are fix +- All methods, classes and interfaces consumables for third parties in the Library has now documentation ### 0.3.0 - 2020-07-29 - * Added MathComparisonExtensions extensions methods for math comparisions - * Added IfArgumentOutOfRange Guard clause + +- Added MathComparisonExtensions extensions methods for math comparisions +- Added IfArgumentOutOfRange Guard clause ### 0.2.3 - 2020-07-28 - * Fixed problem with Possible multiple enumeration of IEnumerable using with Resharper with JETBRAINS_ANNOTATIONS compilation symbol + +- Fixed problem with Possible multiple enumeration of IEnumerable using with Resharper with JETBRAINS_ANNOTATIONS compilation symbol ### 0.2.1 - 2020-07-28 - * Added AllowedOutputExtensionsInPackageBuildOutputFolder in ByteDecoder.Common project + +- Added AllowedOutputExtensionsInPackageBuildOutputFolder in ByteDecoder.Common project ### 0.2.0 - 2020-07-27 - * Added Jetbrains Annotations for avoding false positive: Possible multiple enumeration of IEnumerable + +- Added Jetbrains Annotations for avoding false positive: Possible multiple enumeration of IEnumerable ### 0.1.0 - 2020-07-27 - * Initial release + +- Initial release diff --git a/src/ByteDecoder.Common/DateTimeOffsetExtensions.cs b/src/ByteDecoder.Common/DateTimeOffsetExtensions.cs index c118291..ce19826 100644 --- a/src/ByteDecoder.Common/DateTimeOffsetExtensions.cs +++ b/src/ByteDecoder.Common/DateTimeOffsetExtensions.cs @@ -1,27 +1,24 @@ -using System; +namespace ByteDecoder.Common; -namespace ByteDecoder.Common +/// +/// DateTimeOffset extensions. +/// +public static class DateTimeOffsetExtensions { /// - /// DateTimeOffset extensions. + /// Extend a contract based in a number of months to the last day of the month. /// - public static class DateTimeOffsetExtensions + /// Current date to extend. + /// Month number extension. + /// New extended DateTimeOffset. + public static DateTimeOffset ExtendContract(this DateTimeOffset current, int months) { - /// - /// Extend a contract based in a number of months to the last day of the month. - /// - /// Current date to extend. - /// Month number extension. - /// New extended DateTimeOffset. - public static DateTimeOffset ExtendContract(this DateTimeOffset current, int months) - { - var newContractDate = current.AddMonths(months).AddTicks(-1); + var newContractDate = current.AddMonths(months).AddTicks(-1); - return new DateTimeOffset( - newContractDate.Year, - newContractDate.Month, - DateTime.DaysInMonth(newContractDate.Year, newContractDate.Month), - 23, 59, 59, current.Offset); - } + return new DateTimeOffset( + newContractDate.Year, + newContractDate.Month, + DateTime.DaysInMonth(newContractDate.Year, newContractDate.Month), + 23, 59, 59, current.Offset); } } diff --git a/src/ByteDecoder.Common/GuardClauses/Guard.cs b/src/ByteDecoder.Common/GuardClauses/Guard.cs index 4f13500..dccfb46 100644 --- a/src/ByteDecoder.Common/GuardClauses/Guard.cs +++ b/src/ByteDecoder.Common/GuardClauses/Guard.cs @@ -1,83 +1,82 @@ using JetBrains.Annotations; -namespace ByteDecoder.Common.GuardClauses +namespace ByteDecoder.Common.GuardClauses; + +/// +/// Guard singleton class. +/// +public class Guard : IGuardClause { + private Guard() { } + /// - /// Guard singleton class. + /// Gets the Guard instance. /// - public class Guard : IGuardClause - { - private Guard() { } + /// Guard extension methods. + public static IGuardClause Break { get; } = new Guard(); - /// - /// Gets the Guard instance. - /// - /// Guard extension methods. - public static IGuardClause Break { get; } = new Guard(); - - /// - /// Guard and check a value if is not null. - /// - /// Generic type for the guard. - /// Instance source. - /// Param name. - public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName) - { - if (source == null) - throw new ArgumentNullException(paramName); - } + /// + /// Guard and check a value if is not null. + /// + /// Generic type for the guard. + /// Instance source. + /// Param name. + public void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName) + { + if (source == null) + throw new ArgumentNullException(paramName); + } - /// - /// Guard and check a value if is not null. - /// - /// Generic type for the guard. - /// Instance source. - /// Param name. - /// Message if guard clause breaks. - public void IfArgumentIsNull( - [NoEnumeration][ValidatedNotNull] T source, - string paramName, - string message) - { - if (source == null) - throw new ArgumentNullException(paramName, message); - } + /// + /// Guard and check a value if is not null. + /// + /// Generic type for the guard. + /// Instance source. + /// Param name. + /// Message if guard clause breaks. + public void IfArgumentIsNull( + [NoEnumeration][ValidatedNotNull] T source, + string paramName, + string message) + { + if (source == null) + throw new ArgumentNullException(paramName, message); + } - /// - /// Guard and check a value if is not null or neither empty. - /// - /// Instance source. - /// Param name. - public void IfArgumentIsNullOrEmpty(string? source, string paramName) - { - if (string.IsNullOrEmpty(source)) - throw new ArgumentNullException(paramName); - } + /// + /// Guard and check a value if is not null or neither empty. + /// + /// Instance source. + /// Param name. + public void IfArgumentIsNullOrEmpty(string? source, string paramName) + { + if (string.IsNullOrEmpty(source)) + throw new ArgumentNullException(paramName); + } - /// - /// Guard and check a value if is not null or neither empty. - /// - /// Instance source. - /// Param name. - /// Message if guard clause breaks. - public void IfArgumentIsNullOrEmpty(string? source, string paramName, string message) - { - if (string.IsNullOrEmpty(source)) - throw new ArgumentNullException(paramName, message); - } + /// + /// Guard and check a value if is not null or neither empty. + /// + /// Instance source. + /// Param name. + /// Message if guard clause breaks. + public void IfArgumentIsNullOrEmpty(string? source, string paramName, string message) + { + if (string.IsNullOrEmpty(source)) + throw new ArgumentNullException(paramName, message); + } - /// - /// Guard and check a value if is in a range. - /// - /// Predicate that evaluates the range. - /// Param name. - /// Message if guard clause breaks. - public void IfArgumentOutOfRange(Func predicate, string paramName, string message) - { - IfArgumentIsNull(predicate, nameof(predicate)); + /// + /// Guard and check a value if is in a range. + /// + /// Predicate that evaluates the range. + /// Param name. + /// Message if guard clause breaks. + public void IfArgumentOutOfRange(Func predicate, string paramName, string message) + { + IfArgumentIsNull(predicate, nameof(predicate)); - if (predicate()) - throw new ArgumentOutOfRangeException(paramName, message); - } + if (predicate()) + throw new ArgumentOutOfRangeException(paramName, message); } } diff --git a/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs b/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs index 6726fce..9c07f6b 100644 --- a/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs +++ b/src/ByteDecoder.Common/GuardClauses/IGuardClause.cs @@ -1,53 +1,52 @@ using JetBrains.Annotations; -namespace ByteDecoder.Common.GuardClauses +namespace ByteDecoder.Common.GuardClauses; + +/// +/// Interface for extending the guard clauses using extensions methods. +/// +public interface IGuardClause { /// - /// Interface for extending the guard clauses using extensions methods. + /// Guard and check a value if is not null. /// - public interface IGuardClause - { - /// - /// Guard and check a value if is not null. - /// - /// Generic type for the guard. - /// Instance source. - /// Param name. - void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName); + /// Generic type for the guard. + /// Instance source. + /// Param name. + void IfArgumentIsNull([NoEnumeration][ValidatedNotNull] T source, string paramName); - /// - /// Guard and check a value if is not null. - /// - /// Generic type for the guard. - /// Instance source. - /// Param name. - /// Message if guard clause breaks. - void IfArgumentIsNull( - [NoEnumeration][ValidatedNotNull] T source, - string paramName, - string message); + /// + /// Guard and check a value if is not null. + /// + /// Generic type for the guard. + /// Instance source. + /// Param name. + /// Message if guard clause breaks. + void IfArgumentIsNull( + [NoEnumeration][ValidatedNotNull] T source, + string paramName, + string message); - /// - /// Guard and check a value if is not null or neither empty. - /// - /// Instance source. - /// Param name. - void IfArgumentIsNullOrEmpty(string? source, string paramName); + /// + /// Guard and check a value if is not null or neither empty. + /// + /// Instance source. + /// Param name. + void IfArgumentIsNullOrEmpty(string? source, string paramName); - /// - /// Guard and check a value if is not null or neither empty. - /// - /// Instance source. - /// Param name. - /// Message if guard clause breaks. - void IfArgumentIsNullOrEmpty(string? source, string paramName, string message); + /// + /// Guard and check a value if is not null or neither empty. + /// + /// Instance source. + /// Param name. + /// Message if guard clause breaks. + void IfArgumentIsNullOrEmpty(string? source, string paramName, string message); - /// - /// Guard and check a value if is in a range. - /// - /// Predicate that evaluates the range. - /// Param name. - /// Message if guard clause breaks. - void IfArgumentOutOfRange(Func predicate, string paramName, string message); - } + /// + /// Guard and check a value if is in a range. + /// + /// Predicate that evaluates the range. + /// Param name. + /// Message if guard clause breaks. + void IfArgumentOutOfRange(Func predicate, string paramName, string message); } diff --git a/src/ByteDecoder.Common/GuardClauses/ValidatedNotNullAttribute.cs b/src/ByteDecoder.Common/GuardClauses/ValidatedNotNullAttribute.cs index 5054d25..01c02df 100644 --- a/src/ByteDecoder.Common/GuardClauses/ValidatedNotNullAttribute.cs +++ b/src/ByteDecoder.Common/GuardClauses/ValidatedNotNullAttribute.cs @@ -1,11 +1,8 @@ -using System; +namespace ByteDecoder.Common.GuardClauses; -namespace ByteDecoder.Common.GuardClauses -{ - /// - /// Indicates to Code Analysis that a method validates a particular parameter. - /// https://docs.microsoft.com/en-us/dotnet/api/microsoft.validatednotnullattribute?view=visualstudiosdk-2019. - /// - [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] - public sealed class ValidatedNotNullAttribute : Attribute { } -} +/// +/// Indicates to Code Analysis that a method validates a particular parameter. +/// https://docs.microsoft.com/en-us/dotnet/api/microsoft.validatednotnullattribute?view=visualstudiosdk-2019. +/// +[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] +public sealed class ValidatedNotNullAttribute : Attribute { } diff --git a/src/ByteDecoder.Common/MathComparisonExtensions.cs b/src/ByteDecoder.Common/MathComparisonExtensions.cs index 9b2c211..702765b 100644 --- a/src/ByteDecoder.Common/MathComparisonExtensions.cs +++ b/src/ByteDecoder.Common/MathComparisonExtensions.cs @@ -1,56 +1,55 @@ -namespace ByteDecoder.Common +namespace ByteDecoder.Common; + +/// +/// Integer math comparision extension methods. +/// +public static class MathComparisonExtensions { /// - /// Integer math comparision extension methods. + /// Integer extension method for Greater Than. /// - public static class MathComparisonExtensions - { - /// - /// Integer extension method for Greater Than. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsGreaterThan(this int i, int value) => i > value; + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsGreaterThan(this int i, int value) => i > value; - /// - /// Integer extension method for Less Than. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsLessThan(this int i, int value) => i < value; + /// + /// Integer extension method for Less Than. + /// + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsLessThan(this int i, int value) => i < value; - /// - /// Integer extension method for Equal To. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsEqualTo(this int i, int value) => i == value; + /// + /// Integer extension method for Equal To. + /// + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsEqualTo(this int i, int value) => i == value; - /// - /// Integer extension method for Not Equal To. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsNotEqualTo(this int i, int value) => i != value; + /// + /// Integer extension method for Not Equal To. + /// + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsNotEqualTo(this int i, int value) => i != value; - /// - /// Integer extension method for Greater Than Or Equal To. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsGreaterThanOrEqualTo(this int i, int value) => i >= value; + /// + /// Integer extension method for Greater Than Or Equal To. + /// + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsGreaterThanOrEqualTo(this int i, int value) => i >= value; - /// - /// Integer extension method for Less Than Or Equal To. - /// - /// Current integer source value. - /// integer type to compare against it. - /// Boolean evaluation result. - public static bool IsLessThanOrEqualTo(this int i, int value) => i <= value; - } + /// + /// Integer extension method for Less Than Or Equal To. + /// + /// Current integer source value. + /// integer type to compare against it. + /// Boolean evaluation result. + public static bool IsLessThanOrEqualTo(this int i, int value) => i <= value; } diff --git a/src/ByteDecoder.Common/StringExtensions.cs b/src/ByteDecoder.Common/StringExtensions.cs index 1cabc8b..84dee02 100644 --- a/src/ByteDecoder.Common/StringExtensions.cs +++ b/src/ByteDecoder.Common/StringExtensions.cs @@ -1,53 +1,51 @@ -using System; -using System.Globalization; +using System.Globalization; -namespace ByteDecoder.Common +namespace ByteDecoder.Common; + +/// +/// String extensions methods. +/// +public static class StringExtensions { /// - /// String extensions methods. + /// Convert a string to integer type. /// - public static class StringExtensions + /// Source string. + /// Parse result. + public static int ToInt(this string source) { - /// - /// Convert a string to integer type. - /// - /// Source string. - /// Parse result. - public static int ToInt(this string source) + return int.Parse(source, NumberFormatInfo.CurrentInfo); + } + + /// + /// Convert a string to double type. + /// + /// Source string. + /// Parse result. + public static double ToDouble(this string source) + { + try { - return int.Parse(source, NumberFormatInfo.CurrentInfo); + return double.Parse(source, NumberFormatInfo.CurrentInfo); } - - /// - /// Convert a string to double type. - /// - /// Source string. - /// Parse result. - public static double ToDouble(this string source) + catch (FormatException) { - try - { - return double.Parse(source, NumberFormatInfo.CurrentInfo); - } - catch (FormatException) - { - return double.NaN; - } + return double.NaN; } + } - /// - /// Converts an string into a camelCase representation. - /// - /// Source string. - /// Camel case string result. - public static string ToCamelCase(this string source) + /// + /// Converts an string into a camelCase representation. + /// + /// Source string. + /// Camel case string result. + public static string ToCamelCase(this string source) + { + if (!string.IsNullOrEmpty(source) && source.Length > 1) { - if (!string.IsNullOrEmpty(source) && source.Length > 1) - { - return char.ToLowerInvariant(source[0]) + source.Substring(1); - } - - return source; + return char.ToLowerInvariant(source[0]) + source.Substring(1); } + + return source; } } From ba6638e5664d5d846fb1fb976011aabe7cbd772a Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 15:18:52 -0600 Subject: [PATCH 11/12] CodeQL settings updated --- .github/workflows/codeql-analysis.yml | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e59c621..578545e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,16 +31,6 @@ jobs: # a pull request then we can checkout the head. fetch-depth: 2 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.x - - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 @@ -49,8 +39,8 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 + # - name: Autobuild + # uses: github/codeql-action/autobuild@v1 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -62,6 +52,24 @@ jobs: #- run: | # make bootstrap # make release + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + - name: Install dependencies + run: cd src && dotnet restore + + - name: .Net Version + run: cd src && dotnet --version + + - name: Build + run: cd src && dotnet build --configuration Release --no-restore - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 2e1c01727eece173bdd0bc4fc5a20886d07b06ef Mon Sep 17 00:00:00 2001 From: ByteDecoder Date: Sun, 2 Jan 2022 15:25:20 -0600 Subject: [PATCH 12/12] CHANGELOG updated --- CHANGELOG | 7 +++++++ README.md | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c200bad..9016578 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,13 @@ ## Version Changes +### 1.0.0 - 2022-01-02 + +- C# 10 adopted +- .Net Standard support deprecated +- Support from .Net6 onwards +- New CSA tools added into the build pipeline + ### 0.3.6 - 2021-01-25 - Added ToCamelCase string extension methods. diff --git a/README.md b/README.md index 303e040..d151c3b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Common utility classes, guard clauses, and more. -Targeted to .Net Standard 2.0 +Targeted to .Net6 onwards ## Installation @@ -36,7 +36,7 @@ All the documentation can be found on the [github page](https://bytedecoder.me/B They are a piece of code in charge of protecting params at the top of methods against undesirable values. -Supported *Guard Clauses*: +Supported _Guard Clauses_: - IfArgumentIsNull - IfArgumentIsNullOrEmpty @@ -51,7 +51,7 @@ using ByteDecoder.Common.GuardClauses; public void MethodOne(IEnumerable collection) { Guard.Break.IfArgumentIsNull(collection, nameof(collection)); - + // More logic code if the param is suitable after the guard evaluates the condition. } @@ -59,7 +59,7 @@ public void MethodOne(IEnumerable collection) public void MethodTwo(string word) { Guard.Break.IfArgumentIsNull(word, nameof(word)); - + // More logic code if the param is suitable after the guard evaluates the condition. }