2012 lines
68 KiB
C#
2012 lines
68 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using Microsoft.CodeAnalysis.Emit;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Text;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
public class CSharpCommandLineParser : CommandLineParser
|
|
{
|
|
private static readonly char[] s_quoteOrEquals = new char[2] { '"', '=' };
|
|
|
|
private static readonly char[] s_warningSeparators = new char[3] { ',', ';', ' ' };
|
|
|
|
public static CSharpCommandLineParser Default { get; } = new CSharpCommandLineParser();
|
|
|
|
public static CSharpCommandLineParser Script { get; } = new CSharpCommandLineParser(isScriptCommandLineParser: true);
|
|
|
|
protected override string RegularFileExtension => ".cs";
|
|
|
|
protected override string ScriptFileExtension => ".csx";
|
|
|
|
internal CSharpCommandLineParser(bool isScriptCommandLineParser = false)
|
|
: base((CommonMessageProvider)(object)MessageProvider.Instance, isScriptCommandLineParser)
|
|
{
|
|
}
|
|
|
|
internal sealed override CommandLineArguments CommonParse(IEnumerable<string> args, string baseDirectory, string? sdkDirectory, string? additionalReferenceDirectories)
|
|
{
|
|
return (CommandLineArguments)(object)Parse(args, baseDirectory, sdkDirectory, additionalReferenceDirectories);
|
|
}
|
|
|
|
public CSharpCommandLineArguments Parse(IEnumerable<string> args, string? baseDirectory, string? sdkDirectory, string? additionalReferenceDirectories = null)
|
|
{
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2941: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2983: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_29c0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_29c3: Invalid comparison between Unknown and I4
|
|
//IL_2a2e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_29eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_28be: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_15f0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_15f5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_15f7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2a1f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2a24: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_197e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1983: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_287a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_287f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1a91: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1a96: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1f6a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_235d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2362: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1616: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1618: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_075d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2aa0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_171b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1734: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_236f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2371: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2892: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_174d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2794: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2799: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1e5b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1e63: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_16e0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_17a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_17a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_17aa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1f90: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1f96: Invalid comparison between Unknown and I4
|
|
//IL_2083: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2088: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_1e6b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_16e8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_17b5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_27ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_16f0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_16f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_20a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2b3f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2b89: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2b9f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2ba5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2ba7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bc1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bc3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bc5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bc7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bde: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bf8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2bfa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2c0c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2c34: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2c46: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2c61: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2c68: Expected O, but got Unknown
|
|
//IL_2c8c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2cb9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_2dd6: Unknown result type (might be due to invalid IL or missing references)
|
|
List<Diagnostic> list = new List<Diagnostic>();
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
List<string> list2 = (base.IsScriptCommandLineParser ? new List<string>() : null);
|
|
List<string> list3 = (base.IsScriptCommandLineParser ? new List<string>() : null);
|
|
((CommandLineParser)this).FlattenArgs(args, (IList<Diagnostic>)list, instance, list2, baseDirectory, list3);
|
|
string appConfigPath = null;
|
|
bool displayLogo = true;
|
|
bool displayHelp = false;
|
|
bool displayVersion = false;
|
|
bool displayLangVersions = false;
|
|
bool flag = false;
|
|
bool flag2 = false;
|
|
NullableContextOptions val = (NullableContextOptions)0;
|
|
bool flag3 = false;
|
|
bool flag4 = true;
|
|
bool flag5 = false;
|
|
bool flag6 = false;
|
|
DebugInformationFormat val2 = (DebugInformationFormat)((!PathUtilities.IsUnixLikePlatform) ? 1 : 2);
|
|
bool flag7 = false;
|
|
string pdbPath = null;
|
|
bool flag8 = base.IsScriptCommandLineParser;
|
|
string text = baseDirectory;
|
|
ImmutableArray<KeyValuePair<string, string>> immutableArray = ImmutableArray<KeyValuePair<string, string>>.Empty;
|
|
string outputFileName = null;
|
|
string text2 = null;
|
|
bool flag9 = false;
|
|
string generatedFilesOutputDirectory = null;
|
|
string documentationPath = null;
|
|
ErrorLogOptions val3 = null;
|
|
bool flag10 = false;
|
|
bool utf8Output = false;
|
|
OutputKind val4 = (OutputKind)0;
|
|
SubsystemVersion val5 = SubsystemVersion.None;
|
|
LanguageVersion result = LanguageVersion.Default;
|
|
string text3 = null;
|
|
string text4 = null;
|
|
string win32ResourceFile = null;
|
|
string text5 = null;
|
|
bool noWin32Manifest = false;
|
|
Platform val6 = (Platform)0;
|
|
ulong num = 0uL;
|
|
int num2 = 0;
|
|
bool? flag11 = null;
|
|
string text6 = null;
|
|
string text7 = null;
|
|
List<ResourceDescription> list4 = new List<ResourceDescription>();
|
|
List<CommandLineSourceFile> list5 = new List<CommandLineSourceFile>();
|
|
List<CommandLineSourceFile> list6 = new List<CommandLineSourceFile>();
|
|
ArrayBuilder<string> instance2 = ArrayBuilder<string>.GetInstance();
|
|
List<CommandLineSourceFile> list7 = new List<CommandLineSourceFile>();
|
|
bool flag12 = false;
|
|
bool flag13 = false;
|
|
bool flag14 = false;
|
|
Encoding encoding = null;
|
|
SourceHashAlgorithm checksumAlgorithm = (SourceHashAlgorithm)2;
|
|
ArrayBuilder<string> instance3 = ArrayBuilder<string>.GetInstance();
|
|
List<CommandLineReference> list8 = new List<CommandLineReference>();
|
|
List<CommandLineAnalyzerReference> list9 = new List<CommandLineAnalyzerReference>();
|
|
List<string> list10 = new List<string>();
|
|
List<string> list11 = new List<string>();
|
|
List<string> list12 = new List<string>();
|
|
List<string> list13 = new List<string>();
|
|
ReportDiagnostic val7 = (ReportDiagnostic)0;
|
|
Dictionary<string, ReportDiagnostic> dictionary = new Dictionary<string, ReportDiagnostic>();
|
|
Dictionary<string, ReportDiagnostic> dictionary2 = new Dictionary<string, ReportDiagnostic>();
|
|
Dictionary<string, ReportDiagnostic> dictionary3 = new Dictionary<string, ReportDiagnostic>();
|
|
int num3 = 4;
|
|
bool flag15 = false;
|
|
bool printFullPaths = false;
|
|
string moduleAssemblyName = null;
|
|
string moduleName = null;
|
|
List<string> list14 = new List<string>();
|
|
string text8 = null;
|
|
bool shouldIncludeErrorEndLocation = false;
|
|
bool reportAnalyzer = false;
|
|
bool skipAnalyzers = false;
|
|
ArrayBuilder<InstrumentationKind> instance4 = ArrayBuilder<InstrumentationKind>.GetInstance();
|
|
CultureInfo cultureInfo = null;
|
|
string touchedFilesPath = null;
|
|
bool flag16 = false;
|
|
bool flag17 = false;
|
|
bool flag18 = false;
|
|
string text9 = null;
|
|
string text10 = null;
|
|
bool reportInternalsVisibleToAttributes = false;
|
|
Enumerator<string> enumerator;
|
|
if (!base.IsScriptCommandLineParser)
|
|
{
|
|
enumerator = instance.GetEnumerator();
|
|
ReadOnlyMemory<char> readOnlyMemory = default(ReadOnlyMemory<char>);
|
|
ReadOnlyMemory<char>? readOnlyMemory2 = default(ReadOnlyMemory<char>?);
|
|
while (enumerator.MoveNext())
|
|
{
|
|
string current = enumerator.Current;
|
|
if (CommandLineParser.IsOption("ruleset", current, ref readOnlyMemory, ref readOnlyMemory2))
|
|
{
|
|
string text11 = CommandLineParser.RemoveQuotesAndSlashes(readOnlyMemory2);
|
|
if (RoslynString.IsNullOrEmpty(text11))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", readOnlyMemory.ToString());
|
|
}
|
|
else
|
|
{
|
|
text10 = ((CommandLineParser)this).ParseGenericPathToFile(text11, (IList<Diagnostic>)list, baseDirectory, true);
|
|
val7 = ((CommandLineParser)this).GetDiagnosticOptionsFromRulesetFile(text10, ref dictionary, (IList<Diagnostic>)list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
enumerator = instance.GetEnumerator();
|
|
ReadOnlyMemory<char> readOnlyMemory3 = default(ReadOnlyMemory<char>);
|
|
ReadOnlyMemory<char>? valueMemory = default(ReadOnlyMemory<char>?);
|
|
ulong num5 = default(ulong);
|
|
ushort num4 = default(ushort);
|
|
bool flag19 = default(bool);
|
|
while (enumerator.MoveNext())
|
|
{
|
|
string current2 = enumerator.Current;
|
|
if (flag16 || !CommandLineParser.TryParseOption(current2, ref readOnlyMemory3, ref valueMemory))
|
|
{
|
|
ArrayBuilder<string> instance5 = ArrayBuilder<string>.GetInstance();
|
|
((CommandLineParser)this).ParseFileArgument(current2.AsMemory(), baseDirectory, instance5, (IList<Diagnostic>)list);
|
|
Enumerator<string> enumerator2 = instance5.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
string current3 = enumerator2.Current;
|
|
list5.Add(((CommandLineParser)this).ToCommandLineSourceFile(current3, false));
|
|
}
|
|
instance5.Free();
|
|
if (list5.Count > 0)
|
|
{
|
|
flag12 = true;
|
|
}
|
|
continue;
|
|
}
|
|
if (CommandLineParser.IsOptionName("r", "reference", readOnlyMemory3))
|
|
{
|
|
ParseAssemblyReferences(current2, valueMemory, list, embedInteropTypes: false, list8);
|
|
continue;
|
|
}
|
|
if (CommandLineParser.IsOptionName("langversion", readOnlyMemory3))
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/langversion:");
|
|
}
|
|
else if (text12.StartsWith("0", StringComparison.Ordinal))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_LanguageVersionCannotHaveLeadingZeroes, text12);
|
|
}
|
|
else if (text12 == "?")
|
|
{
|
|
displayLangVersions = true;
|
|
}
|
|
else if (!LanguageVersionFacts.TryParse(text12, out result))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_BadCompatMode, text12);
|
|
}
|
|
continue;
|
|
}
|
|
if (!base.IsScriptCommandLineParser && CommandLineParser.IsOptionName("a", "analyzer", readOnlyMemory3))
|
|
{
|
|
ParseAnalyzers(current2, valueMemory, list9, list);
|
|
continue;
|
|
}
|
|
if (!base.IsScriptCommandLineParser && CommandLineParser.IsOptionName("nowarn", readOnlyMemory3))
|
|
{
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, readOnlyMemory3.ToString());
|
|
}
|
|
else if (valueMemory.Value.Length == 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, readOnlyMemory3.ToString());
|
|
}
|
|
else
|
|
{
|
|
AddWarnings(dictionary2, (ReportDiagnostic)5, valueMemory.Value);
|
|
}
|
|
continue;
|
|
}
|
|
string text13 = readOnlyMemory3.Span.ToString().ToLowerInvariant();
|
|
switch (text13)
|
|
{
|
|
case "?":
|
|
case "help":
|
|
displayHelp = true;
|
|
continue;
|
|
case "version":
|
|
displayVersion = true;
|
|
continue;
|
|
case "features":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (text12 == null)
|
|
{
|
|
list14.Clear();
|
|
}
|
|
else
|
|
{
|
|
list14.Add(StringExtensions.Unquote(text12));
|
|
}
|
|
continue;
|
|
}
|
|
case "libpath":
|
|
case "libpaths":
|
|
case "lib":
|
|
ParseAndResolveReferencePaths(text13, valueMemory, baseDirectory, list10, MessageID.IDS_LIB_OPTION, list);
|
|
continue;
|
|
}
|
|
if (base.IsScriptCommandLineParser)
|
|
{
|
|
string text12 = valueMemoryString();
|
|
switch (text13)
|
|
{
|
|
case "-":
|
|
if (text12 != null)
|
|
{
|
|
break;
|
|
}
|
|
if (current2 == "-")
|
|
{
|
|
if (Console.IsInputRedirected)
|
|
{
|
|
list5.Add(new CommandLineSourceFile("-", true, true));
|
|
flag12 = true;
|
|
}
|
|
else
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
flag16 = true;
|
|
}
|
|
continue;
|
|
case "i":
|
|
case "i+":
|
|
if (text12 != null)
|
|
{
|
|
break;
|
|
}
|
|
flag17 = true;
|
|
continue;
|
|
case "i-":
|
|
if (text12 != null)
|
|
{
|
|
break;
|
|
}
|
|
flag17 = false;
|
|
continue;
|
|
case "loadpath":
|
|
case "loadpaths":
|
|
ParseAndResolveReferencePaths(text13, valueMemory, baseDirectory, list11, MessageID.IDS_REFERENCEPATH_OPTION, list);
|
|
continue;
|
|
case "u":
|
|
case "import":
|
|
case "usings":
|
|
case "using":
|
|
case "imports":
|
|
list13.AddRange(ParseUsings(current2, text12, list));
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (text13)
|
|
{
|
|
case "d":
|
|
case "define":
|
|
if (!valueMemory.HasValue || valueMemory.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", current2);
|
|
}
|
|
else
|
|
{
|
|
ParseConditionalCompilationSymbols(CommandLineParser.RemoveQuotesAndSlashesEx(valueMemory.Value), instance3, out IEnumerable<Diagnostic> diagnostics);
|
|
list.AddRange(diagnostics);
|
|
}
|
|
continue;
|
|
case "codepage":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (text12 == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", text13);
|
|
continue;
|
|
}
|
|
Encoding encoding2 = CommandLineParser.TryParseEncodingName(text12);
|
|
if (encoding2 == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.FTL_BadCodepage, text12);
|
|
}
|
|
else
|
|
{
|
|
encoding = encoding2;
|
|
}
|
|
continue;
|
|
}
|
|
case "checksumalgorithm":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (string.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", text13);
|
|
continue;
|
|
}
|
|
SourceHashAlgorithm val8 = CommandLineParser.TryParseHashAlgorithmName(text12);
|
|
if ((int)val8 == 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.FTL_BadChecksumAlgorithm, text12);
|
|
}
|
|
else
|
|
{
|
|
checksumAlgorithm = val8;
|
|
}
|
|
continue;
|
|
}
|
|
case "checked+":
|
|
case "checked":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag2 = true;
|
|
continue;
|
|
case "checked-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag2 = false;
|
|
continue;
|
|
case "nullable":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (text12 != null)
|
|
{
|
|
if (EnumerableExtensions.IsEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), text13);
|
|
continue;
|
|
}
|
|
switch (text12.ToLower())
|
|
{
|
|
case "disable":
|
|
val = (NullableContextOptions)0;
|
|
break;
|
|
case "enable":
|
|
val = (NullableContextOptions)3;
|
|
break;
|
|
case "warnings":
|
|
val = (NullableContextOptions)1;
|
|
break;
|
|
case "annotations":
|
|
val = (NullableContextOptions)2;
|
|
break;
|
|
default:
|
|
AddDiagnostic(list, ErrorCode.ERR_BadNullableContextOption, text12);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
val = (NullableContextOptions)3;
|
|
}
|
|
continue;
|
|
}
|
|
case "nullable+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
val = (NullableContextOptions)3;
|
|
continue;
|
|
case "nullable-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
val = (NullableContextOptions)0;
|
|
continue;
|
|
case "instrument":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", text13);
|
|
continue;
|
|
}
|
|
foreach (InstrumentationKind item in ParseInstrumentationKinds(text12, list))
|
|
{
|
|
if (!instance4.Contains(item))
|
|
{
|
|
instance4.Add(item);
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
case "sqmsessionguid":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
Guid result3;
|
|
if (text12 == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_MissingGuidForOption, "<text>", text13);
|
|
}
|
|
else if (!Guid.TryParse(text12, out result3))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_InvalidFormatForGuidForOption, text12, text13);
|
|
}
|
|
continue;
|
|
}
|
|
case "preferreduilang":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", current2);
|
|
continue;
|
|
}
|
|
try
|
|
{
|
|
cultureInfo = new CultureInfo(text12);
|
|
if ((cultureInfo.CultureTypes & CultureTypes.UserCustomCulture) != 0)
|
|
{
|
|
cultureInfo = null;
|
|
}
|
|
}
|
|
catch (CultureNotFoundException)
|
|
{
|
|
}
|
|
if (cultureInfo == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.WRN_BadUILang, text12);
|
|
}
|
|
continue;
|
|
}
|
|
case "nosdkpath":
|
|
sdkDirectory = null;
|
|
continue;
|
|
case "out":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (RoslynString.IsNullOrWhiteSpace(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
}
|
|
else
|
|
{
|
|
((CommandLineParser)this).ParseOutputFile(text12, (IList<Diagnostic>)list, baseDirectory, ref outputFileName, ref text);
|
|
}
|
|
continue;
|
|
}
|
|
case "refout":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
}
|
|
else
|
|
{
|
|
text2 = ((CommandLineParser)this).ParseGenericPathToFile(text12, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
continue;
|
|
}
|
|
case "refonly":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag9 = true;
|
|
continue;
|
|
case "t":
|
|
case "target":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (text12 == null)
|
|
{
|
|
break;
|
|
}
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.FTL_InvalidTarget);
|
|
}
|
|
else
|
|
{
|
|
val4 = ParseTarget(text12, list);
|
|
}
|
|
continue;
|
|
}
|
|
case "moduleassemblyname":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
text12 = ((text12 != null) ? StringExtensions.Unquote(text12) : null);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", current2);
|
|
}
|
|
else if (!MetadataHelpers.IsValidAssemblyOrModuleName(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_InvalidAssemblyName, "<text>", current2);
|
|
}
|
|
else
|
|
{
|
|
moduleAssemblyName = text12;
|
|
}
|
|
continue;
|
|
}
|
|
case "modulename":
|
|
{
|
|
string text15 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text15))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "modulename");
|
|
}
|
|
else
|
|
{
|
|
moduleName = text15;
|
|
}
|
|
continue;
|
|
}
|
|
case "platform":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<string>", current2);
|
|
}
|
|
else
|
|
{
|
|
val6 = ParsePlatform(text12, list);
|
|
}
|
|
continue;
|
|
}
|
|
case "recurse":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (text12 == null)
|
|
{
|
|
break;
|
|
}
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
continue;
|
|
}
|
|
int count = list5.Count;
|
|
list5.AddRange(((CommandLineParser)this).ParseRecurseArgument(text12, baseDirectory, (IList<Diagnostic>)list));
|
|
if (list5.Count > count)
|
|
{
|
|
flag12 = true;
|
|
}
|
|
continue;
|
|
}
|
|
case "generatedfilesout":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrWhiteSpace(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), current2);
|
|
}
|
|
else
|
|
{
|
|
generatedFilesOutputDirectory = ((CommandLineParser)this).ParseGenericPathToFile(text12, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
continue;
|
|
}
|
|
case "doc":
|
|
{
|
|
flag10 = true;
|
|
string text12 = valueMemoryString();
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), current2);
|
|
continue;
|
|
}
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text14))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/doc:");
|
|
}
|
|
else
|
|
{
|
|
documentationPath = ((CommandLineParser)this).ParseGenericPathToFile(text14, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
continue;
|
|
}
|
|
case "addmodule":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (text12 == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "/addmodule:");
|
|
}
|
|
else if (text12.Length == 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
}
|
|
else
|
|
{
|
|
list8.AddRange(CommandLineParser.ParseSeparatedPaths(text12).Select((Func<string, CommandLineReference>)((string path) => new CommandLineReference(path, MetadataReferenceProperties.Module))));
|
|
flag14 = true;
|
|
}
|
|
continue;
|
|
}
|
|
case "l":
|
|
case "link":
|
|
ParseAssemblyReferences(current2, valueMemory, list, embedInteropTypes: true, list8);
|
|
continue;
|
|
case "win32res":
|
|
win32ResourceFile = GetWin32Setting(current2, valueMemoryString(), list);
|
|
continue;
|
|
case "win32icon":
|
|
text5 = GetWin32Setting(current2, valueMemoryString(), list);
|
|
continue;
|
|
case "win32manifest":
|
|
text4 = GetWin32Setting(current2, valueMemoryString(), list);
|
|
noWin32Manifest = false;
|
|
continue;
|
|
case "nowin32manifest":
|
|
noWin32Manifest = true;
|
|
text4 = null;
|
|
continue;
|
|
case "resource":
|
|
case "res":
|
|
{
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
ResourceDescription val10 = ParseResourceDescription(current2, valueMemory.Value, baseDirectory, list, embedded: true);
|
|
if (val10 != null)
|
|
{
|
|
list4.Add(val10);
|
|
flag14 = true;
|
|
}
|
|
continue;
|
|
}
|
|
case "linkres":
|
|
case "linkresource":
|
|
{
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
ResourceDescription val9 = ParseResourceDescription(current2, valueMemory.Value, baseDirectory, list, embedded: false);
|
|
if (val9 != null)
|
|
{
|
|
list4.Add(val9);
|
|
flag14 = true;
|
|
}
|
|
continue;
|
|
}
|
|
case "sourcelink":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
}
|
|
else
|
|
{
|
|
text9 = ((CommandLineParser)this).ParseGenericPathToFile(text12, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
continue;
|
|
}
|
|
case "debug":
|
|
{
|
|
flag6 = true;
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (text12 == null)
|
|
{
|
|
continue;
|
|
}
|
|
if (EnumerableExtensions.IsEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), text13);
|
|
continue;
|
|
}
|
|
switch (text12.ToLower())
|
|
{
|
|
case "full":
|
|
case "pdbonly":
|
|
val2 = (DebugInformationFormat)((!PathUtilities.IsUnixLikePlatform) ? 1 : 2);
|
|
break;
|
|
case "portable":
|
|
val2 = (DebugInformationFormat)2;
|
|
break;
|
|
case "embedded":
|
|
val2 = (DebugInformationFormat)3;
|
|
break;
|
|
default:
|
|
AddDiagnostic(list, ErrorCode.ERR_BadDebugType, text12);
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
case "debug+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag6 = true;
|
|
flag7 = true;
|
|
continue;
|
|
case "debug-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag6 = false;
|
|
flag7 = false;
|
|
continue;
|
|
case "o":
|
|
case "optimize":
|
|
case "optimize+":
|
|
case "o+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag = true;
|
|
continue;
|
|
case "optimize-":
|
|
case "o-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag = false;
|
|
continue;
|
|
case "deterministic+":
|
|
case "deterministic":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag5 = true;
|
|
continue;
|
|
case "deterministic-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag5 = false;
|
|
continue;
|
|
case "p":
|
|
case "parallel":
|
|
case "parallel+":
|
|
case "p+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag4 = true;
|
|
continue;
|
|
case "parallel-":
|
|
case "p-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag4 = false;
|
|
continue;
|
|
case "warnaserror+":
|
|
case "warnaserror":
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
val7 = (ReportDiagnostic)1;
|
|
dictionary3.Clear();
|
|
foreach (string key in dictionary.Keys)
|
|
{
|
|
if ((int)dictionary[key] == 2)
|
|
{
|
|
dictionary3[key] = (ReportDiagnostic)1;
|
|
}
|
|
}
|
|
}
|
|
else if (valueMemory.Value.Length == 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
}
|
|
else
|
|
{
|
|
AddWarnings(dictionary3, (ReportDiagnostic)1, valueMemory.Value);
|
|
}
|
|
continue;
|
|
case "warnaserror-":
|
|
{
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
val7 = (ReportDiagnostic)0;
|
|
dictionary3.Clear();
|
|
continue;
|
|
}
|
|
if (!valueMemory.HasValue || valueMemory.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
continue;
|
|
}
|
|
ArrayBuilder<string> instance6 = ArrayBuilder<string>.GetInstance();
|
|
ParseWarnings(valueMemory.Value, instance6);
|
|
Enumerator<string> enumerator2 = instance6.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
string current6 = enumerator2.Current;
|
|
if (dictionary.TryGetValue(current6, out var value))
|
|
{
|
|
dictionary3[current6] = value;
|
|
}
|
|
else
|
|
{
|
|
dictionary3[current6] = (ReportDiagnostic)0;
|
|
}
|
|
}
|
|
instance6.Free();
|
|
continue;
|
|
}
|
|
case "w":
|
|
case "warn":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
int result2;
|
|
if (text12 == null)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
}
|
|
else if (string.IsNullOrEmpty(text12) || !int.TryParse(text12, NumberStyles.Integer, CultureInfo.InvariantCulture, out result2))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
}
|
|
else if (result2 < 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_BadWarningLevel);
|
|
}
|
|
else
|
|
{
|
|
num3 = result2;
|
|
}
|
|
continue;
|
|
}
|
|
case "unsafe":
|
|
case "unsafe+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag3 = true;
|
|
continue;
|
|
case "unsafe-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag3 = false;
|
|
continue;
|
|
case "delaysign":
|
|
case "delaysign+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag11 = true;
|
|
continue;
|
|
case "delaysign-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag11 = false;
|
|
continue;
|
|
case "publicsign":
|
|
case "publicsign+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag18 = true;
|
|
continue;
|
|
case "publicsign-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag18 = false;
|
|
continue;
|
|
case "keyfile":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, "keyfile");
|
|
}
|
|
else
|
|
{
|
|
text6 = text12;
|
|
}
|
|
continue;
|
|
}
|
|
case "keycontainer":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (string.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "keycontainer");
|
|
}
|
|
else
|
|
{
|
|
text7 = text12;
|
|
}
|
|
continue;
|
|
}
|
|
case "highentropyva+":
|
|
case "highentropyva":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag15 = true;
|
|
continue;
|
|
case "highentropyva-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag15 = false;
|
|
continue;
|
|
case "nologo":
|
|
displayLogo = false;
|
|
continue;
|
|
case "baseaddress":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text12) || !CommandLineParser.TryParseUInt64(text12, ref num5))
|
|
{
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
}
|
|
else
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_BadBaseNumber, text12);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
num = num5;
|
|
}
|
|
continue;
|
|
}
|
|
case "subsystemversion":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "subsystemversion");
|
|
continue;
|
|
}
|
|
SubsystemVersion none = SubsystemVersion.None;
|
|
if (SubsystemVersion.TryParse(text12, ref none))
|
|
{
|
|
val5 = none;
|
|
continue;
|
|
}
|
|
AddDiagnostic(list, ErrorCode.ERR_InvalidSubsystemVersion, text12);
|
|
continue;
|
|
}
|
|
case "touchedfiles":
|
|
{
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text14))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), "touchedfiles");
|
|
}
|
|
else
|
|
{
|
|
touchedFilesPath = text14;
|
|
}
|
|
continue;
|
|
}
|
|
case "bugreport":
|
|
UnimplementedSwitch(list, text13);
|
|
continue;
|
|
case "utf8output":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
utf8Output = true;
|
|
continue;
|
|
case "m":
|
|
case "main":
|
|
{
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text14))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", text13);
|
|
}
|
|
else
|
|
{
|
|
text3 = text14;
|
|
}
|
|
continue;
|
|
}
|
|
case "fullpaths":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
printFullPaths = true;
|
|
continue;
|
|
case "pathmap":
|
|
{
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (text14 == null)
|
|
{
|
|
break;
|
|
}
|
|
immutableArray = ImmutableArrayExtensions.Concat<KeyValuePair<string, string>>(immutableArray, ((CommandLineParser)this).ParsePathMap(text14, (IList<Diagnostic>)list));
|
|
continue;
|
|
}
|
|
case "filealign":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsNumber, text13);
|
|
}
|
|
else if (!CommandLineParser.TryParseUInt16(text12, ref num4))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_InvalidFileAlignment, text12);
|
|
}
|
|
else if (!CompilationOptions.IsValidFileAlignment((int)num4))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_InvalidFileAlignment, text12);
|
|
}
|
|
else
|
|
{
|
|
num2 = num4;
|
|
}
|
|
continue;
|
|
}
|
|
case "pdb":
|
|
{
|
|
string text12 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoFileSpec, current2);
|
|
}
|
|
else
|
|
{
|
|
pdbPath = ((CommandLineParser)this).ParsePdbPath(text12, (IList<Diagnostic>)list, baseDirectory);
|
|
}
|
|
continue;
|
|
}
|
|
case "errorendlocation":
|
|
shouldIncludeErrorEndLocation = true;
|
|
continue;
|
|
case "reportanalyzer":
|
|
reportAnalyzer = true;
|
|
continue;
|
|
case "skipanalyzers+":
|
|
case "skipanalyzers":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
skipAnalyzers = true;
|
|
continue;
|
|
case "skipanalyzers-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
skipAnalyzers = false;
|
|
continue;
|
|
case "nostdlib":
|
|
case "nostdlib+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag8 = true;
|
|
continue;
|
|
case "nostdlib-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
flag8 = false;
|
|
continue;
|
|
case "errorlog":
|
|
valueMemory = CommandLineParser.RemoveQuotesAndSlashesEx(valueMemory);
|
|
if (!valueMemory.HasValue || valueMemory.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<file>[,version={1|1.0|2|2.1}]", CommandLineParser.RemoveQuotesAndSlashes(current2));
|
|
continue;
|
|
}
|
|
val3 = ((CommandLineParser)this).ParseErrorLogOptions(valueMemory.Value, (IList<Diagnostic>)list, baseDirectory, ref flag19);
|
|
if (val3 == null && !flag19)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_BadSwitchValue, valueMemory.Value.ToString(), "/errorlog:", "<file>[,version={1|1.0|2|2.1}]");
|
|
}
|
|
continue;
|
|
case "appconfig":
|
|
{
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (RoslynString.IsNullOrEmpty(text14))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, ":<text>", CommandLineParser.RemoveQuotesAndSlashes(current2));
|
|
}
|
|
else
|
|
{
|
|
appConfigPath = ((CommandLineParser)this).ParseGenericPathToFile(text14, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
continue;
|
|
}
|
|
case "runtimemetadataversion":
|
|
{
|
|
string text14 = CommandLineParser.RemoveQuotesAndSlashes(valueMemory);
|
|
if (string.IsNullOrEmpty(text14))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<text>", text13);
|
|
}
|
|
else
|
|
{
|
|
text8 = text14;
|
|
}
|
|
continue;
|
|
}
|
|
case "additionalfile":
|
|
{
|
|
if (!valueMemory.HasValue || valueMemory.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<file list>", text13);
|
|
continue;
|
|
}
|
|
ArrayBuilder<string> instance5 = ArrayBuilder<string>.GetInstance();
|
|
((CommandLineParser)this).ParseSeparatedFileArgument(valueMemory.Value, baseDirectory, instance5, (IList<Diagnostic>)list);
|
|
Enumerator<string> enumerator2 = instance5.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
string current5 = enumerator2.Current;
|
|
list6.Add(((CommandLineParser)this).ToCommandLineSourceFile(current5, false));
|
|
}
|
|
instance5.Free();
|
|
continue;
|
|
}
|
|
case "analyzerconfig":
|
|
if (!valueMemory.HasValue || valueMemory.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SwitchNeedsString, "<file list>", text13);
|
|
}
|
|
else
|
|
{
|
|
ArrayBuilder<string> instance5 = ArrayBuilder<string>.GetInstance();
|
|
((CommandLineParser)this).ParseSeparatedFileArgument(valueMemory.Value, baseDirectory, instance5, (IList<Diagnostic>)list);
|
|
instance2.AddRange(instance5);
|
|
instance5.Free();
|
|
}
|
|
continue;
|
|
case "embed":
|
|
{
|
|
string text12 = valueMemoryString();
|
|
if (RoslynString.IsNullOrEmpty(text12))
|
|
{
|
|
flag13 = true;
|
|
continue;
|
|
}
|
|
ArrayBuilder<string> instance5 = ArrayBuilder<string>.GetInstance();
|
|
((CommandLineParser)this).ParseSeparatedFileArgument(text12.AsMemory(), baseDirectory, instance5, (IList<Diagnostic>)list);
|
|
Enumerator<string> enumerator2 = instance5.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
string current4 = enumerator2.Current;
|
|
list7.Add(((CommandLineParser)this).ToCommandLineSourceFile(current4, false));
|
|
}
|
|
instance5.Free();
|
|
continue;
|
|
}
|
|
case "-":
|
|
if (Console.IsInputRedirected)
|
|
{
|
|
list5.Add(new CommandLineSourceFile("-", false, true));
|
|
flag12 = true;
|
|
}
|
|
else
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
|
|
}
|
|
continue;
|
|
case "reportivts":
|
|
case "reportivts+":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
reportInternalsVisibleToAttributes = true;
|
|
continue;
|
|
case "reportivts-":
|
|
if (valueMemory.HasValue)
|
|
{
|
|
break;
|
|
}
|
|
reportInternalsVisibleToAttributes = false;
|
|
continue;
|
|
case "noconfig":
|
|
case "ruleset":
|
|
case "errorreport":
|
|
continue;
|
|
}
|
|
}
|
|
AddDiagnostic(list, ErrorCode.ERR_BadSwitch, current2);
|
|
string? valueMemoryString()
|
|
{
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
return null;
|
|
}
|
|
return valueMemory.GetValueOrDefault().Span.ToString();
|
|
}
|
|
}
|
|
foreach (KeyValuePair<string, ReportDiagnostic> item2 in dictionary3)
|
|
{
|
|
dictionary[item2.Key] = item2.Value;
|
|
}
|
|
foreach (KeyValuePair<string, ReportDiagnostic> item3 in dictionary2)
|
|
{
|
|
dictionary[item3.Key] = item3.Value;
|
|
}
|
|
if (flag9 && text2 != null)
|
|
{
|
|
AddDiagnostic(list, dictionary, ErrorCode.ERR_NoRefOutWhenRefOnly);
|
|
}
|
|
if ((int)val4 == 3 && (flag9 || text2 != null))
|
|
{
|
|
AddDiagnostic(list, dictionary, ErrorCode.ERR_NoNetModuleOutputWhenRefOutOrRefOnly);
|
|
}
|
|
if (!base.IsScriptCommandLineParser && !flag12 && (EnumBounds.IsNetModule(val4) || !flag14))
|
|
{
|
|
AddDiagnostic(list, dictionary, ErrorCode.WRN_NoSources);
|
|
}
|
|
if (!flag8 && sdkDirectory != null)
|
|
{
|
|
list8.Insert(0, new CommandLineReference(Path.Combine(sdkDirectory, "mscorlib.dll"), MetadataReferenceProperties.Assembly));
|
|
}
|
|
if (!EnumBounds.Requires64Bit(val6) && num > 4294934527u)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_BadBaseNumber, $"0x{num:X}");
|
|
num = 0uL;
|
|
}
|
|
if (!string.IsNullOrEmpty(additionalReferenceDirectories))
|
|
{
|
|
ParseAndResolveReferencePaths(null, additionalReferenceDirectories.AsMemory(), baseDirectory, list10, MessageID.IDS_LIB_ENV, list);
|
|
}
|
|
ImmutableArray<string> referencePaths = BuildSearchPaths(sdkDirectory, list10, list3);
|
|
ValidateWin32Settings(win32ResourceFile, text5, text4, val4, list);
|
|
if (!RoslynString.IsNullOrEmpty(baseDirectory))
|
|
{
|
|
list12.Add(baseDirectory);
|
|
}
|
|
if (RoslynString.IsNullOrEmpty(text))
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_NoOutputDirectory);
|
|
}
|
|
else if (baseDirectory != text)
|
|
{
|
|
list12.Add(text);
|
|
}
|
|
if (flag18 && !RoslynString.IsNullOrEmpty(text6))
|
|
{
|
|
text6 = ((CommandLineParser)this).ParseGenericPathToFile(text6, (IList<Diagnostic>)list, baseDirectory, true);
|
|
}
|
|
if (text9 != null && !flag6)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_SourceLinkRequiresPdb);
|
|
}
|
|
if (flag13)
|
|
{
|
|
list7.AddRange(list5);
|
|
}
|
|
if (list7.Count > 0 && !flag6)
|
|
{
|
|
AddDiagnostic(list, ErrorCode.ERR_CannotEmbedWithoutPdb);
|
|
}
|
|
ImmutableDictionary<string, string> features = CommandLineParser.ParseFeatures(list14);
|
|
GetCompilationAndModuleNames(list, val4, list5, flag12, moduleAssemblyName, ref outputFileName, ref moduleName, out string compilationName);
|
|
instance.Free();
|
|
CSharpParseOptions cSharpParseOptions = new CSharpParseOptions(result, preprocessorSymbols: instance3.ToImmutableAndFree(), documentationMode: (DocumentationMode)(flag10 ? 2 : 0), kind: (SourceCodeKind)(base.IsScriptCommandLineParser ? 1 : 0), features: features);
|
|
bool reportSuppressedDiagnostics = val3 != null;
|
|
OutputKind outputKind = val4;
|
|
string moduleName2 = moduleName;
|
|
string mainTypeName = text3;
|
|
IEnumerable<string> usings = list13;
|
|
OptimizationLevel optimizationLevel = (OptimizationLevel)(flag ? 1 : 0);
|
|
bool checkOverflow = flag2;
|
|
NullableContextOptions nullableContextOptions = val;
|
|
bool allowUnsafe = flag3;
|
|
bool deterministic = flag5;
|
|
bool concurrentBuild = flag4;
|
|
string cryptoKeyContainer = text7;
|
|
string cryptoKeyFile = text6;
|
|
bool? delaySign = flag11;
|
|
Platform platform = val6;
|
|
ReportDiagnostic generalDiagnosticOption = val7;
|
|
int warningLevel = num3;
|
|
IEnumerable<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptions = dictionary;
|
|
bool publicSign = flag18;
|
|
CSharpCompilationOptions cSharpCompilationOptions = new CSharpCompilationOptions(outputKind, reportSuppressedDiagnostics, moduleName2, mainTypeName, "Script", usings, optimizationLevel, checkOverflow, allowUnsafe, cryptoKeyContainer, cryptoKeyFile, default(ImmutableArray<byte>), delaySign, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, concurrentBuild, deterministic, null, null, null, null, null, publicSign, (MetadataImportOptions)0, nullableContextOptions);
|
|
if (flag7)
|
|
{
|
|
cSharpCompilationOptions = cSharpCompilationOptions.WithDebugPlusMode(flag7);
|
|
}
|
|
bool num6 = flag9;
|
|
publicSign = !flag9 && text2 == null;
|
|
DebugInformationFormat val11 = val2;
|
|
ulong num7 = num;
|
|
concurrentBuild = flag15;
|
|
EmitOptions emitOptions = new EmitOptions(num6, val11, (string)null, (string)null, num2, num7, concurrentBuild, val5, text8, false, publicSign, instance4.ToImmutableAndFree(), (HashAlgorithmName?)HashAlgorithmName.SHA256, encoding, (Encoding)null);
|
|
list.AddRange(((CompilationOptions)cSharpCompilationOptions).Errors);
|
|
list.AddRange(((ParseOptions)cSharpParseOptions).Errors);
|
|
if ((int)val != 0 && cSharpParseOptions.LanguageVersion < MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion())
|
|
{
|
|
list.Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_NullableOptionNotAvailable, "nullable", val, cSharpParseOptions.LanguageVersion.ToDisplayString(), new CSharpRequiredLanguageVersion(MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion())), Location.None));
|
|
}
|
|
immutableArray = CommandLineParser.SortPathMap(immutableArray);
|
|
CSharpCommandLineArguments cSharpCommandLineArguments = new CSharpCommandLineArguments();
|
|
((CommandLineArguments)cSharpCommandLineArguments).IsScriptRunner = base.IsScriptCommandLineParser;
|
|
((CommandLineArguments)cSharpCommandLineArguments).InteractiveMode = flag17 || (base.IsScriptCommandLineParser && list5.Count == 0);
|
|
((CommandLineArguments)cSharpCommandLineArguments).BaseDirectory = baseDirectory;
|
|
((CommandLineArguments)cSharpCommandLineArguments).PathMap = immutableArray;
|
|
((CommandLineArguments)cSharpCommandLineArguments).Errors = ImmutableArrayExtensions.AsImmutable<Diagnostic>((IEnumerable<Diagnostic>)list);
|
|
((CommandLineArguments)cSharpCommandLineArguments).Utf8Output = utf8Output;
|
|
((CommandLineArguments)cSharpCommandLineArguments).CompilationName = compilationName;
|
|
((CommandLineArguments)cSharpCommandLineArguments).OutputFileName = outputFileName;
|
|
((CommandLineArguments)cSharpCommandLineArguments).OutputRefFilePath = text2;
|
|
((CommandLineArguments)cSharpCommandLineArguments).PdbPath = pdbPath;
|
|
((CommandLineArguments)cSharpCommandLineArguments).EmitPdb = flag6 && !flag9;
|
|
((CommandLineArguments)cSharpCommandLineArguments).SourceLink = text9;
|
|
((CommandLineArguments)cSharpCommandLineArguments).RuleSetPath = text10;
|
|
((CommandLineArguments)cSharpCommandLineArguments).OutputDirectory = text;
|
|
((CommandLineArguments)cSharpCommandLineArguments).DocumentationPath = documentationPath;
|
|
((CommandLineArguments)cSharpCommandLineArguments).GeneratedFilesOutputDirectory = generatedFilesOutputDirectory;
|
|
((CommandLineArguments)cSharpCommandLineArguments).ErrorLogOptions = val3;
|
|
((CommandLineArguments)cSharpCommandLineArguments).AppConfigPath = appConfigPath;
|
|
((CommandLineArguments)cSharpCommandLineArguments).SourceFiles = ImmutableArrayExtensions.AsImmutable<CommandLineSourceFile>((IEnumerable<CommandLineSourceFile>)list5);
|
|
((CommandLineArguments)cSharpCommandLineArguments).Encoding = encoding;
|
|
((CommandLineArguments)cSharpCommandLineArguments).ChecksumAlgorithm = checksumAlgorithm;
|
|
((CommandLineArguments)cSharpCommandLineArguments).MetadataReferences = ImmutableArrayExtensions.AsImmutable<CommandLineReference>((IEnumerable<CommandLineReference>)list8);
|
|
((CommandLineArguments)cSharpCommandLineArguments).AnalyzerReferences = ImmutableArrayExtensions.AsImmutable<CommandLineAnalyzerReference>((IEnumerable<CommandLineAnalyzerReference>)list9);
|
|
((CommandLineArguments)cSharpCommandLineArguments).AnalyzerConfigPaths = instance2.ToImmutableAndFree();
|
|
((CommandLineArguments)cSharpCommandLineArguments).AdditionalFiles = ImmutableArrayExtensions.AsImmutable<CommandLineSourceFile>((IEnumerable<CommandLineSourceFile>)list6);
|
|
((CommandLineArguments)cSharpCommandLineArguments).ReferencePaths = referencePaths;
|
|
((CommandLineArguments)cSharpCommandLineArguments).SourcePaths = ImmutableArrayExtensions.AsImmutable<string>((IEnumerable<string>)list11);
|
|
((CommandLineArguments)cSharpCommandLineArguments).KeyFileSearchPaths = ImmutableArrayExtensions.AsImmutable<string>((IEnumerable<string>)list12);
|
|
((CommandLineArguments)cSharpCommandLineArguments).Win32ResourceFile = win32ResourceFile;
|
|
((CommandLineArguments)cSharpCommandLineArguments).Win32Icon = text5;
|
|
((CommandLineArguments)cSharpCommandLineArguments).Win32Manifest = text4;
|
|
((CommandLineArguments)cSharpCommandLineArguments).NoWin32Manifest = noWin32Manifest;
|
|
((CommandLineArguments)cSharpCommandLineArguments).DisplayLogo = displayLogo;
|
|
((CommandLineArguments)cSharpCommandLineArguments).DisplayHelp = displayHelp;
|
|
((CommandLineArguments)cSharpCommandLineArguments).DisplayVersion = displayVersion;
|
|
((CommandLineArguments)cSharpCommandLineArguments).DisplayLangVersions = displayLangVersions;
|
|
((CommandLineArguments)cSharpCommandLineArguments).ManifestResources = ImmutableArrayExtensions.AsImmutable<ResourceDescription>((IEnumerable<ResourceDescription>)list4);
|
|
cSharpCommandLineArguments.CompilationOptions = cSharpCompilationOptions;
|
|
cSharpCommandLineArguments.ParseOptions = cSharpParseOptions;
|
|
((CommandLineArguments)cSharpCommandLineArguments).EmitOptions = emitOptions;
|
|
((CommandLineArguments)cSharpCommandLineArguments).ScriptArguments = ImmutableArrayExtensions.AsImmutableOrEmpty<string>((IEnumerable<string>)list2);
|
|
((CommandLineArguments)cSharpCommandLineArguments).TouchedFilesPath = touchedFilesPath;
|
|
((CommandLineArguments)cSharpCommandLineArguments).PrintFullPaths = printFullPaths;
|
|
cSharpCommandLineArguments.ShouldIncludeErrorEndLocation = shouldIncludeErrorEndLocation;
|
|
((CommandLineArguments)cSharpCommandLineArguments).PreferredUILang = cultureInfo;
|
|
((CommandLineArguments)cSharpCommandLineArguments).ReportAnalyzer = reportAnalyzer;
|
|
((CommandLineArguments)cSharpCommandLineArguments).SkipAnalyzers = skipAnalyzers;
|
|
((CommandLineArguments)cSharpCommandLineArguments).EmbeddedFiles = ImmutableArrayExtensions.AsImmutable<CommandLineSourceFile>((IEnumerable<CommandLineSourceFile>)list7);
|
|
((CommandLineArguments)cSharpCommandLineArguments).ReportInternalsVisibleToAttributes = reportInternalsVisibleToAttributes;
|
|
return cSharpCommandLineArguments;
|
|
}
|
|
|
|
private static void ParseAndResolveReferencePaths(string? switchName, ReadOnlyMemory<char>? switchValue, string? baseDirectory, List<string> builder, MessageID origin, List<Diagnostic> diagnostics)
|
|
{
|
|
if (!switchValue.HasValue || switchValue.GetValueOrDefault().Length <= 0)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_PathList.Localize(), switchName);
|
|
return;
|
|
}
|
|
foreach (string item in CommandLineParser.ParseSeparatedPaths(switchValue.Value.ToString()))
|
|
{
|
|
string text = FileUtilities.ResolveRelativePath(item, baseDirectory);
|
|
if (text == null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, item, origin.Localize(), MessageID.IDS_DirectoryHasInvalidPath.Localize());
|
|
}
|
|
else if (!Directory.Exists(text))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, item, origin.Localize(), MessageID.IDS_DirectoryDoesNotExist.Localize());
|
|
}
|
|
else
|
|
{
|
|
builder.Add(text);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static string? GetWin32Setting(string arg, string? value, List<Diagnostic> diagnostics)
|
|
{
|
|
if (value == null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
|
|
}
|
|
else
|
|
{
|
|
string text = CommandLineParser.RemoveQuotesAndSlashes(value);
|
|
if (!string.IsNullOrWhiteSpace(text))
|
|
{
|
|
return text;
|
|
}
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void GetCompilationAndModuleNames(List<Diagnostic> diagnostics, OutputKind outputKind, List<CommandLineSourceFile> sourceFiles, bool sourceFilesSpecified, string? moduleAssemblyName, ref string? outputFileName, ref string? moduleName, out string? compilationName)
|
|
{
|
|
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
string text;
|
|
if (outputFileName == null)
|
|
{
|
|
if (!base.IsScriptCommandLineParser && !sourceFilesSpecified)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_OutputNeedsName);
|
|
text = null;
|
|
}
|
|
else if (EnumBounds.IsApplication(outputKind))
|
|
{
|
|
text = null;
|
|
}
|
|
else
|
|
{
|
|
CommandLineSourceFile val = sourceFiles.FirstOrDefault();
|
|
text = PathUtilities.RemoveExtension(PathUtilities.GetFileName(((CommandLineSourceFile)(ref val)).Path, true));
|
|
outputFileName = text + EnumBounds.GetDefaultExtension(outputKind);
|
|
if (text.Length == 0 && !EnumBounds.IsNetModule(outputKind))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, outputFileName);
|
|
text = (outputFileName = null);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
text = PathUtilities.RemoveExtension(outputFileName);
|
|
if (text.Length == 0)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, outputFileName);
|
|
text = (outputFileName = null);
|
|
}
|
|
}
|
|
if (EnumBounds.IsNetModule(outputKind))
|
|
{
|
|
compilationName = moduleAssemblyName;
|
|
}
|
|
else
|
|
{
|
|
if (moduleAssemblyName != null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_AssemblyNameOnNonModule);
|
|
}
|
|
compilationName = text;
|
|
}
|
|
if (moduleName == null)
|
|
{
|
|
moduleName = outputFileName;
|
|
}
|
|
}
|
|
|
|
private ImmutableArray<string> BuildSearchPaths(string? sdkDirectoryOpt, List<string> libPaths, List<string>? responsePathsOpt)
|
|
{
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
if (sdkDirectoryOpt != null)
|
|
{
|
|
instance.Add(sdkDirectoryOpt);
|
|
}
|
|
instance.AddRange((IEnumerable<string>)libPaths);
|
|
if (responsePathsOpt != null)
|
|
{
|
|
instance.AddRange((IEnumerable<string>)responsePathsOpt);
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
public static IEnumerable<string> ParseConditionalCompilationSymbols(string value, out IEnumerable<Diagnostic> diagnostics)
|
|
{
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
ParseConditionalCompilationSymbols(value.AsMemory(), instance, out diagnostics);
|
|
return instance.ToArrayAndFree();
|
|
}
|
|
|
|
internal static void ParseConditionalCompilationSymbols(ReadOnlyMemory<char> valueMemory, ArrayBuilder<string> defines, out IEnumerable<Diagnostic> diagnostics)
|
|
{
|
|
DiagnosticBag outputDiagnostics = DiagnosticBag.GetInstance();
|
|
if (MemoryExtensions.IsWhiteSpace(valueMemory))
|
|
{
|
|
outputDiagnostics.Add(Diagnostic.Create((CommonMessageProvider)(object)MessageProvider.Instance, 2029, new object[1] { valueMemory.ToString() }));
|
|
diagnostics = outputDiagnostics.ToReadOnlyAndFree();
|
|
return;
|
|
}
|
|
ReadOnlySpan<char> span = valueMemory.Span;
|
|
int nextIndex = 0;
|
|
int index;
|
|
for (index = 0; index < span.Length; index++)
|
|
{
|
|
char c = span[index];
|
|
if ((c == ',' || c == ';') ? true : false)
|
|
{
|
|
add();
|
|
nextIndex = index + 1;
|
|
}
|
|
}
|
|
if (nextIndex < span.Length)
|
|
{
|
|
add();
|
|
}
|
|
diagnostics = outputDiagnostics.ToReadOnlyAndFree();
|
|
void add()
|
|
{
|
|
string text = MemoryExtensions.Trim(valueMemory.Slice(nextIndex, index - nextIndex)).ToString();
|
|
if (SyntaxFacts.IsValidIdentifier(text))
|
|
{
|
|
defines.Add(text);
|
|
}
|
|
else
|
|
{
|
|
outputDiagnostics.Add(Diagnostic.Create((CommonMessageProvider)(object)MessageProvider.Instance, 2029, new object[1] { text }));
|
|
}
|
|
}
|
|
}
|
|
|
|
private static Platform ParsePlatform(string value, IList<Diagnostic> diagnostics)
|
|
{
|
|
switch (value.ToLowerInvariant())
|
|
{
|
|
case "x86":
|
|
return (Platform)1;
|
|
case "x64":
|
|
return (Platform)2;
|
|
case "itanium":
|
|
return (Platform)3;
|
|
case "anycpu":
|
|
return (Platform)0;
|
|
case "anycpu32bitpreferred":
|
|
return (Platform)4;
|
|
case "arm":
|
|
return (Platform)5;
|
|
case "arm64":
|
|
return (Platform)6;
|
|
default:
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_BadPlatformType, value);
|
|
return (Platform)0;
|
|
}
|
|
}
|
|
|
|
private static OutputKind ParseTarget(string value, IList<Diagnostic> diagnostics)
|
|
{
|
|
switch (value.ToLowerInvariant())
|
|
{
|
|
case "exe":
|
|
return (OutputKind)0;
|
|
case "winexe":
|
|
return (OutputKind)1;
|
|
case "library":
|
|
return (OutputKind)2;
|
|
case "module":
|
|
return (OutputKind)3;
|
|
case "appcontainerexe":
|
|
return (OutputKind)5;
|
|
case "winmdobj":
|
|
return (OutputKind)4;
|
|
default:
|
|
AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidTarget);
|
|
return (OutputKind)0;
|
|
}
|
|
}
|
|
|
|
private static IEnumerable<string> ParseUsings(string arg, string? value, IList<Diagnostic> diagnostics)
|
|
{
|
|
if (RoslynString.IsNullOrEmpty(value))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Namespace1.Localize(), arg);
|
|
yield break;
|
|
}
|
|
string[] array = value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
yield return array[i];
|
|
}
|
|
}
|
|
|
|
private static void ParseAnalyzers(string arg, ReadOnlyMemory<char>? valueMemory, List<CommandLineAnalyzerReference> analyzerReferences, List<Diagnostic> diagnostics)
|
|
{
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
if (valueMemory.HasValue)
|
|
{
|
|
ReadOnlyMemory<char> valueOrDefault = valueMemory.GetValueOrDefault();
|
|
if (valueOrDefault.Length == 0)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
|
|
return;
|
|
}
|
|
ArrayBuilder<ReadOnlyMemory<char>> instance = ArrayBuilder<ReadOnlyMemory<char>>.GetInstance();
|
|
CommandLineParser.ParseSeparatedPathsEx((ReadOnlyMemory<char>?)valueOrDefault, instance);
|
|
Enumerator<ReadOnlyMemory<char>> enumerator = instance.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
ReadOnlyMemory<char> current = enumerator.Current;
|
|
if (current.Length != 0)
|
|
{
|
|
analyzerReferences.Add(new CommandLineAnalyzerReference(current.ToString()));
|
|
}
|
|
}
|
|
instance.Free();
|
|
}
|
|
else
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
|
|
}
|
|
}
|
|
|
|
private static void ParseAssemblyReferences(string arg, ReadOnlyMemory<char>? valueMemory, IList<Diagnostic> diagnostics, bool embedInteropTypes, List<CommandLineReference> commandLineReferences)
|
|
{
|
|
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!valueMemory.HasValue)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), arg);
|
|
return;
|
|
}
|
|
ReadOnlyMemory<char> value = valueMemory.Value;
|
|
if (value.Length == 0)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
|
|
return;
|
|
}
|
|
ReadOnlySpan<char> span = value.Span;
|
|
int num = MemoryExtensions.IndexOfAny(span, s_quoteOrEquals);
|
|
string text;
|
|
if (num >= 0 && span[num] == '=')
|
|
{
|
|
text = value.Slice(0, num).ToString();
|
|
value = value.Slice(num + 1);
|
|
if (!SyntaxFacts.IsValidIdentifier(text))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_BadExternIdentifier, text);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
text = null;
|
|
}
|
|
ArrayBuilder<ReadOnlyMemory<char>> instance = ArrayBuilder<ReadOnlyMemory<char>>.GetInstance();
|
|
CommandLineParser.ParseSeparatedPathsEx((ReadOnlyMemory<char>?)value, instance);
|
|
int num2 = 0;
|
|
Enumerator<ReadOnlyMemory<char>> enumerator = instance.GetEnumerator();
|
|
MetadataReferenceProperties val = default(MetadataReferenceProperties);
|
|
while (enumerator.MoveNext())
|
|
{
|
|
ReadOnlyMemory<char> current = enumerator.Current;
|
|
if (!MemoryExtensions.IsWhiteSpace(current))
|
|
{
|
|
num2++;
|
|
ImmutableArray<string> immutableArray = ((text != null) ? ImmutableArray.Create(text) : ImmutableArray<string>.Empty);
|
|
((MetadataReferenceProperties)(ref val))._002Ector((MetadataImageKind)0, immutableArray, embedInteropTypes);
|
|
commandLineReferences.Add(new CommandLineReference(current.ToString(), val));
|
|
}
|
|
}
|
|
instance.Free();
|
|
if (text != null)
|
|
{
|
|
if (num2 > 1)
|
|
{
|
|
commandLineReferences.RemoveRange(commandLineReferences.Count - num2, num2);
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_OneAliasPerReference);
|
|
}
|
|
else if (num2 == 0)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_AliasMissingFile, text);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void ValidateWin32Settings(string? win32ResourceFile, string? win32IconResourceFile, string? win32ManifestFile, OutputKind outputKind, IList<Diagnostic> diagnostics)
|
|
{
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
if (win32ResourceFile != null)
|
|
{
|
|
if (win32IconResourceFile != null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_CantHaveWin32ResAndIcon);
|
|
}
|
|
if (win32ManifestFile != null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_CantHaveWin32ResAndManifest);
|
|
}
|
|
}
|
|
if (EnumBounds.IsNetModule(outputKind) && win32ManifestFile != null)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.WRN_CantHaveManifestForModule);
|
|
}
|
|
}
|
|
|
|
private static IEnumerable<InstrumentationKind> ParseInstrumentationKinds(string value, IList<Diagnostic> diagnostics)
|
|
{
|
|
string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
string[] array2 = array;
|
|
foreach (string text in array2)
|
|
{
|
|
if (text.ToLower() == "testcoverage")
|
|
{
|
|
yield return (InstrumentationKind)1;
|
|
continue;
|
|
}
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidInstrumentationKind, text);
|
|
}
|
|
}
|
|
|
|
internal static ResourceDescription? ParseResourceDescription(string arg, string resourceDescriptor, string? baseDirectory, IList<Diagnostic> diagnostics, bool embedded)
|
|
{
|
|
return ParseResourceDescription(arg, resourceDescriptor.AsMemory(), baseDirectory, diagnostics, embedded);
|
|
}
|
|
|
|
internal static ResourceDescription? ParseResourceDescription(string arg, ReadOnlyMemory<char> resourceDescriptor, string? baseDirectory, IList<Diagnostic> diagnostics, bool embedded)
|
|
{
|
|
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c5: Expected O, but got Unknown
|
|
string text = default(string);
|
|
string fullPath = default(string);
|
|
string text2 = default(string);
|
|
string text3 = default(string);
|
|
string text4 = default(string);
|
|
CommandLineParser.ParseResourceDescription(resourceDescriptor, baseDirectory, false, ref text, ref fullPath, ref text2, ref text3, ref text4);
|
|
bool flag;
|
|
if (text4 == null)
|
|
{
|
|
flag = true;
|
|
}
|
|
else if (string.Equals(text4, "public", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
if (!string.Equals(text4, "private", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_BadResourceVis, text4);
|
|
return null;
|
|
}
|
|
flag = false;
|
|
}
|
|
if (RoslynString.IsNullOrWhiteSpace(text))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.ERR_NoFileSpec, arg);
|
|
return null;
|
|
}
|
|
if (!PathUtilities.IsValidFilePath(fullPath))
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.FTL_InvalidInputFileName, text);
|
|
return null;
|
|
}
|
|
Func<Stream> func = () => new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
return new ResourceDescription(text3, text2, func, flag, embedded, false);
|
|
}
|
|
|
|
private static void ParseWarnings(ReadOnlyMemory<char> value, ArrayBuilder<string> ids)
|
|
{
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
value = MemoryExtensions.Unquote(value);
|
|
ArrayBuilder<ReadOnlyMemory<char>> instance = ArrayBuilder<ReadOnlyMemory<char>>.GetInstance();
|
|
ReadOnlySpan<char> other = "nullable".AsSpan();
|
|
CommandLineParser.ParseSeparatedStrings((ReadOnlyMemory<char>?)value, s_warningSeparators, true, instance);
|
|
Enumerator<ReadOnlyMemory<char>> enumerator = instance.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
ReadOnlyMemory<char> current = enumerator.Current;
|
|
if (current.Span.Equals(other, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
foreach (string nullableWarning in ErrorFacts.NullableWarnings)
|
|
{
|
|
ids.Add(nullableWarning);
|
|
}
|
|
ids.Add(((CommonMessageProvider)MessageProvider.Instance).GetIdForErrorCode(8632));
|
|
ids.Add(((CommonMessageProvider)MessageProvider.Instance).GetIdForErrorCode(8669));
|
|
}
|
|
else
|
|
{
|
|
string text = current.ToString();
|
|
if (ushort.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && ErrorFacts.IsWarning((ErrorCode)result))
|
|
{
|
|
ids.Add(((CommonMessageProvider)MessageProvider.Instance).GetIdForErrorCode((int)result));
|
|
}
|
|
else
|
|
{
|
|
ids.Add(text);
|
|
}
|
|
}
|
|
}
|
|
instance.Free();
|
|
}
|
|
|
|
private static void AddWarnings(Dictionary<string, ReportDiagnostic> d, ReportDiagnostic kind, ReadOnlyMemory<char> warningArgument)
|
|
{
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002b: Invalid comparison between Unknown and I4
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
ParseWarnings(warningArgument, instance);
|
|
Enumerator<string> enumerator = instance.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
string current = enumerator.Current;
|
|
if (d.TryGetValue(current, out var value))
|
|
{
|
|
if ((int)value != 5)
|
|
{
|
|
d[current] = kind;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
d.Add(current, kind);
|
|
}
|
|
}
|
|
instance.Free();
|
|
}
|
|
|
|
private static void UnimplementedSwitch(IList<Diagnostic> diagnostics, string switchName)
|
|
{
|
|
AddDiagnostic(diagnostics, ErrorCode.WRN_UnimplementedCommandLineSwitch, "/" + switchName);
|
|
}
|
|
|
|
internal override void GenerateErrorForNoFilesFoundInRecurse(string path, IList<Diagnostic> diagnostics)
|
|
{
|
|
}
|
|
|
|
private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode)
|
|
{
|
|
diagnostics.Add(Diagnostic.Create((CommonMessageProvider)(object)MessageProvider.Instance, (int)errorCode));
|
|
}
|
|
|
|
private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode, params object[] arguments)
|
|
{
|
|
diagnostics.Add(Diagnostic.Create((CommonMessageProvider)(object)MessageProvider.Instance, (int)errorCode, arguments));
|
|
}
|
|
|
|
private static void AddDiagnostic(IList<Diagnostic> diagnostics, Dictionary<string, ReportDiagnostic> warningOptions, ErrorCode errorCode, params object[] arguments)
|
|
{
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Invalid comparison between Unknown and I4
|
|
warningOptions.TryGetValue(((CommonMessageProvider)MessageProvider.Instance).GetIdForErrorCode((int)errorCode), out var value);
|
|
if ((int)value != 5)
|
|
{
|
|
AddDiagnostic(diagnostics, errorCode, arguments);
|
|
}
|
|
}
|
|
}
|