Skip to content

Commit

Permalink
Ran dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Mar 27, 2024
1 parent f609a0d commit 2766d69
Show file tree
Hide file tree
Showing 9 changed files with 691 additions and 695 deletions.
12 changes: 8 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ csharp_indent_labels = one_less_than_current
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Types: use keywords instead of BCL types, and permit var only when the type is clear
csharp_style_var_for_built_in_types = false:suggestion
Expand Down Expand Up @@ -154,6 +154,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# Custom
csharp_style_namespace_declarations = file_scoped:error
dotnet_diagnostic.IDE0005.severity = error # Using directive is unnecessary.

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
Expand Down
23 changes: 11 additions & 12 deletions src/Foundatio.Minio/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Foundatio.Extensions
namespace Foundatio.Extensions;

internal static class TaskExtensions
{
internal static class TaskExtensions
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task)
{
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task)
{
return task.ConfigureAwait(false);
}
return task.ConfigureAwait(false);
}

[DebuggerStepThrough]
public static ConfiguredTaskAwaitable AnyContext(this Task task)
{
return task.ConfigureAwait(false);
}
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable AnyContext(this Task task)
{
return task.ConfigureAwait(false);
}
}
135 changes: 67 additions & 68 deletions src/Foundatio.Minio/MinioConnectionStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,89 +1,88 @@
using System;
using System.Linq;

namespace Foundatio
namespace Foundatio;

public class MinioConnectionStringBuilder
{
public class MinioConnectionStringBuilder
{
public string AccessKey { get; set; }
public string AccessKey { get; set; }

public string SecretKey { get; set; }
public string SecretKey { get; set; }

public string Region { get; set; }
public string Region { get; set; }

public string EndPoint { get; set; }
public string EndPoint { get; set; }

protected MinioConnectionStringBuilder() { }
protected MinioConnectionStringBuilder() { }

protected MinioConnectionStringBuilder(string connectionString)
{
if (String.IsNullOrEmpty(connectionString))
throw new ArgumentNullException(nameof(connectionString));
Parse(connectionString);
}
protected MinioConnectionStringBuilder(string connectionString)
{
if (String.IsNullOrEmpty(connectionString))
throw new ArgumentNullException(nameof(connectionString));
Parse(connectionString);
}

private void Parse(string connectionString)
private void Parse(string connectionString)
{
foreach (var option in connectionString
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
.Where(kvp => kvp.Contains('='))
.Select(kvp => kvp.Split(new[] { '=' }, 2)))
{
foreach (var option in connectionString
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
.Where(kvp => kvp.Contains('='))
.Select(kvp => kvp.Split(new[] { '=' }, 2)))
var optionKey = option[0].Trim();
var optionValue = option[1].Trim();
if (!ParseItem(optionKey, optionValue))
{
var optionKey = option[0].Trim();
var optionValue = option[1].Trim();
if (!ParseItem(optionKey, optionValue))
{
throw new ArgumentException($"The option '{optionKey}' cannot be recognized in connection string.", nameof(connectionString));
}
throw new ArgumentException($"The option '{optionKey}' cannot be recognized in connection string.", nameof(connectionString));
}
}
}

protected virtual bool ParseItem(string key, string value)
protected virtual bool ParseItem(string key, string value)
{
if (String.Equals(key, "AccessKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Access Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "AccessKeyId", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Access Key Id", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Id", StringComparison.OrdinalIgnoreCase))
{
if (String.Equals(key, "AccessKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Access Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "AccessKeyId", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Access Key Id", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Id", StringComparison.OrdinalIgnoreCase))
{
AccessKey = value;
return true;
}
if (String.Equals(key, "SecretKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "SecretAccessKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret Access Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret", StringComparison.OrdinalIgnoreCase))
{
SecretKey = value;
return true;
}
if (String.Equals(key, "Region", StringComparison.OrdinalIgnoreCase))
{
Region = value;
return true;
}
if (String.Equals(key, "EndPoint", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "End Point", StringComparison.OrdinalIgnoreCase))
{
EndPoint = value;
return true;
}
return false;
AccessKey = value;
return true;
}

public override string ToString()
if (String.Equals(key, "SecretKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "SecretAccessKey", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret Access Key", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "Secret", StringComparison.OrdinalIgnoreCase))
{
SecretKey = value;
return true;
}
if (String.Equals(key, "Region", StringComparison.OrdinalIgnoreCase))
{
Region = value;
return true;
}
if (String.Equals(key, "EndPoint", StringComparison.OrdinalIgnoreCase) ||
String.Equals(key, "End Point", StringComparison.OrdinalIgnoreCase))
{
var connectionString = string.Empty;
if (!string.IsNullOrEmpty(AccessKey))
connectionString += "AccessKey=" + AccessKey + ";";
if (!string.IsNullOrEmpty(SecretKey))
connectionString += "SecretKey=" + SecretKey + ";";
if (!string.IsNullOrEmpty(Region))
connectionString += "Region=" + Region + ";";
if (!string.IsNullOrEmpty(EndPoint))
connectionString += "EndPoint=" + EndPoint + ";";
return connectionString;
EndPoint = value;
return true;
}
return false;
}

public override string ToString()
{
var connectionString = string.Empty;
if (!string.IsNullOrEmpty(AccessKey))
connectionString += "AccessKey=" + AccessKey + ";";
if (!string.IsNullOrEmpty(SecretKey))
connectionString += "SecretKey=" + SecretKey + ";";
if (!string.IsNullOrEmpty(Region))
connectionString += "Region=" + Region + ";";
if (!string.IsNullOrEmpty(EndPoint))
connectionString += "EndPoint=" + EndPoint + ";";
return connectionString;
}
}
Loading

0 comments on commit 2766d69

Please sign in to comment.