diff --git a/src/EventLogExpert.EventDbTool/CreateDatabaseCommand.cs b/src/EventLogExpert.EventDbTool/CreateDatabaseCommand.cs index a223ba95..bc7d9edb 100644 --- a/src/EventLogExpert.EventDbTool/CreateDatabaseCommand.cs +++ b/src/EventLogExpert.EventDbTool/CreateDatabaseCommand.cs @@ -35,11 +35,7 @@ public static Command GetCommand() createDatabaseCommand.AddOption(filterOption); createDatabaseCommand.AddOption(skipProvidersInFileOption); createDatabaseCommand.AddOption(verboseOption); - createDatabaseCommand.SetHandler((fileOptionValue, filterOptionValue, verboseOptionValue, skipProvidersInFileOption) => - { - CreateDatabase(fileOptionValue, filterOptionValue, verboseOptionValue, skipProvidersInFileOption); - }, - fileArgument, filterOption, verboseOption, skipProvidersInFileOption); + createDatabaseCommand.SetHandler(CreateDatabase, fileArgument, filterOption, verboseOption, skipProvidersInFileOption); return createDatabaseCommand; } diff --git a/src/EventLogExpert.EventDbTool/DbToolCommand.cs b/src/EventLogExpert.EventDbTool/DbToolCommand.cs index f37d7db4..2f2c4137 100644 --- a/src/EventLogExpert.EventDbTool/DbToolCommand.cs +++ b/src/EventLogExpert.EventDbTool/DbToolCommand.cs @@ -9,7 +9,7 @@ namespace EventLogExpert.EventDbTool; public class DbToolCommand { - private static string _providerDetailFormat = "{0, -14} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8}"; + private static string s_providerDetailFormat = "{0, -14} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8}"; public static List GetLocalProviderNames(string filter) { @@ -28,20 +28,20 @@ public static void LogProviderDetailHeader(IEnumerable providerNames) { var maxNameLength = providerNames.Any() ? providerNames.Max(p => p.Length) : 14; if (maxNameLength < 14) maxNameLength = 14; - _providerDetailFormat = "{0, -" + maxNameLength + "} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8} {6, 8}"; - Console.WriteLine(string.Format(_providerDetailFormat, "Provider Name", "Events", "Parameters", "Keywords", "Opcodes", "Tasks", "Messages")); + s_providerDetailFormat = "{0, -" + maxNameLength + "} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8} {6, 8}"; + Console.WriteLine(s_providerDetailFormat, "Provider Name", "Events", "Parameters", "Keywords", "Opcodes", "Tasks", "Messages"); } public static void LogProviderDetails(ProviderDetails details) { - Console.WriteLine(string.Format( - _providerDetailFormat, + Console.WriteLine( + s_providerDetailFormat, details.ProviderName, details.Events.Count, details.Parameters.Count, details.Keywords.Count, details.Opcodes.Count, details.Tasks.Count, - details.Messages.Count)); + details.Messages.Count); } } diff --git a/src/EventLogExpert.EventDbTool/DiffDatabaseCommand.cs b/src/EventLogExpert.EventDbTool/DiffDatabaseCommand.cs index d51994e7..c46759c7 100644 --- a/src/EventLogExpert.EventDbTool/DiffDatabaseCommand.cs +++ b/src/EventLogExpert.EventDbTool/DiffDatabaseCommand.cs @@ -1,8 +1,8 @@ // // Copyright (c) Microsoft Corporation. // // Licensed under the MIT License. -using EventLogExpert.Eventing.Providers; using EventLogExpert.Eventing.EventProviderDatabase; +using EventLogExpert.Eventing.Providers; using System.CommandLine; namespace EventLogExpert.EventDbTool; @@ -11,7 +11,7 @@ public class DiffDatabaseCommand : DbToolCommand { public static Command GetCommand() { - var diffDatababaseCommand = new Command( + var diffDatabaseCommand = new Command( name: "diff", description: "Given two databases, produces a third database containing all providers " + "from the second database which are not in the first database."); @@ -27,17 +27,13 @@ public static Command GetCommand() var verboseOption = new Option( name: "--verbose", description: "Verbose logging. May be useful for troubleshooting."); - diffDatababaseCommand.AddArgument(dbOneArgument); - diffDatababaseCommand.AddArgument(dbTwoArgument); - diffDatababaseCommand.AddArgument(newDbArgument); - diffDatababaseCommand.AddOption(verboseOption); - diffDatababaseCommand.SetHandler((dbOneArgValue, dbTwoArgValue, newDbArgValue, verboseOptionValue) => - { - DiffDatabase(dbOneArgValue, dbTwoArgValue, newDbArgValue, verboseOptionValue); - }, - dbOneArgument, dbTwoArgument, newDbArgument, verboseOption); + diffDatabaseCommand.AddArgument(dbOneArgument); + diffDatabaseCommand.AddArgument(dbTwoArgument); + diffDatabaseCommand.AddArgument(newDbArgument); + diffDatabaseCommand.AddOption(verboseOption); + diffDatabaseCommand.SetHandler(DiffDatabase, dbOneArgument, dbTwoArgument, newDbArgument, verboseOption); - return diffDatababaseCommand; + return diffDatabaseCommand; } public static void DiffDatabase(string dbOne, string dbTwo, string newDb, bool verbose) diff --git a/src/EventLogExpert.EventDbTool/MergeDatabaseCommand.cs b/src/EventLogExpert.EventDbTool/MergeDatabaseCommand.cs index 46a51cb0..6daf133b 100644 --- a/src/EventLogExpert.EventDbTool/MergeDatabaseCommand.cs +++ b/src/EventLogExpert.EventDbTool/MergeDatabaseCommand.cs @@ -1,8 +1,8 @@ // // Copyright (c) Microsoft Corporation. // // Licensed under the MIT License. -using EventLogExpert.Eventing.Providers; using EventLogExpert.Eventing.EventProviderDatabase; +using EventLogExpert.Eventing.Providers; using System.CommandLine; namespace EventLogExpert.EventDbTool; @@ -31,11 +31,7 @@ public static Command GetCommand() mergeDatabaseCommand.AddArgument(targetDatabaseArgument); mergeDatabaseCommand.AddOption(overwriteOption); mergeDatabaseCommand.AddOption(verboseOption); - mergeDatabaseCommand.SetHandler((sourceArgumentValue, targetArgumentValue, overwriteOptionValue, verboseOptionValue) => - { - MergeDatabase(sourceArgumentValue, targetArgumentValue, overwriteOptionValue, verboseOptionValue); - }, - sourceDatabaseArgument, targetDatabaseArgument, overwriteOption, verboseOption); + mergeDatabaseCommand.SetHandler(MergeDatabase, sourceDatabaseArgument, targetDatabaseArgument, overwriteOption, verboseOption); return mergeDatabaseCommand; } diff --git a/src/EventLogExpert.EventDbTool/Program.cs b/src/EventLogExpert.EventDbTool/Program.cs index b7881025..2691efc3 100644 --- a/src/EventLogExpert.EventDbTool/Program.cs +++ b/src/EventLogExpert.EventDbTool/Program.cs @@ -5,9 +5,9 @@ namespace EventLogExpert.EventDbTool; -class Program +internal class Program { - static async Task Main(string[] args) + private static async Task Main(string[] args) { var rootCommand = new RootCommand("Tool used to create and modify databases for use with EventLogExpert"); diff --git a/src/EventLogExpert.EventDbTool/ShowDatabaseCommand.cs b/src/EventLogExpert.EventDbTool/ShowDatabaseCommand.cs index 8feb88c4..941188e6 100644 --- a/src/EventLogExpert.EventDbTool/ShowDatabaseCommand.cs +++ b/src/EventLogExpert.EventDbTool/ShowDatabaseCommand.cs @@ -2,14 +2,8 @@ // // Licensed under the MIT License. using EventLogExpert.Eventing.EventProviderDatabase; -using EventLogExpert.Eventing.Providers; -using System; -using System.Collections.Generic; using System.CommandLine; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace EventLogExpert.EventDbTool; @@ -32,11 +26,7 @@ public static Command GetCommand() showDatabaseCommand.AddArgument(fileArgument); showDatabaseCommand.AddOption(filterOption); showDatabaseCommand.AddOption(verboseOption); - showDatabaseCommand.SetHandler((fileArgumentValue, filterOptionValue, verboseOptionValue) => - { - ShowProviderInfo(fileArgumentValue, filterOptionValue, verboseOptionValue); - }, - fileArgument, filterOption, verboseOption); + showDatabaseCommand.SetHandler(ShowProviderInfo, fileArgument, filterOption, verboseOption); return showDatabaseCommand; } diff --git a/src/EventLogExpert.EventDbTool/ShowLocalCommand.cs b/src/EventLogExpert.EventDbTool/ShowLocalCommand.cs index 877c5136..2b2511b9 100644 --- a/src/EventLogExpert.EventDbTool/ShowLocalCommand.cs +++ b/src/EventLogExpert.EventDbTool/ShowLocalCommand.cs @@ -21,11 +21,7 @@ public static Command GetCommand() description: "Verbose logging. May be useful for troubleshooting."); showProvidersCommand.AddOption(filterOption); showProvidersCommand.AddOption(verboseOption); - showProvidersCommand.SetHandler((filterOptionValue, verboseOptionValue) => - { - ShowProviderInfo(filterOptionValue, verboseOptionValue); - }, - filterOption, verboseOption); + showProvidersCommand.SetHandler(ShowProviderInfo, filterOption, verboseOption); return showProvidersCommand; } diff --git a/src/EventLogExpert.EventDbTool/UpgradeDatabaseCommand.cs b/src/EventLogExpert.EventDbTool/UpgradeDatabaseCommand.cs index b3c855af..b347261c 100644 --- a/src/EventLogExpert.EventDbTool/UpgradeDatabaseCommand.cs +++ b/src/EventLogExpert.EventDbTool/UpgradeDatabaseCommand.cs @@ -21,11 +21,7 @@ public static Command GetCommand() description: "Verbose logging. May be useful for troubleshooting."); upgradeDatabaseCommand.AddArgument(fileArgument); upgradeDatabaseCommand.AddOption(verboseOption); - upgradeDatabaseCommand.SetHandler((fileArgumentValue, verboseOptionValue) => - { - UpgradeDatabase(fileArgumentValue, verboseOptionValue); - }, - fileArgument, verboseOption); + upgradeDatabaseCommand.SetHandler(UpgradeDatabase, fileArgument, verboseOption); return upgradeDatabaseCommand; }