Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang/csharp/src/apache/main/CodeGen/CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ protected virtual CodeTypeDeclaration processRecord(Schema schema)
codeField.Attributes = MemberAttributes.Private;
if (field.Schema is EnumSchema es && es.Default != null)
{
codeField.InitExpression = new CodeTypeReferenceExpression($"{es.Name}.{es.Default}");
codeField.InitExpression = new CodeTypeReferenceExpression($"{es.Namespace}.{es.Name}.{es.Default}");
}

// Process field documentation if it exist and add to the field
Expand Down
31 changes: 27 additions & 4 deletions lang/csharp/src/apache/test/AvroGen/AvroGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void GenerateSchema(string schema, IEnumerable<string> typeNamesToCheck,
{
TestSchema(schema, typeNamesToCheck, generatedFilesToCheck: generatedFilesToCheck);
}

[TestCase(
_nullableLogicalTypesArray,
"org.apache.avro.codegentest.testdata", "org.apache.csharp.codegentest.testdata",
Expand Down Expand Up @@ -547,7 +547,7 @@ public void NotSupportedSchema(string schema, Type expectedException)
""name"" : ""ClassKeywords"",
""namespace"" : ""com.base"",
""fields"" :
[
[
{ ""name"" : ""int"", ""type"" : ""int"" },
{ ""name"" : ""base"", ""type"" : ""long"" },
{ ""name"" : ""event"", ""type"" : ""boolean"" },
Expand Down Expand Up @@ -578,7 +578,7 @@ public void NotSupportedSchema(string schema, Type expectedException)
""name"" : ""SchemaObject"",
""namespace"" : ""schematest"",
""fields"" :
[
[
{ ""name"" : ""myobject"", ""type"" :
[
""null"",
Expand All @@ -600,7 +600,7 @@ public void NotSupportedSchema(string schema, Type expectedException)
""name"" : ""LogicalTypes"",
""namespace"" : ""schematest"",
""fields"" :
[
[
{ ""name"" : ""nullibleguid"", ""type"" : [""null"", {""type"": ""string"", ""logicalType"": ""uuid"" } ]},
{ ""name"" : ""guid"", ""type"" : {""type"": ""string"", ""logicalType"": ""uuid"" } },
{ ""name"" : ""nullibletimestampmillis"", ""type"" : [""null"", {""type"": ""long"", ""logicalType"": ""timestamp-millis""}] },
Expand All @@ -616,6 +616,29 @@ public void NotSupportedSchema(string schema, Type expectedException)
]
}",
new object[] { "schematest.LogicalTypes", typeof(Guid?), typeof(Guid), typeof(DateTime?), typeof(DateTime), typeof(DateTime?), typeof(DateTime), typeof(TimeSpan?), typeof(TimeSpan), typeof(TimeSpan?), typeof(TimeSpan), typeof(AvroDecimal?), typeof(AvroDecimal) })]
[TestCase(@"
{
""namespace"": ""enum.base"",
""type"": ""record"",
""name"": ""EnumInDifferentNamespace"",
""doc"": ""Test enum with a default value in a different namespace"",
""fields"": [
{
""name"": ""anEnum"",
""type"": {
""namespace"": ""enum.base.other"",
""type"": ""enum"",
""name"": ""AnEnum"",
""symbols"": [
""A"",
""B""
],
""default"": ""A""
}
}
]
}",
new object[] { "enum.base.EnumInDifferentNamespace", "enum.base.other.AnEnum" })]
public void GenerateSchemaCheckFields(string schema, object[] result)
{
Assembly assembly = TestSchema(schema);
Expand Down