private static ExtendedCompileResult CompileComponent(string inputPath, CliCompileOptions cliOptions) { var compiler = new CompilerService(); var resources = new MappedDirectoryResourceProvider(cliOptions.DefaultIconPath); // Icon paths are specified as: // --icon resourceName fileName // --icon wire_32 wire_32.png wire_64 wire_64.png for (int i = 0; i < cliOptions.IconPaths.Count; i += 2) resources.Mappings.Add(cliOptions.IconPaths[i], cliOptions.IconPaths[i + 1]); var options = new CompileOptions() { CertificateThumbprint = cliOptions.CertificateThumbprint }; if (cliOptions.Sign && cliOptions.CertificateThumbprint == null) options.CertificateThumbprint = SelectCertificate(); string outputPath = GetOutputPath(inputPath, cliOptions); var outputDirectory = Path.GetDirectoryName(outputPath); if (!Directory.Exists(outputDirectory)) Directory.CreateDirectory(outputDirectory); ComponentCompileResult result; using (var input = File.OpenRead(inputPath)) using (var output = File.OpenWrite(outputPath)) { result = compiler.Compile(input, output, resources, options); } var extendedResult = new ExtendedCompileResult(result) { Input = inputPath }; if (result.Success) { Console.WriteLine("{0} -> {1}", Path.GetFullPath(inputPath), Path.GetFullPath(outputPath)); extendedResult.Output = outputPath; } // Generate preview if (cliOptions.Preview != null) { string previewPath = GetPreviewPath(inputPath, cliOptions); string previewDirectory = Path.GetDirectoryName(previewPath); if (!Directory.Exists(previewDirectory)) Directory.CreateDirectory(previewDirectory); var preview = PreviewRenderer.GetSvgPreview(result.Description, null, true); File.WriteAllBytes(previewPath, preview); } return extendedResult; }
public void Generate(ComponentDescription description, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output) { ComponentCompileResult result = compiler.Compile(input, output, resourceProvider, new CompileOptions()); if (!result.Success) { throw new Exception(); } }
public static void Main(string[] args) { string code = "using System; namespace ashok{ public class MyClass{ public static void Main(string[] args){ Console.WriteLine(\"Hola...Working :D\"); } } }"; var compileService = new CompilerService(); var result = compileService.Compile(code); Console.WriteLine(result.Success); Console.WriteLine(result.Result); Console.ReadKey(); }
public void Generate(ComponentDescription description, ComponentConfiguration configuration, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output, SourceFileType sourceType) { ComponentCompileResult result = compiler.Compile(input, output, resourceProvider, new CompileOptions() { WriteExtendedMetadata = true }); if (!result.Success) { throw new Exception(); } }
public ModuleImage CompileModuleFromSource(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext) { compiler.DefineVariable("ЭтотОбъект", "ThisObject", SymbolType.ContextProperty); if (externalContext != null) { foreach (var item in externalContext) { compiler.DefineVariable(item.Key, null, SymbolType.ContextProperty); } } return(compiler.Compile(code)); }
public Process CreateProcess(IHostApplication host, ICodeSource src, CompilerService compilerSvc) { SetGlobalEnvironment(host, src); Initialize(); if (_engine.DebugController != null) { _engine.DebugController.Init(); _engine.DebugController.AttachToThread(_engine.Machine); _engine.DebugController.Wait(); } var module = _engine.LoadModuleImage(compilerSvc.Compile(src)); return(InitProcess(host, module)); }
public void Compile(string sourceCode) { CompilationMessages.Clear(); var diagnostics = _compiler.Compile(sourceCode); var messages = GetCompilationMessages(diagnostics); foreach (var message in messages) { CompilationMessages.Add(message); } GenerateDrawings(); }
public static ModuleImage CompileModule(CompilerService compiler, ICodeSource src) { compiler.DefineVariable(THISOBJ_RU, THISOBJ_EN, SymbolType.ContextProperty); for (int i = 0; i < _ownProperties.Count; i++) { var currentProp = _ownProperties.GetProperty(i); compiler.DefineVariable(currentProp.Name, currentProp.Alias, SymbolType.ContextProperty); } for (int i = 0; i < _ownMethods.Count; i++) { compiler.DefineMethod(_ownMethods.GetMethodInfo(i)); } return(compiler.Compile(src)); }
public void TestCompile() { var assembly = Assembly.GetExecutingAssembly(); string testComponentResource = assembly.GetManifestResourceNames().First(r => r.EndsWith("TestComponent.xml")); var compiler = new CompilerService(); var output = new MemoryStream(); ComponentCompileResult result; using (var input = assembly.GetManifestResourceStream(testComponentResource)) { result = compiler.Compile(input, output, Mock.Of<IResourceProvider>(), new CompileOptions()); } Assert.That(result.Success); Assert.That(result.ComponentName, Is.EqualTo("Wire")); }
public ModuleImage CompileModuleFromSource(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext) { compiler.DefineVariable("ЭтотОбъект", "ThisObject", SymbolType.ContextProperty); foreach (var methodInfo in UserScriptContextInstance.GetOwnMethodsDefinition()) { compiler.DefineMethod(methodInfo); } if (externalContext != null) { foreach (var item in externalContext) { compiler.DefineVariable(item.Key, null, SymbolType.ContextProperty); } } return(compiler.Compile(code)); }
public void TestCompile() { var assembly = typeof(CompilerServiceTest).GetTypeInfo().Assembly; string testComponentResource = assembly.GetManifestResourceNames().First(r => r.EndsWith("TestComponent.xml")); var compiler = new CompilerService(NullLoggerFactory.Instance); var output = new MemoryStream(); ComponentCompileResult result; using (var input = assembly.GetManifestResourceStream(testComponentResource)) { result = compiler.Compile(input, output, Mock.Of <IResourceProvider>(), new CompileOptions()); } Assert.That(result.Success); Assert.That(result.ComponentName, Is.EqualTo("Wire")); }
private void Recompile(bool sendRuntimeUpdate) { _compilerService.Compile(FilePath, sendRuntimeUpdate); }