diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml index 5f345a06..f3872b4e 100644 --- a/.github/workflows/SonarCloud.yml +++ b/.github/workflows/SonarCloud.yml @@ -17,8 +17,8 @@ jobs: # (PRs from forks can't access secrets other than secrets.GITHUB_TOKEN for security reasons) if: ${{ !github.event.pull_request.head.repo.fork }} env: - version: '3.5.2' - versionFile: '3.5.2' + version: '3.5.3' + versionFile: '3.5.3' steps: - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -53,7 +53,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ github.event.repository.owner.login }}_SmartFormat" /o:"${{ github.event.repository.owner.login }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="**/SmartFormat.ZString/**/*" /d:sonar.cs.opencover.reportsPaths="./src/SmartFormat.Tests/**/coverage*.xml" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ github.event.repository.owner.login }}_SmartFormat" /o:"${{ github.event.repository.owner.login }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.scanner.scanAll=false /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="**/SmartFormat.ZString/**/*" /d:sonar.cs.opencover.reportsPaths="./src/SmartFormat.Tests/**/coverage*.xml" dotnet sln ./src/SmartFormat.sln remove ./src/Demo/Demo.csproj dotnet add ./src/SmartFormat.Tests/SmartFormat.Tests.csproj package AltCover dotnet restore ./src/SmartFormat.sln diff --git a/appveyor.yml b/appveyor.yml index f996200f..4df7fc3d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,7 +27,7 @@ for: - ps: dotnet restore SmartFormat.sln --verbosity quiet - ps: dotnet add .\SmartFormat.Tests\SmartFormat.Tests.csproj package AltCover - ps: | - $version = "3.5.2" + $version = "3.5.3" $versionFile = $version + "." + ${env:APPVEYOR_BUILD_NUMBER} if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 2d37c9f1..b72999c5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,8 +8,8 @@ Copyright 2011-$(CurrentYear) SmartFormat Project https://github.com/axuno/SmartFormat.git true - 3.5.2 - 3.5.2 + 3.5.3 + 3.5.3 3.0.0 latest true diff --git a/src/SmartFormat/Core/Parsing/SplitList.cs b/src/SmartFormat/Core/Parsing/SplitList.cs index 06da87e7..9855be39 100644 --- a/src/SmartFormat/Core/Parsing/SplitList.cs +++ b/src/SmartFormat/Core/Parsing/SplitList.cs @@ -58,7 +58,8 @@ public Format this[int index] { get { - if (index > _splits.Count) throw new ArgumentOutOfRangeException(nameof(index)); //NOSONAR - ArgumentOutOfRangeException.ThrowIfGreaterThan < net5.0 + // Can't use ArgumentOutOfRangeException.ThrowIfGreaterThan < net5.0 + if (index > _splits.Count) throw new ArgumentOutOfRangeException(nameof(index)); //NOSONAR if (_splits.Count == 0) return _format; diff --git a/src/SmartFormat/Extensions/PersistentVariables/VariablesGroup.cs b/src/SmartFormat/Extensions/PersistentVariables/VariablesGroup.cs index d7433967..a76a5ac5 100644 --- a/src/SmartFormat/Extensions/PersistentVariables/VariablesGroup.cs +++ b/src/SmartFormat/Extensions/PersistentVariables/VariablesGroup.cs @@ -123,11 +123,7 @@ public void Add(string name, IVariable variable) /// if a variable with the specified name was removed, if one was not. public bool Remove(string name) { - if (_variableLookup.TryGetValue(name, out var v)) - { - return _variableLookup.Remove(name); - } - return false; + return _variableLookup.Remove(name); } /// @@ -200,4 +196,4 @@ public void Clear() { _variableLookup.Clear(); } -} \ No newline at end of file +} diff --git a/src/SmartFormat/Extensions/PersistentVariablesSource.cs b/src/SmartFormat/Extensions/PersistentVariablesSource.cs index bb58ae4e..c3683e5e 100644 --- a/src/SmartFormat/Extensions/PersistentVariablesSource.cs +++ b/src/SmartFormat/Extensions/PersistentVariablesSource.cs @@ -139,13 +139,7 @@ public void Add(string name, VariablesGroup group) /// if a with a matching name was found and removed, or if one was not. public bool Remove(string name) { - if (GroupLookup.TryGetValue(name, out var v)) - { - GroupLookup.Remove(name); - return true; - } - - return false; + return GroupLookup.Remove(name); } /// @@ -248,4 +242,4 @@ private static bool TryEvaluateGroup(ISelectorInfo selectorInfo, IVariablesGroup selectorInfo.Result = variable.GetValue(); return true; } -} \ No newline at end of file +} diff --git a/src/SmartFormat/Extensions/PluralLocalizationFormatter.cs b/src/SmartFormat/Extensions/PluralLocalizationFormatter.cs index a652c7a0..063d8389 100644 --- a/src/SmartFormat/Extensions/PluralLocalizationFormatter.cs +++ b/src/SmartFormat/Extensions/PluralLocalizationFormatter.cs @@ -49,7 +49,7 @@ public PluralLocalizationFormatter(string defaultTwoLetterIsoLanguageName) } /// - /// Gets or sets the two letter ISO language name. + /// Gets or sets the two-letter ISO language name. /// /// /// Culture is now determined in this sequence:
@@ -79,7 +79,7 @@ public PluralLocalizationFormatter(string defaultTwoLetterIsoLanguageName) /// With == , the formatter can only be /// called by its name in the input format string. /// - /// Auto detection only works with more than 1 format argument. + /// Auto-detection only works with more than 1 format argument. /// It is recommended to set to . This will be the default in a future version. /// ///
@@ -111,8 +111,8 @@ public bool TryEvaluateFormat(IFormattingInfo formattingInfo) var useAutoDetection = string.IsNullOrEmpty(formattingInfo.Placeholder?.FormatterName); - // This extension requires at least two plural words for auto detection - // Valid types for auto detection are checked later + // This extension requires at least two plural words for auto-detection + // Valid types for auto-detection are checked later if (useAutoDetection && pluralWords.Count <= 1) return false; decimal value; @@ -133,7 +133,7 @@ public bool TryEvaluateFormat(IFormattingInfo formattingInfo) break; default: { - // Auto detection calls just return a failure to evaluate + // Auto-detection calls just return a failure to evaluate if (useAutoDetection) return false; // throw, if the formatter has been called explicitly @@ -150,7 +150,7 @@ public bool TryEvaluateFormat(IFormattingInfo formattingInfo) if (pluralIndex < 0 || pluralWords.Count <= pluralIndex) throw new FormattingException(format, $"Invalid number of plural parameters in {nameof(PluralLocalizationFormatter)}", - pluralWords.Last().EndIndex); + pluralWords.Count - 1); // Output the selected word (allowing for nested formats): var pluralForm = pluralWords[pluralIndex];