Skip to content

Commit

Permalink
Updated packages
Browse files Browse the repository at this point in the history
  • Loading branch information
nmakhmutov committed Dec 15, 2024
1 parent 32d471b commit fa076fa
Show file tree
Hide file tree
Showing 45 changed files with 318 additions and 130 deletions.
107 changes: 101 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,23 +1,118 @@
root = true
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
max_line_length = 120
insert_final_newline = true
trim_trailing_whitespace = false
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

# Microsoft .NET properties
csharp_preferred_modifier_order = public, protected, internal, private, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# ReSharper properties
resharper_align_multiline_binary_expressions_chain = false
resharper_align_multiline_statement_conditions = false
resharper_braces_for_ifelse = not_required_for_both
resharper_braces_for_lock = required_for_multiline
resharper_braces_for_using = required_for_multiline
resharper_braces_for_for = required_for_multiline
resharper_braces_for_foreach = required_for_multiline
resharper_braces_for_dowhile = required_for_multiline
resharper_braces_for_while = required_for_multiline
resharper_braces_for_fixed = required_for_multiline
resharper_builtin_type_apply_to_native_integer = true
resharper_csharp_int_align_fix_in_adjacent = false
resharper_csharp_keep_blank_lines_in_code = 1
resharper_csharp_keep_blank_lines_in_declarations = 1
resharper_csharp_max_enum_members_on_line = 1
resharper_csharp_wrap_before_binary_opsign = true
resharper_csharp_wrap_before_first_type_parameter_constraint = true
resharper_csharp_wrap_extends_list_style = chop_always
resharper_enforce_line_ending_style = true
resharper_force_attribute_style = join
resharper_int_align_methods = true
resharper_keep_existing_embedded_arrangement = false
resharper_keep_existing_expr_member_arrangement = false
resharper_keep_existing_initializer_arrangement = false
resharper_keep_existing_primary_constructor_declaration_parens_arrangement = true
resharper_keep_existing_property_patterns_arrangement = false
resharper_keep_existing_switch_expression_arrangement = false
resharper_local_function_body = expression_body
resharper_max_attribute_length_for_same_line = 120
resharper_new_line_before_while = true
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_accessor_attribute_on_same_line = true
resharper_place_expr_accessor_on_single_line = true
resharper_place_expr_method_on_single_line = false
resharper_place_expr_property_on_single_line = false
resharper_place_field_attribute_on_same_line = false
resharper_place_record_field_attribute_on_same_line = true
resharper_place_simple_accessor_on_single_line = false
resharper_place_simple_embedded_statement_on_same_line = false
resharper_place_simple_initializer_on_single_line = false
resharper_show_autodetect_configure_formatting_tip = false
resharper_static_members_qualify_with = current_type
resharper_use_indent_from_vs = false
resharper_wrap_array_initializer_style = chop_always
resharper_wrap_before_primary_constructor_declaration_lpar = false
resharper_wrap_before_primary_constructor_declaration_rpar = true
resharper_wrap_for_stmt_header_style = wrap_if_long
resharper_wrap_lines = true
resharper_wrap_linq_expressions = chop_always
resharper_wrap_list_pattern = chop_always
resharper_wrap_object_and_collection_initializer_style = chop_always

# ReSharper inspection severities
resharper_arrange_attributes_highlighting = suggestion
resharper_arrange_default_value_when_type_not_evident_highlighting = suggestion
resharper_arrange_local_function_body_highlighting = suggestion
resharper_arrange_null_checking_pattern_highlighting = suggestion
resharper_arrange_object_creation_when_type_not_evident_highlighting = suggestion
resharper_arrange_redundant_parentheses_highlighting = suggestion
resharper_convert_closure_to_method_group_highlighting = none
resharper_convert_to_primary_constructor_highlighting = none
resharper_enforce_do_while_statement_braces_highlighting = suggestion
resharper_enforce_fixed_statement_braces_highlighting = suggestion
resharper_enforce_foreach_statement_braces_highlighting = suggestion
resharper_enforce_for_statement_braces_highlighting = suggestion
resharper_enforce_if_statement_braces_highlighting = suggestion
resharper_enforce_lock_statement_braces_highlighting = suggestion
resharper_enforce_using_statement_braces_highlighting = suggestion
resharper_enforce_while_statement_braces_highlighting = suggestion
resharper_razor_assembly_not_resolved_highlighting = warning
resharper_remove_redundant_braces_highlighting = suggestion
resharper_suggest_discard_declaration_var_style_highlighting = suggestion
resharper_web_config_module_not_resolved_highlighting = warning
resharper_web_config_type_not_resolved_highlighting = warning
resharper_web_config_wrong_module_highlighting = warning

