`Expression.Bind` should throw `ArgumentException` if called with `FieldInfo` for a global field. The exception is thrown from validation of the (null) `DeclaringType` (see https://github.com/dotnet/corefx/pull/15318).
Mono returns `"<Module>"` in this case and doesn't throw so the test fails.
Fixes mono/mono#14917 .
Commit migrated from https://github.com/mono/mono/commit/
e8d7f7c0045a38c41a70f6d0a21ef3ccf9a21662
# https://github.com/mono/mono/issues/14912
-nomethod System.Linq.Expressions.Tests.ArrayBoundsTests.NewArrayBounds*
-# Expected exception to be thrown. None is
-# https://github.com/mono/mono/issues/14917
--nomethod System.Linq.Expressions.Tests.BindTests.GlobalField
-
# Exceptions are different.
# https://github.com/mono/mono/issues/14918
-nomethod System.Linq.Expressions.Tests.BindTests.ConstantField
}
public override Type DeclaringType {
get {
- return GetParentType (true);
+ Type parentType = GetParentType (true);
+ return parentType.Name != "<Module>" ? parentType : null;
}
}
public override string Name {
}
void CheckGeneric () {
- if (DeclaringType.ContainsGenericParameters)
+ Type declaringType = DeclaringType;
+ if (declaringType != null && declaringType.ContainsGenericParameters)
throw new InvalidOperationException ("Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.");
}