Skip to content

[Tizen.WindowSystem] Replace manual null checks with ArgumentNullException.ThrowIfNull()#7662

Open
JoonghyunCho wants to merge 1 commit into
mainfrom
ai-task/issue-7548-windowsystem
Open

[Tizen.WindowSystem] Replace manual null checks with ArgumentNullException.ThrowIfNull()#7662
JoonghyunCho wants to merge 1 commit into
mainfrom
ai-task/issue-7548-windowsystem

Conversation

@JoonghyunCho

Copy link
Copy Markdown
Member

Summary

Replaces legacy if (arg == null) throw new ArgumentNullException(nameof(arg)); patterns in src/Tizen.WindowSystem with the single-statement helper ArgumentNullException.ThrowIfNull(arg) introduced in .NET 6.

This is the second module-level slice of the umbrella refactor tracked in #7548 (the first slice, Tizen.Applications.Common, is in PR #7566).

Changes

  • src/Tizen.WindowSystem/src/KVMService.cs — constructor null checks for tzShell, win
  • src/Tizen.WindowSystem/src/QuickPanelService.cs — constructor null checks for tzShell, win; SetContentRegion and SetHandlerRegion null check for regions
  • src/Tizen.WindowSystem/src/QuickPanelClient.cs — constructor null checks for tzShell, win (also normalizes the pre-existing literal-string paramNames "tzShell" / "win"ArgumentNullException.ThrowIfNull derives the same paramName via CallerArgumentExpression)
  • src/Tizen.WindowSystem/src/ScreensaverService.cs — constructor null checks for tzShell, win
  • src/Tizen.WindowSystem/src/TaskbarService.cs — constructor null checks for tzShell, win
  • src/Tizen.WindowSystem/src/SoftkeyClient.cs — constructor null checks for tzShell, win
  • src/Tizen.WindowSystem/src/SoftkeyService.cs — constructor null checks for tzShell, win

Net change: 7 files, +16 / -64 lines.

Mode

Refactoring

API Compatibility

Item Result
Public API signatures Unchanged
Thrown exception type Unchanged (ArgumentNullException)
paramName carried by exception Unchanged (same nameof(arg) value; for the previous literal-string sites in QuickPanelClient.cs, the literal already matched the parameter name)
Native interop surface Unchanged
Backward compatibility 100% preserved

Verification

  • Build: dotnet build src/Tizen.WindowSystem → 0 errors, 4 unrelated warnings inherited from Tizen.Applications.Common
  • Tests: N/A — no behavior change; existing unit tests in dependent suites remain valid
  • Benchmark: skipped — the change is a behavior-preserving IL-size reduction; per-call cost is identical and these are not on hot paths. No sdb device available in this environment for runtime measurement.

Refs #7548

…ption.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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several service and client classes within the Tizen.WindowSystem namespace to use the ArgumentNullException.ThrowIfNull helper method for parameter validation, replacing manual null checks with a more concise implementation. I have no feedback to provide as there were no review comments to assess.

@JoonghyunCho

Copy link
Copy Markdown
Member Author

🤖 [AI Review]

Reviewed — no findings.

Scope checked:

  • TFM compatibility: Tizen.WindowSystem.csproj targets net8.0; ArgumentNullException.ThrowIfNull is available since .NET 6 ✓
  • 11 replacement sites across 7 files — all are vanilla if (x == null) throw new ArgumentNullException(...) blocks with no custom message (no information lost)
  • Mixed legacy patterns handled: both nameof(x) and string-literal "x" forms (e.g., QuickPanelClient) consolidated — ThrowIfNull's [CallerArgumentExpression] produces the correct parameter name in either case
  • Surrounding ArgumentException checks (tzShell.SafeHandle == null || IsInvalid) intentionally left untouched — semantics differ from ArgumentNullException
  • Public API surface unchanged: signatures, exception types, and <exception cref="ArgumentNullException"> doc tags remain accurate

No 🔴 critical issues, no 🟡 suggestions to flag.


Automated review — final merge decision rests with human reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant