| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… easier to maintain
There was a problem hiding this comment.
This PR refactors the module path construction code in PowerShell to fix issue #26536, which involves two main problems: insufficient error diagnostics in exception fallback handling and incorrect handling of multi-path PSModulePath values from configuration files. The refactoring moves module path initialization to a static constructor, consolidates path manipulation methods, and improves error reporting by including stack traces.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| test/powershell/Host/ConsoleHost.Tests.ps1 | Added test for PSModulePath with multiple paths from config file; contains platform-specific path separator issues |
| src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs | Refactored module path construction: moved initialization to static constructor, consolidated UpdatePath logic, improved PathContainsSubstring with better return semantics |
| src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs | Enhanced exception reporting to include stack traces for debugging ShellCannotBeStarted errors; contains potential null reference issues |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
On top of ModuleIntrinsics.cs I see we define Tracer. It would be nice to add to the trace source and result path strings for more easy diagnostics.
Sorry, something went wrong.
| // Local function to normalize a path by removing trailing directory separators. | ||
| static string NormalizePath(string path) | ||
| { | ||
| string normalizedPath = path.TrimEnd(Path.DirectorySeparatorChar); |
There was a problem hiding this comment.
Why not use NormalizePath method from FileSystemProvider? Then we will follow the basic PowerShell behavior regarding directory separators.
Otherwise, we could use Path.TrimEndingDirectorySeparator()
Sorry, something went wrong.
There was a problem hiding this comment.
Path.TrimEndingDirectorySeparator doesn't remove duplicate trailing directory separators. It only removes the ending one. But I think it should be practically fine, and also, I favor over simplicity. We can get back to it if it turns out to be an issue.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
|
Ready to merge. |
Sorry, something went wrong.
|
Ilya (@iSazonov) Thanks for the review! |
Sorry, something went wrong.
… easier to maintain (PowerShell#26565)
… easier to maintain (PowerShell#26565)
… easier to maintain (PowerShell#26565)
- Note that PowerShell/PowerShell#26565 fixed the crash in 7.7 and that the patch can be dropped with 7.7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
PR Summary
Fix #26536
There are 2 issues surfaced from #26536 that we need to address:
The fixes are:
With the changes, PowerShell won't crash even if the personal module path is like C:\Users\marcv\OneDrive - company & name namepart2\Dokumente\PowerShell\Modules as reported in the issue.
PR Checklist