@@ -290,10 +290,9 @@ private static Type EmitType(IList<DynamicProperty> properties, bool createParam
290290 var fieldName = properties [ i ] . Name ;
291291 var fieldType = properties [ i ] . Type ;
292292
293- // Use object-based equality comparer for types that are not publicly accessible from
294- // the dynamic assembly (e.g., compiler-generated anonymous types). Calling
295- // EqualityComparer<T>.get_Default() for a non-public T will throw MethodAccessException.
296- var fieldTypeIsAccessible = IsTypePubliclyAccessible ( fieldType . GetTypeInfo ( ) ) ;
293+ // Use object-based equality comparer for types that are not publicly accessible from the dynamic assembly (e.g., compiler-generated anonymous types).
294+ // Calling EqualityComparer<T>.get_Default() for a non-public T will throw MethodAccessException.
295+ var fieldTypeIsAccessible = IsTypePubliclyAccessible ( fieldType ) ;
297296 var equalityType = fieldTypeIsAccessible ? fieldType : typeof ( object ) ;
298297 var equalityComparerT = EqualityComparer . MakeGenericType ( equalityType ) ;
299298
@@ -428,7 +427,7 @@ private static Type EmitType(IList<DynamicProperty> properties, bool createParam
428427
429428 EmitEqualityOperators ( typeBuilder , equals ) ;
430429
431- return typeBuilder . CreateType ( ) ;
430+ return typeBuilder . CreateType ( ) ! ;
432431 }
433432
434433 /// <summary>
@@ -437,10 +436,10 @@ private static Type EmitType(IList<DynamicProperty> properties, bool createParam
437436 /// type arguments in EqualityComparer<T> from a dynamic assembly without causing
438437 /// a <see cref="MethodAccessException"/> at runtime.
439438 /// </summary>
440- private static bool IsTypePubliclyAccessible ( TypeInfo typeInfo )
439+ private static bool IsTypePubliclyAccessible ( Type typeInfo )
441440 {
442441 // Check if the type itself is public
443- if ( ! typeInfo . IsPublic && ! typeInfo . IsNestedPublic )
442+ if ( ! typeInfo . GetTypeInfo ( ) . IsPublic && ! typeInfo . GetTypeInfo ( ) . IsNestedPublic )
444443 {
445444 return false ;
446445 }
@@ -449,9 +448,9 @@ private static bool IsTypePubliclyAccessible(TypeInfo typeInfo)
449448 // all type arguments must also be publicly accessible.
450449 // Generic type definitions (e.g., List<>) have unbound type parameters
451450 // which are not concrete types and should not be checked.
452- if ( typeInfo . IsGenericType && ! typeInfo . IsGenericTypeDefinition )
451+ if ( typeInfo . GetTypeInfo ( ) . IsGenericType && ! typeInfo . GetTypeInfo ( ) . IsGenericTypeDefinition )
453452 {
454- return typeInfo . GetGenericArguments ( ) . All ( t => IsTypePubliclyAccessible ( t . GetTypeInfo ( ) ) ) ;
453+ return typeInfo . GetGenericArguments ( ) . All ( IsTypePubliclyAccessible ) ;
455454 }
456455
457456 return true ;
0 commit comments