Avro C#
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
Avro.CodeGen Class Reference

Generates C# code from Avro schemas and protocols. More...

Public Member Functions

 CodeGen ()
 Default constructor More...
 
virtual void AddProtocol (Protocol protocol)
 Adds a protocol object to generate code for More...
 
virtual void AddSchema (Schema schema)
 Adds a schema object to generate code for More...
 
virtual CodeCompileUnit GenerateCode ()
 Generates code for the given protocol and schema objects More...
 
virtual void WriteCompileUnit (string outputFile)
 Writes the generated compile unit into one file More...
 
virtual void WriteTypes (string outputdir)
 Writes each types in each namespaces into individual files More...
 

Static Public Member Functions

static Schema getNullableType (UnionSchema schema)
 Gets the schema of a union with null More...
 

Protected Member Functions

virtual CodeNamespace addNamespace (string name)
 Adds a namespace object for the given name into the dictionary if it doesn't exist yet More...
 
virtual void processSchemas ()
 Generates code for the schema objects More...
 
virtual void processProtocols ()
 Generates code for the protocol objects More...
 
virtual SchemaNames generateNames (Protocol protocol)
 Generate list of named schemas from given protocol More...
 
virtual SchemaNames generateNames (Schema schema)
 Generate list of named schemas from given schema More...
 
virtual void addName (Schema schema, SchemaNames names)
 Recursively search the given schema for named schemas and adds them to the given container More...
 
virtual void processFixed (Schema schema)
 Creates a class declaration for fixed schema More...
 
virtual void processEnum (Schema schema)
 Creates an enum declaration More...
 
virtual void processInterface (Protocol protocol)
 Generates code for an individual protocol. More...
 
virtual CodeTypeDeclaration processRecord (Schema schema)
 Creates a class declaration More...
 
virtual void createSchemaField (Schema schema, CodeTypeDeclaration ctd, bool overrideFlag)
 Creates the static schema field for class types More...
 
virtual CodeCommentStatement createDocComment (string comment)
 Creates an XML documentation for the given comment More...
 

Protected Attributes

Dictionary< string, CodeNamespace > namespaceLookup = new Dictionary<string, CodeNamespace>(StringComparer.Ordinal)
 List of generated namespaces More...
 

Properties

CodeCompileUnit CompileUnit [get]
 Object that contains all the generated types More...
 
IList< SchemaSchemas [get]
 List of schemas to generate code for More...
 
IList< ProtocolProtocols [get]
 List of protocols to generate code for More...
 
IDictionary< string, string > NamespaceMapping [get]
 Mapping of Avro namespaces to C# namespaces More...
 
Dictionary< string, CodeNamespace > NamespaceLookup [get, set]
 List of generated namespaces. More...
 

Detailed Description

Generates C# code from Avro schemas and protocols.

Constructor & Destructor Documentation

◆ CodeGen()

Avro.CodeGen.CodeGen ( )
inline

Default constructor

Member Function Documentation

◆ addName()

virtual void Avro.CodeGen.addName ( Schema  schema,
SchemaNames  names 
)
inlineprotectedvirtual

Recursively search the given schema for named schemas and adds them to the given container

Parameters
schemaschema object to search
nameslist of named schemas

◆ addNamespace()

virtual CodeNamespace Avro.CodeGen.addNamespace ( string  name)
inlineprotectedvirtual

Adds a namespace object for the given name into the dictionary if it doesn't exist yet

Parameters
namename of namespace
Returns

◆ AddProtocol()

virtual void Avro.CodeGen.AddProtocol ( Protocol  protocol)
inlinevirtual

Adds a protocol object to generate code for

Parameters
protocolprotocol object

◆ AddSchema()

virtual void Avro.CodeGen.AddSchema ( Schema  schema)
inlinevirtual

Adds a schema object to generate code for

Parameters
schemaschema object

◆ createDocComment()

virtual CodeCommentStatement Avro.CodeGen.createDocComment ( string  comment)
inlineprotectedvirtual

