Generates C# code from Avro schemas and protocols.
More...
|
| CodeGen () |
| Initializes a new instance of the CodeGen class. More...
|
|
| CodeGen (Dictionary< string, CodeNamespace > namespaceLookup) |
| Initializes a new instance of the CodeGen class. More...
|
|
virtual void | AddProtocol (Protocol protocol) |
| Adds a protocol object to generate code for. More...
|
|
virtual void | AddProtocol (string protocolText, IEnumerable< KeyValuePair< string, string >> namespaceMapping=null) |
| Parses and adds a protocol object to generate code for. More...
|
|
virtual void | AddSchema (Schema schema) |
| Adds a schema object to generate code for. More...
|
|
virtual void | AddSchema (string schemaText, IEnumerable< KeyValuePair< string, string >> namespaceMapping=null) |
| Parses and 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 IDictionary< string, string > | GetTypes () |
| Gets names and generated code of the schema(s) types More...
|
|
virtual void | WriteTypes (string outputdir, bool skipDirectories=false) |
| Writes each types in each namespaces into individual files. More...
|
|
Generates C# code from Avro schemas and protocols.
◆ CodeGen() [1/2]
Initializes a new instance of the CodeGen class.
◆ CodeGen() [2/2]
Avro.CodeGen.CodeGen |
( |
Dictionary< string, CodeNamespace > |
namespaceLookup | ) |
|
|
inline |
Initializes a new instance of the CodeGen class.
- Parameters
-
namespaceLookup | The namespace lookup. |
◆ addName()
Recursively search the given schema for named schemas and adds them to the given container.
- Parameters
-
schema | schema object to search. |
names | list of named schemas. |
- Exceptions
-
◆ 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
-
- Returns
- Code Namespace.
- Exceptions
-
ArgumentNullException | name - name cannot be null. |
◆ 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
-
- Returns
- Code Namespace.
- Exceptions
-
ArgumentNullException | name - name cannot be null. |
◆ AddProtocol() [1/2]
virtual void Avro.CodeGen.AddProtocol |
( |
Protocol |
protocol | ) |
|
|
inlinevirtual |
Adds a protocol object to generate code for.
- Parameters
-
◆ AddProtocol() [2/2]
virtual void Avro.CodeGen.AddProtocol |
( |
string |
protocolText, |
|
|
IEnumerable< KeyValuePair< string, string >> |
namespaceMapping = null |
|
) |
| |
|
inlinevirtual |
Parses and adds a protocol object to generate code for.
- Parameters
-
protocolText | The protocol. |
namespaceMapping | namespace mapping key value pairs. |
◆ AddSchema() [1/2]
virtual void Avro.CodeGen.AddSchema |
( |
Schema |
schema | ) |
|
|
inlinevirtual |
Adds a schema object to generate code for.
- Parameters
-
◆ AddSchema() [2/2]
virtual void Avro.CodeGen.AddSchema |
( |
string |
schemaText, |
|
|
IEnumerable< KeyValuePair< string, string >> |
namespaceMapping = null |
|
) |
| |
|
inlinevirtual |
Parses and adds a schema object to generate code for.
- Parameters
-
schemaText | schema object. |
namespaceMapping | namespace mapping key value pairs. |
◆ createDocComment()
virtual CodeCommentStatement Avro.CodeGen.createDocComment |
( |
string |
comment | ) |
|
|
inlineprotectedvirtual |
Creates an XML documentation for the given comment.
- Parameters
-
- Returns
- a statement consisting of a single comment.
◆ createSchemaField()
virtual void Avro.CodeGen.createSchemaField |
( |
Schema |
schema, |
|
|
CodeTypeDeclaration |
ctd, |
|
|
bool |
overrideFlag |
|
) |
| |
|
inlineprotectedvirtual |
Creates the static schema field for class types.
- Parameters
-
schema | schema. |
ctd | CodeTypeDeclaration for the class. |
overrideFlag | Indicates 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]
Generate list of named schemas from given protocol.
- Parameters
-
protocol | protocol to process. |
- Returns
- List of named schemas.
- Exceptions
-
ArgumentNullException | protocol - Protocol can not be null. |
◆ GenerateNames() [1/2]
Generate list of named schemas from given protocol.
- Parameters
-
protocol | protocol to process. |
- Returns
- List of named schemas.
- Exceptions
-
ArgumentNullException | protocol - Protocol can not be null. |
◆ generateNames() [2/2]
Generate list of named schemas from given schema.
- Parameters
-
- Returns
- List of named schemas.
◆ GenerateNames() [2/2]
Generate list of named schemas from given schema.
- Parameters
-
- Returns
- List of named schemas.
◆ getNullableType()
Gets the schema of a union with null.
- Parameters
-
- Returns
- schema that is nullable.
- Exceptions
-
ArgumentNullException | schema - UnionSchema can not be null. |
◆ GetNullableType()
Gets the schema of a union with null.
- Parameters
-
- Returns
- schema that is nullable.
- Exceptions
-
ArgumentNullException | schema - UnionSchema can not be null. |
◆ GetTypes()
virtual IDictionary<string, string> Avro.CodeGen.GetTypes |
( |
| ) |
|
|
inlinevirtual |
Gets names and generated code of the schema(s) types
- Returns
◆ processEnum()
virtual void Avro.CodeGen.processEnum |
( |
Schema |
schema | ) |
|
|
inlineprotectedvirtual |
Creates an enum declaration.
- Parameters
-
- Exceptions
-
CodeGenException | Unable to cast schema into an enum or Enum symbol " + symbol + " is a C# reserved keyword or Namespace required for enum schema " + enumschema.Name. |
◆ processFixed()
virtual void Avro.CodeGen.processFixed |
( |
Schema |
schema | ) |
|
|
inlineprotectedvirtual |
Creates a class declaration for fixed schema.
- Parameters
-
- Exceptions
-
CodeGenException | Unable to cast schema into a fixed or Namespace required for enum schema " + fixedSchema.Name. |
◆ processInterface()
virtual void Avro.CodeGen.processInterface |
( |
Protocol |
protocol | ) |
|
|
inlineprotectedvirtual |
Generates code for an individual protocol.
- Parameters
-
- Exceptions
-
◆ ProcessProtocols()
virtual void Avro.CodeGen.ProcessProtocols |
( |
| ) |
|
|
inlineprotectedvirtual |
Generates code for the protocol objects.
- Exceptions
-
◆ processProtocols()
virtual void Avro.CodeGen.processProtocols |
( |
| ) |
|
|
inlineprotectedvirtual |
Generates code for the protocol objects.
- Exceptions
-
◆ processRecord()
virtual CodeTypeDeclaration Avro.CodeGen.processRecord |
( |
Schema |
schema | ) |
|
|
inlineprotectedvirtual |
Creates a class declaration.
- Parameters
-
- Returns
- A new class code type declaration.
- Exceptions
-
CodeGenException | Unable to cast schema into a record or Namespace required for record schema " + recordSchema.Name. |
◆ ProcessSchemas()
virtual void Avro.CodeGen.ProcessSchemas |
( |
| ) |
|
|
inlineprotectedvirtual |
Generates code for the schema objects.
- Exceptions
-
◆ processSchemas()
virtual void Avro.CodeGen.processSchemas |
( |
| ) |
|
|
inlineprotectedvirtual |
Generates code for the schema objects.
- Exceptions
-
◆ WriteCompileUnit()
virtual void Avro.CodeGen.WriteCompileUnit |
( |
string |
outputFile | ) |
|
|
inlinevirtual |
Writes the generated compile unit into one file.
- Parameters
-
outputFile | name of output file to write to. |
◆ WriteTypes()
virtual void Avro.CodeGen.WriteTypes |
( |
string |
outputdir, |
|
|
bool |
skipDirectories = false |
|
) |
| |
|
inlinevirtual |
Writes each types in each namespaces into individual files.
- Parameters
-
outputdir | name of directory to write to. |
skipDirectories | skip creation of directories based on schema namespace |
◆ CompileUnit
CodeCompileUnit Avro.CodeGen.CompileUnit |
|
get |
Gets object that contains all the generated types.
The code compile unit.
◆ NamespaceLookup
Dictionary<string, CodeNamespace> Avro.CodeGen.NamespaceLookup |
|
getprotected |
Gets list of generated namespaces.
The namespace lookup.
◆ NamespaceMapping
IDictionary<string, string> Avro.CodeGen.NamespaceMapping |
|
get |
Gets mapping of Avro namespaces to C# namespaces.
The namespace mapping.
◆ Protocols
Gets list of protocols to generate code for.
The protocols.
◆ Schemas
IList<Schema> Avro.CodeGen.Schemas |
|
get |
Gets list of schemas to generate code for.
The schemas.
The documentation for this class was generated from the following file:
- src/apache/main/CodeGen/CodeGen.cs