public ServiceDescriptorYaml(string baseName, DirectoryInfo d) { var basepath = Path.Combine(d.FullName, baseName); using (var reader = new StreamReader(basepath + ".yml")) { var file = reader.ReadToEnd(); var deserializer = new DeserializerBuilder().Build(); this.Configurations = deserializer.Deserialize <YamlConfiguration>(file); } Environment.SetEnvironmentVariable("BASE", d.FullName); // ditto for ID Environment.SetEnvironmentVariable("SERVICE_ID", this.Configurations.Id); // New name Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameExecutablePath, Defaults.ExecutablePath); // Also inject system environment variables Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameServiceId, this.Configurations.Id); this.Configurations.LoadEnvironmentVariables(); }
public static int Main(string[] args) { var diagnostics = new ErrorTrackingDiagnostics( ); Diagnostics.Implementation = diagnostics; if (args.Length < 2) { Diagnostics.Error("USAGE: LlvmBindingsGenerator <llvmRoot> <extensionsRoot> [OutputPath]"); return(-1); } string llvmRoot = args[0]; string extensionsRoot = args[1]; string outputPath = args.Length > 2 ? args[2] : System.Environment.CurrentDirectory; // read in the binding configuration from the YAML file // It is hoped, that going forward, the YAML file is the only thing that needs to change // but either way, helps keep the declarative part in a more easily understood format. string configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BindingsConfig.yml"); var config = new ReadOnlyConfig(YamlConfiguration.ParseFrom(configPath)); var library = new LibLlvmGeneratorLibrary(config, llvmRoot, extensionsRoot, outputPath); Driver.Run(library); return(diagnostics.ErrorCount); /* TODO: * Auto merge the generated docs XML with the Hand edited API Docs as hand merging is tedious and error prone. * 1) delete entries in APIDocs no longer in generated docs * 2) add entries to APIDocs for elements in generated docs but not in API Docs * 3) Leave everything else in APIDocs, intact */ }
private static int Run(Options options) { var diagnostics = new ErrorTrackingDiagnostics( ) { Level = options.Diagnostics }; Diagnostics.Implementation = diagnostics; string configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BindingsConfig.yml"); try { // read in the binding configuration from the YAML file // It is hoped, that going forward, the YAML file is the only thing that needs to change // but either way, it helps keep the declarative part in a more easily edited format. var config = new ReadOnlyConfig(YamlConfiguration.ParseFrom(configPath)); var library = new LibLlvmGeneratorLibrary(config, options.LlvmRoot, options.ExtensionsRoot, options.OutputPath); Driver.Run(library); } catch (IOException ioex) { Diagnostics.Error(ioex.Message); } catch (YamlDotNet.Core.SyntaxErrorException yamlex) { // Sadly the yaml exception message includes the location info in a format that doesn't match any standard tooling // for parsing error messages, so unpack it to get just the message of interest and re-format var matcher = new Regex(@"\(Line\: \d+, Col\: \d+, Idx\: \d+\) - \(Line\: \d+, Col\: \d+, Idx\: \d+\)\: (.*)\Z"); var result = matcher.Match(yamlex.Message); if (result.Success) { Diagnostics.Error("{0}({1},{2},{3},{4}): error CFG001: {5}" , configPath , yamlex.Start.Line , yamlex.Start.Column , yamlex.End.Line , yamlex.End.Column , result.Groups[1]); } else { // message didn't match expectations, best effort at this point... Diagnostics.Error(yamlex.Message); } } return(diagnostics.ErrorCount); /* TODO: * Auto merge the generated docs XML with the Hand edited API Docs as hand merging is tedious and error prone. * 1) delete entries in APIDocs no longer in generated docs * 2) add entries to APIDocs for elements in generated docs but not in API Docs * 3) Leave everything else in APIDocs, intact */ }
public ServiceDescriptorYaml() { string p = Defaults.ExecutablePath; string baseName = Path.GetFileNameWithoutExtension(p); if (baseName.EndsWith(".vshost")) { baseName = baseName.Substring(0, baseName.Length - 7); } DirectoryInfo d = new DirectoryInfo(Path.GetDirectoryName(p)); while (true) { if (File.Exists(Path.Combine(d.FullName, baseName + ".yml"))) { break; } if (d.Parent is null) { throw new FileNotFoundException("Unable to locate " + baseName + ".yml file within executable directory or any parents"); } d = d.Parent; } var basepath = Path.Combine(d.FullName, baseName); using (var reader = new StreamReader(basepath + ".yml")) { var file = reader.ReadToEnd(); var deserializer = new DeserializerBuilder().Build(); this.Configurations = deserializer.Deserialize <YamlConfiguration>(file); } Environment.SetEnvironmentVariable("BASE", d.FullName); // ditto for ID Environment.SetEnvironmentVariable("SERVICE_ID", this.Configurations.Id); // New name Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameExecutablePath, Defaults.ExecutablePath); // Also inject system environment variables Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameServiceId, this.Configurations.Id); this.Configurations.LoadEnvironmentVariables(); }
private async Task InitializeDatabaseAsync() { var configurationFilePath = _tasmotaOptions.Value.ConfigurationFile ?? ".\tasmocc.yaml"; var configuration = new YamlConfiguration(); if (File.Exists(configurationFilePath)) { var parser = new YamlConfigurationParser(); configuration = parser.ParseConfiguration(configurationFilePath); } await _templateRepository.InsertInitialTemplatesAsync(configuration.Templates?.Values); await _deviceConfigurationRepository.InsertInitialDeviceConfigurationsAsync(configuration.Devices?.Values); }
public void TestYamlLoading() { YamlConfiguration config = (YamlConfiguration)GetConfig(); var nl = Environment.NewLine; string yaml = $"Test1: \"A\"{nl}" + $"NestedObjectTest:{nl}" + $" NestedStringValue: \"B\"{nl}" + $" NestedNumberValue: 4{nl}" + $" VeryNestedObject:{nl}" + $" Value: \"3\"{nl}"; config.LoadFromYaml(yaml); AssertConfigEquality(config); AssertSaveException(config); }
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. public ServiceDescriptorYaml(YamlConfiguration configs) #pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. { this.Configurations = configs; this.Configurations.LoadEnvironmentVariables(); }
public ReadOnlyConfig(YamlConfiguration config) { YamlConfig = config; }
public ServiceDescriptorYaml(YamlConfiguration configs) { this.Configurations = configs; this.Configurations.LoadEnvironmentVariables(); }