mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Added fix for duplicate node fields found
* Added fix for duplicate node fields found while iterating through base fields; on 2019.3 using .Net 20 getting the fields of the node type will return all base type fields as well. This results in the iteration up through the base classes and adding their instance fields resulting in duplicates which causes errors on node creation when assigning port information.
This commit is contained in:
parent
1ef3896893
commit
bbfc44b04f
@ -156,7 +156,14 @@ namespace XNode {
|
|||||||
// GetFields doesnt return inherited private fields, so walk through base types and pick those up
|
// GetFields doesnt return inherited private fields, so walk through base types and pick those up
|
||||||
System.Type tempType = nodeType;
|
System.Type tempType = nodeType;
|
||||||
while ((tempType = tempType.BaseType) != typeof(XNode.Node)) {
|
while ((tempType = tempType.BaseType) != typeof(XNode.Node)) {
|
||||||
fieldInfo.AddRange(tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance));
|
FieldInfo[] parentFields = tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
for (int i = 0; i < parentFields.Length; i++) {
|
||||||
|
// Ensure that we do not already have a member with this type and name
|
||||||
|
FieldInfo parentField = parentFields[i];
|
||||||
|
if (fieldInfo.TrueForAll(x => x.Name != parentField.Name)) {
|
||||||
|
fieldInfo.Add(parentField);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fieldInfo;
|
return fieldInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user