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
14 changes: 7 additions & 7 deletions lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public GenericEnumAccess(EnumSchema schema)

public object CreateEnum(object reuse, int ordinal)
{
if (reuse is GenericEnum)
if (reuse is GenericEnum ge)
{
var ge = (GenericEnum) reuse;
if (ge.Schema.Equals(this.schema))
if (ge.Schema.Equals(schema))
{
ge.Value = this.schema[ordinal];
ge.Value = schema[ordinal];
return ge;
}
}
return new GenericEnum(this.schema, this.schema[ordinal]);

return new GenericEnum(schema, schema[ordinal]);
}
}

Expand Down Expand Up @@ -204,12 +204,12 @@ class GenericMapAccess : MapAccess
{
public object Create(object reuse)
{
if (reuse is IDictionary<string, object>)
if (reuse is IDictionary<string, object> result)
{
var result = (IDictionary<string, object>)reuse;
result.Clear();
return result;
}

return new Dictionary<string, object>();
}

Expand Down
11 changes: 5 additions & 6 deletions lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,14 @@ private ReadItem ResolveUnion(UnionSchema writerSchema, Schema readerSchema)

for (int i = 0; i < writerSchema.Count; i++)
{
var writerBranch = writerSchema[i];
Schema writerBranch = writerSchema[i];

if (readerSchema is UnionSchema)
if (readerSchema is UnionSchema unionReader)
{
var unionReader = (UnionSchema) readerSchema;
var readerBranch = unionReader.MatchingBranch(writerBranch);
int readerBranch = unionReader.MatchingBranch(writerBranch);
if (readerBranch == -1)
{
lookup[i] = (r, d) => { throw new AvroException( "No matching schema for " + writerBranch + " in " + unionReader ); };
lookup[i] = (r, d) => { throw new AvroException("No matching schema for " + writerBranch + " in " + unionReader); };
}
else
{
Expand All @@ -338,7 +337,7 @@ private ReadItem ResolveUnion(UnionSchema writerSchema, Schema readerSchema)
{
if (!readerSchema.CanRead(writerBranch))
{
lookup[i] = (r, d) => { throw new AvroException( "Schema mismatch Reader: " + ReaderSchema + ", writer: " + WriterSchema ); };
lookup[i] = (r, d) => { throw new AvroException("Schema mismatch Reader: " + ReaderSchema + ", writer: " + WriterSchema); };
}
else
{
Expand Down