Creates an XML documentation for the given comment

Parameters
commentcomment
Returns
CodeCommentStatement object

◆ createSchemaField()

virtual void Avro.CodeGen.createSchemaField ( Schema  schema,
CodeTypeDeclaration  ctd,
bool  overrideFlag 
)
inlineprotectedvirtual

Creates the static schema field for class types

Parameters
schemaschema
ctdCodeTypeDeclaration for the class
overrideFlagIndicates whether we should add the MemberAttributes.Override to the generated property.

◆ GenerateCode()

virtual CodeCompileUnit Avro.CodeGen.GenerateCode ( )
inlinevirtual

Generates code for the given protocol and schema objects

Returns
CodeCompileUnit object

◆ generateNames() [1/2]

virtual SchemaNames Avro.CodeGen.generateNames ( Protocol  protocol)
inlineprotectedvirtual

Generate list of named schemas from given protocol

Parameters
protocolprotocol to process
Returns

◆ generateNames() [2/2]

virtual SchemaNames Avro.CodeGen.generateNames ( Schema  schema)
inlineprotectedvirtual

Generate list of named schemas from given schema

Parameters
schemaschema to process
Returns

◆ getNullableType()

static Schema Avro.CodeGen.getNullableType ( UnionSchema  schema)
inlinestatic

Gets the schema of a union with null

Parameters
schemaunion schema
Returns
schema that is nullible

◆ processEnum()

virtual void Avro.CodeGen.processEnum ( Schema  schema)
inlineprotectedvirtual

Creates an enum declaration

Parameters
schemaenum schema

◆ processFixed()

virtual void Avro.CodeGen.processFixed ( Schema  schema)
inlineprotectedvirtual

Creates a class declaration for fixed schema

Parameters
schemafixed schema

◆ processInterface()

virtual void Avro.CodeGen.processInterface ( Protocol  protocol)
inlineprotectedvirtual

Generates code for an individual protocol.

Parameters
protocolProtocol to generate code for.

◆ processProtocols()

virtual void Avro.CodeGen.processProtocols ( )
inlineprotectedvirtual

Generates code for the protocol objects

◆ processRecord()

virtual CodeTypeDeclaration Avro.CodeGen.processRecord ( Schema  schema)
inlineprotectedvirtual

Creates a class declaration

Parameters
schemarecord schema
Returns
A new class code type declaration

◆ processSchemas()

virtual void Avro.CodeGen.processSchemas ( )
inlineprotectedvirtual

Generates code for the schema objects

◆ WriteCompileUnit()

virtual void Avro.CodeGen.WriteCompileUnit ( string  outputFile)
inlinevirtual

Writes the generated compile unit into one file

Parameters
outputFilename of output file to write to

◆ WriteTypes()

virtual void Avro.CodeGen.WriteTypes ( string  outputdir)
inlinevirtual

Writes each types in each namespaces into individual files

Parameters
outputdirname of directory to write to

Member Data Documentation

◆ namespaceLookup

Dictionary<string, CodeNamespace> Avro.CodeGen.namespaceLookup = new Dictionary<string, CodeNamespace>(StringComparer.Ordinal)
protected

List of generated namespaces

Property Documentation

◆ CompileUnit

CodeCompileUnit Avro.CodeGen.CompileUnit
get

Object that contains all the generated types

◆ NamespaceLookup

Dictionary<string, CodeNamespace> Avro.CodeGen.NamespaceLookup
getsetprotected

List of generated namespaces.

◆ NamespaceMapping

IDictionary<string, string> Avro.CodeGen.NamespaceMapping
get

Mapping of Avro namespaces to C# namespaces

◆ Protocols

IList<Protocol> Avro.CodeGen.Protocols
get

List of protocols to generate code for

◆ Schemas

IList<Schema> Avro.CodeGen.Schemas
get

List of schemas to generate code for


The documentation for this class was generated from the following file: