diff --git a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs index 75907b4a978..113a24663fe 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs @@ -143,24 +143,15 @@ private void Initialize(dynamic project) } // This happens before we obtain warning properties, so this Logger is still IConsole. - IConsole console = Logger as IConsole; - switch (LogLevel) + if (Logger is IConsole console) { - case LogLevel.Verbose: - { - console.Verbosity = Verbosity.Detailed; - break; - } - case LogLevel.Information: - { - console.Verbosity = Verbosity.Normal; - break; - } - case LogLevel.Minimal: - { - console.Verbosity = Verbosity.Quiet; - break; - } + console.Verbosity = LogLevel switch + { + LogLevel.Verbose => Verbosity.Detailed, + LogLevel.Information => Verbosity.Normal, + LogLevel.Minimal => Verbosity.Quiet, + _ => console.Verbosity + }; } }