Avro 3603 dotnet reflect refactoring 1#1823
Avro 3603 dotnet reflect refactoring 1#1823KhrystynaPopadyuk wants to merge 11 commits intoapache:masterfrom
Conversation
Merge with apache/avro master
| case Schema.Type.Error: | ||
| case Schema.Type.Record: | ||
| return _classCache.GetClass(sc as RecordSchema).GetClassType() == obj.GetType(); | ||
| return _reflectCache.GetClass(sc.Fullname).GetClassType() == obj.GetType(); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
| return _reflectCache.GetClass(sc.Fullname).GetClassType() == obj.GetType(); | ||
| case Schema.Type.Enumeration: | ||
| return EnumCache.GetEnumeration(sc as EnumSchema) == obj.GetType(); | ||
| return _reflectCache.GetEnum(sc.Fullname) == obj.GetType(); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
| } | ||
|
|
||
| return c; | ||
| return (DotnetClass)GetClass(schema.Fullname); |
Check warning
Code scanning / CodeQL
Call to obsolete method
| throw new AvroException($"Type {dotnetClass.Name} is not a class"); | ||
| } | ||
|
|
||
| _refletCache.AddClass(schema.Fullname, _dotnetclassFactory.CreateDotnetClass(schema, dotnetClass)); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
| private static ConcurrentBag<IAvroFieldConverter> _defaultConverters = new ConcurrentBag<IAvroFieldConverter>(); | ||
|
|
||
| private ConcurrentDictionary<string, DotnetClass> _nameClassMap = new ConcurrentDictionary<string, DotnetClass>(); | ||
| private ConcurrentDictionary<string, IDotnetClass> _nameClassMap = new ConcurrentDictionary<string, IDotnetClass>(); |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity
| { | ||
| private ConcurrentDictionary<string, DotnetProperty> _propertyMap = new ConcurrentDictionary<string, DotnetProperty>(); | ||
|
|
||
| private Dictionary<string, IDotnetProperty> _propertyMap; |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity
| foreach (var attr in p.GetCustomAttributes(true)) | ||
| { | ||
| var avroAttr = attr as AvroFieldAttribute; | ||
| if (avroAttr != null && avroAttr.FieldName != null && avroAttr.FieldName == field.Name) | ||
| { | ||
| return p; | ||
| } | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use OfType
| foreach (var c in _convertors) | ||
| { | ||
| if (c.GetAvroType() == avroType && c.GetPropertyType() == property.PropertyType) | ||
| { | ||
| return c; | ||
| } | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use Where
| foreach (var f in rs.Fields) | ||
| { | ||
| /* | ||
| //.StackOverflowException | ||
| var t = c.GetPropertyType(f); | ||
| LoadClassCache(t, f.Schema); | ||
| */ | ||
| if (!previousFields.ContainsKey(f.Name)) | ||
| { | ||
| previousFields.Add(f.Name, f.Schema); | ||
| var t = c.GetPropertyType(f); | ||
| LoadClassCache(t, f.Schema); | ||
| } | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use Where
| foreach (var o in us.Schemas) | ||
| { | ||
| if (o.Tag == Schema.Type.Record && _refletCache.GetClass(o.Fullname) == null) | ||
| { | ||
| throw new AvroException($"Class for union record type {o.Fullname} is not registered. Create a ClassCache object and call LoadClassCache"); | ||
| } | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use Where
Jira
My PR addresses the following Avro Jira issues and references them in the PR title.
Tests
TBD
Commits
My commits all reference Jira issues in their subject lines.
Documentation
TBU