fix: resolve --api-headers relative patterns from CWD not include roots#29
Merged
Merged
Conversation
The requirement ApiMarkCpp-CppGenerator-SupportAbsoluteAndRelativeHeader Patterns was authored incorrectly, stating that relative patterns should be expanded against each PublicIncludeRoot. The user guide specifies CWD. This caused a pattern like 'include/**' to be joined onto each --includes path, producing doubled paths that match nothing. Fixes: - Correct the requirement: relative patterns resolve from CWD - Fix ExpandExplicitPatterns() to resolve relative patterns from CWD with a single expansion per pattern (not one per include root) - Update CppGeneratorOptions.ApiHeaderPatterns XML docs - Update design and verification docs for cpp-generator Add two new tests using non-root-agnostic CWD-relative patterns that would have failed with the old include-root expansion: - CwdRelativePattern_OnlyMatchingFilesDocumented - CwdRelativeExclusionPattern_ExcludesMatchingFiles Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects C++ --api-headers glob resolution so that relative patterns are interpreted from the current working directory (CWD) (as documented in the user guide), rather than being expanded under each PublicIncludeRoots entry, which previously produced incorrect doubled paths.
Changes:
- Update
CppGeneratorpattern handling to resolve relativeApiHeaderPatternsfrom CWD (single expansion per pattern). - Update XML docs for
CppGeneratorOptions.ApiHeaderPatterns/PublicIncludeRootsto reflect CWD-based relative pattern semantics. - Update requirements, design, verification docs, and add new integration tests covering CWD-relative include/exclude patterns.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ApiMark.Cpp.Tests/CppGeneratorTests.cs | Adds new tests for CWD-relative include and exclusion patterns. |
| src/ApiMark.Cpp/CppGeneratorOptions.cs | Updates option XML documentation to state relative patterns resolve from CWD. |
| src/ApiMark.Cpp/CppGenerator.cs | Changes explicit-pattern expansion logic to base relative patterns on CWD. |
| docs/verification/api-mark-cpp/cpp-generator.md | Documents verification scenarios for CWD-relative patterns. |
| docs/reqstream/api-mark-cpp/cpp-generator.yaml | Corrects requirement text and adds tests covering the behavior. |
| docs/design/api-mark-cpp/cpp-generator.md | Updates design description of pattern resolution behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- GlobFileCollector now treats absolute paths with no glob metacharacters as literal file paths (include if exists) rather than silently skipping - Updated CppGeneratorTests ApiHeaderPatterns tests to use correct absolute/CWD-relative patterns rather than root-agnostic ** prefixes - Added GlobFileCollector tests for literal path behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bFileCollector - Add WorkingDirectory property to CppGeneratorOptions (nullable, defaults to Directory.GetCurrentDirectory() at parse time, matching VhdlGeneratorOptions) - CppGenerator.CollectHeaderFiles uses WorkingDirectory, eliminating the need to mutate the process working directory in tests - Remove ExpandExplicitPatterns — GlobFileCollector already resolves relative patterns natively via its workingDirectory parameter - GlobFileCollector.ParsePattern: replace Path.IsPathRooted with Path.IsPathFullyQualified so Windows rooted-but-not-fully-qualified paths (e.g. C:foo.h, \foo.h) resolve against workingDirectory rather than entering the absolute literal-path fast path incorrectly - Update GlobFileCollector literal-path doc comment to reflect the corrected absolute-path classification - Remove SetCurrentDirectory/previousCwd/try/finally from all ApiHeaderPatterns tests; set WorkingDirectory = FixturePaths.GetFixtureIncludeDir() instead - Add GlobFileCollectorTests for non-canonical literal path normalization and wrong-extension literal exclusion no-op Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…c indentation - docs/design/api-mark-cpp/cpp-generator.md: update Parse() execution steps to reflect that patterns are forwarded directly to GlobFileCollector (not via the now-deleted ExpandExplicitPatterns); remove the ExpandExplicitPatterns method section entirely - src/ApiMark.Cpp/CppGeneratorOptions.cs: fix accidental extra indentation in PublicIncludeRoots XML doc comment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set WorkingDirectory to the parent of the fixture include directory so that relative patterns contain an 'include/' prefix (e.g. include/fixtures/SampleClass.h). Under the old include-root expansion bug these patterns would have been joined onto the include root, producing a doubled path (include/include/...) that matches nothing — making the tests genuine regression detectors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 19, 2026
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.
The requirement ApiMarkCpp-CppGenerator-SupportAbsoluteAndRelativeHeader Patterns was authored incorrectly, stating that relative patterns should be expanded against each PublicIncludeRoot. The user guide specifies CWD. This caused a pattern like 'include/**' to be joined onto each --includes path, producing doubled paths that match nothing.
Fixes:
Add two new tests using non-root-agnostic CWD-relative patterns that would have failed with the old include-root expansion: