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>
7 changes: 6 additions & 1 deletion examples/ConfigStoreDemo/ConfigStoreDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Azure.AppConfiguration.AspNetCore\Microsoft.Azure.AppConfiguration.AspNetCore.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
4 changes: 0 additions & 4 deletions examples/ConfigStoreDemo/Pages/About.cshtml.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 System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.Examples.ConfigStoreDemo.Pages
Expand Down
4 changes: 0 additions & 4 deletions examples/ConfigStoreDemo/Pages/Contact.cshtml.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 System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.Examples.ConfigStoreDemo.Pages
Expand Down
6 changes: 1 addition & 5 deletions examples/ConfigStoreDemo/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.Examples.ConfigStoreDemo.Pages
{
Expand Down
2 changes: 1 addition & 1 deletion examples/ConsoleApplication/ConsoleApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
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" />

<PropertyGroup>
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" />

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654" +
"753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46" +
"ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484c" +
"f7045cc7")]
"f7045cc7")]
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public AzureAppConfigurationProvider(IConfigurationClientManager configClientMan
requestTracingDisabled = Environment.GetEnvironmentVariable(RequestTracingConstants.RequestTracingDisabledEnvironmentVariable);
}
catch (SecurityException) { }

_requestTracingEnabled = bool.TryParse(requestTracingDisabled, out bool tracingDisabled) ? !tracingDisabled : true;

if (_requestTracingEnabled)
Expand Down Expand Up @@ -208,7 +209,7 @@ public async Task RefreshAsync(CancellationToken cancellationToken)

