From ee46ffcccf92925a3dc2fa573792b67fdcaf9f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 25 Jun 2026 10:27:32 +0200 Subject: [PATCH] Fix hashtable .Keys/.Values member-access collision in skill coverage Get-SignificantTerms returned $terms.Keys; when a teaching point contains the word 'keys', PowerShell hashtable member access resolves to that entry's value instead of the key collection, collapsing the keyword set and making points like test-tagging Step 3 uncoverable. Use get_Keys()/get_Values() to bypass key-name shadowing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/skill-coverage/Measure-SkillCoverage.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eng/skill-coverage/Measure-SkillCoverage.ps1 b/eng/skill-coverage/Measure-SkillCoverage.ps1 index f1fda885bf..c856667040 100644 --- a/eng/skill-coverage/Measure-SkillCoverage.ps1 +++ b/eng/skill-coverage/Measure-SkillCoverage.ps1 @@ -216,7 +216,7 @@ function Get-CodePatterns([string]$content) { if ($inCode) { $block += "$line`n" } } - $seen.Values | ForEach-Object { + $seen.get_Values() | ForEach-Object { [PSCustomObject]@{ Category = 'CodePattern' Description = $_[0] @@ -257,7 +257,7 @@ function Get-BlockPatterns([string]$code) { if ($code -match $_.Value) { $found[$_.Key.ToLower()] = $_.Key } } - $found.Values + $found.get_Values() } function Get-SignificantTerms([string]$text) { @@ -283,7 +283,10 @@ function Get-SignificantTerms([string]$text) { } } - [string[]]$terms.Keys + # Use get_Keys() rather than .Keys: if a significant term is literally + # "keys", PowerShell's hashtable member access returns that entry's value + # instead of the key collection, collapsing the keyword set. + [string[]]$terms.get_Keys() } # ═══════════════════════════════════════════════════════════