internal static InputModule LoadInputs(Options options) { if (options.InputParameters.Count == 0) { throw new ToolArgumentException(SR.Format(SR.ErrNoValidInputFilesSpecified)); } InputModule inputs = new InputModule(); InputModuleLoader loader = new InputModuleLoader(inputs, options); loader.LoadInputs(); return(inputs); }
internal InputModuleLoader(InputModule newInputModule, Options options) { _options = options; _newInputModule = newInputModule; }
private void LoadSMReferenceAssembly() { IList <string> referencedAssembliesArgs = _arguments.GetArguments(Options.Cmd.SMReference); if (referencedAssembliesArgs != null && referencedAssembliesArgs.Count > 0) { string smassembly = referencedAssembliesArgs[0]; // Allow the reference to be for System.Private.ServiceModel as well. if ((smassembly.LastIndexOf("System.ServiceModel.Primitives", StringComparison.OrdinalIgnoreCase) == -1) && (smassembly.LastIndexOf("System.Private.ServiceModel", StringComparison.OrdinalIgnoreCase) == -1)) { ToolConsole.WriteError("Need to pass the right path of System.ServiceModel.Primitives for smreference parameter"); throw new ArgumentException("Invalid smreference value"); } string smpassembly = smassembly.Replace("System.ServiceModel.Primitives", "System.Private.ServiceModel"); //for some lowercase path smpassembly = smpassembly.Replace("system.servicemodel.primitives", "system.private.servicemodel"); int refplace = smassembly.LastIndexOf("ref"); if (refplace > 0) { smassembly = smassembly.Remove(refplace, 3).Insert(refplace, "lib"); refplace = smpassembly.LastIndexOf("ref"); smpassembly = smpassembly.Remove(refplace, 3).Insert(refplace, "lib"); int libplace = smpassembly.LastIndexOf("lib"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { smpassembly = smpassembly.Remove(libplace, 3).Insert(libplace, @"runtimes\win\lib"); } else { smpassembly = smpassembly.Remove(libplace, 3).Insert(libplace, @"runtimes/unix/lib"); } } try { ToolConsole.WriteLine("Load Assembly From " + smpassembly); InputModule.LoadAssembly(smpassembly); ToolConsole.WriteLine($"Successfully Load {smpassembly}"); } catch (Exception e) { ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message)); throw; } try { ToolConsole.WriteLine("Load Assembly From " + smassembly); Tool.SMAssembly = InputModule.LoadAssembly(smassembly); ToolConsole.WriteLine($"Successfully Load {smassembly}"); } catch (Exception e) { ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smassembly, e.Message)); throw; } } else { ToolConsole.WriteError("Need pass the System.ServiceModel.Primitive.dll through SM parameter"); throw new ArgumentException("Need pass the System.ServiceModel.Primitive.dll through SM parameter"); } }
private void LoadSMReferenceAssembly() { ToolConsole.WriteLine("[Logging] Getting list of referenced assemblies."); string smReferenceArg = _arguments.GetArgument(Options.Cmd.SMReference); ToolConsole.WriteLine("[Logging] The string of reference assemblies before parsing: " + smReferenceArg); IList <string> referencedAssembliesArgs = smReferenceArg.Split(';').ToList(); if (referencedAssembliesArgs != null && referencedAssembliesArgs.Count > 0) { string smassembly = ""; string smpassembly = ""; foreach (string path in referencedAssembliesArgs) { var file = new FileInfo(path); if (file.Name.Equals("System.ServiceModel.Primitives.dll", StringComparison.OrdinalIgnoreCase)) { smassembly = path; } if (file.Name.Equals("System.Private.ServiceModel.dll", StringComparison.OrdinalIgnoreCase)) { smpassembly = path; } } if ((string.IsNullOrEmpty(smassembly)) || (string.IsNullOrEmpty(smpassembly))) { ToolConsole.WriteLine("The full path found for System.ServiceModel.Primitives.dll is: " + smassembly); ToolConsole.WriteLine("The full path found for System.Private.ServiceModel.dll is: " + smpassembly); ToolConsole.WriteError("Missing one or both of the paths for System.ServiceModel.Primitives and System.Private.ServiceModel"); throw new ArgumentException("Invalid smreference value"); } try { ToolConsole.WriteLine("Load Assembly From " + smpassembly); InputModule.LoadAssembly(smpassembly); ToolConsole.WriteLine($"Successfully Load {smpassembly}"); } catch (Exception e) { ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message)); throw; } try { ToolConsole.WriteLine("Load Assembly From " + smassembly); Tool.SMAssembly = InputModule.LoadAssembly(smassembly); ToolConsole.WriteLine($"Successfully Load {smassembly}"); } catch (Exception e) { ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smassembly, e.Message)); throw; } } else { ToolConsole.WriteError("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter."); throw new ArgumentException("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter."); } }