//
// Filter clients based on their backoff status
clients = clients.Where(client =>
clients = clients.Where(client =>
{
Uri endpoint = _configClientManager.GetEndpointForClient(client);

Expand Down Expand Up @@ -320,7 +321,8 @@ await CallWithRequestTracing(
refreshAll = true;
break;
}
} else
}
else
{
logDebugBuilder.AppendLine(LogHelper.BuildKeyValueReadMessage(change.ChangeType, change.Key, change.Label, endpoint.ToString()));
}
Expand Down Expand Up @@ -697,7 +699,7 @@ private async Task<bool> TryInitializeAsync(IEnumerable<ConfigurationClient> cli

return false;
}

throw;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class AzureAppConfigurationRefreshOptions
{
internal TimeSpan CacheExpirationInterval { get; private set; } = RefreshConstants.DefaultCacheExpirationInterval;
internal ISet<KeyValueWatcher> RefreshRegistrations = new HashSet<KeyValueWatcher>();

/// <summary>
/// Register the specified individual key-value to be refreshed when the configuration provider's <see cref="IConfigurationRefresher"/> triggers a refresh.
/// The <see cref="IConfigurationRefresher"/> instance can be obtained by calling <see cref="AzureAppConfigurationOptions.GetRefresher()"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal class AzureAppConfigurationSource : IConfigurationSource

public AzureAppConfigurationSource(Action<AzureAppConfigurationOptions> optionsInitializer, bool optional = false)
{
_optionsProvider = () => {
_optionsProvider = () =>
{
var options = new AzureAppConfigurationOptions();
optionsInitializer(options);
return options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ private string ParseSecretReferenceUri(ConfigurationSetting setting)
return secretRefUri;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void RefreshClients()
{
DateTimeOffset now = DateTimeOffset.UtcNow;

if (_replicaDiscoveryEnabled &&
if (_replicaDiscoveryEnabled &&
now >= _lastFallbackClientRefreshAttempt + MinimalClientRefreshInterval)
{
_lastFallbackClientRefreshAttempt = now;
Expand Down Expand Up @@ -262,9 +262,9 @@ private async Task RefreshFallbackClients(CancellationToken cancellationToken)

// Honor with the DNS based service discovery protocol, but shuffle the results first to ensure hosts can be picked randomly,
// Srv lookup does retrieve trailing dot in the host name, just trim it.
IEnumerable<string> OrderedHosts = srvTargetHosts.Any() ?
srvTargetHosts.ToList().Shuffle().SortSrvRecords().Select(r => $"{r.Target.Value.TrimEnd('.')}") :
Enumerable.Empty<string>();
IEnumerable<string> OrderedHosts = srvTargetHosts.Any()
? srvTargetHosts.ToList().Shuffle().SortSrvRecords().Select(r => $"{r.Target.Value.TrimEnd('.')}")
: Enumerable.Empty<string>();

foreach (string host in OrderedHosts)
{
Expand All @@ -274,9 +274,9 @@ private async Task RefreshFallbackClients(CancellationToken cancellationToken)
{
var targetEndpoint = new Uri($"https://{host}");

var configClient = _credential == null ?
new ConfigurationClient(ConnectionStringUtils.Build(targetEndpoint, _id, _secret), _clientOptions) :
new ConfigurationClient(targetEndpoint, _credential, _clientOptions);
var configClient = _credential == null
? new ConfigurationClient(ConnectionStringUtils.Build(targetEndpoint, _id, _secret), _clientOptions)
: new ConfigurationClient(targetEndpoint, _credential, _clientOptions);

newDynamicClients.Add(new ConfigurationClientWrapper(targetEndpoint, configClient));
}
Expand Down Expand Up @@ -320,7 +320,7 @@ internal bool IsValidEndpoint(string hostName)

public void Dispose()
{
if (!_isDisposed)
if (!_isDisposed)
{
_cancellationTokenSource.Cancel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ internal class HttpStatusCodes
// This constant is necessary because System.Net.HttpStatusCode.TooManyRequests is only available in netstandard2.1 and higher.
public static readonly int TooManyRequests = 429;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class RequestTracingConstants
public const string AzureWebAppEnvironmentVariable = "WEBSITE_SITE_NAME";
public const string ContainerAppEnvironmentVariable = "CONTAINER_APP_NAME";
public const string KubernetesEnvironmentVariable = "KUBERNETES_PORT";

public const string AspNetCoreEnvironmentVariable = "ASPNETCORE_ENVIRONMENT";
public const string DotNetCoreEnvironmentVariable = "DOTNET_ENVIRONMENT";
public const string DevelopmentEnvironmentName = "Development";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class KeyVaultReferenceException : Exception
/// <param name="inner">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. /// </param>
public KeyVaultReferenceException(string message,
Exception inner)
:base(string.Empty, inner)
: base(string.Empty, inner)
{
_message = message;
}
Expand All @@ -29,7 +29,7 @@ public KeyVaultReferenceException(string message,
///Gets a message that describes the current exception.
///Returns The error message that explains the reason for the exception, or an empty string("").
/// </summary>
public override string Message => $"{_message} ErrorCode:'{ErrorCode}' Key:'{Key}' Label:'{Label}' Etag:'{Etag}' SecretIdentifier:'{SecretIdentifier}'";
public override string Message => $"{_message} ErrorCode:'{ErrorCode}' Key:'{Key}' Label:'{Label}' Etag:'{Etag}' SecretIdentifier:'{SecretIdentifier}'";

/// <summary>
/// The key of the Key Vault reference that caused the exception.
Expand All @@ -56,5 +56,4 @@ public KeyVaultReferenceException(string message,
/// </summary>
public string ErrorCode { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static async Task<IEnumerable<KeyValueChange>> GetKeyValueChangeCollectio
await TracingUtils.CallWithRequestTracing(options.RequestTracingEnabled, RequestType.Watch, options.RequestTracingOptions,
async () =>
{
await foreach(ConfigurationSetting setting in client.GetConfigurationSettingsAsync(selector, cancellationToken).ConfigureAwait(false))
await foreach (ConfigurationSetting setting in client.GetConfigurationSettingsAsync(selector, cancellationToken).ConfigureAwait(false))
{
if (!eTagMap.TryGetValue(setting.Key, out ETag etag) || !etag.Equals(setting.ETag))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ public static bool TryCreatePushNotification(this EventGridEvent eventGridEvent,
return false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ public static void AppendUnique<T>(this List<T> items, T item)
items.Add(item);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ internal class ClientFilter

public JsonElement Parameters { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ internal class FeatureConditions

public string RequirementType { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class FeatureFilterTracing
public bool UsesPercentageFilter { get; set; } = false;
public bool UsesTimeWindowFilter { get; set; } = false;
public bool UsesTargetingFilter { get; set; } = false;

public bool UsesAnyFeatureFilter()
{
return UsesCustomFilter || UsesPercentageFilter || UsesTimeWindowFilter || UsesTargetingFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ internal class FeatureFlag

public FeatureConditions Conditions { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.Extensions.Configuration.AzureAppConfiguration.Models;
using Microsoft.Extensions.Configuration.AzureAppConfiguration.Extensions;
using Microsoft.Extensions.Configuration.AzureAppConfiguration.Models;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private FeatureConditions ParseFeatureConditions(ref Utf8JsonReader reader, stri

default:
reader.Skip();

break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void VisitJsonElement(JsonElement element)
{
VisitJsonProperty(property);
}

break;

case JsonValueKind.Array:
Expand All @@ -45,6 +46,7 @@ private void VisitJsonElement(JsonElement element)
VisitJsonElement(element[index]);
ExitContext();
}

break;

case JsonValueKind.String:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.Configuration.AzureAppConfiguration
{
internal class JsonKeyValueAdapter : IKeyValueAdapter
{
private static readonly IEnumerable<string> ExcludedJsonContentTypes = new[]
private static readonly IEnumerable<string> ExcludedJsonContentTypes = new[]
{
FeatureManagementConstants.ContentType,
KeyVaultConstants.ContentType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\build\NugetProperties.props" />

<PropertyGroup>
Expand Down Expand Up @@ -50,5 +51,5 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>

</Project>
Loading