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
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# editorconfig.org

# top-most EditorConfig file
root = true

## Default settings ##
[*]
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

## Formatting rule ##
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055
dotnet_diagnostic.IDE0055.severity = error

# 'Using' directive preferences
dotnet_sort_system_directives_first = false

# New line preferences
dotnet_diagnostic.IDE2002.severity = error
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
dotnet_diagnostic.IDE2004.severity = error
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
dotnet_diagnostic.IDE2005.severity = error
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
dotnet_diagnostic.IDE2006.severity = error
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
dotnet_diagnostic.IDE2000.severity = error
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_diagnostic.IDE2003.severity = error
dotnet_style_allow_statement_immediately_after_block_experimental = false

[*.csproj]
indent_size = 2
charset = utf-8

[*.json]
indent_size = 2
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<PropertyGroup>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# .NET Feature Management

[![Microsoft.FeatureManagement](https://img.shields.io/nuget/v/Microsoft.FeatureManagement?label=Microsoft.FeatureManagement)](https://www.nuget.org/packages/Microsoft.FeatureManagement)
[![Microsoft.FeatureManagement.AspNetCore](https://img.shields.io/nuget/v/Microsoft.FeatureManagement.AspNetCore?label=Microsoft.FeatureManagement.AspNetCore)](https://www.nuget.org/packages/Microsoft.FeatureManagement.AspNetCore)

Feature management provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common .NET code patterns to make exposing these features possible.

## Get started
Expand Down
2 changes: 1 addition & 1 deletion examples/BlazorServerApp/BlazorServerApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.FeatureManagement\Microsoft.FeatureManagement.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/BlazorServerApp/BrowserFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static bool IsChromeBrowser(string userAgentContext)
return false;
}

return userAgentContext.Contains("chrome", StringComparison.OrdinalIgnoreCase) &&
return userAgentContext.Contains("chrome", StringComparison.OrdinalIgnoreCase) &&
!userAgentContext.Contains("edg", StringComparison.OrdinalIgnoreCase);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/BlazorServerApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ public static void Main(string[] args)
app.Run();
}
}
}
}
2 changes: 1 addition & 1 deletion examples/ConsoleApp/AccountServiceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class AccountServiceContext : IAccountContext
{
public string AccountId { get; set; }
}
}
7 changes: 5 additions & 2 deletions examples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.Extensions.Configuration;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FeatureManagement;

Expand Down Expand Up @@ -49,4 +52,4 @@
// Output results
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} for the '{account}' account.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace EvaluationDataToApplicationInsights.Pages
public class CheckoutModel : PageModel
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public void OnGet()
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public IActionResult OnPost()
{
string val = Request.Form["imageScore"];

if (val != null &&
if (val != null &&
int.TryParse(val, out int rating))
{
_telemetry.TrackEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
// Licensed under the MIT license.
//
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;

namespace FeatureFlagDemo.Authentication
{
Expand Down Expand Up @@ -49,7 +45,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()

foreach (string group in groups)
{
identity.AddClaim(new Claim(ClaimTypes.GroupName, group));
identity.AddClaim(new Claim(ClaimTypes.Role, group));
}

Logger.LogInformation($"Assigning the following groups '{string.Join(", ", groups)}' to the request.");
Expand Down
5 changes: 0 additions & 5 deletions examples/FeatureFlagDemo/BrowserFilter.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.FeatureManagement;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
{
Expand Down
2 changes: 0 additions & 2 deletions examples/FeatureFlagDemo/BrowserFilterSettings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Collections.Generic;

namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
{
public class BrowserFilterSettings
Expand Down
10 changes: 0 additions & 10 deletions examples/FeatureFlagDemo/ClaimTypes.cs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/Controllers/BetaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace FeatureFlagDemo.Controllers
{
public class BetaController: Controller
public class BetaController : Controller
{
private readonly IFeatureManager _featureManager;

Expand Down
6 changes: 2 additions & 4 deletions examples/FeatureFlagDemo/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using FeatureFlagDemo.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.Mvc;
using System.Threading.Tasks;
using System.Diagnostics;

namespace FeatureFlagDemo.Controllers
{
Expand Down
2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/FeatureFlagDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand Down
66 changes: 0 additions & 66 deletions examples/FeatureFlagDemo/HttpContextTargetingContextAccessor.cs

This file was deleted.

4 changes: 1 addition & 3 deletions examples/FeatureFlagDemo/Models/ErrorViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System;

namespace FeatureFlagDemo.Models
{
public class ErrorViewModel
Expand All @@ -11,4 +9,4 @@ public class ErrorViewModel

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
}
2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddFeatureManagement()
.AddFeatureFilter<BrowserFilter>()
.WithTargeting<HttpContextTargetingContextAccessor>()
.WithTargeting()
.UseDisabledFeaturesHandler(new FeatureNotEnabledDisabledHandler());

services.AddMvc(o =>
Expand Down
1 change: 0 additions & 1 deletion examples/FeatureFlagDemo/SuperUserFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.
//
using Microsoft.FeatureManagement;
using System.Threading.Tasks;

namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
{
Expand Down
2 changes: 0 additions & 2 deletions examples/FeatureFlagDemo/ThirdPartyActionFilter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace FeatureFlagDemo
{
Expand Down
4 changes: 0 additions & 4 deletions examples/FeatureFlagDemo/ThirdPartyMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;

namespace FeatureFlagDemo
{
public class ThirdPartyMiddleware
Expand Down
2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/Views/Shared/Error.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public void OnGet()
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
}
2 changes: 1 addition & 1 deletion examples/RazorPages/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public void OnGet()
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
}
2 changes: 1 addition & 1 deletion examples/RazorPages/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public void OnGet()

}
}
}
}
5 changes: 2 additions & 3 deletions examples/RazorPages/Pages/Privacy.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace RazorPages.Pages
{
Expand All @@ -16,4 +15,4 @@ public void OnGet()
{
}
}
}
}
2 changes: 0 additions & 2 deletions examples/TargetingConsoleApp/Identity/IUserRepository.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Threading.Tasks;

namespace TargetingConsoleApp.Identity
{
interface IUserRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TargetingConsoleApp.Identity
{
class InMemoryUserRepository : IUserRepository
Expand Down
Loading