Implement managed SegmentCommandLine#82883
Merged
jkotas merged 5 commits intodotnet:mainfrom Mar 3, 2023
Merged
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
jkotas
reviewed
Mar 2, 2023
jkoritzinsky
reviewed
Mar 2, 2023
Comment on lines
225
to
240
| //--------------------------------------------------------------------- | ||
| // Splits a command line into argc/argv lists, using the VC7 parsing rules. | ||
| // | ||
| // This functions interface mimics the CommandLineToArgvW api. | ||
| // | ||
| //--------------------------------------------------------------------- | ||
| // NOTE: Implementation-wise, once every few years it would be a good idea to | ||
| // compare this code with the C runtime library's parse_cmdline method, | ||
| // which is in vctools\crt\crtw32\startup\stdargv.c. (Note we don't | ||
| // support wild cards, and we use Unicode characters exclusively.) | ||
| // We are up to date as of ~6/2005. | ||
| //--------------------------------------------------------------------- | ||
|
|
||
| // The C# version is ported from C++ version in coreclr | ||
| // The behavior mimics what MSVCRT does before main, | ||
| // which is slightly different with CommandLineToArgvW |
Member
There was a problem hiding this comment.
I don't think these comments are useful as written, especially since we're adding this specifically to not be in sync with MSVC's CommandLineToArgvW API.
jkotas
reviewed
Mar 3, 2023
Comment on lines
225
to
240
| //--------------------------------------------------------------------- | ||
| // Splits a command line into argc/argv lists, using the VC7 parsing rules. | ||
| // | ||
| // This functions interface mimics the CommandLineToArgvW api. | ||
| // | ||
| //--------------------------------------------------------------------- | ||
| // NOTE: Implementation-wise, once every few years it would be a good idea to | ||
| // compare this code with the C runtime library's parse_cmdline method, | ||
| // which is in vctools\crt\crtw32\startup\stdargv.c. (Note we don't | ||
| // support wild cards, and we use Unicode characters exclusively.) | ||
| // We are up to date as of ~6/2005. | ||
| //--------------------------------------------------------------------- | ||
|
|
||
| // The C# version is ported from C++ version in coreclr | ||
| // The behavior mimics what MSVCRT does before main, | ||
| // which is slightly different with CommandLineToArgvW |
Member
There was a problem hiding this comment.
Suggested change
| //--------------------------------------------------------------------- | |
| // Splits a command line into argc/argv lists, using the VC7 parsing rules. | |
| // | |
| // This functions interface mimics the CommandLineToArgvW api. | |
| // | |
| //--------------------------------------------------------------------- | |
| // NOTE: Implementation-wise, once every few years it would be a good idea to | |
| // compare this code with the C runtime library's parse_cmdline method, | |
| // which is in vctools\crt\crtw32\startup\stdargv.c. (Note we don't | |
| // support wild cards, and we use Unicode characters exclusively.) | |
| // We are up to date as of ~6/2005. | |
| //--------------------------------------------------------------------- | |
| // The C# version is ported from C++ version in coreclr | |
| // The behavior mimics what MSVCRT does before main, | |
| // which is slightly different with CommandLineToArgvW | |
| // Parse command line arguments using the rules documented at | |
| // https://learn.microsoft.com/cpp/cpp/main-function-command-line-args#parsing-c-command-line-arguments | |
| // | |
| // CommandLineToArgvW API cannot be used here since | |
| // it has slightly different behavior. |
Simplify this comment
jkotas
reviewed
Mar 3, 2023
Member
You can access the method via private reflection (call |
Member
|
Known failure according to the Build Analysis |
jkoritzinsky
approved these changes
Mar 3, 2023
radical
pushed a commit
to radical/runtime
that referenced
this pull request
Mar 4, 2023
* Implement managed version of SegmentCommandLine * Remove P/Invoke for CommandLineToArgv * Update parsing to latest UCRT * Add test and fix trailing space in command * Fix test cases
huoyaoyuan
commented
Mar 4, 2023
| var method = typeof(Environment).GetMethod("SegmentCommandLine", BindingFlags.Static | BindingFlags.NonPublic); | ||
| Assert.NotNull(method); | ||
|
|
||
| var span = cmdLine.AsSpan(); // Workaround |
Member
Author
There was a problem hiding this comment.
Here is workaround for xUnit issue xunit/xunit#1969
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #77644
Ported from the code deleted by #71111
How should we test it? Can we mark the method
internaland test in some unit test?