/// <summary> /// Final step to generate binary. /// </summary> /// <param name="source">Source code or list of files.</param> /// <param name="parameters">Compiler settings.</param> /// <param name="cfg">Settings of IModeCSharp.</param> /// <returns></returns> protected CompilerResults toBinary(string source, CompilerParameters parameters, IModeCSharp cfg) { string hash = formatHashForAsm(cfg); CSharpCodeProvider provider = new CSharpCodeProvider(); if (!cfg.FilesMode) { return(provider.CompileAssemblyFromSource(parameters, source, hash)); } Log.Trace("[Compiler] use as list of files with source code."); if (string.IsNullOrEmpty(hash)) { return(provider.CompileAssemblyFromFile( parameters, filesFromCommand(source).ExtractFiles(Settings.WPath) )); } using (TempAssemblyInfo f = new TempAssemblyInfo(hash)) { return(provider.CompileAssemblyFromFile( parameters, filesFromCommand($"{source}\n{f.FullPath}").ExtractFiles(Settings.WPath) )); } }
/// <summary> /// Final step to generate binary. /// </summary> /// <param name="source">Source code or list of files.</param> /// <param name="parameters">Compiler settings.</param> /// <param name="cfg">Settings of IModeCSharp.</param> /// <returns></returns> protected CompilerResults toBinary(string source, CompilerParameters parameters, IModeCSharp cfg) { string hash = formatHashForAsm(cfg); CSharpCodeProvider provider = new CSharpCodeProvider(); if(!cfg.FilesMode) { return provider.CompileAssemblyFromSource(parameters, source, hash); } Log.Trace("[Compiler] use as list of files with source code."); if(String.IsNullOrEmpty(hash)) { return provider.CompileAssemblyFromFile(parameters, extractFiles(filesFromCommand(source))); } using(TempAssemblyInfo f = new TempAssemblyInfo(hash)) { return provider.CompileAssemblyFromFile(parameters, extractFiles(filesFromCommand(String.Format("{0}\n{1}", source, f.FullPath)))); } }