@@ -32,11 +32,6 @@ internal abstract class HostItemBase : IReflect
3232 /// </summary>
3333 private readonly FieldInfo [ ] _fields ;
3434
35- /// <summary>
36- /// List of field names
37- /// </summary>
38- private string [ ] _fieldNames ;
39-
4035 /// <summary>
4136 /// List of properties
4237 /// </summary>
@@ -71,19 +66,37 @@ protected HostItemBase(Type type, object target, JsEngineMode engineMode, bool i
7166
7267 BindingFlags defaultBindingFlags = ReflectionHelpers . GetDefaultBindingFlags ( instance ) ;
7368 FieldInfo [ ] fields = _type . GetFields ( defaultBindingFlags ) ;
74- string [ ] fieldNames = fields . Length > 0 ? Array . ConvertAll ( fields , f => f . Name ) : new string [ 0 ] ;
7569 PropertyInfo [ ] properties = _type . GetProperties ( defaultBindingFlags ) ;
7670 MethodInfo [ ] methods = _type . GetMethods ( defaultBindingFlags ) ;
77- MethodInfo [ ] fullyFledgedMethods = methods . Length > 0 ?
78- Array . FindAll ( methods , ReflectionHelpers . IsFullyFledgedMethod ) : methods ;
71+ if ( methods . Length > 0 && properties . Length > 0 )
72+ {
73+ methods = ReflectionHelpers . GetFullyFledgedMethods ( methods ) ;
74+ }
7975
8076 _fields = fields ;
81- _fieldNames = fieldNames ;
8277 _properties = properties ;
83- _methods = fullyFledgedMethods ;
78+ _methods = methods ;
8479 }
8580
8681
82+ private bool IsField ( string name )
83+ {
84+ bool isField = false ;
85+ FieldInfo [ ] fields = _fields ;
86+ int fieldCount = fields . Length ;
87+
88+ for ( int fieldIndex = 0 ; fieldIndex < fieldCount ; fieldIndex ++ )
89+ {
90+ if ( fields [ fieldIndex ] . Name . Equals ( name , StringComparison . Ordinal ) )
91+ {
92+ isField = true ;
93+ break ;
94+ }
95+ }
96+
97+ return isField ;
98+ }
99+
87100 protected abstract object InnerInvokeMember ( string name , BindingFlags invokeAttr , Binder binder , object target ,
88101 object [ ] args , ParameterModifier [ ] modifiers , CultureInfo culture , string [ ] namedParameters ) ;
89102
@@ -94,7 +107,7 @@ protected object InvokeStandardMember(string name, BindingFlags invokeAttr, Bind
94107 if ( ( processedInvokeAttr . HasFlag ( BindingFlags . GetProperty )
95108 || processedInvokeAttr . HasFlag ( BindingFlags . SetProperty )
96109 || processedInvokeAttr . HasFlag ( BindingFlags . PutDispProperty ) )
97- && Array . IndexOf ( _fieldNames , name ) != - 1 )
110+ && IsField ( name ) )
98111 {
99112 if ( processedInvokeAttr . HasFlag ( BindingFlags . GetProperty ) )
100113 {
0 commit comments