-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AVRO-4028: Avro.AvroException: Unable to find type 'IDictionary<string, Foo>' in all loaded assemblies #3072
base: main
Are you sure you want to change the base?
Conversation
@@ -90,6 +95,14 @@ private Type FindType(string name) | |||
return GenericIListType.MakeGenericType(FindType(itemTypeName)); | |||
} | |||
|
|||
if (TryGetIDictionaryItemTypeName(name, out var itemTypesName)) | |||
{ | |||
var key = itemTypesName[0].GetType().Name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic on the line 135 (if (name == t.Name || name == t.FullName ..) compare in case sensetive way. So it's not able to handle string (system name is String)
.GetType().Name helps to handle string type correctly (changing string to String).
That is not a flexible solution and it requires key to always be a string. Changing the type names comparing logic also does not sound like a good idea.
catch | ||
{ | ||
} |
Check notice
Code scanning / CodeQL
Poor error handling: empty catch block Note
catch | ||
{ | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note
case Schema.Type.Array: | ||
{ | ||
ArraySchema arrSchema = schema as ArraySchema; | ||
Type itemSchema = GetType(arrSchema.ItemSchema); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
arrSchema
this
{ | ||
return FindType(named.Fullname); | ||
MapSchema mapSchema = schema as MapSchema; | ||
Type itemSchema = GetType(mapSchema.ValueSchema); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
What is the purpose of the change
This pull request improves type finding logic of ObjectCreator.cs helping to handle nested dictionaries (map in the map).
Fixes the issue https://issues.apache.org/jira/browse/AVRO-4028
Verifying this change
(Please pick one of the following options)
This change is a trivial rework. New test cases were added to an existing unit test (TestGetTypeAssignable(), ObjectCreatorTests.cs) to validate nested dictionaries are handled correctly.
Documentation
This pull request does not introduce a new feature