public Dictionary <string, string> Translate() { var config = this.ReadConfig(); this.Plugins = Bridge.Translator.Plugins.GetPlugins(this, config); this.Plugins.OnConfigRead(config); if (config != null && !string.IsNullOrWhiteSpace(config.BeforeBuild)) { try { this.RunEvent(config.BeforeBuild); } catch (Exception exc) { throw new Bridge.Translator.Exception("Error: Unable to run beforeBuild event command: " + exc.Message + "\nStack trace:\n" + exc.StackTrace); } } if (this.FolderMode) { this.ReadFolderFiles(); } else { this.ReadProjectFile(); if (this.Rebuild || !File.Exists(this.AssemblyLocation)) { this.BuildAssembly(); } } var references = this.InspectReferences(); this.BuildSyntaxTree(); var resolver = new MemberResolver(this.ParsedSourceFiles, Emitter.ToAssemblyReferences(references)); this.InspectTypes(resolver, config); resolver.CanFreeze = true; var emitter = this.CreateEmitter(resolver); emitter.Translator = this; emitter.AssemblyInfo = this.AssemblyInfo; emitter.ChangeCase = this.ChangeCase; emitter.References = references; emitter.SourceFiles = this.SourceFiles; emitter.Log = this.Log; emitter.Plugins = this.Plugins; this.Plugins.BeforeEmit(emitter, this); this.Outputs = emitter.Emit(); this.Plugins.AfterEmit(emitter, this); return(this.Outputs); }
public Dictionary <string, string> Translate() { this.Plugins = Bridge.Translator.Plugins.GetPlugins(this); var config = this.ReadConfig(); if (config != null && !string.IsNullOrWhiteSpace(config.BeforeBuild)) { this.RunEvent(config.BeforeBuild); } this.ReadProjectFile(); if (this.Rebuild || !File.Exists(this.AssemblyLocation)) { this.BuildAssembly(); } var references = this.InspectReferences(); var resolver = new MemberResolver(this.SourceFiles, Emitter.ToAssemblyReferences(references)); this.InspectTypes(resolver, config); resolver.CanFreeze = true; var emitter = this.CreateEmitter(); emitter.TypeInfoDefinitions = this.TypeInfoDefinitions; emitter.AssemblyInfo = this.AssemblyInfo; emitter.Resolver = resolver; emitter.ChangeCase = this.ChangeCase; emitter.References = references; emitter.SourceFiles = this.SourceFiles; emitter.Log = this.Log; emitter.Plugins = this.Plugins; this.Plugins.BeforeEmit(emitter, this); this.Outputs = emitter.Emit(); return(this.Outputs); }
public Dictionary <string, string> Translate() { var logger = this.Log; logger.Info("Translating..."); this.LogProductInfo(); var config = this.AssemblyInfo; if (this.FolderMode) { this.ReadFolderFiles(); } else { this.ReadProjectFile(); if (this.Rebuild || !File.Exists(this.AssemblyLocation)) { this.BuildAssembly(); } } var references = this.InspectReferences(); this.References = references; this.Plugins = Bridge.Translator.Plugins.GetPlugins(this, config, logger); logger.Info("Reading plugin configs..."); this.Plugins.OnConfigRead(config); logger.Info("Reading plugin configs done"); if (!string.IsNullOrWhiteSpace(config.BeforeBuild)) { try { logger.Info("Running BeforeBuild event " + config.BeforeBuild + " ..."); this.RunEvent(config.BeforeBuild); logger.Info("Running BeforeBuild event done"); } catch (System.Exception exc) { var message = "Error: Unable to run beforeBuild event command: " + exc.Message + "\nStack trace:\n" + exc.StackTrace; logger.Error("Exception occurred. Message: " + message); throw new Bridge.Translator.TranslatorException(message); } } this.BuildSyntaxTree(); var resolver = new MemberResolver(this.ParsedSourceFiles, Emitter.ToAssemblyReferences(references, logger), this.AssemblyDefinition); resolver = this.Preconvert(resolver); this.InspectTypes(resolver, config); resolver.CanFreeze = true; var emitter = this.CreateEmitter(resolver); if (!this.AssemblyInfo.OverflowMode.HasValue) { this.AssemblyInfo.OverflowMode = this.OverflowMode; } emitter.Translator = this; emitter.AssemblyInfo = this.AssemblyInfo; emitter.References = references; emitter.SourceFiles = this.SourceFiles; emitter.Log = this.Log; emitter.Plugins = this.Plugins; emitter.InitialLevel = 1; this.SortReferences(); logger.Info("Before emitting..."); this.Plugins.BeforeEmit(emitter, this); logger.Info("Before emitting done"); this.Outputs = emitter.Emit(); logger.Info("After emitting..."); this.Plugins.AfterEmit(emitter, this); logger.Info("After emitting done"); logger.Info("Translating done"); return(this.Outputs); }
public Dictionary <string, string> Translate() { var logger = this.Log; logger.Info("Translating..."); var config = this.ReadConfig(); if (config.LoggerLevel.HasValue) { var l = logger as Bridge.Translator.Logging.Logger; if (l != null) { l.LoggerLevel = config.LoggerLevel.Value; } } logger.Trace("Read config file: " + Utils.AssemblyConfigHelper.ConfigToString(config)); if (!string.IsNullOrWhiteSpace(config.Configuration)) { this.Configuration = config.Configuration; logger.Trace("Set configuration: " + this.Configuration); } if (config.DefineConstants != null && config.DefineConstants.Count > 0) { this.DefineConstants.AddRange(config.DefineConstants); this.DefineConstants = this.DefineConstants.Distinct().ToList(); logger.Trace("Set constants: " + string.Join(",", this.DefineConstants)); } if (this.FolderMode) { this.ReadFolderFiles(); logger.Trace("Read folder files"); } else { this.ReadProjectFile(); logger.Trace("Read project file"); if (this.Rebuild || !File.Exists(this.AssemblyLocation)) { this.BuildAssembly(); logger.Trace("Build assembly"); } } var references = this.InspectReferences(); this.References = references; this.Plugins = Bridge.Translator.Plugins.GetPlugins(this, config, logger); this.Plugins.OnConfigRead(config); if (!string.IsNullOrWhiteSpace(config.BeforeBuild)) { try { logger.Trace("Running BeforeBuild event"); this.RunEvent(config.BeforeBuild); } catch (Exception exc) { var message = "Error: Unable to run beforeBuild event command: " + exc.Message + "\nStack trace:\n" + exc.StackTrace; logger.Error("Exception occurred. Message: " + message); throw new Bridge.Translator.Exception(message); } } logger.Trace("BuildSyntaxTree"); this.BuildSyntaxTree(); var resolver = new MemberResolver(this.ParsedSourceFiles, Emitter.ToAssemblyReferences(references)); this.InspectTypes(resolver, config); resolver.CanFreeze = true; var emitter = this.CreateEmitter(resolver); XmlMetaMaker.Load(XmlMetaFiles, emitter); emitter.Translator = this; emitter.AssemblyInfo = this.AssemblyInfo; emitter.References = references; emitter.SourceFiles = this.SourceFiles; emitter.Log = this.Log; emitter.Plugins = this.Plugins; this.SortReferences(); this.Plugins.BeforeEmit(emitter, this); this.Outputs = emitter.Emit(); this.Plugins.AfterEmit(emitter, this); logger.Info("Translating done"); return(this.Outputs); }
public void Translate() { var logger = this.Log; logger.Info("Translating..."); this.LogProductInfo(); var config = this.AssemblyInfo; if (!this.FolderMode) { if (this.Rebuild) { logger.Info("Building assembly as Rebuild option is enabled"); this.BuildAssembly(); } else if (!File.Exists(this.AssemblyLocation)) { logger.Info("Building assembly as it is not found at " + this.AssemblyLocation); this.BuildAssembly(); } } this.Outputs.Report = new TranslatorOutputItem { Content = new StringBuilder(), OutputKind = TranslatorOutputKind.Report, OutputType = TranslatorOutputType.None, Name = this.AssemblyInfo.Report.FileName ?? "bridge.report.log", Location = this.AssemblyInfo.Report.Path }; var references = this.InspectReferences(); this.References = references; this.Plugins = Bridge.Translator.Plugins.GetPlugins(this, config, logger); logger.Info("Reading plugin configs..."); this.Plugins.OnConfigRead(config); logger.Info("Reading plugin configs done"); if (!string.IsNullOrWhiteSpace(config.BeforeBuild)) { try { logger.Info("Running BeforeBuild event " + config.BeforeBuild + " ..."); this.RunEvent(config.BeforeBuild); logger.Info("Running BeforeBuild event done"); } catch (System.Exception exc) { var message = "Error: Unable to run beforeBuild event command: " + exc.Message + "\nStack trace:\n" + exc.StackTrace; logger.Error("Exception occurred. Message: " + message); throw new Bridge.Translator.TranslatorException(message); } } this.BuildSyntaxTree(); var resolver = new MemberResolver(this.ParsedSourceFiles, Emitter.ToAssemblyReferences(references, logger), this.AssemblyDefinition); resolver = this.Preconvert(resolver); this.InspectTypes(resolver, config); resolver.CanFreeze = true; var emitter = this.CreateEmitter(resolver); if (!this.AssemblyInfo.OverflowMode.HasValue) { this.AssemblyInfo.OverflowMode = this.OverflowMode; } emitter.Translator = this; emitter.AssemblyInfo = this.AssemblyInfo; emitter.References = references; emitter.SourceFiles = this.SourceFiles; emitter.Log = this.Log; emitter.Plugins = this.Plugins; emitter.InitialLevel = 1; this.SortReferences(); logger.Info("Before emitting..."); this.Plugins.BeforeEmit(emitter, this); logger.Info("Before emitting done"); this.AddMainOutputs(emitter.Emit()); this.EmitterOutputs = emitter.Outputs; logger.Info("After emitting..."); this.Plugins.AfterEmit(emitter, this); logger.Info("After emitting done"); logger.Info("Translating done"); }