Skip to content

Commit

Permalink
Merge pull request #9 from configcat/feature/semverupdate
Browse files Browse the repository at this point in the history
move semver into repo and remove nuget reference
  • Loading branch information
endret authored Apr 19, 2020
2 parents 1a19621 + 14c2563 commit 694cd31
Show file tree
Hide file tree
Showing 8 changed files with 666 additions and 13 deletions.
5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

This repository includes two files originally copied from https://github.com/maxhauser/semver
repository: https://github.com/maxhauser/semver/blob/master/Semver/IntExtensions.cs and
https://github.com/maxhauser/semver/blob/master/Semver/SemVersion.cs. The
original versions of the files are MIT licensed. See the file headers for details.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 5.0.{build}
version: 5.1.{build}
image: Visual Studio 2019
configuration: Release
platform: Any CPU
Expand All @@ -22,7 +22,7 @@ before_test:
- ps: choco install codecov --no-progress
test_script:
- ps: . .\set-debug-type.ps1 src\ConfigCatClient\ConfigCatClient.csproj
- OpenCover.Console.exe -register:user -target:dotnet.exe -targetargs:"test src\ConfigCat.Client.Tests\ConfigCat.Client.Tests.csproj -c Release" -output:.\coverage.xml -filter:"+[*]ConfigCat.Client.* -[ConfigCatClientTests]*" -oldstyle -returntargetcode
- cmd: coverage.cmd
after_test:
- codecov -f "coverage.xml"
artifacts:
Expand All @@ -33,4 +33,4 @@ notifications:
to:
- [email protected]
on_build_success: false
on_build_failure: true
on_build_failure: true
4 changes: 1 addition & 3 deletions coverage.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
OpenCover.Console.exe -register:user -target:dotnet.exe -targetargs:"test src\ConfigCat.Client.Tests\ConfigCat.Client.Tests.csproj -c Release" -output:.\coverage.xml -filter:"+[*]ConfigCat.Client.* -[ConfigCatClientTests]*" -oldstyle -returntargetcode

pause
OpenCover.Console.exe -register:user -target:dotnet.exe -targetargs:"test src\ConfigCat.Client.Tests\ConfigCat.Client.Tests.csproj -c Release" -output:.\coverage.xml -filter:"+[*]ConfigCat.Client.* -[ConfigCatClientTests]* -[*]ConfigCat.Client.Versioning.*" -oldstyle -returntargetcode
7 changes: 4 additions & 3 deletions src/ConfigCatClient/ConfigCatClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<AssemblyName>ConfigCat.Client</AssemblyName>
<RootNamespace>ConfigCat.Client</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand All @@ -15,7 +15,9 @@
<PackageProjectUrl>https://github.com/ConfigCat/.net-sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/ConfigCat/.net-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Version 5.0.0
<PackageReleaseNotes>Version 5.1.0
* Remove semver nuget packages
Version 5.0.0
* Breaking change: Renamed `API Key` to `SDK Key`.
Version 4.0.0
* Supporting sensitive text comparators.
Expand Down Expand Up @@ -77,7 +79,6 @@ Works with .NET, .NET Core, .NET Standard</Description>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="semver" Version="2.0.4" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/ConfigCatClient/Evaluate/RolloutEvaluator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json.Linq;
using Semver;
using ConfigCat.Client.Versioning;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down
55 changes: 55 additions & 0 deletions src/ConfigCatClient/Versioning/IntExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//Copyright(c) 2013 Max Hauser

//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.

using System.Text;
#if !NETSTANDARD
#endif

namespace ConfigCat.Client.Versioning
{
internal static class IntExtensions
{
/// <summary>
/// The number of digits in a non-negative number. Returns 1 for all
/// negative numbers. That is ok because we are using it to calculate
/// string length for a <see cref="StringBuilder"/> for numbers that
/// aren't supposed to be negative, but when they are it is just a little
/// slower.
/// </summary>
/// <remarks>
/// This approach is based on https://stackoverflow.com/a/51099524/268898
/// where the poster offers performance benchmarks showing this is the
/// fastest way to get a number of digits.
/// </remarks>
public static int Digits(this int n)
{
if (n < 10) return 1;
if (n < 100) return 2;
if (n < 1_000) return 3;
if (n < 10_000) return 4;
if (n < 100_000) return 5;
if (n < 1_000_000) return 6;
if (n < 10_000_000) return 7;
if (n < 100_000_000) return 8;
if (n < 1_000_000_000) return 9;
return 10;
}
}
}
Loading

0 comments on commit 694cd31

Please sign in to comment.