Skip to content

Commit b29b86b

Browse files
Merge pull request #473 from microsoft/zhiyuanliang/merge-main-to-preview
Merge main to preview
2 parents 7681f37 + 7557b1d commit b29b86b

File tree

61 files changed

+247
-204
lines changed

Some content is hidden

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

61 files changed

+247
-204
lines changed

.editorconfig

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
## Default settings ##
7+
[*]
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 4
11+
trim_trailing_whitespace = true
12+
13+
## Formatting rule ##
14+
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055
15+
dotnet_diagnostic.IDE0055.severity = error
16+
17+
# 'Using' directive preferences
18+
dotnet_sort_system_directives_first = false
19+
20+
# New line preferences
21+
dotnet_diagnostic.IDE2002.severity = error
22+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
23+
dotnet_diagnostic.IDE2004.severity = error
24+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
25+
dotnet_diagnostic.IDE2005.severity = error
26+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
27+
dotnet_diagnostic.IDE2006.severity = error
28+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
29+
dotnet_diagnostic.IDE2000.severity = error
30+
dotnet_style_allow_multiple_blank_lines_experimental = false
31+
dotnet_diagnostic.IDE2003.severity = error
32+
dotnet_style_allow_statement_immediately_after_block_experimental = false
33+
34+
[*.csproj]
35+
indent_size = 2
36+
charset = utf-8
37+
38+
[*.json]
39+
indent_size = 2

Directory.Build.props

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
5+
</PropertyGroup>
6+
7+
</Project>

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# .NET Feature Management
22

3+
[![Microsoft.FeatureManagement](https://img.shields.io/nuget/v/Microsoft.FeatureManagement?label=Microsoft.FeatureManagement)](https://www.nuget.org/packages/Microsoft.FeatureManagement)
4+
[![Microsoft.FeatureManagement.AspNetCore](https://img.shields.io/nuget/v/Microsoft.FeatureManagement.AspNetCore?label=Microsoft.FeatureManagement.AspNetCore)](https://www.nuget.org/packages/Microsoft.FeatureManagement.AspNetCore)
5+
36
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.
47

58
## Get started

examples/BlazorServerApp/BlazorServerApp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net6.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/BrowserFilter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private static bool IsChromeBrowser(string userAgentContext)
4545
return false;
4646
}
4747

48-
return userAgentContext.Contains("chrome", StringComparison.OrdinalIgnoreCase) &&
48+
return userAgentContext.Contains("chrome", StringComparison.OrdinalIgnoreCase) &&
4949
!userAgentContext.Contains("edg", StringComparison.OrdinalIgnoreCase);
5050
}
5151

examples/BlazorServerApp/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ public static void Main(string[] args)
4848
app.Run();
4949
}
5050
}
51-
}
51+
}

examples/ConsoleApp/AccountServiceContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
class AccountServiceContext : IAccountContext
55
{
66
public string AccountId { get; set; }
7-
}
7+
}

examples/ConsoleApp/Program.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using Microsoft.Extensions.Configuration;
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
//
4+
using Microsoft.Extensions.Configuration;
25
using Microsoft.Extensions.DependencyInjection;
36
using Microsoft.FeatureManagement;
47

@@ -49,4 +52,4 @@
4952
// Output results
5053
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} for the '{account}' account.");
5154
}
52-
}
55+
}

examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace EvaluationDataToApplicationInsights.Pages
55
public class CheckoutModel : PageModel
66
{
77
}
8-
}
8+
}

examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ public void OnGet()
2424
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2525
}
2626
}
27-
}
27+
}

examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public IActionResult OnPost()
4747
{
4848
string val = Request.Form["imageScore"];
4949

50-
if (val != null &&
50+
if (val != null &&
5151
int.TryParse(val, out int rating))
5252
{
5353
_telemetry.TrackEvent(

examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
// Licensed under the MIT license.
33
//
44
using Microsoft.AspNetCore.Authentication;
5-
using Microsoft.Extensions.Logging;
65
using Microsoft.Extensions.Options;
76
using Microsoft.Extensions.Primitives;
8-
using System.Collections.Generic;
9-
using System.Linq;
107
using System.Security.Claims;
118
using System.Text.Encodings.Web;
12-
using System.Threading.Tasks;
139

1410
namespace FeatureFlagDemo.Authentication
1511
{
@@ -49,7 +45,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
4945

5046
foreach (string group in groups)
5147
{
52-
identity.AddClaim(new Claim(ClaimTypes.GroupName, group));
48+
identity.AddClaim(new Claim(ClaimTypes.Role, group));
5349
}
5450

5551
Logger.LogInformation($"Assigning the following groups '{string.Join(", ", groups)}' to the request.");

examples/FeatureFlagDemo/BrowserFilter.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using Microsoft.AspNetCore.Http;
5-
using Microsoft.Extensions.Configuration;
64
using Microsoft.FeatureManagement;
7-
using System;
8-
using System.Linq;
9-
using System.Threading.Tasks;
105

116
namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
127
{

examples/FeatureFlagDemo/BrowserFilterSettings.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System.Collections.Generic;
5-
64
namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
75
{
86
public class BrowserFilterSettings

examples/FeatureFlagDemo/ClaimTypes.cs

-10
This file was deleted.

examples/FeatureFlagDemo/Controllers/BetaController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace FeatureFlagDemo.Controllers
99
{
10-
public class BetaController: Controller
10+
public class BetaController : Controller
1111
{
1212
private readonly IFeatureManager _featureManager;
1313

examples/FeatureFlagDemo/Controllers/HomeController.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System.Diagnostics;
5-
using Microsoft.AspNetCore.Mvc;
64
using FeatureFlagDemo.Models;
7-
using Microsoft.AspNetCore.Http;
5+
using Microsoft.AspNetCore.Mvc;
86
using Microsoft.FeatureManagement;
97
using Microsoft.FeatureManagement.Mvc;
10-
using System.Threading.Tasks;
8+
using System.Diagnostics;
119

1210
namespace FeatureFlagDemo.Controllers
1311
{

examples/FeatureFlagDemo/FeatureFlagDemo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>

examples/FeatureFlagDemo/HttpContextTargetingContextAccessor.cs

-66
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System;
5-
64
namespace FeatureFlagDemo.Models
75
{
86
public class ErrorViewModel
@@ -11,4 +9,4 @@ public class ErrorViewModel
119

1210
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1311
}
14-
}
12+
}

examples/FeatureFlagDemo/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services)
4545

4646
services.AddFeatureManagement()
4747
.AddFeatureFilter<BrowserFilter>()
48-
.WithTargeting<HttpContextTargetingContextAccessor>()
48+
.WithTargeting()
4949
.UseDisabledFeaturesHandler(new FeatureNotEnabledDisabledHandler());
5050

5151
services.AddMvc(o =>

examples/FeatureFlagDemo/SuperUserFilter.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33
//
44
using Microsoft.FeatureManagement;
5-
using System.Threading.Tasks;
65

76
namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
87
{

examples/FeatureFlagDemo/ThirdPartyActionFilter.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System.Threading.Tasks;
54
using Microsoft.AspNetCore.Mvc.Filters;
6-
using Microsoft.Extensions.Logging;
75

86
namespace FeatureFlagDemo
97
{

examples/FeatureFlagDemo/ThirdPartyMiddleware.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using Microsoft.AspNetCore.Http;
5-
using Microsoft.Extensions.Logging;
6-
using System.Threading.Tasks;
7-
84
namespace FeatureFlagDemo
95
{
106
public class ThirdPartyMiddleware

examples/FeatureFlagDemo/Views/Shared/Error.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ public void OnGet()
2424
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2525
}
2626
}
27-
}
27+
}

examples/RazorPages/Pages/Error.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ public void OnGet()
2424
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2525
}
2626
}
27-
}
27+
}

examples/RazorPages/Pages/Index.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public void OnGet()
1818

1919
}
2020
}
21-
}
21+
}

examples/RazorPages/Pages/Privacy.cshtml.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.AspNetCore.Mvc;
2-
using Microsoft.AspNetCore.Mvc.RazorPages;
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
32

43
namespace RazorPages.Pages
54
{
@@ -16,4 +15,4 @@ public void OnGet()
1615
{
1716
}
1817
}
19-
}
18+
}

examples/TargetingConsoleApp/Identity/IUserRepository.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System.Threading.Tasks;
5-
64
namespace TargetingConsoleApp.Identity
75
{
86
interface IUserRepository

examples/TargetingConsoleApp/Identity/InMemoryUserRepository.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33
//
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
84
namespace TargetingConsoleApp.Identity
95
{
106
class InMemoryUserRepository : IUserRepository

0 commit comments

Comments
 (0)