private static async Task <IDictionary <string, string> > PackagingFilesAsync(string name, IPreprocessedRule preprocessedRule) { var inMemoryFiles = new Dictionary <string, string> { { $"{name}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) } }; var assembly = Assembly.GetExecutingAssembly(); // TODO we can deserialize a KuduFunctionConfig instead of using a fixed file... using (var stream = assembly.GetManifestResourceStream("aggregator.cli.Rules.function.json")) { using (var reader = new StreamReader(stream)) { var content = await reader.ReadToEndAsync(); inMemoryFiles.Add("function.json", content); } } using (var stream = assembly.GetManifestResourceStream("aggregator.cli.Rules.run.csx")) { using (var reader = new StreamReader(stream)) { var content = await reader.ReadToEndAsync(); inMemoryFiles.Add("run.csx", content); } } return(inMemoryFiles); }
public void RuleLanguageReadWrite_Succeeds(string ruleCode) { var mincedCode = ruleCode.Mince(); (IPreprocessedRule ppRule, _) = RuleFileParser.Read(mincedCode); var ruleCode2 = RuleFileParser.Write(ppRule); Assert.Equal(mincedCode, ruleCode2, StringComparer.OrdinalIgnoreCase); }
private static async Task <IDictionary <string, string> > PackagingFilesAsync(string ruleName, IPreprocessedRule preprocessedRule) { var inMemoryFiles = new Dictionary <string, string> { { $"{ruleName}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) } }; //var assembly = Assembly.GetExecutingAssembly(); //await inMemoryFiles.AddFunctionDefaultFiles(assembly); return(inMemoryFiles); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously private static async Task <IDictionary <string, string> > PackagingFilesAsync(string ruleName, IPreprocessedRule preprocessedRule) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { var inMemoryFiles = new Dictionary <string, string> { { $"{ruleName}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) } }; //var assembly = Assembly.GetExecutingAssembly(); //await inMemoryFiles.AddFunctionDefaultFiles(assembly); return(inMemoryFiles); }
public void RuleLanguageReadWrite_Succeeds() { string ruleCode = @".language=C# .reference=System.Xml.XDocument .import=System.Diagnostics return $""Hello { self.WorkItemType } #{ self.Id } - { self.Title }!""; "; var mincedCode = ruleCode.Mince(); (IPreprocessedRule ppRule, _) = RuleFileParser.Read(mincedCode); var ruleCode2 = RuleFileParser.Write(ppRule); Assert.Equal(mincedCode, ruleCode2, StringComparer.OrdinalIgnoreCase); }