[*.{cs,vb}]
dotnet_sort_system_directives_first = true
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_coalesce_expression = true:warning

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<EmailAccount> Handle(ConfirmEmailCommand request, Cancellation
var confirmation = await _confirmation.VerifyEmailAsync(request.Token, request.Code, ct);

var account = await _repository.GetAsync(confirmation.AccountId, ct)
?? throw AccountException.NotFound(confirmation.AccountId);
?? throw AccountException.NotFound(confirmation.AccountId);

account.ConfirmEmail(confirmation.Email, _timeProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public async Task<SignInResult> Handle(SignInByGoogleCommand request, Cancellati
var google = await _google.GetAsync(request.Token, ct);

var result = await _dbContext.Accounts
.AsNoTracking()
.WhereGoogle(google.Identity)
.Select(x => new SignInResult(x.Id, x.Name.FullName()))
.FirstOrDefaultAsync(ct)
?? throw ExternalAccountException.NotFound(ExternalService.Google, google.Identity);
.AsNoTracking()
.WhereGoogle(google.Identity)
.Select(x => new SignInResult(x.Id, x.Name.FullName()))
.FirstOrDefaultAsync(ct)
?? throw ExternalAccountException.NotFound(ExternalService.Google, google.Identity);

var evt = new AccountActivity.LoggedInIntegrationEvent(Guid.NewGuid(), _timeProvider.UtcNow(), result.Id);
await _bus.PublishAsync(evt, ct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public async Task<SignInResult> Handle(SignInByMicrosoftCommand request, Cancell
var microsoft = await _microsoft.GetAsync(request.Token, ct);

var result = await _dbContext.Accounts
.AsNoTracking()
.WhereMicrosoft(microsoft.Identity)
.Select(x => new SignInResult(x.Id, x.Name.FullName()))
.FirstOrDefaultAsync(ct)
?? throw ExternalAccountException.NotFound(ExternalService.Microsoft, microsoft.Identity);
.AsNoTracking()
.WhereMicrosoft(microsoft.Identity)
.Select(x => new SignInResult(x.Id, x.Name.FullName()))
.FirstOrDefaultAsync(ct)
?? throw ExternalAccountException.NotFound(ExternalService.Microsoft, microsoft.Identity);

var evt = new AccountActivity.LoggedInIntegrationEvent(Guid.NewGuid(), _timeProvider.UtcNow(), result.Id);
await _bus.PublishAsync(evt, ct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public async Task<string> Handle(SigningInByEmailCommand request, CancellationTo
{
var email = await _dbContext.Emails
.Where(x => x.Email == request.Email.Address)
.Select(x => new { x.AccountId, Email = new MailAddress(x.Email), x.IsConfirmed })
.Select(x => new
{
x.AccountId,
Email = new MailAddress(x.Email),
x.IsConfirmed
})
.FirstOrDefaultAsync(ct) ?? throw EmailException.NotFound(request.Email);

if (!email.IsConfirmed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public async Task<string> Handle(SigningUpByEmailCommand request, CancellationTo
{
var email = await _dbContext.Emails
.Where(x => x.Email == request.Email.Address)
.Select(x => new { x.AccountId, Email = new MailAddress(x.Email), x.IsConfirmed })
.Select(x => new
{
x.AccountId,
Email = new MailAddress(x.Email),
x.IsConfirmed
})
.FirstOrDefaultAsync(ct);

if (email is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public async Task<bool> Handle(IsAccountActiveQuery request, CancellationToken c
{
var data = await _dataProvider
.Sql($"SELECT is_activated, ban IS NOT NULL FROM accounts WHERE id = {request.Id} LIMIT 1")
.Select(x => new { IsActivated = x.GetBoolean(0), IsBanned = x.GetBoolean(1) })
.Select(x => new
{
IsActivated = x.GetBoolean(0),
IsBanned = x.GetBoolean(1)
})
.FirstOrDefaultAsync(ct);

if (data is null)
Expand Down
4 changes: 2 additions & 2 deletions src/People.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /
COPY "src" "src/"
WORKDIR /src/People.Api
Expand Down
3 changes: 2 additions & 1 deletion src/People.Api/Endpoints/Account/Requests/UpdateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ internal sealed record UpdateRequest(
string TimeZone,
string DateFormat,
string TimeFormat,
DayOfWeek StartOfWeek)
DayOfWeek StartOfWeek
)
{
public UpdateAccountCommand ToCommand(AccountId id) =>
new(
Expand Down
5 changes: 4 additions & 1 deletion src/People.Api/Grpc/PeopleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public override async Task<BoolValue> IsAccountActive(AccountRequest request, Se
var query = new IsAccountActiveQuery(request.Id);
var result = await _mediator.Send(query, context.CancellationToken);

return new BoolValue { Value = result };
return new BoolValue
{
Value = result
};
}

public override async Task<EmailSigningUpReply> SigningUpByEmail(EmailSigningUpRequest request,
Expand Down
5 changes: 4 additions & 1 deletion src/People.Api/Infrastructure/ErrorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public static ValidationProblemDetails ToProblem(this ValidationException ex) =>
ValidationProblemDetails(GetValidationErrors(ex));

private static ValidationProblemDetails ToProblem(this ArgumentException ex) =>
ValidationProblemDetails(new Dictionary<string, string[]> { [ex.ParamName ?? "@"] = new[] { ex.Message } });
ValidationProblemDetails(new Dictionary<string, string[]>
{
[ex.ParamName ?? "@"] = [ex.Message]
});

private static ProblemDetails ToProblem(this PeopleException exception)
{
Expand Down
4 changes: 1 addition & 3 deletions src/People.Api/Infrastructure/GlobalExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ public sealed class GlobalExceptionHandler : IExceptionHandler
{
private readonly ILogger<GlobalExceptionHandler> _logger;

public GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger)
{
public GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger) =>
_logger = logger;
}

public async ValueTask<bool> TryHandleAsync(HttpContext context, Exception exception, CancellationToken ct)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ private RpcException WrapPeopleException(ServerCallContext context, PeopleExcept

var meta = new Metadata
{
{ "ex-name", ex.Name },
{ "ex-code", ex.Code },
{
"ex-name", ex.Name
},
{
"ex-code", ex.Code
},
{
"ex-id", ex switch
{
Expand All @@ -73,8 +77,12 @@ private RpcException WrapValidationException(ServerCallContext context, Validati

var meta = new Metadata
{
{ "ex-name", name },
{ "ex-code", "InvalidModel" }
{
"ex-name", name
},
{
"ex-code", "InvalidModel"
}
};

var result = ex.Errors.GroupBy(x => x.PropertyName)
Expand All @@ -93,9 +101,15 @@ private RpcException WrapArgumentExceptions(ServerCallContext context, ArgumentE

var meta = new Metadata
{
{ "ex-name", name },
{ "ex-code", "InvalidModel" },
{ $"ex-field-{ex.ParamName}", ex.Message }
{
"ex-name", name
},
{
"ex-code", "InvalidModel"
},
{
$"ex-field-{ex.ParamName}", ex.Message
}
};

throw new RpcException(new Status(StatusCode.InvalidArgument, ex.Message), meta);
Expand All @@ -108,8 +122,12 @@ private RpcException WrapUnhandledException(ServerCallContext context, Exception

var meta = new Metadata
{
{ "ex-name", name },
{ "ex-code", "Unhandled" }
{
"ex-name", name
},
{
"ex-code", "Unhandled"
}
};

throw new RpcException(new Status(StatusCode.Internal, ex.Message), meta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ public async Task SendConfirmationAsync(MailAddress email, string code, Language
var template = $"Confirmation.{language}.liquid";
var (subject, body) = await _emailBuilder.CreateEmailAsync(template, new ConfirmationCodeModel(code));

var message = new SendRequest { Email = email.Address, Subject = subject, Body = body };
var message = new SendRequest
{
Email = email.Address,
Subject = subject,
Body = body
};
await _notification.SendEmailAsync(message, cancellationToken: ct);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ public sealed class IpApiService : IIpApiService
private static readonly JsonSerializerOptions Options = new()
{
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
Converters =
{
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
}
};

private readonly HttpClient _client;
Expand Down
11 changes: 9 additions & 2 deletions src/People.Api/Messages/AccountReply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ internal static AccountReply Map(AccountSummary account) =>
TimeZone = account.TimeZone.ToString(),
Language = Language.Create(account.Language),
Ban = Types.Ban.Map(account.Ban),
Roles = { account.Roles }
Roles =
{
account.Roles
}
};

public partial class Types
Expand All @@ -29,7 +32,11 @@ public partial class Ban
public static Ban? Map(Domain.ValueObjects.Ban? ban) =>
ban switch
{
not null => new Ban { Reason = ban.Reason, ExpiresAt = ban.ExpiredAt.ToTimestamp() },
not null => new Ban
{
Reason = ban.Reason,
ExpiresAt = ban.ExpiredAt.ToTimestamp()
},
_ => null
};
}
Expand Down
5 changes: 4 additions & 1 deletion src/People.Api/Messages/EmailSigningInReply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ namespace People.Grpc.People;
public partial class EmailSigningInReply
{
internal static EmailSigningInReply Map(string token) =>
new() { Token = token };
new()
{
Token = token
};
}
5 changes: 4 additions & 1 deletion src/People.Api/Messages/EmailSigningUpReply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ namespace People.Grpc.People;
public partial class EmailSigningUpReply
{
internal static EmailSigningUpReply Map(string token) =>
new() { Token = token };
new()
{
Token = token
};
}
Loading

0 comments on commit fa076fa

Please sign in to comment.