Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '3.1.x'
dotnet-version: |
6.0
7.0
8.0
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
3 changes: 2 additions & 1 deletion ConsoleAppExample/ConsoleAppExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<LangVersion>7.1</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
23 changes: 12 additions & 11 deletions FeatureHubSDK/FeatureHubSDK.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Title>FeatureHub Client .NET SDK</Title>
<Authors>FeatureHub IO</Authors>
<Copyright>MIT</Copyright>
Expand All @@ -16,24 +15,26 @@
<RepositoryUrl>https://github.com/featurehub-io/featurehub-dotnet-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>FeatureFlags FeatureToggles SDK Flags Toggles RemoteConfig</PackageTags>
<PackageReleaseNotes>2.5.0 - EventSource library dependency update.</PackageReleaseNotes>
<Version>2.5.0</Version>
<PackageVersion>2.5.0</PackageVersion>
<PackageReleaseNotes>3.0.0 - EventSource library dependency update.</PackageReleaseNotes>
<Version>3.0.0</Version>
<PackageVersion>3.0.0</PackageVersion>
<LangVersion>7.1</LangVersion>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IPNetwork2" Version="2.5.240" />
<PackageReference Include="JsonSubTypes" Version="1.9.0" />
<PackageReference Include="LaunchDarkly.EventSource" Version="4.2.0" />
<PackageReference Include="IPNetwork2" Version="3.0.712" />
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="LaunchDarkly.EventSource" Version="5.2.0" />
<PackageReference Include="murmurhash" Version="1.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NodaTime" Version="3.0.5" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NodaTime" Version="3.2.1" />
<PackageReference Include="Polly" Version="8.5.2" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="RestSharp" Version="106.13.0" />
<None Include="FeatureHub-icon.png" Pack="true" PackagePath="\" />
<None Include="../README.md" Pack="true" PackagePath="\" />
<PackageReference Include="SemanticVersioning" Version="1.3.0" />
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
</ItemGroup>

</Project>
24 changes: 11 additions & 13 deletions FeatureHubSDK/StrategyMatchers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using FeatureHubSDK;
using IO.FeatureHub.SSE.Model;
using Murmur;
using NodaTime;
using NodaTime.Text;
using Version = SemVer.Version;

namespace FeatureHubSDK
{
Expand All @@ -23,7 +21,7 @@ public interface IPercentageCalculator

public class PercentageMurmur3Calculator : IPercentageCalculator, IDisposable
{
public static int MAX_PERCENTAGE = 1000000;
private static int MAX_PERCENTAGE = 1000000;
private readonly HashAlgorithm _hashAlgorithm;

public PercentageMurmur3Calculator()
Expand Down Expand Up @@ -52,8 +50,8 @@ public class Applied

public Applied(bool matched, object value)
{
this.Matched = matched;
this.Value = value;
Matched = matched;
Value = value;
}
}

Expand Down Expand Up @@ -103,7 +101,7 @@ public Applied Apply(List<FeatureRolloutStrategy> strategies, string key, Guid f
int useBasePercentage = (rsi.Attributes == null || rsi.Attributes.Count == 0) ? basePercentageVal : 0;
// if the percentage is lower than the user's key +
// id of feature value then apply it
if (percentage <= (useBasePercentage + rsi.Percentage))
if (percentage <= useBasePercentage + rsi.Percentage)
{
if (rsi.Attributes != null && rsi.Attributes.Count != 0)
{
Expand All @@ -121,7 +119,7 @@ public Applied Apply(List<FeatureRolloutStrategy> strategies, string key, Guid f
// this was only a percentage and had no other attributes
if (rsi.Attributes == null || rsi.Attributes.Count == 0)
{
basePercentage[percentageKey] = basePercentage[percentageKey] + rsi.Percentage;
basePercentage[percentageKey] += rsi.Percentage;
}
}

Expand Down Expand Up @@ -256,7 +254,7 @@ public bool Match(string suppliedValue, FeatureRolloutStrategyAttribute attr)

if (attr.Conditional == RolloutStrategyAttributeConditional.EQUALS)
{
return val == (attr.Values[0] is bool ? ((bool) attr.Values[0]) : bool.Parse(attr.Values[0].ToString()));
return val == (attr.Values[0] is bool ? (bool) attr.Values[0] : bool.Parse(attr.Values[0].ToString()));
}

if (attr.Conditional == RolloutStrategyAttributeConditional.NOTEQUALS)
Expand Down Expand Up @@ -383,7 +381,7 @@ internal class NumberMatcher : IStrategyMatcher

public bool Match(string suppliedValue, FeatureRolloutStrategyAttribute attr)
{
this._attr = attr;
_attr = attr;
var dec = decimal.Parse(suppliedValue);

switch (attr.Conditional)
Expand Down Expand Up @@ -420,8 +418,8 @@ internal class SemanticVersionMatcher : IStrategyMatcher
{
public bool Match(string suppliedValue, FeatureRolloutStrategyAttribute attr)
{
var vals = attr.Values.Where(v => v != null).Select(v => new Version(v.ToString())).ToList();
var version = new Version(suppliedValue);
var vals = attr.Values.Where(v => v != null).Select(v => new SemanticVersioning.Version(v.ToString())).ToList();
var version = new SemanticVersioning.Version(suppliedValue);

switch (attr.Conditional)
{
Expand Down Expand Up @@ -479,7 +477,7 @@ public bool Match(string suppliedValue, FeatureRolloutStrategyAttribute attr)
internal class IPNetworkProxy
{
private IPAddress _address;
private IPNetwork _network;
private IPNetwork2 _network;
private bool _isAddress;

public IPNetworkProxy(string addr)
Expand All @@ -488,7 +486,7 @@ public IPNetworkProxy(string addr)
{
// it is a CIDR
_isAddress = false;
_network = IPNetwork.Parse(addr);
_network = IPNetwork2.Parse(addr);
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion FeatureHubTest/FeatureHubTest.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>

<LangVersion>7.1</LangVersion>

<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading