test: guard PackagePath declarations against backslashes - #2
Merged
Conversation
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.
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.
There was a problem hiding this comment.
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
PackagePathdeclaration contains a backslash. - Update
.gitignoreto ignore*.tmpscratch 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trellis.ResourceNamingalready packs its API reference at the cleantrellis/trellis-api-resourcenaming.md, unlike its sibling repositories —Trellis.Core3.0.0-alpha.458 andTrellis.Microservices.Abstractions0.1.0-alpha.72 both ship the malformedtrellis//<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
PackagePathmay 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.XDocumenthandles all of these and supplies line numbers viaIXmlLineInfo.Property indirection (
PackagePath="$(SomeVar)") is not statically visible; the existing packed-path assertions cover that on Linux.Validation
<!-- -->that quotes the malformed patternNo production code changes — test/gate only.
Companion PRs fix the actual defect upstream: xavierjohn/Trellis#713 and xavierjohn/Trellis.Microservices#57.