Skip to content

Tighten up context cmdlets - #28

Open
RiverHeart wants to merge 1 commit into
mainfrom
UpdateContextMgmt
Open

Tighten up context cmdlets#28
RiverHeart wants to merge 1 commit into
mainfrom
UpdateContextMgmt

Conversation

@RiverHeart

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI 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.

Pull request overview

This PR tightens how the WPF control registry “context” is resolved across helper cmdlets, making explicit -ContextId usage strict (must exist) while improving fallback behavior when -ContextId is omitted (object context → active context → single context).

Changes:

  • Added Test-WPFControlContextId and updated multiple helpers to validate explicit -ContextId values rather than silently falling back.
  • Updated Resolve-WPFControlContextId to focus on fallback resolution and to error when an explicitly-bound -InputObject is not associated with a context.
  • Expanded Pester coverage and updated keyword documentation for the new resolution rules (Get-WPFWindow, Reference, registry context helpers).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/modules/WPF/Tests/RegistryContext.Tests.ps1 Adds tests for fallback context resolution, explicit-null handling, and new context existence helper.
src/modules/WPF/Tests/Get-WPFWindow.Tests.ps1 Updates behavior expectations for missing implicit context and adds “single context” fallback coverage.
src/modules/WPF/Public/Helpers/Register-WPFObject.ps1 Reworks explicit -ContextId handling to either use an existing context or create it before registering.
src/modules/WPF/Public/Helpers/Get-WPFWindow.ps1 Implements strict explicit context validation and fallback context resolution when -ContextId is omitted.
src/modules/WPF/Public/DSL/Helpers/Reference.ps1 Implements strict explicit context validation and fallback context resolution.
src/modules/WPF/Private/ControlRegistry/Test-WPFControlContextId.ps1 New helper to check context existence and optionally emit an error if missing.
src/modules/WPF/Private/ControlRegistry/Resolve-WPFControlContextId.ps1 Simplifies context resolution rules and errors on explicitly-bound non-associated input objects.
src/modules/WPF/Private/ControlRegistry/Remove-WPFControlContext.ps1 Uses strict explicit context validation semantics instead of resolving/falling back.
src/modules/WPF/Private/ControlRegistry/Get-WPFRegisteredObjectNames.ps1 Uses strict explicit context validation semantics (empty when explicit context missing).
src/modules/WPF/Private/ControlRegistry/Get-WPFControlTable.ps1 Uses strict explicit context validation/creation path before returning a control table.
src/modules/WPF/Private/ControlRegistry/Get-WPFControlContextId.ps1 Tightens parameter contract and adds comment-based help.
src/modules/WPF/Docs/KeywordReference.md Documents the strict -ContextId rules and fallback behavior for Get-WPFWindow and Reference.

Comment on lines 64 to 66
if ($State.ActiveContextId) {
return $State.ActiveContextId
}
Comment on lines +17 to +26
if ($PSBoundParameters.ContainsKey('ContextId')) {
if (Test-WPFControlContextId -ContextId $ContextId) {
$Id = $ContextId
} elseif ($CreateIfMissing) {
$Id = New-WPFControlContext -Name $Name -ContextId $ContextId -Activate:$Activate
} else {
[void] (Test-WPFControlContextId -ContextId $ContextId -ErrorIfMissing)
return $null
}
} else {
Comment on lines 43 to +47
foreach($Item in $Name) {
$ResolvedContextId = Resolve-WPFControlContextId -ContextId $ContextId -InputObject $ScopeObject
if ($PSBoundParameters.ContainsKey('ContextId')) {
if (-not (Test-WPFControlContextId -ContextId $ContextId -ErrorIfMissing)) {
return
}
@RiverHeart RiverHeart changed the title WIP Tighten up context cmdlets Tighten up context cmdlets Jun 13, 2026
Base automatically changed from IntegrateAppWithImageViewer to main June 14, 2026 02:34
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