From 77ff4cda4db4afec4b07063fcc0fc6df2ebaf063 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Dec 2024 14:41:46 -0500 Subject: [PATCH] chore: linting Signed-off-by: Vincent Biret --- src/Kiota.Builder/KiotaBuilder.cs | 2 +- src/Kiota.Builder/Logging/FileLogLogger.cs | 5 +---- src/Kiota.Builder/Logging/FileLogLoggerProvider.cs | 13 ++++--------- src/kiota/Handlers/BaseKiotaCommandHandler.cs | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 40c3207ff9..b4466a5bf0 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -77,7 +77,7 @@ private async Task CleanOutputDirectoryAsync(CancellationToken cancellationToken Directory.Delete(subDir, true); await workspaceManagementService.BackupStateAsync(config.OutputPath, cancellationToken).ConfigureAwait(false); foreach (var subFile in Directory.EnumerateFiles(config.OutputPath) - .Where(x => !x.EndsWith(FileLogLogger.LogFileName, StringComparison.OrdinalIgnoreCase))) + .Where(static x => !x.EndsWith(FileLogLogger.LogFileName, StringComparison.OrdinalIgnoreCase))) File.Delete(subFile); } } diff --git a/src/Kiota.Builder/Logging/FileLogLogger.cs b/src/Kiota.Builder/Logging/FileLogLogger.cs index dba4b6cf43..82a2cdb0c0 100644 --- a/src/Kiota.Builder/Logging/FileLogLogger.cs +++ b/src/Kiota.Builder/Logging/FileLogLogger.cs @@ -71,9 +71,6 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except } } -public class FileLogLogger : FileLogLogger, ILogger +public class FileLogLogger(string logFileDirectoryAbsolutePath, LogLevel logLevel) : FileLogLogger(logFileDirectoryAbsolutePath, logLevel, typeof(T).FullName ?? string.Empty), ILogger { - public FileLogLogger(string logFileDirectoryAbsolutePath, LogLevel logLevel) : base(logFileDirectoryAbsolutePath, logLevel, typeof(T).FullName ?? string.Empty) - { - } } diff --git a/src/Kiota.Builder/Logging/FileLogLoggerProvider.cs b/src/Kiota.Builder/Logging/FileLogLoggerProvider.cs index 2f0bb466ae..3ce3c650ca 100644 --- a/src/Kiota.Builder/Logging/FileLogLoggerProvider.cs +++ b/src/Kiota.Builder/Logging/FileLogLoggerProvider.cs @@ -4,16 +4,11 @@ namespace Kiota.Builder.Logging; -public sealed class FileLogLoggerProvider : ILoggerProvider +public sealed class FileLogLoggerProvider(string logFileDirectoryAbsolutePath, LogLevel logLevel) : ILoggerProvider { - private readonly LogLevel _logLevel; - private readonly string _logFileDirectoryAbsolutePath; - public FileLogLoggerProvider(string logFileDirectoryAbsolutePath, LogLevel logLevel) - { - _logLevel = logLevel; - _logFileDirectoryAbsolutePath = logFileDirectoryAbsolutePath; - } - private readonly List _loggers = new(); + private readonly LogLevel _logLevel = logLevel; + private readonly string _logFileDirectoryAbsolutePath = logFileDirectoryAbsolutePath; + private readonly List _loggers = []; public ILogger CreateLogger(string categoryName) { var instance = new FileLogLogger(_logFileDirectoryAbsolutePath, _logLevel, categoryName); diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index 700bf37711..a7b857b22a 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -132,7 +132,7 @@ protected async Task CheckForNewVersionAsync(ILogger logger, CancellationToken c DisplayWarning(result); } public abstract Task InvokeAsync(InvocationContext context); - private readonly List disposables = new(); + private readonly List disposables = []; protected (ILoggerFactory, ILogger) GetLoggerAndFactory(InvocationContext context, string logFileRootPath = "") { LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);