Repository navigation
Fix gallery search-index placeholder false positives - #1609
PaperHammer (PaperHammer) wants to merge 1 commit into
Conversation
Alexandre Zollinger Chohfi (azchohfi)
left a comment
There was a problem hiding this comment.
Nice fix. The Roslyn masking is a lot more robust than the old regex, and the coverage manifest is a good safety net. Left a few comments inline.
| var uri = list.Parent is ObjectCreationExpressionSyntax creation | ||
| && creation.Type.ToString() is "Uri" or "System.Uri" or "global::System.Uri"; |
There was a problem hiding this comment.
This narrows the URI check to new Uri(...) only. Every other string literal gets masked before the ... scan, so Image("ms-appx:///Assets/.../photo.png") or MediaPlayerElement("https://<your-host>/clip.mp4") would now get indexed. The old regex rejected both. Nothing in the gallery hits this today, but the Image and Media pages are where it's most likely to show up.
Could we run the path and <your…> checks on any string literal that starts with a URI scheme? If the narrower rule is intended, the CHANGELOG line about URI placeholders should say new Uri(...) to match the README.
| [InlineData("MapControl(\"<your-key>\");")] | ||
| [InlineData("MapControl(@\"<your-key>\");")] | ||
| [InlineData("MapControl(\"\"\"<your-key>\"\"\");")] | ||
| [InlineData("MapControl(\"<yourApiKey>\");")] | ||
| [InlineData("MapControl(<yourApiKey>);")] | ||
| [InlineData("MapControl(mapServiceToken: \"<your.azure.maps.key>\");")] | ||
| [InlineData("MapControl(\"<yourapikey>\");")] | ||
| [InlineData("var uri = new Uri(\"ms-appx:///.../image.png\");")] | ||
| [InlineData("var uri = new Uri(\"https://example.com/media/(...)\");")] | ||
| [InlineData("var uri = new Uri(\"https://example.com/media/( ... )\");")] | ||
| [InlineData("var uri = new System.Uri(uriString: \"https://example.com/.../page\");")] |
There was a problem hiding this comment.
A few HasDirectPlaceholder shapes aren't covered here. Factories.MapControl, global::System.Uri, new Uri("https://<your-host>/x") and the first-argument-only rule for MapControl could all be narrowed without anything going red. Maybe add rows for those, plus a kept case like MapControl("configured-key", "<your-note>").
| problems.Add($"{id}: editorial override is missing a manifest entry."); | ||
|
|
||
| var actual = indexed[id].EnumerateArray().Select(s => s.GetProperty("header").GetString()!).ToArray(); | ||
| if (expected.SequenceEqual(actual)) continue; | ||
|
|
||
| var missing = expected.Except(actual).ToArray(); | ||
| var unexpected = actual.Except(expected).ToArray(); | ||
| problems.Add($"{id}: expected {expected.Count}, got {actual.Length}. " | ||
| + $"Missing: [{string.Join(", ", missing)}]. " | ||
| + $"Unexpected: [{string.Join(", ", unexpected)}]. " | ||
| + "If both lists are empty, check the order or duplicate count."); | ||
| } | ||
|
|
||
| problems.AddRange(remainingChanges.Select(entry => | ||
| $"{entry.Key.Control} / {entry.Key.Title} ({entry.Key.Occurrence}): stale manifest entry ({entry.Value.Reason}).")); |
There was a problem hiding this comment.
The stale manifest and "override is missing a manifest entry" branches never fire in any test. TESTING.md calls out stale entry detection, so a MiniGallery case for each would be good.
| [new("grid", "Basic Grid")] = new(Action.Skip, "Remaining grid cells are elided."), | ||
| [new("list-view", "Basic ListView")] = new(Action.Skip, "Additional list items are elided."), | ||
| [new("list-view", "Animated edit (spec 042)")] = new(Action.Skip, "The mutation signature and item template are elided."), | ||
| [new("map-control", "Interactive map")] = new(Action.Replace, "Editorial code supplies the complete no-token branch."), |
There was a problem hiding this comment.
Nit, take it or leave it. The Replace entries duplicate sampleOverride in editorial.json. Deriving them from the override (first non-skipped card gets the override header) would mean one less file to touch next time.
|
|
||
| var routes = Routes(gallery); | ||
| var pageNames = included.Select(id => routes[id]).ToHashSet(StringComparer.Ordinal); | ||
| var pageFiles = Directory.EnumerateFiles(Path.Join(gallery, "ControlPages"), "*.cs", SearchOption.AllDirectories); |
There was a problem hiding this comment.
Nit. This is another copy of the page loader that GallerySources is there to avoid, and unlike ReadSources it doesn't skip bin/obj. Could we make GallerySources.ReadSources internal and reuse it here?
Summary
Complete Gallery samples could be silently omitted from the search index when comments or display text contained ellipses. This change makes placeholder filtering context-aware and adds an independent coverage check that detects missing samples after index regeneration.
Linked issue / spec
Fixes #1020.
Related design — spec 064 §3.2.
Test plan
--check— passed.git diff --check— passed.Both CS1503 failures also reproduce on the unchanged baseline at
7e3d0254:DidYouMeanAnalyzerParityTests.CS1503_string_for_element_fires_in_both_enginesSymbolSuggesterTests.CS1503_Element_expected_string_supplied_proposes_text_factoryLayoutModifiersTests.Fluent_Layout_Updates_Allocate_Only_The_Returned_Recordsfailed during the full run, then passed in focused reruns on both the baseline and the fixed tree. The full-suite result remains recorded as three failures.Risk / breaking changes
Resource-placeholder checks cover direct string-literal MapControl token arguments and explicit Uri construction. Other resource-call shapes, target-typed construction, and computed placeholders require an explicit omission marker such as
// omitted: reason.The independent coverage check compares sample headers and order. Changes to snippets already listed as intentional omissions require manual review of those exceptions.