Skip to content

refactor: use -not for string parameter null/empty checks (#870 follow-up) - #916

Open
pavankadabala-png wants to merge 7 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/870-isnullorempty-string-params
Open

refactor: use -not for string parameter null/empty checks (#870 follow-up)#916
pavankadabala-png wants to merge 7 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/870-isnullorempty-string-params

Conversation

@pavankadabala-png

Copy link
Copy Markdown
Contributor

Follow-up to #913, per @FH-Inway's request to apply the [string]::IsNullOrEmpty -> -not simplification (suggested by @FriedrichWeinmann in #870) to other string-parameter checks across the module.

For a [string] parameter, [string]::IsNullOrEmpty($x) is equivalent to -not $x, so this replaces the more verbose form. Changes span 7 files. Public cmdlets: Invoke-D365AzCopyTransfer ($FileName, 2x), Import-D365Bacpac ($DiagnosticFile, $ModelFile), New-D365Bacpac ($DiagnosticFile), Repair-D365BacpacModelFile ($OutputPath + 3 path params), Get-D365TfsWorkspace ($TfsUri). Internal helpers: Invoke-Process ($LogPath), Test-PathExists ($item, iterating [string[]] $Path).

Scope was limited to operands that are declared [string]/[string[]] parameters, where -not is exactly equivalent. I intentionally left the sites where the operand is an object or external-command output (Get-MpComputerStatus $defenderOptions, the tf.exe $res results, $res.FlightingServiceCatalogID), since -not is not equivalent there (matching the caveat from #913). Only if-condition expressions changed; no parameter or help changes. (The web editor also normalized a missing end-of-file newline in each touched file.)

Refs #870, #913

@FH-Inway FH-Inway self-assigned this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants