diff --git a/.editorconfig b/.editorconfig index e468705b..8477cf8b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -191,10 +191,22 @@ dotnet_diagnostic.RCS1194.severity = none # RCS1163: Unused parameter. dotnet_diagnostic.RCS1163.severity = silent +# RCS1097: Remove redundant 'ToString' call +dotnet_diagnostic.RCS1097.severity = silent + # RCS1239: Use 'for' statement instead of 'while' statement. dotnet_diagnostic.RCS1239.severity = silent csharp_style_prefer_primary_constructors = true:suggestion +# RCS1158: Static member in generic type should use a type parameter +dotnet_diagnostic.RCS1158.severity = silent + +# RCS1202: Avoid NullReferenceException +dotnet_diagnostic.RCS1202.severity = silent + +# RCS1075: Avoid empty catch clause that catches System.Exception +dotnet_diagnostic.RCS1075.severity = silent + [*.vb] # Modifier preferences visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion diff --git a/EtLast.AdoNet.MsSql/EtLast.AdoNet.MsSql.csproj b/EtLast.AdoNet.MsSql/EtLast.AdoNet.MsSql.csproj index 6d4985ee..4fd66457 100644 --- a/EtLast.AdoNet.MsSql/EtLast.AdoNet.MsSql.csproj +++ b/EtLast.AdoNet.MsSql/EtLast.AdoNet.MsSql.csproj @@ -17,8 +17,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.AdoNet.MsSql/Scopes/ResilientSqlScope/ResilientSqlScope.cs b/EtLast.AdoNet.MsSql/Scopes/ResilientSqlScope/ResilientSqlScope.cs index 9cf8b380..c052c785 100644 --- a/EtLast.AdoNet.MsSql/Scopes/ResilientSqlScope/ResilientSqlScope.cs +++ b/EtLast.AdoNet.MsSql/Scopes/ResilientSqlScope/ResilientSqlScope.cs @@ -280,7 +280,6 @@ private class TableWithOrder } } - [EditorBrowsable(EditorBrowsableState.Never)] public static class ResilientSqlScopeFluent { diff --git a/EtLast.AdoNet.PostgreSql/EtLast.AdoNet.PostgreSql.csproj b/EtLast.AdoNet.PostgreSql/EtLast.AdoNet.PostgreSql.csproj index ae95b61c..5c9dc170 100644 --- a/EtLast.AdoNet.PostgreSql/EtLast.AdoNet.PostgreSql.csproj +++ b/EtLast.AdoNet.PostgreSql/EtLast.AdoNet.PostgreSql.csproj @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.AdoNet/EtLast.AdoNet.csproj b/EtLast.AdoNet/EtLast.AdoNet.csproj index 5b4561bd..446cc891 100644 --- a/EtLast.AdoNet/EtLast.AdoNet.csproj +++ b/EtLast.AdoNet/EtLast.AdoNet.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.AdoNet/EtlConnectionManager.cs b/EtLast.AdoNet/EtlConnectionManager.cs index 20ccbeea..90047f45 100644 --- a/EtLast.AdoNet/EtlConnectionManager.cs +++ b/EtLast.AdoNet/EtlConnectionManager.cs @@ -129,10 +129,7 @@ public static void ReleaseConnection(IProcess process, ref DatabaseConnection co }); }, onClosed: connection => ioCommand.End(), - onError: (connection, ex) => - { - ioCommand.Failed(ex); - }); + onError: (connection, ex) => ioCommand.Failed(ex)); if (connection == null) return; diff --git a/EtLast.AdoNet/Mutators/MergeToSql/MergeToSqlMutator.cs b/EtLast.AdoNet/Mutators/MergeToSql/MergeToSqlMutator.cs index d3266719..db802a63 100644 --- a/EtLast.AdoNet/Mutators/MergeToSql/MergeToSqlMutator.cs +++ b/EtLast.AdoNet/Mutators/MergeToSql/MergeToSqlMutator.cs @@ -207,7 +207,6 @@ private void ExecuteStatements() _command = null; _statements.Clear(); } - } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/EtLast.ConsoleHost/CommandImplementations/ModuleLoader.cs b/EtLast.ConsoleHost/CommandImplementations/ModuleLoader.cs index df3e6daf..34aa4b5c 100644 --- a/EtLast.ConsoleHost/CommandImplementations/ModuleLoader.cs +++ b/EtLast.ConsoleHost/CommandImplementations/ModuleLoader.cs @@ -246,6 +246,7 @@ private static List FindTypesFromAppDomain(string moduleName) { var matchingTypes = assembly.GetTypes() .Where(t => t.IsClass && !t.IsAbstract && interfaceType.IsAssignableFrom(t) && t.Namespace.EndsWith(moduleName, StringComparison.OrdinalIgnoreCase)); + result.AddRange(matchingTypes); } catch (Exception) { } diff --git a/EtLast.ConsoleHost/ConsoleHost.cs b/EtLast.ConsoleHost/ConsoleHost.cs index ef03e467..436c797a 100644 --- a/EtLast.ConsoleHost/ConsoleHost.cs +++ b/EtLast.ConsoleHost/ConsoleHost.cs @@ -51,6 +51,8 @@ public ConsoleHost(string name) HostArgumentsFolder = @".\HostArguments"; ReferenceAssemblyFolders.Add(@"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\"); ReferenceAssemblyFolders.Add(@"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\"); + + AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; } protected override ILogger CreateHostLogger() diff --git a/EtLast.ConsoleHost/ConsoleHostSessionBuilderExtensions.cs b/EtLast.ConsoleHost/ConsoleHostSessionBuilderExtensions.cs index 7fa03a3b..e6f78af2 100644 --- a/EtLast.ConsoleHost/ConsoleHostSessionBuilderExtensions.cs +++ b/EtLast.ConsoleHost/ConsoleHostSessionBuilderExtensions.cs @@ -3,7 +3,7 @@ [EditorBrowsable(EditorBrowsableState.Never)] public static class ConsoleHostSessionBuilderExtensions { - public static ISessionBuilder UseRollingDevLogManifestFiles(this ISessionBuilder session, int? maxFileCount, int? maxSizeOnDisk = 16 * 1024 * 1024) + public static ISessionBuilder UseRollingDevLogManifestFiles(this ISessionBuilder session, int? maxFileCount, int? maxSizeOnDisk = 16 * 1024 * 1024) { var folder = Path.Combine(session.DevLogFolder, "manifest"); CleanupManifestFolder(maxFileCount, maxSizeOnDisk, folder); diff --git a/EtLast.ConsoleHost/EtLast.ConsoleHost.csproj b/EtLast.ConsoleHost/EtLast.ConsoleHost.csproj index b93e78bd..0bc82565 100644 --- a/EtLast.ConsoleHost/EtLast.ConsoleHost.csproj +++ b/EtLast.ConsoleHost/EtLast.ConsoleHost.csproj @@ -28,7 +28,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.ConsoleHost/Global.cs b/EtLast.ConsoleHost/Global.cs index 36f7952b..7d89316c 100644 --- a/EtLast.ConsoleHost/Global.cs +++ b/EtLast.ConsoleHost/Global.cs @@ -7,16 +7,10 @@ global using System.IO; global using System.Linq; global using System.Reflection; -global using System.Runtime.InteropServices; global using System.Runtime.Loader; global using System.Text; global using System.Text.Json; -global using System.Text.RegularExpressions; global using System.Threading; global using System.Transactions; global using Serilog; -global using Serilog.Core; global using Serilog.Events; -global using Serilog.Formatting.Compact; -global using Serilog.Formatting.Display; -global using Serilog.Parsing; diff --git a/EtLast.Diagnostics.HttpSender/DiagnosticsHttpSender.cs b/EtLast.Diagnostics.HttpSender/DiagnosticsHttpSender.cs index bf1a64b4..fca31604 100644 --- a/EtLast.Diagnostics.HttpSender/DiagnosticsHttpSender.cs +++ b/EtLast.Diagnostics.HttpSender/DiagnosticsHttpSender.cs @@ -21,7 +21,6 @@ public class DiagnosticsHttpSender : IDisposable, IEtlContextListener private readonly IEtlContext _context; private ExtendedBinaryWriter _currentWriter; private readonly ExtendedBinaryWriter _eventWriter = new(new MemoryStream(), Encoding.UTF8); - private readonly ExtendedBinaryWriter _dictWriter = new(new MemoryStream(), Encoding.UTF8); private readonly object _currentWriterLock = new(); private bool _finished; private int _communicationErrorCount; diff --git a/EtLast.Diagnostics.HttpSender/EtLast.Diagnostics.HttpSender.csproj b/EtLast.Diagnostics.HttpSender/EtLast.Diagnostics.HttpSender.csproj index ebfb46b3..57148cc8 100644 --- a/EtLast.Diagnostics.HttpSender/EtLast.Diagnostics.HttpSender.csproj +++ b/EtLast.Diagnostics.HttpSender/EtLast.Diagnostics.HttpSender.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Diagnostics.Interface/EtLast.Diagnostics.Interface.csproj b/EtLast.Diagnostics.Interface/EtLast.Diagnostics.Interface.csproj index 73726f5f..2f23309e 100644 --- a/EtLast.Diagnostics.Interface/EtLast.Diagnostics.Interface.csproj +++ b/EtLast.Diagnostics.Interface/EtLast.Diagnostics.Interface.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Diagnostics.Windows/Controls/ContextProcessInvocationListControl.cs b/EtLast.Diagnostics.Windows/Controls/ContextProcessInvocationListControl.cs index e3e524d5..0ae4b5ab 100644 --- a/EtLast.Diagnostics.Windows/Controls/ContextProcessInvocationListControl.cs +++ b/EtLast.Diagnostics.Windows/Controls/ContextProcessInvocationListControl.cs @@ -175,14 +175,8 @@ private void ListView_MouseDoubleClick(object sender, MouseEventArgs e) }; var control = new ProcessRowListControl(form, process, rows.Values.ToList()); - control.Updater.RefreshStarted += (sender, args) => - { - form.Text = "LOADING..."; - }; - control.Updater.RefreshFinished += (sender, args) => - { - form.Text = "Process output: " + process.Name; - }; + control.Updater.RefreshStarted += (sender, args) => form.Text = "LOADING..."; + control.Updater.RefreshFinished += (sender, args) => form.Text = "Process output: " + process.Name; ToolTipSingleton.Remove(ListView); form.ShowDialog(); diff --git a/EtLast.Diagnostics.Windows/EtLast.Diagnostics.Windows.csproj b/EtLast.Diagnostics.Windows/EtLast.Diagnostics.Windows.csproj index 3bde055f..fb8a8391 100644 --- a/EtLast.Diagnostics.Windows/EtLast.Diagnostics.Windows.csproj +++ b/EtLast.Diagnostics.Windows/EtLast.Diagnostics.Windows.csproj @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.EPPlus/EtLast.EPPlus.csproj b/EtLast.EPPlus/EtLast.EPPlus.csproj index 58276015..48ed7ddc 100644 --- a/EtLast.EPPlus/EtLast.EPPlus.csproj +++ b/EtLast.EPPlus/EtLast.EPPlus.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Hosting.AspNet/EtLast.Hosting.AspNet.csproj b/EtLast.Hosting.AspNet/EtLast.Hosting.AspNet.csproj index e74cfb77..d7692d15 100644 --- a/EtLast.Hosting.AspNet/EtLast.Hosting.AspNet.csproj +++ b/EtLast.Hosting.AspNet/EtLast.Hosting.AspNet.csproj @@ -26,7 +26,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Hosting/EtLast.Hosting.csproj b/EtLast.Hosting/EtLast.Hosting.csproj index 6dc0297f..ee46080d 100644 --- a/EtLast.Hosting/EtLast.Hosting.csproj +++ b/EtLast.Hosting/EtLast.Hosting.csproj @@ -16,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Hosting/Host/AbstractHost.cs b/EtLast.Hosting/Host/AbstractHost.cs index 4a23010e..331039d0 100644 --- a/EtLast.Hosting/Host/AbstractHost.cs +++ b/EtLast.Hosting/Host/AbstractHost.cs @@ -199,7 +199,9 @@ private void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArg var formattedMessage = ex.FormatExceptionWithDetails(); if (Logger != null) + { Logger.Write(LogEventLevel.Fatal, "unexpected error during execution: {ErrorMessage}", formattedMessage); + } else { Console.WriteLine("unexpected error during execution: " + formattedMessage); diff --git a/EtLast.Hosting/Logging/EtlContextDevToFileLogger.cs b/EtLast.Hosting/Logging/EtlContextDevToFileLogger.cs index 7b20e923..a78137f7 100644 --- a/EtLast.Hosting/Logging/EtlContextDevToFileLogger.cs +++ b/EtLast.Hosting/Logging/EtlContextDevToFileLogger.cs @@ -12,39 +12,39 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int var config = new LoggerConfiguration() .WriteTo.File(new Serilog.Formatting.Compact.CompactJsonFormatter(), Path.Combine(folder, "events-.json"), restrictedToMinimumLevel: (LogEventLevel)minimumLogLevel, - rollingInterval: RollingInterval.Day, - retainedFileCountLimit: infoFileCount, buffered: true, flushToDiskInterval: TimeSpan.FromSeconds(1), + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: infoFileCount, encoding: Encoding.UTF8) .WriteTo.File(Path.Combine(folder, "2-info-.txt"), - outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", restrictedToMinimumLevel: LogEventLevel.Information, + outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, rollingInterval: RollingInterval.Day, retainedFileCountLimit: infoFileCount, encoding: Encoding.UTF8) .WriteTo.File(Path.Combine(folder, "3-warning-.txt"), - outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", restrictedToMinimumLevel: LogEventLevel.Warning, + outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, rollingInterval: RollingInterval.Day, retainedFileCountLimit: importantFileCount, encoding: Encoding.UTF8) .WriteTo.File(Path.Combine(folder, "4-error-.txt"), - outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", restrictedToMinimumLevel: LogEventLevel.Error, + outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, rollingInterval: RollingInterval.Day, retainedFileCountLimit: importantFileCount, encoding: Encoding.UTF8) .WriteTo.File(Path.Combine(folder, "5-fatal-.txt"), - outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", restrictedToMinimumLevel: LogEventLevel.Fatal, + outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, rollingInterval: RollingInterval.Day, retainedFileCountLimit: importantFileCount, @@ -57,10 +57,10 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int restrictedToMinimumLevel: LogEventLevel.Debug, outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, - rollingInterval: RollingInterval.Day, - retainedFileCountLimit: lowFileCount, buffered: true, flushToDiskInterval: TimeSpan.FromSeconds(1), + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: lowFileCount, encoding: Encoding.UTF8); } @@ -71,10 +71,10 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int restrictedToMinimumLevel: LogEventLevel.Verbose, outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}", formatProvider: CultureInfo.InvariantCulture, - rollingInterval: RollingInterval.Day, - retainedFileCountLimit: lowFileCount, buffered: true, flushToDiskInterval: TimeSpan.FromSeconds(1), + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: lowFileCount, encoding: Encoding.UTF8); } diff --git a/EtLast.Hosting/Logging/EtlContextIoToFileLogger.cs b/EtLast.Hosting/Logging/EtlContextIoToFileLogger.cs index 915f05e5..9f401615 100644 --- a/EtLast.Hosting/Logging/EtlContextIoToFileLogger.cs +++ b/EtLast.Hosting/Logging/EtlContextIoToFileLogger.cs @@ -12,12 +12,12 @@ public EtlContextIoToFileLogger(string folder, int lowFileCount = 4) .WriteTo.File(Path.Combine(folder, "io-.tsv"), outputTemplate: "{Timestamp:HH:mm:ss.fff zzz}\t{Message:l}{NewLine}", formatProvider: CultureInfo.InvariantCulture, - rollingInterval: RollingInterval.Day, - retainedFileCountLimit: lowFileCount, buffered: true, flushToDiskInterval: TimeSpan.FromSeconds(1), - hooks: new IoFileLifecycleHooks(), - encoding: Encoding.UTF8); + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: lowFileCount, + encoding: Encoding.UTF8, + hooks: new IoFileLifecycleHooks()); _logger = config.CreateLogger(); } @@ -155,7 +155,6 @@ public override Stream OnFileOpened(string path, Stream underlyingStream, Encodi writer.Flush(); underlyingStream.Flush(); } - } return base.OnFileOpened(path, underlyingStream, encoding); diff --git a/EtLast.LocalFiles/EtLast.LocalFiles.csproj b/EtLast.LocalFiles/EtLast.LocalFiles.csproj index b499bdeb..345a6d2b 100644 --- a/EtLast.LocalFiles/EtLast.LocalFiles.csproj +++ b/EtLast.LocalFiles/EtLast.LocalFiles.csproj @@ -16,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.ServiceModel/EtLast.ServiceModel.csproj b/EtLast.ServiceModel/EtLast.ServiceModel.csproj index 9a571398..259ccf18 100644 --- a/EtLast.ServiceModel/EtLast.ServiceModel.csproj +++ b/EtLast.ServiceModel/EtLast.ServiceModel.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast.Specialized/EtLast.Specialized.csproj b/EtLast.Specialized/EtLast.Specialized.csproj index 58acc8d0..48d63968 100644 --- a/EtLast.Specialized/EtLast.Specialized.csproj +++ b/EtLast.Specialized/EtLast.Specialized.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast/EtLast.csproj b/EtLast/EtLast.csproj index 13adc883..d49b3090 100644 --- a/EtLast/EtLast.csproj +++ b/EtLast/EtLast.csproj @@ -16,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EtLast/Mutators/Aggregation/Memory/MemoryAggregationMutator.cs b/EtLast/Mutators/Aggregation/Memory/MemoryAggregationMutator.cs index 7b154da1..2995bce4 100644 --- a/EtLast/Mutators/Aggregation/Memory/MemoryAggregationMutator.cs +++ b/EtLast/Mutators/Aggregation/Memory/MemoryAggregationMutator.cs @@ -130,7 +130,7 @@ protected override IEnumerable EvaluateImpl(Stopwatch netTimeStopwatch) } foreach (var row in groupRows) - (row as IRow).SetOwner(null); + (row as IRow)?.SetOwner(null); foreach (var aggregate in aggregates) { diff --git a/EtLast/Mutators/Aggregation/Memory/SortedMemoryAggregationMutator.cs b/EtLast/Mutators/Aggregation/Memory/SortedMemoryAggregationMutator.cs index ddf4d0c2..4f6b87d1 100644 --- a/EtLast/Mutators/Aggregation/Memory/SortedMemoryAggregationMutator.cs +++ b/EtLast/Mutators/Aggregation/Memory/SortedMemoryAggregationMutator.cs @@ -125,7 +125,7 @@ protected override IEnumerable EvaluateImpl(Stopwatch netTimeStopwatch) } foreach (var groupRow in groupRows) - (groupRow as IRow).SetOwner(null); + (groupRow as IRow)?.SetOwner(null); groupRows.Clear(); @@ -175,7 +175,7 @@ protected override IEnumerable EvaluateImpl(Stopwatch netTimeStopwatch) } foreach (var groupRow in groupRows) - (groupRow as IRow).SetOwner(null); + (groupRow as IRow)?.SetOwner(null); groupRows.Clear(); diff --git a/EtLast/Mutators/ThrowExceptionOnRowErrorMutator.cs b/EtLast/Mutators/ThrowExceptionOnRowErrorMutator.cs index 87f2d495..a4a781bc 100644 --- a/EtLast/Mutators/ThrowExceptionOnRowErrorMutator.cs +++ b/EtLast/Mutators/ThrowExceptionOnRowErrorMutator.cs @@ -2,11 +2,6 @@ public sealed class ThrowExceptionOnRowErrorMutator : AbstractMutator { - protected override void StartMutator() - { - base.StartMutator(); - } - protected override IEnumerable MutateRow(IRow row, long rowInputIndex) { if (row.HasError()) diff --git a/EtLast/Processes/Abstracts/AbstractProcess.cs b/EtLast/Processes/Abstracts/AbstractProcess.cs index de24ffec..11a40bee 100644 --- a/EtLast/Processes/Abstracts/AbstractProcess.cs +++ b/EtLast/Processes/Abstracts/AbstractProcess.cs @@ -150,7 +150,7 @@ protected void BeginExecution(ICaller caller, FlowState flowState, bool overwrit .ToHashSet(); var properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.Public) - .Where(p => p.SetMethod != null && p.SetMethod.IsPrivate != true && !baseProperties.Contains(p.Name) && p.GetIndexParameters().Length == 0) + .Where(p => p.SetMethod?.IsPrivate == false && !baseProperties.Contains(p.Name) && p.GetIndexParameters().Length == 0) .ToList(); foreach (var property in properties) @@ -178,7 +178,7 @@ public void ValidateParameterAnnotations() public static void ValidateParameterAnnotations(IProcess process, object instance) { var properties = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.Public) - .Where(p => p.SetMethod != null && p.SetMethod.IsPrivate != true && p.GetIndexParameters().Length == 0) + .Where(p => p.SetMethod?.IsPrivate == false && p.GetIndexParameters().Length == 0) .ToList(); foreach (var property in properties) diff --git a/EtLast/Processes/Delimited/WriteToDelimitedMutator.cs b/EtLast/Processes/Delimited/WriteToDelimitedMutator.cs index 65ef835d..f7cefac5 100644 --- a/EtLast/Processes/Delimited/WriteToDelimitedMutator.cs +++ b/EtLast/Processes/Delimited/WriteToDelimitedMutator.cs @@ -241,7 +241,6 @@ private class SinkEntry public required MemoryStream Buffer { get; init; } public int RowCount = 0; } - } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/EtLast/Processes/Json/JsonArrayReader.cs b/EtLast/Processes/Json/JsonArrayReader.cs index 94591961..cb2004ab 100644 --- a/EtLast/Processes/Json/JsonArrayReader.cs +++ b/EtLast/Processes/Json/JsonArrayReader.cs @@ -77,6 +77,7 @@ protected override IEnumerable Produce() } var entry = enumerator.Current; + entryIndex++; resultCount++; initialValues[ColumnName] = entry; diff --git a/EtLast/Rows/Row.cs b/EtLast/Rows/Row.cs index 61058018..4c7d9c6e 100644 --- a/EtLast/Rows/Row.cs +++ b/EtLast/Rows/Row.cs @@ -5,7 +5,7 @@ public sealed class Row(IEtlContext context, IProcess process, long id, IEnumerable> initialValues) : IRow { public IProcess Owner { get; private set; } = process; - public long Id { get; private set; } = id; + public long Id { get; } = id; public IEnumerable> Values => _values; public int ValueCount => _values.Count; diff --git a/EtLast/TypeConverters/DoubleConverter.cs b/EtLast/TypeConverters/DoubleConverter.cs index cafc8c73..a4b09bba 100644 --- a/EtLast/TypeConverters/DoubleConverter.cs +++ b/EtLast/TypeConverters/DoubleConverter.cs @@ -87,5 +87,4 @@ public static class DoubleConverterFluent public static ReaderColumn AsDouble(this ReaderColumn column) => column.WithTypeConverter(new DoubleConverter()); public static TextReaderColumn AsDouble(this TextReaderColumn column) => column.WithTypeConverter(new DoubleConverter()); public static IConvertMutatorBuilder_NullStrategy ToDouble(this IConvertMutatorBuilder_WithTypeConverter builder) => builder.WithTypeConverter(new DoubleConverter()); - } \ No newline at end of file diff --git a/Samples/Sample.Etl.Host/Program.cs b/Samples/Sample.Etl.Host/Program.cs index 7a91225d..2f91b970 100644 --- a/Samples/Sample.Etl.Host/Program.cs +++ b/Samples/Sample.Etl.Host/Program.cs @@ -1,9 +1,7 @@ using FizzCode.EtLast; -return (int)ConsoleHostBuilder.New("Sample ETL Host") - .HandleCommandLineArgs(args) - .UseCommandLineListener(hostArguments => new ConsoleCommandLineListener()) +return (int)new ConsoleHost("Sample ETL Host") + .UseCommandListener(hostArguments => new ConsoleCommandListener()) .SetAlias("test", "test-modules -a") .SetAlias("load", "run SampleModule Load") - .Build() .Run(); diff --git a/Samples/Sample.Etl.Host/Sample.Etl.Host.csproj b/Samples/Sample.Etl.Host/Sample.Etl.Host.csproj index 4112caf5..095e4e02 100644 --- a/Samples/Sample.Etl.Host/Sample.Etl.Host.csproj +++ b/Samples/Sample.Etl.Host/Sample.Etl.Host.csproj @@ -10,15 +10,15 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Samples/Sample.Etl.Modules/Modules/SampleModule/Startup.cs b/Samples/Sample.Etl.Modules/Modules/SampleModule/Startup.cs index 55a08e78..f5d2fd40 100644 --- a/Samples/Sample.Etl.Modules/Modules/SampleModule/Startup.cs +++ b/Samples/Sample.Etl.Modules/Modules/SampleModule/Startup.cs @@ -2,9 +2,14 @@ public class Startup : IStartup { - public void Configure(EnvironmentSettings settings, IArgumentCollection arguments) + public void BuildSession(ISessionBuilder session, IArgumentCollection arguments) { - System.Data.Common.DbProviderFactories.RegisterFactory("Microsoft.Data.SqlClient", Microsoft.Data.SqlClient.SqlClientFactory.Instance); + session + .EnableMicrosoftSqlClient() + .LogToConsole(LogSeverity.Debug) + .LogDevToFile() + .LogOpsToFile() + .LogIoToFile(); } public Dictionary> CustomTasks => []; diff --git a/Samples/Sample.Etl.Modules/Sample.Etl.Modules.csproj b/Samples/Sample.Etl.Modules/Sample.Etl.Modules.csproj index aa2613a5..2cba603a 100644 --- a/Samples/Sample.Etl.Modules/Sample.Etl.Modules.csproj +++ b/Samples/Sample.Etl.Modules/Sample.Etl.Modules.csproj @@ -6,16 +6,17 @@ - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tests/EtLast.Tests.Base/EtLast.Tests.Base.csproj b/Tests/EtLast.Tests.Base/EtLast.Tests.Base.csproj index cb52d6ef..a0db01b5 100644 --- a/Tests/EtLast.Tests.Base/EtLast.Tests.Base.csproj +++ b/Tests/EtLast.Tests.Base/EtLast.Tests.Base.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Benchmarks/EtLast.Tests.Benchmarks.csproj b/Tests/EtLast.Tests.Benchmarks/EtLast.Tests.Benchmarks.csproj index a55bf1f8..09a9f108 100644 --- a/Tests/EtLast.Tests.Benchmarks/EtLast.Tests.Benchmarks.csproj +++ b/Tests/EtLast.Tests.Benchmarks/EtLast.Tests.Benchmarks.csproj @@ -15,12 +15,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.EPPlus/EtLast.Tests.EPPlus.csproj b/Tests/EtLast.Tests.EPPlus/EtLast.Tests.EPPlus.csproj index da486876..d6eca4e3 100644 --- a/Tests/EtLast.Tests.EPPlus/EtLast.Tests.EPPlus.csproj +++ b/Tests/EtLast.Tests.EPPlus/EtLast.Tests.EPPlus.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/EtLast.Tests.Integration.AdoNetTests.csproj b/Tests/EtLast.Tests.Integration.AdoNetTests/EtLast.Tests.Integration.AdoNetTests.csproj index df4c8c6f..ac0d57fb 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/EtLast.Tests.Integration.AdoNetTests.csproj +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/EtLast.Tests.Integration.AdoNetTests.csproj @@ -21,7 +21,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/CreatePrimaryKeyConstraintTests.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/CreatePrimaryKeyConstraintTests.cs index b68edcde..5d34af14 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/CreatePrimaryKeyConstraintTests.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/CreatePrimaryKeyConstraintTests.cs @@ -30,10 +30,7 @@ public override void Execute(IFlow flow) AND CONSTRAINT_CATALOG = '{DatabaseName}' AND CONSTRAINT_TYPE = 'PRIMARY KEY'", }) - .CustomJob("Test", job => - { - Assert.AreEqual(0, countOfPrimaryKeys1); - }) + .CustomJob("Test", job => Assert.AreEqual(0, countOfPrimaryKeys1)) .CreatePrimaryKeyConstraint(() => new CreatePrimaryKeyConstraint() { Name = "CreatePrimaryKey", @@ -52,9 +49,6 @@ public override void Execute(IFlow flow) AND CONSTRAINT_CATALOG = '{DatabaseName}' AND CONSTRAINT_TYPE = 'PRIMARY KEY'", }) - .CustomJob("Test", job => - { - Assert.AreEqual(1, countOfPrimaryKeys2); - }); + .CustomJob("Test", job => Assert.AreEqual(1, countOfPrimaryKeys2)); } } \ No newline at end of file diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableMaxValueTests.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableMaxValueTests.cs index 17d26f0a..cda66e29 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableMaxValueTests.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableMaxValueTests.cs @@ -25,9 +25,6 @@ public override void Execute(IFlow flow) ColumnName = "DateTimeValue", WhereClause = null, }) - .CustomJob("Test", job => - { - Assert.AreEqual(new DateTime(2022, 7, 9), result.MaxValue); - }); + .CustomJob("Test", job => Assert.AreEqual(new DateTime(2022, 7, 9), result.MaxValue)); } } \ No newline at end of file diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableRecordCountTests.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableRecordCountTests.cs index fcd50e3c..ac410ca1 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableRecordCountTests.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/Jobs/GetTableRecordCountTests.cs @@ -24,9 +24,6 @@ public override void Execute(IFlow flow) TableName = ConnectionString.Escape(nameof(GetTableRecordCountTests)), WhereClause = null, }) - .CustomJob("Test", job => - { - Assert.AreEqual(2, result); - }); + .CustomJob("Test", job => Assert.AreEqual(2, result)); } } \ No newline at end of file diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/AssertFail.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/AssertFail.cs index 58000c2a..318770f4 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/AssertFail.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/AssertFail.cs @@ -4,9 +4,6 @@ public class AssertFail : AbstractEtlTask { public override void Execute(IFlow flow) { - flow.CustomJob("StoredProcedureAdoNetDbReader", job => - { - Assert.Fail("Expected fail from Assert TestAssertAndException"); - }); + flow.CustomJob("StoredProcedureAdoNetDbReader", job => Assert.Fail("Expected fail from Assert TestAssertAndException")); } } diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/Exception.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/Exception.cs index 219fc8d0..41762325 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/Exception.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestAssertAndException/Exception.cs @@ -8,9 +8,6 @@ public class Exception : AbstractEtlTask public override void Execute(IFlow flow) { flow - .CustomJob(nameof(Exception), job => - { - throw new System.Exception("Test Exception."); - }); + .CustomJob(nameof(Exception), job => throw new System.Exception("Test Exception.")); } } diff --git a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestHelpers.cs b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestHelpers.cs index 1eb8cfbd..4c289fdc 100644 --- a/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestHelpers.cs +++ b/Tests/EtLast.Tests.Integration.AdoNetTests/Modules/AdoNetTests/TestHelpers.cs @@ -8,10 +8,7 @@ public static CustomJob CreateReadSqlTableAndAssertExactMatch(NamedConnectionStr return new CustomJob() { Name = "ReadAndCheck" + table + "Table", - Action = job => - { - ReadSqlTableAndAssertExactMacth(job, connectionString, table, expectedRowsList); - } + Action = job => ReadSqlTableAndAssertExactMacth(job, connectionString, table, expectedRowsList) }; } diff --git a/Tests/EtLast.Tests.Integration.FlowTests/EtLast.Tests.Integration.FlowTests.csproj b/Tests/EtLast.Tests.Integration.FlowTests/EtLast.Tests.Integration.FlowTests.csproj index 6848e670..42be5e5c 100644 --- a/Tests/EtLast.Tests.Integration.FlowTests/EtLast.Tests.Integration.FlowTests.csproj +++ b/Tests/EtLast.Tests.Integration.FlowTests/EtLast.Tests.Integration.FlowTests.csproj @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/GetFiles.cs b/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/GetFiles.cs index 16c9a51d..47251742 100644 --- a/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/GetFiles.cs +++ b/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/GetFiles.cs @@ -7,9 +7,6 @@ public class GetFiles : AbstractEtlTask public override void Execute(IFlow flow) { flow - .CustomJob(nameof(GetFiles), job => - { - FileNames = ["a.txt", "b.txt", "c.txt"]; - }); + .CustomJob(nameof(GetFiles), job => FileNames = ["a.txt", "b.txt", "c.txt"]); } } \ No newline at end of file diff --git a/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/ShowMessage.cs b/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/ShowMessage.cs index eb2c9413..5de26bb3 100644 --- a/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/ShowMessage.cs +++ b/Tests/EtLast.Tests.Integration.FlowTests/Modules/FlowTests/Tasks/ShowMessage.cs @@ -8,9 +8,6 @@ public class ShowMessage : AbstractEtlTask public override void Execute(IFlow flow) { flow - .CustomJob("ShowMessageJob", job => - { - Context.Log(LogSeverity.Warning, job, Message); - }); + .CustomJob("ShowMessageJob", job => Context.Log(LogSeverity.Warning, job, Message)); } } \ No newline at end of file diff --git a/Tests/EtLast.Tests.Integration/EtLast.Tests.Integration.csproj b/Tests/EtLast.Tests.Integration/EtLast.Tests.Integration.csproj index e84aaf99..e4179553 100644 --- a/Tests/EtLast.Tests.Integration/EtLast.Tests.Integration.csproj +++ b/Tests/EtLast.Tests.Integration/EtLast.Tests.Integration.csproj @@ -16,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Integration/Program.cs b/Tests/EtLast.Tests.Integration/Program.cs index 1a760b53..247945ed 100644 --- a/Tests/EtLast.Tests.Integration/Program.cs +++ b/Tests/EtLast.Tests.Integration/Program.cs @@ -19,10 +19,12 @@ .SetAlias("flow", "run FlowTests Main") //.DisableSerilogForModules() //.DisableSerilogForCommands() - .IfDebuggerAttached(host => host - .RegisterEtlContextListener(context => new DiagnosticsHttpSender(context) - { - MaxCommunicationErrorCount = 2, - Url = "http://localhost:8642", - })) + .IfInstanceIs("WSDEVONE", host => host + .IfDebuggerAttached(host => host + .RegisterEtlContextListener(context => new DiagnosticsHttpSender(context) + { + MaxCommunicationErrorCount = 2, + Url = "http://localhost:8642", + })) + ) .Run(); diff --git a/Tests/EtLast.Tests.Unit/EtLast.Tests.Unit.csproj b/Tests/EtLast.Tests.Unit/EtLast.Tests.Unit.csproj index 01c32229..cf7ece9f 100644 --- a/Tests/EtLast.Tests.Unit/EtLast.Tests.Unit.csproj +++ b/Tests/EtLast.Tests.Unit/EtLast.Tests.Unit.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/EtLast.Tests.Unit/Tests/Mutators/Cross/ExpandFromLookupMutatorTests.cs b/Tests/EtLast.Tests.Unit/Tests/Mutators/Cross/ExpandFromLookupMutatorTests.cs index b5319274..1b79d474 100644 --- a/Tests/EtLast.Tests.Unit/Tests/Mutators/Cross/ExpandFromLookupMutatorTests.cs +++ b/Tests/EtLast.Tests.Unit/Tests/Mutators/Cross/ExpandFromLookupMutatorTests.cs @@ -22,10 +22,7 @@ public void Complex() Process = TestData.Country(), KeyGenerator = row => row.GenerateKey("id"), }, - MatchSelector = (row, lookup) => - { - return lookup.GetSingleRowByKey(row.GenerateKey("countryId")); - }, + MatchSelector = (row, lookup) => lookup.GetSingleRowByKey(row.GenerateKey("countryId")), NoMatchAction = new NoMatchAction(MatchMode.Custom) { CustomAction = row => diff --git a/Tests/EtLast.Tests.Unit/Tests/Mutators/CustomMutatorTests.cs b/Tests/EtLast.Tests.Unit/Tests/Mutators/CustomMutatorTests.cs index f8a158d4..e08c0823 100644 --- a/Tests/EtLast.Tests.Unit/Tests/Mutators/CustomMutatorTests.cs +++ b/Tests/EtLast.Tests.Unit/Tests/Mutators/CustomMutatorTests.cs @@ -41,10 +41,7 @@ public void RemoveRowsWithDelegate() .ReadFrom(TestData.Person()) .CustomCode(new CustomMutator() { - Action = row => - { - return row.GetAs("id") < 4; - } + Action = row => row.GetAs("id") < 4 }); var result = TestExecuter.Execute(context, builder); diff --git a/Tests/EtLast.Tests.Unit/Tests/Rows/RowTests.cs b/Tests/EtLast.Tests.Unit/Tests/Rows/RowTests.cs index e4f5c677..63ef0f7a 100644 --- a/Tests/EtLast.Tests.Unit/Tests/Rows/RowTests.cs +++ b/Tests/EtLast.Tests.Unit/Tests/Rows/RowTests.cs @@ -35,7 +35,6 @@ public void KeyCaseIgnored() Assert.AreEqual(new DateTime(2020, 02, 20, 12, 12, 0, 666), result); } - [TestMethod] public void SingleNullColumnResultsNullKey() {