Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORELIB-182] Fix dotnet and rider warnings, remove StyleCop leftovers #750

Merged
merged 21 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,24 @@ dotnet_naming_symbols.everything_else.applicable_accessibilities = *
dotnet_diagnostic.CA1812.severity = none
dotnet_diagnostic.CA1724.severity = none
dotnet_diagnostic.CA1515.severity = none
dotnet_diagnostic.CA2007.severity = none
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.CA1062.severity = none
dotnet_diagnostic.CA1816.severity = none
dotnet_diagnostic.CA1303.severity = none
dotnet_diagnostic.CA1002.severity = none
dotnet_diagnostic.CA1032.severity = none
dotnet_diagnostic.CA1034.severity = none
dotnet_diagnostic.CA1019.severity = none
dotnet_diagnostic.CA1308.severity = none
dotnet_diagnostic.IDE0058.severity = none

# Disable temporarily
dotnet_diagnostic.xUnit1051.severity = none

# Rider
resharper_inconsistent_naming_highlighting=hint

[test-bed/**/*.cs]
resharper_not_null_or_required_member_is_not_initialized_highlighting = none
resharper_class_never_instantiated_global_highlighting = none
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class CQRSPipelineBuilder
{
public Func<CQRSObjectMetadata, bool> ObjectsFilter { get; set; } = _ => true;

public Action<ICQRSApplicationBuilder> Commands { get; set; } = app => { };
public Action<ICQRSApplicationBuilder> Queries { get; set; } = app => { };
public Action<ICQRSApplicationBuilder> Operations { get; set; } = app => { };
public Action<ICQRSApplicationBuilder> Commands { get; set; } = _ => { };
public Action<ICQRSApplicationBuilder> Queries { get; set; } = _ => { };
public Action<ICQRSApplicationBuilder> Operations { get; set; } = _ => { };

private readonly IEndpointRouteBuilder routeBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ internal class LocalCallContext : HttpContext, IDisposable

public override IFeatureCollection Features => features;

public override ClaimsPrincipal User { get; set; }
public override string TraceIdentifier { get; set; }
public sealed override ClaimsPrincipal User { get; set; }
public sealed override string TraceIdentifier { get; set; }
public override HttpRequest Request { get; }
public override HttpResponse Response { get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Metrics;
using LeanCode.CQRS.AspNetCore.Serialization;
using LeanCode.CQRS.Execution;
using Microsoft.AspNetCore.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text;
using LeanCode.Contracts;
using LeanCode.CQRS.Execution;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.ModelBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public void AddCQRSObjects(TypesCatalog contractsCatalog, TypesCatalog handlersC
continue;
}

var handlerCandidates = handlers[contract];
var handlerCandidates = handlers[contract].ToList();

if (handlerCandidates.Count() != 1)
if (handlerCandidates.Count != 1)
{
// TODO: shouldn't we throw here?
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json;
using LeanCode.Serialization;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;

namespace LeanCode.CQRS.AspNetCore;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Execution;

public class CommandHandlerNotFoundException : Exception
Expand Down
1 change: 0 additions & 1 deletion src/CQRS/LeanCode.CQRS.Execution/ICommandHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using LeanCode.Contracts;
using Microsoft.AspNetCore.Http;

Expand Down
1 change: 0 additions & 1 deletion src/CQRS/LeanCode.CQRS.Execution/IOperationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using LeanCode.Contracts;
using Microsoft.AspNetCore.Http;

Expand Down
1 change: 0 additions & 1 deletion src/CQRS/LeanCode.CQRS.Execution/IQueryHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using LeanCode.Contracts;
using Microsoft.AspNetCore.Http;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Execution;

public class OperationHandlerNotFoundException : Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Execution;

public class QueryHandlerNotFoundException : Exception
Expand Down
1 change: 0 additions & 1 deletion src/CQRS/LeanCode.CQRS.RemoteHttp.Client/Exceptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Net;

namespace LeanCode.CQRS.RemoteHttp.Client;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
using LeanCode.Contracts;
using LeanCode.Contracts.Validation;

Expand All @@ -30,7 +25,7 @@ public virtual async Task<CommandResult> RunAsync(ICommand command, Cancellation
{
using var content = JsonContent.Create(command, command.GetType(), options: serializerOptions);
using var response = await client.PostAsync(
"command/" + command.GetType().FullName,
new Uri("command/" + command.GetType().FullName, UriKind.Relative),
content,
cancellationToken
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public virtual async Task<TResult> GetAsync<TResult>(
{
using var content = JsonContent.Create(operation, operation.GetType(), options: serializerOptions);
using var response = await client.PostAsync(
"operation/" + operation.GetType().FullName,
new Uri("operation/" + operation.GetType().FullName, UriKind.Relative),
content,
cancellationToken
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
using LeanCode.Contracts;

namespace LeanCode.CQRS.RemoteHttp.Client;
Expand All @@ -27,7 +24,11 @@ public virtual async Task<TResult> GetAsync<TResult>(
)
{
using var content = JsonContent.Create(query, query.GetType(), options: serializerOptions);
using var response = await client.PostAsync("query/" + query.GetType().FullName, content, cancellationToken);
using var response = await client.PostAsync(
new Uri("query/" + query.GetType().FullName, UriKind.Relative),
content,
cancellationToken
);

response.HandleCommonCQRSErrors<QueryNotFoundException, InvalidQueryException>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Net.Http;
using static System.Net.HttpStatusCode;

namespace LeanCode.CQRS.RemoteHttp.Client;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using System.Security.Claims;

namespace LeanCode.CQRS.Security;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Security;

public class CustomAuthorizerNotFoundException : Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Security.Claims;
using System.Threading.Tasks;
using LeanCode.Contracts.Security;
using Microsoft.AspNetCore.Http;

namespace LeanCode.CQRS.Security;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Security.Exceptions;

public class InsufficientPermissionException : Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.CQRS.Security.Exceptions;

public class UnauthenticatedException : Exception
Expand Down
2 changes: 0 additions & 2 deletions src/CQRS/LeanCode.CQRS.Security/IRoleRegistration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace LeanCode.CQRS.Security;

public interface IRoleRegistration
Expand Down
2 changes: 0 additions & 2 deletions src/CQRS/LeanCode.CQRS.Security/Role.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;

namespace LeanCode.CQRS.Security;
Expand Down
2 changes: 0 additions & 2 deletions src/CQRS/LeanCode.CQRS.Security/RoleRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;

namespace LeanCode.CQRS.Security;

Expand Down
1 change: 0 additions & 1 deletion src/CQRS/LeanCode.CQRS.Validation/ICommandValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using LeanCode.Contracts;
using LeanCode.Contracts.Validation;
using Microsoft.AspNetCore.Http;
Expand Down
2 changes: 0 additions & 2 deletions src/Core/LeanCode.Components/TypesCatalog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;

namespace LeanCode.Components;
Expand Down
1 change: 0 additions & 1 deletion src/Core/LeanCode.Startup.Autofac/LeanProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand Down
1 change: 0 additions & 1 deletion src/Domain/LeanCode.DomainModels.EF/DbContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using LeanCode.DomainModels.Model;
using Microsoft.EntityFrameworkCore;

Expand Down
2 changes: 0 additions & 2 deletions src/Domain/LeanCode.DomainModels.EF/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
using LeanCode.DomainModels.Model;
using Microsoft.EntityFrameworkCore;
Expand Down
3 changes: 0 additions & 3 deletions src/Domain/LeanCode.DomainModels/DataAccess/IRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using LeanCode.DomainModels.Model;

namespace LeanCode.DomainModels.DataAccess;
Expand Down
3 changes: 3 additions & 0 deletions src/Domain/LeanCode.DomainModels/Model/DomainEvents.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Diagnostics.CodeAnalysis;

namespace LeanCode.DomainModels.Model;

public static class DomainEvents
Expand All @@ -9,6 +11,7 @@ public static void SetInterceptor(IDomainEventInterceptor interceptor)
EventInterceptor = interceptor;
}

[SuppressMessage("?", "CA1030", Justification = "Convention for `DomainEvents`.")]
public static void Raise<TEvent>(TEvent domainEvent)
where TEvent : class, IDomainEvent
{
Expand Down
2 changes: 0 additions & 2 deletions src/Domain/LeanCode.DomainModels/Model/IDomainEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.DomainModels.Model;

public interface IDomainEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.DomainModels.Model;

public interface IOptimisticConcurrency
Expand Down
1 change: 1 addition & 0 deletions src/Domain/LeanCode.DomainModels/Ulids/Ulid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ internal Ulid(ReadOnlySpan<char> base32)
// HACK: We assume the layout of a Guid is the following:
// Int32, Int16, Int16, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8
// source: https://github.com/dotnet/runtime/blob/4f9ae42d861fcb4be2fcd5d3d55d5f227d30e723/src/libraries/System.Private.CoreLib/src/System/Guid.cs
[SuppressMessage("?", "CA1720", Justification = "Vendored code.")]
public Ulid(Guid guid)
{
Span<byte> buf = stackalloc byte[16];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using IdentityModel.Client;

namespace LeanCode.ClientCredentialsHandler;
Expand Down
4 changes: 0 additions & 4 deletions src/Infrastructure/LeanCode.Dapper/DbContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand Down
3 changes: 0 additions & 3 deletions src/Infrastructure/LeanCode.Dapper/RawQueryValidator.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;

namespace LeanCode.Dapper;
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/LeanCode.Dapper/RawSqlQueryAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.Dapper;

[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/LeanCode.Firebase.FCM/FCMSendException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.Firebase.FCM;

public class FCMSendException : Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LeanCode.Firebase.FCM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using LeanCode.TimeProvider;

namespace LeanCode.Firebase.FCM;

public sealed record class PushNotificationTokenEntity<TUserId>(TUserId UserId, string Token, DateTime DateCreated)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using FirebaseAdmin;
using Google.Api.Gax;
using Google.Cloud.Firestore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace LeanCode.Localization;

public sealed class LocalizationConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Globalization;
using System.Resources;
using static System.Globalization.CultureInfo;
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/LeanCode.Logging/BaseSanitizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Serilog.Core;
using Serilog.Events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static IHostBuilder ConfigureDefaultLogging(

if (configuration.GetValue<string>(SeqEndpointKey) is string seqEndpoint)
{
loggerConfiguration.WriteTo.Seq(seqEndpoint);
loggerConfiguration.WriteTo.Seq(seqEndpoint, formatProvider: CultureInfo.InvariantCulture);
}

if (context.HostingEnvironment.IsDevelopment())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
Expand Down
Loading