From 9d0d3c29cd7b367828bbe0366b432c52db8003e9 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 14 Dec 2024 23:04:45 +1100 Subject: [PATCH 1/3] fix incorrect as usage in ProjectFactory --- .../Commands/ProjectFactory.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs index 75907b4a978..34e7ba06bba 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs @@ -143,25 +143,14 @@ 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) + var console = (IConsole) Logger; + console.Verbosity = LogLevel switch { - case LogLevel.Verbose: - { - console.Verbosity = Verbosity.Detailed; - break; - } - case LogLevel.Information: - { - console.Verbosity = Verbosity.Normal; - break; - } - case LogLevel.Minimal: - { - console.Verbosity = Verbosity.Quiet; - break; - } - } + LogLevel.Verbose => Verbosity.Detailed, + LogLevel.Information => Verbosity.Normal, + LogLevel.Minimal => Verbosity.Quiet, + _ => console.Verbosity + }; } public WarningProperties GetWarningPropertiesForProject() From c7db036bcbec6b5195e938e11c62b599afce3122 Mon Sep 17 00:00:00 2001 From: Nigusu Solomon Yenework <59111203+Nigusu-Allehu@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:11:45 -0800 Subject: [PATCH 2/3] Update ProjectFactory.cs --- src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs index 34e7ba06bba..c10a0110fa7 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs @@ -143,7 +143,7 @@ private void Initialize(dynamic project) } // This happens before we obtain warning properties, so this Logger is still IConsole. - var console = (IConsole) Logger; + var console = (IConsole)Logger; console.Verbosity = LogLevel switch { LogLevel.Verbose => Verbosity.Detailed, From 4f44c63d3219117fa658cb7a823255c43ebc0484 Mon Sep 17 00:00:00 2001 From: Nigusu Solomon Yenework <59111203+Nigusu-Allehu@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:31:13 -0800 Subject: [PATCH 3/3] type check --- .../NuGet.CommandLine/Commands/ProjectFactory.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs index c10a0110fa7..113a24663fe 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Commands/ProjectFactory.cs @@ -143,14 +143,16 @@ private void Initialize(dynamic project) } // This happens before we obtain warning properties, so this Logger is still IConsole. - var console = (IConsole)Logger; - console.Verbosity = LogLevel switch + if (Logger is IConsole console) { - LogLevel.Verbose => Verbosity.Detailed, - LogLevel.Information => Verbosity.Normal, - LogLevel.Minimal => Verbosity.Quiet, - _ => console.Verbosity - }; + console.Verbosity = LogLevel switch + { + LogLevel.Verbose => Verbosity.Detailed, + LogLevel.Information => Verbosity.Normal, + LogLevel.Minimal => Verbosity.Quiet, + _ => console.Verbosity + }; + } } public WarningProperties GetWarningPropertiesForProject()