From 7a2c52abdbd61dde4a7341f800bc2c206a482173 Mon Sep 17 00:00:00 2001 From: Jay Cho Date: Sun, 24 May 2026 20:05:32 +0900 Subject: [PATCH] [Tizen.WindowSystem] Replace manual null checks with ArgumentNullException.ThrowIfNull() Convert legacy 'if (arg == null) throw new ArgumentNullException(nameof(arg));' patterns in Tizen.WindowSystem to the single-statement helper ArgumentNullException.ThrowIfNull(arg) introduced in .NET 6+. This reduces generated IL size, improving JIT inlining heuristics on hot paths, and tightens the source. Exception type and paramName (used by ArgumentNullException.ThrowIfNull) remain identical, so behavior and public API surface are preserved. Affected files: - KVMService.cs - QuickPanelService.cs (incl. SetContentRegion/SetHandlerRegion) - QuickPanelClient.cs (also normalized literal-string paramNames) - ScreensaverService.cs - TaskbarService.cs - SoftkeyClient.cs - SoftkeyService.cs Refs #7548 --- src/Tizen.WindowSystem/src/KVMService.cs | 10 ++-------- .../src/QuickPanelClient.cs | 10 ++-------- .../src/QuickPanelService.cs | 20 ++++--------------- .../src/ScreensaverService.cs | 10 ++-------- src/Tizen.WindowSystem/src/SoftkeyClient.cs | 10 ++-------- src/Tizen.WindowSystem/src/SoftkeyService.cs | 10 ++-------- src/Tizen.WindowSystem/src/TaskbarService.cs | 10 ++-------- 7 files changed, 16 insertions(+), 64 deletions(-) diff --git a/src/Tizen.WindowSystem/src/KVMService.cs b/src/Tizen.WindowSystem/src/KVMService.cs index f0c0550b0dd..e27fbd139aa 100644 --- a/src/Tizen.WindowSystem/src/KVMService.cs +++ b/src/Tizen.WindowSystem/src/KVMService.cs @@ -50,18 +50,12 @@ public class KVMService : IDisposable /// 12 public KVMService(TizenShell tzShell, IWindowProvider win) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); diff --git a/src/Tizen.WindowSystem/src/QuickPanelClient.cs b/src/Tizen.WindowSystem/src/QuickPanelClient.cs index 31f1ea00ee4..81dcadf9126 100644 --- a/src/Tizen.WindowSystem/src/QuickPanelClient.cs +++ b/src/Tizen.WindowSystem/src/QuickPanelClient.cs @@ -60,18 +60,12 @@ public class QuickPanelClient : IDisposable public QuickPanelClient(TizenShell tzShell, IWindowProvider win, QuickPanelCategory type) { int width = 0, height = 0; - if (tzShell == null) - { - throw new ArgumentNullException("tzShell"); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException("win"); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); diff --git a/src/Tizen.WindowSystem/src/QuickPanelService.cs b/src/Tizen.WindowSystem/src/QuickPanelService.cs index 73e5bcedfaf..167c52084e2 100644 --- a/src/Tizen.WindowSystem/src/QuickPanelService.cs +++ b/src/Tizen.WindowSystem/src/QuickPanelService.cs @@ -47,18 +47,12 @@ public class QuickPanelService : IDisposable /// 12 public QuickPanelService(TizenShell tzShell, IWindowProvider win, QuickPanelCategory type) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); @@ -187,10 +181,7 @@ public void Hide() /// Thrown when an argument is null. public void SetContentRegion(uint angle, params (int x, int y, int width, int height)[] regions) { - if (regions == null) - { - throw new ArgumentNullException(nameof(regions)); - } + ArgumentNullException.ThrowIfNull(regions); var regionHandle = Interop.TizenShellRegion.Create(_tzsh.SafeHandle); if (regionHandle.IsInvalid) @@ -224,10 +215,7 @@ public void SetContentRegion(uint angle, params (int x, int y, int width, int he /// Thrown when an argument is null. public void SetHandlerRegion(uint angle, params (int x, int y, int width, int height)[] regions) { - if (regions == null) - { - throw new ArgumentNullException(nameof(regions)); - } + ArgumentNullException.ThrowIfNull(regions); var regionHandle = Interop.TizenShellRegion.Create(_tzsh.SafeHandle); if (regionHandle.IsInvalid) diff --git a/src/Tizen.WindowSystem/src/ScreensaverService.cs b/src/Tizen.WindowSystem/src/ScreensaverService.cs index 9b8d65999ea..6008c50e83c 100644 --- a/src/Tizen.WindowSystem/src/ScreensaverService.cs +++ b/src/Tizen.WindowSystem/src/ScreensaverService.cs @@ -42,18 +42,12 @@ public class ScreensaverService : IDisposable /// Thrown when an argument is null. public ScreensaverService(TizenShell tzShell, IWindowProvider win) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); diff --git a/src/Tizen.WindowSystem/src/SoftkeyClient.cs b/src/Tizen.WindowSystem/src/SoftkeyClient.cs index fe3e604a349..062dc36c9b7 100644 --- a/src/Tizen.WindowSystem/src/SoftkeyClient.cs +++ b/src/Tizen.WindowSystem/src/SoftkeyClient.cs @@ -47,18 +47,12 @@ public class SoftkeyClient : IDisposable /// 12 public SoftkeyClient(TizenShell tzShell, IWindowProvider win) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); diff --git a/src/Tizen.WindowSystem/src/SoftkeyService.cs b/src/Tizen.WindowSystem/src/SoftkeyService.cs index 7c1f265d329..6bb2b6c330c 100644 --- a/src/Tizen.WindowSystem/src/SoftkeyService.cs +++ b/src/Tizen.WindowSystem/src/SoftkeyService.cs @@ -50,18 +50,12 @@ public class SoftkeyService : IDisposable /// Thrown when a argument is null. public SoftkeyService(TizenShell tzShell, IWindowProvider win) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); diff --git a/src/Tizen.WindowSystem/src/TaskbarService.cs b/src/Tizen.WindowSystem/src/TaskbarService.cs index 4ac9ce61846..87dea26390c 100755 --- a/src/Tizen.WindowSystem/src/TaskbarService.cs +++ b/src/Tizen.WindowSystem/src/TaskbarService.cs @@ -44,18 +44,12 @@ public class TaskbarService : IDisposable /// Thrown when a argument is null. public TaskbarService(TizenShell tzShell, IWindowProvider win, TaskbarPosition position = TaskbarPosition.Bottom) { - if (tzShell == null) - { - throw new ArgumentNullException(nameof(tzShell)); - } + ArgumentNullException.ThrowIfNull(tzShell); if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) { throw new ArgumentException("tzShell is not initialized."); } - if (win == null) - { - throw new ArgumentNullException(nameof(win)); - } + ArgumentNullException.ThrowIfNull(win); _tzsh = tzShell; _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle);