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
Refactor UTF-7 encoding detection #18384
base: master
Are you sure you want to change the base?
Conversation
Perhaps @JamesWTruher could review? |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
void WarnIfUtf7Encoding(Encoding value) | ||
{ | ||
const int CodePageUtf7 = 65000; | ||
|
||
// Use the recommended pattern to check for UTF-7. | ||
// https://docs.microsoft.com/dotnet/core/compatibility/core-libraries/5.0/utf-7-code-paths-obsolete | ||
if (value is { CodePage: CodePageUtf7 }) | ||
{ | ||
_provider.WriteWarning(PathUtilsStrings.Utf7EncodingObsolete); | ||
} | ||
} |
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.
This seems overkill to me. I prefer the original code.
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.
@xtqqczze Can you please respond to this comment? Thanks!
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 prefer the symbolic constant because it explains the meaning at a glance without having to read the comment for an explanation.
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.
@iSazonov, @SteveL-MSFT Thoughts?
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 guess @daxian-dbw don't like the modern syntax in the place but ok with the new name WarnIfUtf7Encoding
. If so I agree with him.
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 should be clearer on my comment.
It's not the syntax value is { CodePage: CodePageUtf7 }
, but that you have a local method in a setter. Please avoid having a local method in a setter unless it's really needed.
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.
@xtqqczze Please revert the change.
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.
@xtqqczze - please respond to this feedback
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Motivation
Remove the unnecessary string comparison in
EncodingConversion.Convert
.PowerShell/src/System.Management.Automation/utils/EncodingUtils.cs
Line 67 in f3f56d4
Context
cc: @JamesWTruher