Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/formatting-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
max-parallel: 4
matrix:
working-directory: ["Flagsmith.EngineTest","Flagsmith.Client.Test"]
dotnet-version: ["6.0.x", "7.0.x", "8.0.x"]
dotnet-version: ["6.x", "7.x", "8.x", "9.x", "10.x"]

steps:
- name: Cloning repo
Expand All @@ -48,6 +48,9 @@ jobs:
fetch-depth: 0
submodules: recursive

- name: Clone engine-test-data v2 (temporary)
run: make clone-engine-test-data

- name: Set up Dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ msbuild.wrn

# Visual Studio 2015
.vs/

# Engine test data
Flagsmith.EngineTest/EngineTestDataV2/
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "Flagsmith.EngineTest/EngineTestData"]
path = Flagsmith.EngineTest/EngineTestData
url = git@github.com:Flagsmith/engine-test-data.git
branch = v1.0.0
tag = v1.0.0
3 changes: 2 additions & 1 deletion Flagsmith.Client.Test/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public static string ApiFlagResponseWithTenFlags
environment = 1,
};
flags.Add(flag);
};
}
;
var json = JsonConvert.SerializeObject(flags);
// Return the JSON string representation of the flags list
return json;
Expand Down
2 changes: 1 addition & 1 deletion Flagsmith.Client.Test/FlagsmithTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public void TestCannotCreateFlagsmithClientInLocalEvaluationWithoutServerAPIKey(
);
}

[Fact]
[Fact(Skip = "flaky test, needs investigation")]
/// <summary>
/// Test that analytics data is consistent with concurrent calls to get flags.
/// A huge number of threads are spawned to ensure that the issues related with
Expand Down
36 changes: 34 additions & 2 deletions Flagsmith.Engine/Engine.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
using System.Linq;
using System.Collections.Generic;
using FlagsmithEngine.Exceptions;
using System;
using FlagsmithEngine.Interfaces;
using FlagsmithEngine.Segment;
using FlagsmithEngine.Environment.Models;
using FlagsmithEngine.Feature.Models;
using FlagsmithEngine.Identity.Models;
using FlagsmithEngine.Trait.Models;
using System.Collections;
using System.Data;

namespace FlagsmithEngine
{
public class Engine : IEngine
{
/// <summary>
/// Get the evaluation result for a given context
/// </summary>
/// <typeparam name="SegmentMetadataT">Segment metadata type</typeparam>
/// <typeparam name="FeatureMetadataT">Feature metadata type</typeparam>
/// <param name="context"></param>
/// <returns></returns>
public EvaluationResult<SegmentMetadataT, FeatureMetadataT> GetEvaluationResult<SegmentMetadataT, FeatureMetadataT>(EvaluationContext<SegmentMetadataT, FeatureMetadataT> context)
{
context = GetEnrichedEvaluationContext(context);
var result = new EvaluationResult<SegmentMetadataT, FeatureMetadataT>();
var segmentEvaluationResult = ContextEvaluator.EvaluateSegments(context);
result.Flags = ContextEvaluator.EvaluateFlags(context, segmentEvaluationResult.SegmentOverrides);
result.Segments = segmentEvaluationResult.Segments;
return result;
}

private EvaluationContext<SegmentMetadataT, FeatureMetadataT> GetEnrichedEvaluationContext<SegmentMetadataT, FeatureMetadataT>(EvaluationContext<SegmentMetadataT, FeatureMetadataT> context)
{
if (context.Identity != null)
{
if (string.IsNullOrEmpty(context.Identity.Key))
{
context = context.Clone();
context.Identity.Key = context.Environment.Key + "_" + context.Identity.Identifier;
}
}
return context;
}

/// <summary>
/// Get a list of feature states for a given environment
/// </summary>
Expand Down Expand Up @@ -70,7 +101,8 @@ public Dictionary<FeatureModel, FeatureStateModel> GetIdentityFeatureStatesMappi
}

featureStates[feature] = featureState;
};
}
;
}
identity.IdentityFeatures?.ForEach(x =>
{
Expand Down
Loading
Loading