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
Error message enhancement for clear-content cmdlet when targeting a directory #8134
Conversation
if (Directory.Exists(path)) | ||
{ | ||
throw PSTraceSource.NewNotSupportedException(SessionStateStrings.ClearDirectoryContent, path); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect non-terminating error.
/cc @mklement0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should be non-terminating error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the check should be in the FileSystemProvider in this function:
public void ClearContent(string path) |
if (Directory.Exists(path)) | ||
{ | ||
throw PSTraceSource.NewNotSupportedException(SessionStateStrings.ClearDirectoryContent, path); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should be non-terminating error.
if (Directory.Exists(path)) | ||
{ | ||
throw PSTraceSource.NewNotSupportedException(SessionStateStrings.ClearDirectoryContent, path); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the check should be in the FileSystemProvider in this function:
public void ClearContent(string path) |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/resources/SessionStateStrings.resx
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Clear-Content.Tests.ps1
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/System.Management.Automation/resources/SessionStateStrings.resx
Outdated
Show resolved
Hide resolved
@kvprasoon Please add empty commit with "[Feature]" in header to run full test set. |
PR Summary
Error message enhancement for clear-content cmdlet when targeting a directory
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.[feature]
if the change is significant or affects feature tests