From 476be52af62cb5853419ac4b356776c2ccf9965d Mon Sep 17 00:00:00 2001
From: Rocket Understudy <33589210+rsg-bot@users.noreply.github.com>
Date: Fri, 27 Dec 2024 06:29:28 -0500
Subject: [PATCH] Automatically linting code
---
...Rocket.Surgery.LaunchPad.Foundation.csproj | 15 ++++++--
src/Mapping/DateTimeMapper.cs | 36 +++++++++++++++----
.../Conventions/SerilogTelemetryConvention.cs | 26 +++++++-------
.../Helpers/GraphQlExtension.cs | 24 ++++---------
4 files changed, 63 insertions(+), 38 deletions(-)
diff --git a/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj b/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj
index c309f5d34..d0cec622a 100644
--- a/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj
+++ b/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj
@@ -39,7 +39,18 @@
-
-
+
+
diff --git a/src/Mapping/DateTimeMapper.cs b/src/Mapping/DateTimeMapper.cs
index 5407e11d0..9324364d6 100644
--- a/src/Mapping/DateTimeMapper.cs
+++ b/src/Mapping/DateTimeMapper.cs
@@ -10,23 +10,33 @@ namespace Rocket.Surgery.LaunchPad.Mapping;
///
[Mapper]
[PublicAPI]
+[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")]
public partial class DateTimeMapper
{
+ [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
+ private string DebuggerDisplay
+ {
+ get
+ {
+ return ToString();
+ }
+ }
+
///
/// Converts a to a .
///
///
///
- public static DateTime FromDateTimeOffset(DateTimeOffset source)
- {
- return source.UtcDateTime;
- }
+ public static DateTime FromDateTimeOffset(DateTimeOffset source) => source.UtcDateTime;
///
/// Converts a to a .
///
///
///
+
+/* Unmerged change from project 'Rocket.Surgery.LaunchPad.Mapping(net9.0)'
+Before:
public static DateTimeOffset ToDateTimeOffset(DateTime source)
{
return source switch
@@ -34,5 +44,19 @@ public static DateTimeOffset ToDateTimeOffset(DateTime source)
{ Kind: DateTimeKind.Unspecified or DateTimeKind.Local, } => new(source.ToUniversalTime(), TimeSpan.Zero),
{ Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
};
- }
-}
\ No newline at end of file
+ }
+After:
+ public static DateTimeOffset ToDateTimeOffset(DateTime source) => source switch
+ {
+ { Kind: DateTimeKind.Unspecified or DateTimeKind.Local, } => new(source.ToUniversalTime(), TimeSpan.Zero),
+ { Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
+ _ => throw new NotImplementedException(),
+ };
+*/
+ public static DateTimeOffset ToDateTimeOffset(DateTime source) => source switch
+ {
+ { Kind: DateTimeKind.Unspecified or DateTimeKind.Local, } => new(source.ToUniversalTime(), TimeSpan.Zero),
+ { Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
+ _ => throw new NotImplementedException(),
+ };
+}
diff --git a/src/Telemetry/Conventions/SerilogTelemetryConvention.cs b/src/Telemetry/Conventions/SerilogTelemetryConvention.cs
index 303001934..49bdec1de 100644
--- a/src/Telemetry/Conventions/SerilogTelemetryConvention.cs
+++ b/src/Telemetry/Conventions/SerilogTelemetryConvention.cs
@@ -1,9 +1,7 @@
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OpenTelemetry.Logs;
-using OpenTelemetry.Metrics;
-using OpenTelemetry.Trace;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.DependencyInjection;
using Rocket.Surgery.LaunchPad.Serilog;
@@ -17,15 +15,23 @@ namespace Rocket.Surgery.LaunchPad.Telemetry.Conventions;
///
[PublicAPI]
[ConventionCategory(ConventionCategory.Core)]
+[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")]
public partial class SerilogTelemetryConvention : ISerilogConvention, IServiceConvention
{
- ///
- public void Register(IConventionContext context, IConfiguration configuration, IServiceProvider services, LoggerConfiguration loggerConfiguration)
+ [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
+ private string DebuggerDisplay
{
- loggerConfiguration.WriteTo.OpenTelemetry(
+ get
+ {
+ return ToString();
+ }
+ }
+
+ ///
+ public void Register(IConventionContext context, IConfiguration configuration, IServiceProvider services, LoggerConfiguration loggerConfiguration) => loggerConfiguration.WriteTo.OpenTelemetry(
options =>
{
- services.GetRequiredService>();
+ _ = services.GetRequiredService>();
var di = services.GetRequiredService>();
options.BatchingOptions.BatchSizeLimit = di.CurrentValue.BatchingOptions.BatchSizeLimit;
options.BatchingOptions.BufferingTimeLimit = di.CurrentValue.BatchingOptions.BufferingTimeLimit;
@@ -46,11 +52,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I
options.TracesEndpoint = di.CurrentValue.TracesEndpoint;
}
);
- }
///
- public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services)
- {
- services.AddOptions();
- }
+ public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) => services.AddOptions();
}
diff --git a/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs b/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs
index 6d5efc10a..e04a5f602 100644
--- a/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs
+++ b/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs
@@ -16,15 +16,9 @@ internal class GraphQlExtension : IAlbaExtension
{
public void Dispose() { }
- public ValueTask DisposeAsync()
- {
- return ValueTask.CompletedTask;
- }
+ public ValueTask DisposeAsync() => ValueTask.CompletedTask;
- public Task Start(IAlbaHost host)
- {
- return Task.CompletedTask;
- }
+ public Task Start(IAlbaHost host) => Task.CompletedTask;
public IHostBuilder Configure(IHostBuilder builder)
{
@@ -50,7 +44,7 @@ public IHostBuilder Configure(IHostBuilder builder)
return builder;
}
- public class CO(TestServer testServer) : PostConfigureOptions(Options.DefaultName, null)
+ internal class CO(TestServer testServer) : PostConfigureOptions(Options.DefaultName, null)
{
public override void PostConfigure(string? name, HttpClientFactoryOptions options)
{
@@ -66,18 +60,12 @@ public override void PostConfigure(string? name, HttpClientFactoryOptions option
}
[DebuggerDisplay("{DebuggerDisplay,nq}")]
-public class TestServerDiagnosticEventListener(ILogger logger) : ServerDiagnosticEventListener
+internal class TestServerDiagnosticEventListener(ILogger logger) : ServerDiagnosticEventListener
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => ToString();
- public override void HttpRequestError(HttpContext context, Exception exception)
- {
- logger.LogError(exception, "HttpRequestError");
- }
+ public override void HttpRequestError(HttpContext context, Exception exception) => logger.LogError(exception, "HttpRequestError");
- public override void HttpRequestError(HttpContext context, IError error)
- {
- logger.LogError(error.Exception, "HttpRequestError");
- }
+ public override void HttpRequestError(HttpContext context, IError error) => logger.LogError(error.Exception, "HttpRequestError");
}