public void HandshakeResponse_avsc() { const string PREFIX = "Simple_avpr() - "; const string inputFile = "CodeGen/HandshakeResponse.avsc"; string outputFile = Path.GetFullPath(inputFile); outputFile = Path.ChangeExtension(inputFile, ".cs"); Schema schema = loadSchemaFromFile(inputFile); AvroGen generator = new AvroGen(); generator.Types.Add(schema); CodeCompileUnit cu = generate(generator); writeSource(outputFile, cu); CompilerParameters parms = new CompilerParameters(); parms.ReferencedAssemblies.Add(typeof(Schema).Assembly.Location); parms.ReferencedAssemblies.Add(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute).Assembly.Location); CompilerResults results = csp.CompileAssemblyFromDom(parms, cu); foreach (CompilerError error in results.Errors) { if (log.IsErrorEnabled) log.ErrorFormat(PREFIX + "{0}", error); } Assert.IsTrue(results.Errors.Count == 0, "Errors were encountered."); }
public void wordcount_avsc() { const string inputFile = "CodeGen/WordCount.avsc"; string outputFile = Path.GetFullPath(inputFile); outputFile = Path.ChangeExtension(inputFile, ".cs"); Schema schema = loadSchemaFromFile(inputFile); AvroGen generator = new AvroGen(); generator.Types.Add(schema); CodeCompileUnit cu = generate(generator); writeSource(outputFile, cu); }
private static CodeCompileUnit generate(AvroGen generator) { CodeCompileUnit cu = generator.GenerateClient(); Assert.IsNotNull(cu); Assert.IsTrue(cu.Namespaces.Count > 0, "Some namespaces should have been generated."); return cu; }
public void namespace_avpr() { const string inputFile = "CodeGen/namespace.avpr"; string outputFile = Path.GetFullPath(inputFile); outputFile = Path.ChangeExtension(inputFile, ".cs"); Protocol protocol = loadProtocolFromFile(inputFile); AvroGen generator = new AvroGen(); generator.Protocols.Add(protocol); CodeCompileUnit cu = generate(generator); writeSource(outputFile, cu); }