/// <summary> /// Creates a new command line argument parser. /// </summary> /// <param name="argumentSpecification">The argument type containing fields decorated /// with <see cref="CommandLineArgumentAttribute" /></param> /// <param name="responseFileReader">The delegate to use for reading response files instead of the default, /// or null to disable reading from response files.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="argumentSpecification"/> is null.</exception> public CommandLineArgumentParser(Type argumentSpecification, ResponseFileReader responseFileReader) { if (argumentSpecification == null) { throw new ArgumentNullException(@"argumentSpecification"); } this.argumentSpecification = argumentSpecification; this.responseFileReader = responseFileReader; PopulateArgumentMap(); }
protected override void InitializeUserScriptOptions(UserScriptOptions options) { var rspFile = GetResponseFile("CSharpInteractive.rsp"); if (rspFile == null) { return; } ReplEditor.OutputPrintLine(string.Format(dnSpy_Scripting_Roslyn_Resources.LoadingContextFromFile, Path.GetFileName(rspFile)), BoxedTextColor.ReplOutputText); foreach (var t in ResponseFileReader.Read(rspFile)) { switch (t.Item1.ToLowerInvariant()) { case "r": case "reference": options.References.AddRange(RespFileUtils.GetReferences(t.Item2)); break; case "u": case "using": case "usings": case "import": case "imports": options.Imports.AddRange(t.Item2.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); break; case "lib": case "libpath": case "libpaths": options.LibPaths.AddRange(RespFileUtils.GetReferencePaths(t.Item2)); break; case "loadpath": case "loadpaths": options.LoadPaths.AddRange(RespFileUtils.GetReferencePaths(t.Item2)); break; default: Debug.Fail($"Unknown option: '{t.Item1}'"); break; } } }
protected override ScriptOptions CreateScriptOptions(ScriptOptions options) { var rspFile = GetResponseFile("CSharpInteractive.rsp"); if (rspFile == null) { return(options); } this.replEditor.OutputPrintLine(string.Format(dnSpy_Scripting_Roslyn_Resources.LoadingContextFromFile, Path.GetFileName(rspFile))); foreach (var t in ResponseFileReader.Read(rspFile)) { if (t.Item1 == "/r") { Debug.Assert(t.Item3.Length == 0); if (t.Item3.Length != 0) { continue; } options = options.AddReferences(t.Item2); } else if (t.Item1 == "/u") { Debug.Assert(t.Item3.Length == 0); if (t.Item3.Length != 0) { continue; } options = options.AddImports(t.Item2); } else { Debug.Fail(string.Format("Unknown option: '{0}'", t.Item1)); } } return(options); }
/// <summary> /// Creates a new command line argument parser. /// </summary> /// <param name="argumentSpecification">The argument type containing fields decorated /// with <see cref="CommandLineArgumentAttribute" /></param> /// <param name="responseFileReader">The delegate to use for reading response files instead of the default, /// or null to disable reading from response files.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="argumentSpecification"/> is null.</exception> public CommandLineArgumentParser(Type argumentSpecification, ResponseFileReader responseFileReader) { if (argumentSpecification == null) throw new ArgumentNullException(@"argumentSpecification"); this.argumentSpecification = argumentSpecification; this.responseFileReader = responseFileReader; PopulateArgumentMap(); }