-
Notifications
You must be signed in to change notification settings - Fork 293
Add artifact naming service with template support for consistent naming across extensions #6587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d51897b
Initial plan
Copilot eb60a65
Initial exploration and plan for artifact naming service
Copilot 32a3424
Add artifact naming service implementation with backward compatibility
Copilot 3f373e1
Add integration test for artifact naming service templates and fix mi…
Copilot 4d2d2f3
Fix process name retrieval and improve integration test robustness
Copilot ca27413
Change process-name placeholder to pname for consistency with short n…
Copilot 3ee129e
Change assembly placeholder to asm for consistency with short names
Copilot 042d74d
Merge branch 'main' into copilot/fix-6586
Evangelink 63a96be
Fixes
Evangelink 9afa902
Apply suggestions from code review
Evangelink 1de7408
Merge branch 'main' into copilot/fix-6586
Evangelink f934d44
Fixes
Evangelink 8e9c2a7
More fixes
Evangelink ef9e0ea
Merge branch 'main' into copilot/fix-6586
Evangelink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Artifact Naming Service | ||
|
|
||
| The artifact naming service provides a standardized way to generate consistent names and paths for test artifacts across all extensions. | ||
|
|
||
| ## Features | ||
|
|
||
| ### Template-Based Naming | ||
|
|
||
| Use placeholders in angle brackets to create dynamic file names: | ||
|
|
||
| ```text | ||
| <pname>_<pid>_<id>_hang.dmp | ||
| ``` | ||
|
Evangelink marked this conversation as resolved.
|
||
|
|
||
| Resolves to: `MyTests_12345_a1b2c3d4_hang.dmp` | ||
|
|
||
| ### Complex Path Templates | ||
|
Evangelink marked this conversation as resolved.
|
||
|
|
||
| Create structured directory layouts: | ||
|
|
||
| ```text | ||
| <root>/artifacts/<os>/<asm>/dumps/<pname>_<pid>_<tfm>_<time>.dmp | ||
| ``` | ||
|
Evangelink marked this conversation as resolved.
|
||
|
|
||
| Resolves to: `c:/myproject/artifacts/linux/MyTests/dumps/my-child-process_10001_net9.0_2025-09-22T13:49:34.dmp` | ||
|
|
||
| ### Available Placeholders | ||
|
|
||
| | Placeholder | Description | Example | | ||
| |-------------|-------------|---------| | ||
| | `<pname>` | Name of the process | `MyTests` | | ||
| | `<pid>` | Process ID | `12345` | | ||
| | `<id>` | Short random identifier (8 chars) | `a1b2c3d4` | | ||
| | `<os>` | Operating system | `windows`, `linux`, `macos` | | ||
| | `<asm>` | Assembly name | `MyTests` | | ||
| | `<tfm>` | Target framework moniker | `net9.0`, `net8.0` | | ||
| | `<time>` | Timestamp (1-second precision) | `2025-09-22T13:49:34` | | ||
| | `<root>` | Project root directory | Found via solution/git/working dir | | ||
|
|
||
| ### Backward Compatibility | ||
|
Evangelink marked this conversation as resolved.
|
||
|
|
||
| Legacy patterns are still supported: | ||
|
|
||
| ```csharp | ||
| // Old pattern | ||
| "myfile_%p.dmp" | ||
|
|
||
| // Works with legacy support | ||
| service.ResolveTemplateWithLegacySupport("myfile_%p.dmp", | ||
| legacyReplacements: new Dictionary<string, string> { ["%p"] = "12345" }); | ||
| ``` | ||
|
|
||
| ### Custom Replacements | ||
|
Evangelink marked this conversation as resolved.
|
||
|
|
||
| Override default values for specific scenarios: | ||
|
|
||
| ```csharp | ||
| // When dumping a different process than the test host | ||
| var customReplacements = new Dictionary<string, string> | ||
| { | ||
| ["pname"] = "Notepad", | ||
| ["pid"] = "1111" | ||
| }; | ||
|
|
||
| string result = service.ResolveTemplate("<pname>_<pid>.dmp", customReplacements); | ||
| // Result: "Notepad_1111.dmp" | ||
| ``` | ||
|
|
||
| ## Usage in Extensions | ||
|
|
||
| Extensions can use the service through dependency injection: | ||
|
|
||
| ```csharp | ||
| public class MyExtension | ||
| { | ||
| private readonly IArtifactNamingService _artifactNamingService; | ||
|
|
||
| public MyExtension(IServiceProvider serviceProvider) | ||
| { | ||
| _artifactNamingService = serviceProvider.GetArtifactNamingService(); | ||
| } | ||
|
|
||
| public void CreateArtifact(string template) | ||
| { | ||
| string fileName = _artifactNamingService.ResolveTemplate(template); | ||
| // Use fileName for artifact creation | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Hang Dump Integration | ||
|
|
||
| The hang dump extension now uses the artifact naming service and supports both legacy and modern patterns: | ||
|
|
||
| ```text | ||
| # Legacy pattern (still works) | ||
| --hangdump-filename "mydump_%p.dmp" | ||
|
|
||
| # New template pattern | ||
| --hangdump-filename "<pname>_<pid>_<id>_hang.dmp" | ||
|
|
||
| # Complex path template | ||
| --hangdump-filename "<root>/dumps/<os>/<pname>_<pid>_<time>.dmp" | ||
| ``` | ||
|
|
||
| This provides consistent artifact naming across all extensions while maintaining backward compatibility. | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.