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
4 changes: 4 additions & 0 deletions examples/BlazorServerApp/BlazorServerApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<ProjectReference Include="..\..\src\Microsoft.FeatureManagement\Microsoft.FeatureManagement.csproj" />
</ItemGroup>

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

</Project>
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; }
}
}
4 changes: 4 additions & 0 deletions examples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
</None>
</ItemGroup>

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

</Project>
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 @@ -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
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
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
6 changes: 5 additions & 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 Expand Up @@ -32,4 +32,8 @@
</Content>
</ItemGroup>

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

</Project>
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);
}
}
}
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()
{
}
}
}
}
4 changes: 4 additions & 0 deletions examples/RazorPages/RazorPages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<ProjectReference Include="..\..\src\Microsoft.FeatureManagement.AspNetCore\Microsoft.FeatureManagement.AspNetCore.csproj" />
</ItemGroup>

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

</Project>
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
2 changes: 0 additions & 2 deletions examples/TargetingConsoleApp/Identity/User.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 TargetingConsoleApp.Identity
{
class User
Expand Down
2 changes: 1 addition & 1 deletion examples/TargetingConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
// Output results
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} for the user '{userId}'.");
}
}
}
5 changes: 5 additions & 0 deletions examples/TargetingConsoleApp/TargetingConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public override async Task OnActionExecutionAsync(ActionExecutingContext context

//
// Enabled state is determined by either 'any' or 'all' features being enabled.
bool enabled = RequirementType == RequirementType.All ?
await Features.All(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false)) :
await Features.Any(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false));
bool enabled = RequirementType == RequirementType.All
? await Features.All(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false))
: await Features.Any(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false));

if (enabled)
{
Expand All @@ -134,9 +134,9 @@ public async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext contex

//
// Enabled state is determined by either 'any' or 'all' features being enabled.
bool enabled = RequirementType == RequirementType.All ?
await Features.All(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false)) :
await Features.Any(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false));
bool enabled = RequirementType == RequirementType.All
? await Features.All(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false))
: await Features.Any(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false));

if (enabled)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\NugetProperties.props" />

<!-- Official Version -->
Expand Down Expand Up @@ -44,4 +44,8 @@
<Copy SourceFiles="$(DocumentationFile)" DestinationFolder="$(OutDir)\XMLComments" SkipUnchangedFiles="false" />
</Target>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
{
IEnumerable<string> names = Name.Split(',').Select(n => n.Trim());

enabled = Requirement == RequirementType.All ?
await names.All(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false)) :
await names.Any(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false));
enabled = Requirement == RequirementType.All
? await names.All(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false))
: await names.Any(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false));
}

if (Negate)
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.FeatureManagement/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System.Runtime.CompilerServices;
Expand All @@ -9,4 +9,4 @@
"3ae70fbea5662f61dd9d640de2205b7bd5359a43dda006e51d83d1f5f7a7d3f849267a0a28676d" +
"cf49727a32487d4c75c4aacd5febb0069e1adc66ec63bbd18ec2276091a0e3c1326aa626c9e4db" +
"800714a134f2a81e405f35752b55220021923429cb61776cd2fa66d25c335f8dc27bb92292905a" +
"3798d896")]
"3798d896")]
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ private IEnumerable<IConfigurationSection> GetFeatureDefinitionSections()
.FirstOrDefault(section =>
string.Equals(
section.Key,
_microsoftFeatureManagementSchemaEnabled ?
MicrosoftFeatureManagementFields.FeatureManagementSectionName :
ConfigurationFields.FeatureManagementSectionName,
_microsoftFeatureManagementSchemaEnabled
? MicrosoftFeatureManagementFields.FeatureManagementSectionName
: ConfigurationFields.FeatureManagementSectionName,
StringComparison.OrdinalIgnoreCase));

if (featureManagementConfigurationSection == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.FeatureManagement/ConfigurationFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ internal static class ConfigurationFields
public const string NameKeyword = "Name";
public const string FeatureManagementSectionName = "FeatureManagement";
}
}
}
Loading