Skip to content

Commit

Permalink
style: format code with dotnet-format
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in fc6d559 according to the output
from dotnet-format.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Jan 19, 2024
1 parent fc6d559 commit 718ef7a
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 147 deletions.
32 changes: 16 additions & 16 deletions src/Configuration/AutoConfiguratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ public class AutoConfiguratorConfiguration : Collection<type>
public class AutoConfiguratorConfigurator(IConfiguration configuration)
: IConfigureOptions<AutoConfiguratorConfiguration>
{
public void Configure(AutoConfiguratorConfiguration options)
{
var section = configuration.GetSection(AutoConfiguratorConfiguration.SectionName);
Console.WriteLine(section.ToJson());
if (section.Exists())
{
foreach (var configurator in section.GetChildren())
{
var type = Type.GetType(configurator.Value);
if (type != null)
{
options.Add(type);
}
}
}
}
public void Configure(AutoConfiguratorConfiguration options)
{
var section = configuration.GetSection(AutoConfiguratorConfiguration.SectionName);
Console.WriteLine(section.ToJson());
if (section.Exists())
{
foreach (var configurator in section.GetChildren())
{
var type = Type.GetType(configurator.Value);
if (type != null)
{
options.Add(type);
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/Configuration/KeyPerJsonFileConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ bool recursive
.EnumerateFiles(
"*.json",
recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly
)
// .Where(IsForThisEnvironment)
)
// .Where(IsForThisEnvironment)
.OrderBy(jsonFile => jsonFile.Name);

internal static string RemoveEnvironmentIfIsForThisEnvironment(this string jsonFileName) =>
Expand Down
128 changes: 64 additions & 64 deletions src/Http/Mime/TempMediaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,68 @@ namespace Dgmjr.Mime;

public readonly record struct TempMediaType(string Name) : IMediaType
{
public string DisplayName { get; } = Name;
private static readonly MD5 MD5 = MD5.Create();
public string[] Synonyms { get; init; } = Empty<string>();
Uri IHaveAUri.Uri => new(UriString);
object IIdentifiable.Id => Id;
public int Id => 0;
public int Value => Id;
public string UriString => "urn:publicid:temp:media-type:" + DisplayName.ToKebabCase();
public string GuidString => MD5.ComputeHash(UriString.ToUTF8Bytes()).ToHexString();
public guid Guid => new(GuidString);
public string Description => Name;
public string GroupName => Name;
public string ShortName => Name;
public string Name => DisplayName;
public int Order => 0;
public string Prompt => "";

// uri IMediaType.Uri => UriString;
// uri IHaveAuri.Uri => UriString;

object IHaveAValue.Value => Value;

int IHaveAValue<int>.Value => Id;

MediaTypes IHaveAValue<MediaTypes>.Value => MediaTypes.Any;

TypeCode IConvertible.GetTypeCode() => TypeCode.Object;

bool IConvertible.ToBoolean(IFormatProvider? provider) => true;

byte IConvertible.ToByte(IFormatProvider? provider) => Convert.ToByte(Value);

char IConvertible.ToChar(IFormatProvider? provider) => Convert.ToChar(Value);

datetime IConvertible.ToDateTime(IFormatProvider? provider) => Convert.ToDateTime(Value);

decimal IConvertible.ToDecimal(IFormatProvider? provider) => Convert.ToDecimal(Value);

double IConvertible.ToDouble(IFormatProvider? provider) => Convert.ToDouble(Value);

short IConvertible.ToInt16(IFormatProvider? provider) => Convert.ToInt16(Value);

int IConvertible.ToInt32(IFormatProvider? provider) => Convert.ToInt32(Value);

long IConvertible.ToInt64(IFormatProvider? provider) => Convert.ToInt64(Value);

sbyte IConvertible.ToSByte(IFormatProvider? provider) => Convert.ToSByte(Value);

float IConvertible.ToSingle(IFormatProvider? provider) => Convert.ToSingle(Value);

string IConvertible.ToString(IFormatProvider? provider) => Convert.ToString(Value);

object IConvertible.ToType(type conversionType, IFormatProvider? provider) =>
Convert.ChangeType(Value, conversionType);

ushort IConvertible.ToUInt16(IFormatProvider? provider) => Convert.ToUInt16(Value);

uint IConvertible.ToUInt32(IFormatProvider? provider) => Convert.ToUInt32(Value);

ulong IConvertible.ToUInt64(IFormatProvider? provider) => Convert.ToUInt64(Value);

bool IEquatable<int>.Equals(int other) => Id == other;

bool IEquatable<IMediaType>.Equals(IMediaType other) => this.Matches(other);
public string DisplayName { get; } = Name;
private static readonly MD5 MD5 = MD5.Create();
public string[] Synonyms { get; init; } = Empty<string>();
Uri IHaveAUri.Uri => new(UriString);
object IIdentifiable.Id => Id;
public int Id => 0;
public int Value => Id;
public string UriString => "urn:publicid:temp:media-type:" + DisplayName.ToKebabCase();
public string GuidString => MD5.ComputeHash(UriString.ToUTF8Bytes()).ToHexString();
public guid Guid => new(GuidString);
public string Description => Name;
public string GroupName => Name;
public string ShortName => Name;
public string Name => DisplayName;
public int Order => 0;
public string Prompt => "";

// uri IMediaType.Uri => UriString;
// uri IHaveAuri.Uri => UriString;

object IHaveAValue.Value => Value;

int IHaveAValue<int>.Value => Id;

MediaTypes IHaveAValue<MediaTypes>.Value => MediaTypes.Any;

TypeCode IConvertible.GetTypeCode() => TypeCode.Object;

bool IConvertible.ToBoolean(IFormatProvider? provider) => true;

byte IConvertible.ToByte(IFormatProvider? provider) => Convert.ToByte(Value);

char IConvertible.ToChar(IFormatProvider? provider) => Convert.ToChar(Value);

datetime IConvertible.ToDateTime(IFormatProvider? provider) => Convert.ToDateTime(Value);

decimal IConvertible.ToDecimal(IFormatProvider? provider) => Convert.ToDecimal(Value);

double IConvertible.ToDouble(IFormatProvider? provider) => Convert.ToDouble(Value);

short IConvertible.ToInt16(IFormatProvider? provider) => Convert.ToInt16(Value);

int IConvertible.ToInt32(IFormatProvider? provider) => Convert.ToInt32(Value);

long IConvertible.ToInt64(IFormatProvider? provider) => Convert.ToInt64(Value);

sbyte IConvertible.ToSByte(IFormatProvider? provider) => Convert.ToSByte(Value);

float IConvertible.ToSingle(IFormatProvider? provider) => Convert.ToSingle(Value);

string IConvertible.ToString(IFormatProvider? provider) => Convert.ToString(Value);

object IConvertible.ToType(type conversionType, IFormatProvider? provider) =>
Convert.ChangeType(Value, conversionType);

ushort IConvertible.ToUInt16(IFormatProvider? provider) => Convert.ToUInt16(Value);

uint IConvertible.ToUInt32(IFormatProvider? provider) => Convert.ToUInt32(Value);

ulong IConvertible.ToUInt64(IFormatProvider? provider) => Convert.ToUInt64(Value);

bool IEquatable<int>.Equals(int other) => Id == other;

bool IEquatable<IMediaType>.Equals(IMediaType other) => this.Matches(other);
}
130 changes: 65 additions & 65 deletions src/Http/Services/HttpServicesExtensions.UseHttpServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
{
var options = app.ApplicationServices.GetRequiredService<IOptions<HttpServicesOptions>>().Value;

if(options.UseRequestDecompression)
if (options.UseRequestDecompression)
{
app.UseRequestDecompression();
}
Expand All @@ -22,69 +22,69 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
app.UseResponseCompression();
}

if(options.UseFileServer)
if (options.UseFileServer)
{
app.UseFileServer(options.FileServer);

if(options.FileServer.EnableDefaultFiles)
if (options.FileServer.EnableDefaultFiles)
{
app.UseDefaultFiles(options.FileServer.DefaultFilesOptions);
}

if(options.FileServer.EnableDirectoryBrowsing)
if (options.FileServer.EnableDirectoryBrowsing)
{
app.UseDirectoryBrowser(options.FileServer.DirectoryBrowserOptions);
}

if(options.FileServer.StaticFileOptions != null || options.UseStaticFiles)
if (options.FileServer.StaticFileOptions != null || options.UseStaticFiles)
{
app.UseStaticFiles(options.FileServer.StaticFileOptions);
}
}

if(options.UseResponseCaching)
if (options.UseResponseCaching)
{
app.UseResponseCaching();
}

if(options.UseForwardedHeaders)
if (options.UseForwardedHeaders)
{
app.UseForwardedHeaders(options.ForwardedHeaders);
}

if(options.UseCors)
if (options.UseCors)
{
var corsOptions = app.ApplicationServices.GetRequiredService<IOptions<AspNetCorsOptions>>().Value;
app.UseCors(builder =>
{
var defaultPolicy = corsOptions.GetPolicy(options.Cors.DefaultPolicyName);
builder.WithExposedHeaders([.. defaultPolicy.ExposedHeaders])
.WithHeaders([.. defaultPolicy.Headers])
.WithMethods([.. defaultPolicy.Methods])
.WithOrigins([.. defaultPolicy.Origins])

.SetPreflightMaxAge(defaultPolicy.PreflightMaxAge ?? duration.Zero);
if(defaultPolicy.AllowAnyHeader)
{
builder.AllowAnyHeader();
}
if(defaultPolicy.AllowAnyMethod)
{
builder.AllowAnyMethod();
}
if(defaultPolicy.AllowAnyOrigin)
{
builder.AllowAnyOrigin();
}
});
// _ = app.UseCors(corsOptions => corsOptions
// .WithExposedHeaders(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).ExposedHeaders.ToArray())
// .WithHeaders(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Headers.ToArray())
// .WithMethods(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Methods.ToArray())
// .WithOrigins(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Origins.ToArray())
// .SetPreflightMaxAge(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).PreflightMaxAge ?? TimeSpan.Zero)
// );
}
{
var defaultPolicy = corsOptions.GetPolicy(options.Cors.DefaultPolicyName);
builder.WithExposedHeaders([..defaultPolicy.ExposedHeaders])
.WithHeaders([..defaultPolicy.Headers])
.WithMethods([..defaultPolicy.Methods])
.WithOrigins([..defaultPolicy.Origins])

.SetPreflightMaxAge(defaultPolicy.PreflightMaxAge ?? duration.Zero);
if (defaultPolicy.AllowAnyHeader)
{
builder.AllowAnyHeader();
}
if (defaultPolicy.AllowAnyMethod)
{
builder.AllowAnyMethod();
}
if (defaultPolicy.AllowAnyOrigin)
{
builder.AllowAnyOrigin();
}
});
// _ = app.UseCors(corsOptions => corsOptions
// .WithExposedHeaders(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).ExposedHeaders.ToArray())
// .WithHeaders(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Headers.ToArray())
// .WithMethods(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Methods.ToArray())
// .WithOrigins(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).Origins.ToArray())
// .SetPreflightMaxAge(options.Cors.GetPolicy(options.Cors.DefaultPolicyName).PreflightMaxAge ?? TimeSpan.Zero)
// );
}

if(options.UseCookiePolicy)
{
Expand All @@ -94,33 +94,33 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
if(options.UseSession)
{
app.UseSession(options.Session);
}

if(options.UseHsts)
{
app.UseHsts();
}

if(options.UseHttpsRedirection)
{
app.UseHttpsRedirection();
}

if(options.ExceptionHandling?.UseDeveloperExceptionPage == true)
{
app.UseDeveloperExceptionPage();
}

if(options.UseExceptionHandler)
{
app.UseExceptionHandler(options.ExceptionHandling);
}

if(options.UseWelcomePage)
{
app.UseWelcomePage(options.WelcomePage);
}

return app;
}

if (options.UseHsts)
{
app.UseHsts();
}

if (options.UseHttpsRedirection)
{
app.UseHttpsRedirection();
}

if (options.ExceptionHandling?.UseDeveloperExceptionPage == true)
{
app.UseDeveloperExceptionPage();
}

if (options.UseExceptionHandler)
{
app.UseExceptionHandler(options.ExceptionHandling);
}

if (options.UseWelcomePage)
{
app.UseWelcomePage(options.WelcomePage);
}

return app;
}
}

0 comments on commit 718ef7a

Please sign in to comment.