Skip to content

test: guard PackagePath declarations against backslashes - #2

Merged
xavierjohn merged 3 commits into
mainfrom
test/guard-packagepath-declarations
Aug 19, 2026
Merged

test: guard PackagePath declarations against backslashes#2
xavierjohn merged 3 commits into
mainfrom
test/guard-packagepath-declarations

Conversation

@xavierjohn

Copy link
Copy Markdown
Owner

Trellis.ResourceNaming already packs its API reference at the clean trellis/trellis-api-resourcenaming.md, unlike its sibling repositories — Trellis.Core 3.0.0-alpha.458 and Trellis.Microservices.Abstractions 0.1.0-alpha.72 both ship the malformed trellis//<name>.md. The exact-path assertion in this gate is what made that fix stick here.

That assertion has a blind spot: it can only fail on Linux. A trailing backslash in PackagePath="trellis\" is a directory marker on Windows and packs correctly there. On Linux it is not a separator: it normalizes and NuGet appends its own, producing the double slash. A developer reintroducing a backslash would see every check pass locally and only discover the regression from published bytes.

Adds a platform-independent declaration check: no PackagePath may contain a backslash.

It parses the XML rather than scanning text. A line-based regex missed two of three planted violations in testing — the single-quoted attribute form PackagePath='trellis\' and the <PackagePath>trellis\</PackagePath> metadata element — and would also have flagged the comments that quote the malformed value on purpose. XDocument handles all of these and supplies line numbers via IXmlLineInfo.

Property indirection (PackagePath="$(SomeVar)") is not statically visible; the existing packed-path assertions cover that on Linux.

Validation

  • Full gate passes end to end (16 assertions, exit 0)
  • New check catches a planted single-quoted attribute and a planted metadata element, both at correct line numbers
  • Correctly ignores prose inside <!-- --> that quotes the malformed pattern

No production code changes — test/gate only.

Companion PRs fix the actual defect upstream: xavierjohn/Trellis#713 and xavierjohn/Trellis.Microservices#57.

This repository already packs the API reference at the clean
trellis/trellis-api-resourcenaming.md, unlike its sibling repositories,
which pack the malformed trellis//<name>.md. The packed-path assertion
here is what made that fix stick.

That assertion has a blind spot: it can only fail on Linux. A trailing
backslash in PackagePath="trellis\" is a directory marker on Windows and
packs correctly there, so a developer reintroducing one would see every
check pass locally and only discover the regression from published bytes.

Adds a platform-independent declaration check: no PackagePath may contain
a backslash. It parses the XML rather than scanning text, because a
line-based regex misses the single-quoted attribute form and the
<PackagePath> metadata element - two of three planted violations went
undetected in testing - and would also flag the comments that quote the
malformed value on purpose to explain the defect. XDocument handles all
of these and supplies line numbers through IXmlLineInfo.

Property indirection, PackagePath="$(SomeVar)" where the variable holds a
backslash, is not statically visible; the existing packed-path assertions
cover that case on Linux.

Verified: the full gate passes, and the new check catches both a planted
single-quoted attribute and a planted metadata element at the correct
line numbers.
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:13
msg.tmp is a temporary file used to pass a multi-line message to
git commit -F. It was captured by git add -A in the previous commit
because, unlike the sibling repositories, this repo's .gitignore did
not cover *.tmp. Removes the file and closes the gap.

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

Tightens the API-reference packaging gate in Trellis.ResourceNaming by adding a platform-independent check that prevents malformed NuGet PackagePath values (backslashes that can produce trellis//... on Linux), and makes a small repo hygiene update.

Changes:

  • Add an XML-parsing validation step to fail the gate if any PackagePath declaration contains a backslash.
  • Update .gitignore to ignore *.tmp scratch files used for multi-line git/gh messages.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
build/test-apireference-packaging.ps1 Adds XML-based scan of MSBuild files to reject backslashes in PackagePath declarations (platform-independent).
.gitignore Adds *.tmp ignore rule; also modifies the first line.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@xavierjohn
xavierjohn merged commit 32ad8bf into main Aug 19, 2026
1 check passed
@xavierjohn
xavierjohn deleted the test/guard-packagepath-declarations branch August 19, 2026 17:10
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