-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add C#-style type accelerators and suffixes for ushort, uint, ulong, and short literals #7813
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
Add C#-style type accelerators and suffixes for ushort, uint, ulong, and short literals #7813
Conversation
s -> short u -> unsigned
Update numeric parsing tests
|
@iSazonov I think this is tidier now. shudders I need to take a rebasing class! 😝 The remaining build errors appear to be build environment errors unrelated to this PR. ^^ The CodeFactor issues are (I think) not particularly serious, and I have a follow-up PR that will address the vast majority of those coming shortly. |
|
@vexx32 To rebase you can use the pattern: # rebase pull request on top of master
git chechout <branch>
git fetch PowerShell master
git pull --rebase PowerShell master
git push -fYou can catch a conflict but it is another story. |
|
Reopened to restart CIs. Looks all good, I guess the Linux issues were resolved. @iSazonov I have never had the good fortune to get a rebase to work without painstaking editing at every step along the way. Not sure why... I think I must be doing it wrong somehow. I need to read up on it! 😄 |
SteveL-MSFT
left a comment
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
|
@daxian-dbw Could you please look th PR? @vexx32 want to continue working on the code in follow PR. |
daxian-dbw
left a comment
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.
About the comments regarding the tests, I think it makes sense to keep some of the existing tests. They can be put only in the #Standard numeric notation section, not in other sections for the new notations.
|
Marked this PR with |
|
@vexx32 I'm trying to tidy the PR description because the documentation work that follows up will need the accurate information.
By looking into the code, the suffix I copied the |
|
@daxian-dbw Yes, the automatic step-up to |
|
@daxian-dbw I think I got them all, but let me know if I missed anything! 😄 PR description has been cleaned up and made hopefully useful as a jumping off point for some proper documentation. |
For Thoroughness!
|
Aww, I was enjoying the all-green. Appveyor's failing on a Test-Connection due to timeout. |
daxian-dbw
left a comment
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 @vexx32 for your contribution! I will restart the AppVeyor CI.
|
Yay! 😄 Now I can get the next one ready for Hacktoberfest 😉 AppVeyor's still having difficulty with Test-Connection, it seems... |
PR Summary
This has been split off of #7509 at request of @iSazonov as that PR has become overly complex, and this portion of the PR was already approved by Powershell Committee. Re-submitting instead of working with #7575 due to messy rebase shenanigans that just... made a mess.
This fixes #3313.
Brief summary:
Adds the following numeric literal suffixes:
Adds the following type accelerators:
[short][ushort][uint][ulong]And of course, adds tests for all the above.
Comprehensive Summary:
s(short) andu(unsigned) to complement the existinglsuffix.usorulto result inushortorulongtypes.usuffix is used alone,uintwill be returned unless value exceedsuint.MaxValue, in which case it will automatically resolve asulonginstead.[short]=>Int16[ushort]=>UInt16[uint]=>UInt32[ulong]=>UInt64l/Lsuffix, where it will also perform rounding functions when applied to arealliteral while also ensuring it still returns an appropriateuintorulongvalue:105.5u => 106[Flags]enumNumberSuffixFlagsthat takes care of one-or-more numerical type suffixes.u,l,sand valid combinations thereof will error out and register as an invalid numeric literal if their value after multiplication exceeds the type(s) contraints.500sgb(500gb -as Int16)then the parser should not be expected to figure out what they meant.strNumparameter ofTryGetNumberValuetoReadOnlySpan<char>to reduce the number of string allocations required for parsing.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files 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