// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Globalization;
usingSystem.IO;
usingSystem.Linq;
usingSystem.Reflection;
usingSystem.Text;
usingSystem.Threading;
usingRoslyn.Utilities;
usingMicrosoft.Build.Framework;
usingMicrosoft.Build.Utilities;
usingRoslyn.Utilities;
usingMicrosoft.CodeAnalysis.CommandLine;
usingSystem.Collections.Generic;
usingSystem.Runtime.InteropServices;
namespaceMicrosoft.CodeAnalysis.BuildTasks
{
...
...
@@ -25,6 +24,8 @@ public abstract class ManagedCompiler : ToolTask
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem;
usingSystem.Diagnostics;
usingSystem.IO;
usingSystem.Text;
usingSystem.Collections.Generic;
usingSystem.Globalization;
usingMicrosoft.Build.Framework;
usingMicrosoft.Build.Utilities;
usingMicrosoft.Build.Tasks.Hosting;
usingMicrosoft.CodeAnalysis.CommandLine;
usingSystem.Diagnostics;
namespaceMicrosoft.CodeAnalysis.BuildTasks
{
...
...
@@ -36,6 +35,8 @@ public class Vbc : ManagedCompiler
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem.Collections.Generic;
usingSystem.Text;
namespaceRoslyn.Utilities
{
internalstaticclassCommandLineUtilities
{
/// <summary>
/// Split a command line by the same rules as Main would get the commands except the original
/// state of backslashes and quotes are preserved. For example in normal Windows command line
/// parsing the following command lines would produce equivalent Main arguments:
///
/// - /r:a,b
/// - /r:"a,b"
///
/// This method will differ as the latter will have the quotes preserved. The only case where
/// quotes are removed is when the entire argument is surrounded by quotes without any inner
/// quotes.
/// </summary>
/// <remarks>
/// Rules for command line parsing, according to MSDN:
///
/// Arguments are delimited by white space, which is either a space or a tab.
///
/// A string surrounded by double quotation marks ("string") is interpreted
/// as a single argument, regardless of white space contained within.
/// A quoted string can be embedded in an argument.
///
/// A double quotation mark preceded by a backslash (\") is interpreted as a
/// literal double quotation mark character (").
///
/// Backslashes are interpreted literally, unless they immediately precede a
/// double quotation mark.
///
/// If an even number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is interpreted as a string delimiter.
///
/// If an odd number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is "escaped" by the remaining backslash,
/// causing a literal double quotation mark (") to be placed in argv.