Skip to content

Commit 636a702

Browse files
rossgramboamerjusupovicjimmyca15zhiyuanliang-msjulealgon
authored
Merge preview into main (#494)
* Add variants for feature flags (#250) * in progress, add new classes for variants and define methods in featuremanager * Revert "Revert "Add cancellation token parameter to async feature management interfaces. (#131)" (#139)" This reverts commit e531863. * Revert "Revert "Added default value for cancellation token in interfaces to keep existing usage possible. (#133)" (#138)" This reverts commit 8f9a7e4. * fix any conflicts left from adding cancellationToken back * add in progress changes to allocation and featuredefinitionprovider * add examples for testing * fix adding new featuredefinition properties from featuremanagement definition * progress adding getvariant logic classes * continued * remove repeated code in contextual targeting * fix version of contextual filter * more progress on getting the contextual allocator to work * about to test getvariant * add example to test * add snapshot changes * variant can be detected and retrieved from getvariantasync * progress on allocation logic, add comments where consideration needed * add use of optionsresolver for reference, todo work on isenabledasync between customer use and variant use * All working except couple TODOs, need to add unit tests * remove some comments, add null check where needed * update todo comments * fix line eols * add unit test, in progress * TODOs in progress, need to restructure featurevariantassigner design * fix seed logic * update comments, status logic * remove unnecessary files for custom assigners, fix featuremanager methods and interfaces to match * fix naming from allocator to assigner for classes and files * cleanup extra methods, todo config section logic * in progress adding configurationsection returned when using configurationvalue * continuation of last commit * working return for configvalue * move logic to featuremanager for assigning * remove unused assigner classes * add new configurationsection to handle return for variant * null error, in progress new configurationsection class * fix old bug * progress on unit tests * more null check changes, test fixes * reset examples changes * Revert "Revert "Revert "Added default value for cancellation token in interfaces to keep existing usage possible. (#133)" (#138)"" This reverts commit d087e7b. * Revert "Revert "Revert "Add cancellation token parameter to async feature management interfaces. (#131)" (#139)"" This reverts commit c1451d3. * add comments for new classes * fix comments for public classes again * update comments, default values * fix variantconfigurationsection, comments in definitionprovider * fix using statements, null checks * fix unit test failures with servicecollectionextensions * add revisions: fix namepaces, add exceptions tests, combine percentage logic, fix comments, add cancellationtoken to new interface * change context accessor logic * fix comments for default variants * PR revisions * change class names, PR fixes * fix edge case percentage targeting * rename allocation classes, remove exceptions and add warning logs, prioritize inline value for variant config, more revisions * refactor isenabled to remove boolean param * change configurationvalue to IConfigurationSection instead of string * fix enabledwithvariants logic * PR revisions, fix logic in new methods from last commit * set session managers last in flow * make false explicit for status disabled or missing definition * fix constructor default params, move session managers logic, pr revisions * fix comment * fix resolvedefaultvariant, isexternalinit error * add back 3.1 * Apply suggestions from code review Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * isexternalinit comments, remove resolvedefault helper * remove binding, fix featuredefinitionprovider issues * change to Debug.Assert from Assert * update method name * remove parseenum, add ConfigurationFields class * test failing, fixed PR revisions * fix invalid scenarios test * simplify context in test * remove unused using * remove unused param * Clarify how From and To bounds work in PercentileAllocation Co-authored-by: Ross Grambo <rossgrambo@microsoft.com> * fix error messages * add feature name as default seed with allocation prefix * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> Co-authored-by: Ross Grambo <rossgrambo@microsoft.com> * Adds GetFeatureNamesAsync to IVariantFeatureManager and uses the interface in FeatureManagerSnapshot (#270) * Adds telemetry pipeline (#259) * Adds telemetry pipeline. Adds evaluationevent, publisher interface, and a publisher instance for app insights. * Use await insead of .result * Reverting unused dependency removal * Update src/Microsoft.FeatureManagement/FeatureDefinition.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Update src/Microsoft.FeatureManagement/FeatureDefinition.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Update src/Microsoft.FeatureManagement.AppInsightsTelemetryPublisher/TelemetryPublisherAppInsights.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Removed factory pattern for publisher DI * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Resolve misc. comments * Adjusts descriptions for FeatureDefinition properties * Rename AppInsights to ApplicationInsights * Resolves project reference in sln * Adjusts ServiceCollectionExtensions to use TryAddSingleton * Removes langversion from .csproj * Temp * Adds explicit null checkts before publishing fields to app insights * Addressing misc. comments * Removing project reference for example project * Syncing telemetry and variants * Adds null check for feature definitions * Adjusted TelemetryPublishers to no longer be inserted into DI * Resolving comments * Removing Application Insights project * Converts some variables to inline * Resolving misc. comments * Moves AddTelemetryPublisher to be an extension method * Removing IVariantFeatureManager GetFeatureNamesAsync definition, as it should it it's own PR * Remove unused dependency * Resolving comments * Remove invisible character changes * Remove Dependency Injection package * Update src/Microsoft.FeatureManagement/FeatureManagerSnapshot.cs * Update src/Microsoft.FeatureManagement/IVariantFeatureManager.cs * Persists cancellation token to PublishEvent and adds null check for null publisher collection * Adds TargetingContext to the EvaluationResult * Resolving comments * Removes TargetingContext from EvaluationEvent for now * Moves tags, etag, and label under 'TelemetryMetadata' * Adjusts telemetry metadata to already be a flattened dictionary * Removes bind in favor of ToDictionary. Removes unused using --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Application Insights Publisher (#281) * Adds Application Insights publisher * Change readonly to const * Update src/Microsoft.FeatureManagement.Telemetry.ApplicationInsights/ApplicationInsightsTelemetryPublisher.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Update src/Microsoft.FeatureManagement.Telemetry.ApplicationInsights/ApplicationInsightsTelemetryPublisher.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Adds example library for Application Insights * Adds readme to example * Updates readme and persists telemetry metadata by placing it in the correct field * Update README file for variants (#264) * update readme with variants, first draft * small summary revisions * fix wording of summary * fix code description * Apply suggestions from code review Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * revisions * PR revisions, describe Allocation properties, fix descriptions and titles * clarify configurationvalue possible values * clarify seed description * remove all mentions of On filter * fix example for override, clarify allowing no configurationvalue or reference * change statusoverride example * Apply suggestions from code review Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * revisions to summaries, fix allocation table --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Edits to README for variants (#289) * add edits for variants * fix wording * Simplified javascript and other slight modifications * Adjusts IVarantManager to use ValueTask (#293) * remove conflict mark * add missing comment & [Fact] attribute * Updates. * Updates. * Improvements. * Add missing project in sln file. * Fix various solution issues * missing project inclusion in solution file * Project declared nullable support but wasn't written with it in mind * pack.ps1 script didn't reference newest project. * Remove nullable usage. Other updates. * remove & add empty line * resolve conflicts * Fix project added twice. * use const string and feature flag referece * Add Telemetry section * Made section casing consistent. * Add section for enabling telemetry on flags. * Update TOC. * Use relative links. * should -> must * Updates based on feedback. Reordered telemetry sections. * Add note. * Update README.md * Update telemetry schema in feature flags. * Merges variants and isenabled paths. Adds variant reason field. (#290) * Adds Reason field and adjusts evaluation logic * use enum AssignmentReason * add more testcases & remove some interal methods * fix typo * update comments * resolve comments * update comment for DisabledDefault * fix typo * update * update telemetry publisher * add reason when no allocation section * update * remove nullable * resolve comments * update comments --------- Co-authored-by: zhiyuanliang <zhiyuanliang@microsoft.com> * Undo whitespace changes from merge. * Readme clarifications. Added argument exception if feature definition telemetry is null when passed into app insights telemetry publisher. * Update property summary. * Prepare packages for 4.0.0-preview release. * Add preview label. Update telemetry package description. * Bumps Application Insights version (#342) * Updates example application insights version (#344) * Mention TargetingContext and fix wording in Variants section of readme (#330) * mention itargetingcontextaccessor for variant allocation * update changes * add reference to ITargetingContextAccessor to readme for allocation * update with new discussed changes, rename sections and introduce context sooner * fix wording of default * fix wording to avoid implying variants are assigned per feature * use the term assign when referring to variants returned for a user * use assign term in more places * small changes * Update README.md Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * update section titles * resolve comments * fix typo * update link to allocating variants section --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Adds TargetingContext to EvaluationEvent & Emits TargetingId in the App Insights Publisher (#347) * Adds TargetingId to EvaluationEvent * Adjusts EvaluationEvent to use TargetingContext instead of ITargetingContext * move public method to the front of private method (#349) * Adds extension methods for TrackEvent and TrackMetric (#348) * Adds extension methods for TrackEvent and TrackMetric * Adds copyright, crefs, and uses []= instead of .Add for properties * Update src/Microsoft.FeatureManagement.Telemetry.ApplicationInsights/ApplicationInsightsTelemetryExtensions.cs Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Added null check, moved shared logic to helper functions * Removed TrackMetric extension for now --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Adds missing cref (#352) * Adjusts private methods from Task to ValueTask (#353) * Adds targeting middleware and targeting initializer (#350) * Adds targeting middleware and targeting initializer * Added logger and added prefix to targetingId * Apply suggestions from code review Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * Adjustments from comments --------- Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> * unify the parse methods * update * Adjusts example to use middleware and initializer for targeting id (#357) * Adjusts example to use middleware and initializer for targeting id * Update examples/EvaluationDataToApplicationInsights/README.md * remove unused package * Feature-based Injection (#335) * init * draft * use ValueTask * support factory method * add example * update * Update * Update * update example * match variant name or configuration value * update to the latest design * merge with preview branch * resolve comments * rename to VariantService * update & add comments * remove POC example * add testcases & use method name GetServiceAsync * update comments * add variant service cache * resolve comments * throw exception for duplicated registration * add testcase * remove unused package * update comment * set feature name in constructor * adjust-tab-size (#366) * Merge main to preview (#373) * Add a constructor without FeatureManagementOption parameter for FeatureManager (#363) * add new constructor * update * Target on .NET 8.0 (#365) * target on .NET 8.0 * remove file * add net8.0 for Microsoft.FeatureManagement.AspNetCore * update package version * update * Add feature management schema for main branch (#362) * schema file added * README update * update * update * update README & remove the Microsoft schema file * update readme * update * Updates test schema and adjusts title (#372) * Support Microsoft Feature Management schema for main branch (#370) * use snake case * do not support root fall back for MS schema & remove EnsureInit * update * rename variable * update .NET FM schema * re-add schema link * add whitespace (#374) * update --------- Co-authored-by: Ross Grambo <rossgrambo@microsoft.com> * add missing param comment (#380) * Version bump * Adds .Telemetry.ApplicationInsights.AspNetCore to build packages * Support Microsoft Feature Management schema for preview branch (#375) * support microsoft feature flag schema v2 * add more testcases * add empty lines * add schema & update README * update schema * update (#398) * Optional Cancellation Token (#395) * make cancelltation optional for feature manager & add cancellation token for session manager * revert breaking change in ISessionManager * remove unused package * Update README to mention the usage of feature-based injection (variant service) (#388) * update README * update * update * update * update * fix typo * update * update * Avoid redundant validation for cached TargetingFilterSettings (#387) * do validation during binding parameters * adjust method order * Update target framework for telemetry packages (#413) * update target framework * update language version * Adjusts namespace to simply ~.Telemetry * Adjusts ApplicationInsights extension methods namespace * Adjusts class name of TelemetryClientExceptions * Removed changes to FM.Telemetry.ApplicationInsights.AspNetCore namespace * Ensure the consistency of targeting evaluation across CPU architectures. (#405) * check system endianness * remove period * update reverse method * update comment * adjust comment * version bump (#420) * Move warning deeper into variant code * Adjusted warning message * Boolean zen * Updating from comments * Adjusted wording * Formatting update * Promote Microsoft FM schema in README (#414) * replace examples using Microsoft schema * update * correct section name * update * update schema reference link * Remove variant & telemetry support for .NET Feature Management schema (#421) * reorg test suite * remove variant and telemetry & reorg test suite * update * update constructor * update appsettings.json of EvaluationDataToApplicationInsights example project * update appsetting.json for all examples * add dependency for telemetry aspnetcore package (#439) * Support variant for FeatureTagHelper (#407) * add variant for feature tag helper * update * Negate also applies for variant * correct comment * update comment * update README * update README * throw exception for Requirement All * update readme * update * Moves telemetry publishing to Activity * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Juliano Leal Goncalves <julealgon@gmail.com> * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Juliano Leal Goncalves <julealgon@gmail.com> * Resolving comments * avoid null reference (#457) * Some formatting updates * Adjusted exception & exception message * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Juliano Leal Goncalves <julealgon@gmail.com> * Adjusts hosted service to use the ServiceProvider instead of manually creating the publisher * Update src/Microsoft.FeatureManagement/FeatureManager.cs Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com> * Resolving comments * Moved conditional checks * Switched to standard null checks * Adjusted to use activity parent instead of thread check and adjusted null or empty event field check * Updated string null check * Updates activity event to be PascalCase * update example name * Update Variant Example Application (#437) * add example for variant based injection * readme added * not use third-party api * update * update README * fix typo * use latest api * Switches to Activity for storing TargetingId and removes Microsoft.FeatureManagement.Telemetry.AspNetCore project * Removes Microsoft.FeatureManagement.Telemetry.ApplicationInsights.AspNetCore * Adds null check in middleware * Added debug logs for unexpected nulls * Respect .NET and Microsoft feature management schemas in configuration (#470) * respect all feature management schemas * add testcase * add testcase * correct test case * simplify methods * remove unused package * unify newline usage * remove useless code & rename variables * reuse ParseEnum * rename variable * Switching log from debug to warning (#471) * Switching log from debug to warning * Adjusted warning logs * adjust spacing * version bump 4.0.0-preview4 (#476) * fix typo in comment (#480) * Adjusts builder extension methods to be friendlier (#487) * Adds and adjusts builder extension methods * Removed UseFeatureManagement and adjusted name of AddAppInsightsTelemetryPublisher * Adjusts examples * Use ITargetingContext when calling GetVariantAsync (#484) * add variant feature manager extensions * use TContext to avoid future breaking change * TargetingContext in EvaluationEvent * update comments & not use ambient context in contextual case * update comment * use ITargetingContext & check runtime context type * use TargetingCotnext for private method * use var instead of type * revert change on ContextualTestFilter * update comment * update comment * remove configuration reference from variant feature flag (#488) * Renames and updates EvaluationDataToAppInsights example (#490) * Renames project and cleans up startup code + auth * Update examples/VariantAndTelemetryDemo/Program.cs Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com> --------- Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com> * For examples and tests- fixes warnings, updates packages, and updates… (#491) * Renames project and cleans up startup code + auth * For examples and tests- fixes warnings, updates packages, and updates .net versions * Switched to var * Reverted construtor away from primary constructor style * Missing semicolon * use TimeProvider (#452) (#492) Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com> * Removes preview (#493) * Removes unused using statements and cleans up spacing. (#496) --------- Co-authored-by: Amer Jusupovic <32405726+amerjusupovic@users.noreply.github.com> Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com> Co-authored-by: zhiyuanliang <zhiyuanliang@microsoft.com> Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com> Co-authored-by: Juliano Leal Goncalves <julealgon@gmail.com> Co-authored-by: AMER JUSUPOVIC <ajusupovic@microsoft.com>
1 parent 3b838a4 commit 636a702

File tree

227 files changed

+154919
-1985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+154919
-1985
lines changed

Microsoft.FeatureManagement.sln

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{FB
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.FeatureManagement.AspNetCore", "tests\Tests.FeatureManagement.AspNetCore\Tests.FeatureManagement.AspNetCore.csproj", "{FC0DC3E2-5646-4AEC-A7DB-2D6167BC3BB4}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "examples\ConsoleApp\ConsoleApp.csproj", "{7B98D293-F270-423E-A9A6-0D388E903AE9}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "examples\ConsoleApp\ConsoleApp.csproj", "{7B98D293-F270-423E-A9A6-0D388E903AE9}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPages", "examples\RazorPages\RazorPages.csproj", "{36DBB413-D9CA-4C56-AE5B-EAEA4C344DB3}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPages", "examples\RazorPages\RazorPages.csproj", "{36DBB413-D9CA-4C56-AE5B-EAEA4C344DB3}"
2121
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatureFlagDemo", "examples\FeatureFlagDemo\FeatureFlagDemo.csproj", "{DACAB624-4611-42E8-844C-529F93A54980}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatureFlagDemo", "examples\FeatureFlagDemo\FeatureFlagDemo.csproj", "{DACAB624-4611-42E8-844C-529F93A54980}"
2323
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TargetingConsoleApp", "examples\TargetingConsoleApp\TargetingConsoleApp.csproj", "{283D3EBB-4716-4F1D-BA51-A435F7E2AB82}"
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetingConsoleApp", "examples\TargetingConsoleApp\TargetingConsoleApp.csproj", "{283D3EBB-4716-4F1D-BA51-A435F7E2AB82}"
2525
EndProject
26-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorServerApp", "examples\BlazorServerApp\BlazorServerApp.csproj", "{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}"
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FeatureManagement.Telemetry.ApplicationInsights", "src\Microsoft.FeatureManagement.Telemetry.ApplicationInsights\Microsoft.FeatureManagement.Telemetry.ApplicationInsights.csproj", "{7964DC66-B2D3-412D-B18A-86D1E07D149D}"
27+
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VariantAndTelemetryDemo", "examples\VariantAndTelemetryDemo\VariantAndTelemetryDemo.csproj", "{1502529E-47E9-4306-98C4-BF6CF7C7C275}"
29+
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServerApp", "examples\BlazorServerApp\BlazorServerApp.csproj", "{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}"
31+
EndProject
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VariantServiceDemo", "examples\VariantServiceDemo\VariantServiceDemo.csproj", "{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F}"
2733
EndProject
2834
Global
2935
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -63,10 +69,22 @@ Global
6369
{283D3EBB-4716-4F1D-BA51-A435F7E2AB82}.Debug|Any CPU.Build.0 = Debug|Any CPU
6470
{283D3EBB-4716-4F1D-BA51-A435F7E2AB82}.Release|Any CPU.ActiveCfg = Release|Any CPU
6571
{283D3EBB-4716-4F1D-BA51-A435F7E2AB82}.Release|Any CPU.Build.0 = Release|Any CPU
72+
{7964DC66-B2D3-412D-B18A-86D1E07D149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73+
{7964DC66-B2D3-412D-B18A-86D1E07D149D}.Debug|Any CPU.Build.0 = Debug|Any CPU
74+
{7964DC66-B2D3-412D-B18A-86D1E07D149D}.Release|Any CPU.ActiveCfg = Release|Any CPU
75+
{7964DC66-B2D3-412D-B18A-86D1E07D149D}.Release|Any CPU.Build.0 = Release|Any CPU
76+
{1502529E-47E9-4306-98C4-BF6CF7C7C275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
77+
{1502529E-47E9-4306-98C4-BF6CF7C7C275}.Debug|Any CPU.Build.0 = Debug|Any CPU
78+
{1502529E-47E9-4306-98C4-BF6CF7C7C275}.Release|Any CPU.ActiveCfg = Release|Any CPU
79+
{1502529E-47E9-4306-98C4-BF6CF7C7C275}.Release|Any CPU.Build.0 = Release|Any CPU
6680
{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6781
{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}.Debug|Any CPU.Build.0 = Debug|Any CPU
6882
{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}.Release|Any CPU.ActiveCfg = Release|Any CPU
6983
{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}.Release|Any CPU.Build.0 = Release|Any CPU
84+
{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
87+
{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F}.Release|Any CPU.Build.0 = Release|Any CPU
7088
EndGlobalSection
7189
GlobalSection(SolutionProperties) = preSolution
7290
HideSolutionNode = FALSE
@@ -78,7 +96,9 @@ Global
7896
{36DBB413-D9CA-4C56-AE5B-EAEA4C344DB3} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
7997
{DACAB624-4611-42E8-844C-529F93A54980} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
8098
{283D3EBB-4716-4F1D-BA51-A435F7E2AB82} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
99+
{1502529E-47E9-4306-98C4-BF6CF7C7C275} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
81100
{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
101+
{E8E17CB9-434E-4386-BF96-FA53BBFDCD6F} = {FB5C34DF-695C-4DF9-8AED-B3EA2516EA72}
82102
EndGlobalSection
83103
GlobalSection(ExtensibilityGlobals) = postSolution
84104
SolutionGuid = {84DA6C54-F140-4518-A1B4-E4CF42117FBD}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Feature management provides a way to develop and expose application functionalit
2020
* [ASP.NET Core Web App (Razor Page)](./examples/RazorPages)
2121
* [ASP.NET Core Web App (MVC)](./examples/FeatureFlagDemo)
2222
* [Blazor Server App](./examples/BlazorServerApp)
23+
* [ASP.NET Core Web App with Variants and Telemetry](./examples/VariantAndTelemetryDemo)
24+
* [ASP.NET Core Web App with Variant Service](./examples/VariantServiceDemo)
2325

2426
## Contributing
2527

examples/BlazorServerApp/BlazorServerApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
7-
7+
88
<ItemGroup>
99
<ProjectReference Include="..\..\src\Microsoft.FeatureManagement\Microsoft.FeatureManagement.csproj" />
1010
</ItemGroup>

examples/BlazorServerApp/README.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,44 @@ This app demonstrates how to use the Feature Management library in Blazor apps.
1717
This app uses two feature flags: "BrowserEnhancement" and "Beta".
1818

1919
``` json
20-
"FeatureManagement": {
21-
"BrowserEnhancement": {
22-
"EnabledFor": [
23-
{
24-
"Name": "Browser",
25-
"Parameters": {
26-
"AllowedBrowsers": [ "Edge" ]
27-
}
20+
"feature_management": {
21+
"feature_flags": [
22+
{
23+
"id": "BrowserEnhancement",
24+
"enabled": true,
25+
"conditions": {
26+
"client_filters": [
27+
{
28+
"name": "Browser",
29+
"parameters": {
30+
"AllowedBrowsers": [ "Edge" ]
2831
}
32+
}
2933
]
34+
}
3035
},
31-
"Beta": {
32-
"EnabledFor": [
33-
{
34-
"Name": "Targeting",
35-
"Parameters": {
36-
"Audience": {
37-
"DefaultRolloutPercentage": 50,
38-
"Exclusion": {
39-
"Groups": [
40-
"Guests"
41-
]
42-
}
43-
}
36+
{
37+
"id": "Beta",
38+
"enabled": true,
39+
"conditions": {
40+
"client_filters": [
41+
{
42+
"name": "Targeting",
43+
"parameters": {
44+
"Audience": {
45+
"DefaultRolloutPercentage": 50,
46+
"Exclusion": {
47+
"Groups": [
48+
"Guests"
49+
]
4450
}
51+
}
4552
}
53+
}
4654
]
55+
}
4756
}
57+
]
4858
}
4959
```
5060

@@ -65,6 +75,7 @@ This app uses [cookie authentication](https://learn.microsoft.com/en-us/aspnet/c
6575
Rather than `HttpContext`, the [`AuthenticationStateProvider`](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-8.0#authenticationstateprovider-service) service is used to obtain the user authentication state information for setting targeting context. The details can be found in the [`MyTargetingContextAccessor`](./MyTargetingContextAccessor.cs).
6676

6777
## Service Registration
78+
6879
Blazor applications like this one typically pull ambient contextual data from scoped services. For example, the `UserAgentContext`, `AuthenticationStateProvider` and `ITargetingContextAccessor` are all scoped services. This pattern *breaks* if the feature management services are added as singleton, which is typical in non-blazor web apps.
6980

7081
In Blazor, *avoid* the following

examples/BlazorServerApp/appsettings.json

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,43 @@
66
}
77
},
88
"AllowedHosts": "*",
9-
"FeatureManagement": {
10-
"BrowserEnhancement": {
11-
"EnabledFor": [
12-
{
13-
"Name": "Browser",
14-
"Parameters": {
15-
"AllowedBrowsers": [ "Edge" ]
16-
}
9+
"feature_management": {
10+
"feature_flags": [
11+
{
12+
"id": "BrowserEnhancement",
13+
"enabled": true,
14+
"conditions": {
15+
"client_filters": [
16+
{
17+
"name": "Browser",
18+
"parameters": {
19+
"AllowedBrowsers": [ "Edge" ]
20+
}
21+
}
22+
]
1723
}
18-
]
19-
},
20-
"Beta": {
21-
"EnabledFor": [
22-
{
23-
"Name": "Targeting",
24-
"Parameters": {
25-
"Audience": {
26-
"DefaultRolloutPercentage": 50,
27-
"Exclusion": {
28-
"Groups": [
29-
"Guests"
30-
]
24+
},
25+
{
26+
"id": "Beta",
27+
"enabled": true,
28+
"conditions": {
29+
"client_filters": [
30+
{
31+
"name": "Targeting",
32+
"parameters": {
33+
"Audience": {
34+
"DefaultRolloutPercentage": 50,
35+
"Exclusion": {
36+
"Groups": [
37+
"Guests"
38+
]
39+
}
40+
}
3141
}
3242
}
33-
}
43+
]
3444
}
35-
]
36-
}
45+
}
46+
]
3747
}
3848
}

examples/ConsoleApp/ConsoleApp.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
11-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
10+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
11+
<PackageReference Include="System.Text.Json" Version="8.0.4" />
12+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
1213
</ItemGroup>
1314

1415
<ItemGroup>
@@ -20,5 +21,5 @@
2021
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2122
</None>
2223
</ItemGroup>
23-
24+
2425
</Project>
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
2-
"FeatureManagement": {
3-
"Beta": {
4-
"EnabledFor": [
5-
{
6-
"Name": "AccountId",
7-
"Parameters": {
8-
"AllowedAccounts": [ "abcdefghijklmnopqrstuvwxyz" ]
9-
}
2+
"feature_management": {
3+
"feature_flags": [
4+
{
5+
"id": "Beta",
6+
"enabled": true,
7+
"conditions": {
8+
"client_filters": [
9+
{
10+
"name": "AccountId",
11+
"parameters": {
12+
"AllowedAccounts": [ "abcdefghijklmnopqrstuvwxyz" ]
13+
}
14+
}
15+
]
1016
}
11-
]
12-
}
17+
}
18+
]
1319
}
1420
}

examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ namespace FeatureFlagDemo.Authentication
1515
///
1616
/// To assign a user, use the following query string structure "?username=JohnDoe&groups=MyGroup1,MyGroup2"
1717
/// </summary>
18-
class QueryStringAuthenticationHandler : AuthenticationHandler<QueryStringAuthenticationOptions>
18+
class QueryStringAuthenticationHandler(IOptionsMonitor<QueryStringAuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder) : AuthenticationHandler<QueryStringAuthenticationOptions>(options, logger, encoder)
1919
{
20-
public QueryStringAuthenticationHandler(IOptionsMonitor<QueryStringAuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)
21-
: base(options, logger, encoder, clock)
22-
{
23-
}
24-
2520
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
2621
{
2722
var identity = new ClaimsIdentity();
@@ -32,9 +27,9 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
3227
{
3328
string username = value.First();
3429

35-
identity.AddClaim(new Claim(System.Security.Claims.ClaimTypes.Name, username));
30+
identity.AddClaim(new Claim(ClaimTypes.Name, username));
3631

37-
Logger.LogInformation($"Assigning the username '{username}' to the request.");
32+
Logger.LogInformation("Assigning the username {username} to the request.", username);
3833
}
3934

4035
//
@@ -48,7 +43,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
4843
identity.AddClaim(new Claim(ClaimTypes.Role, group));
4944
}
5045

51-
Logger.LogInformation($"Assigning the following groups '{string.Join(", ", groups)}' to the request.");
46+
Logger.LogInformation("Assigning the following groups '{groups}' to the request.", string.Join(", ", groups));
5247
}
5348

5449
//

examples/FeatureFlagDemo/FeatureFlagDemo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="3.0.1" />
9+
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="7.3.0" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

0 commit comments

Comments
 (0)