diff options
author | stakx <stakx@eml.cc> | 2018-05-07 18:28:37 +0200 |
---|---|---|
committer | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2018-05-07 09:28:37 -0700 |
commit | dbcfd2f9d18a595757194202de518b62ae9eb9f7 (patch) | |
tree | 49f9f9277c558f4a71611a1347718637b88ea11a | |
parent | fceac03e8202fb07dc1bb3b4f3ec3cf0921e12de (diff) | |
download | coreclr-dbcfd2f9d18a595757194202de518b62ae9eb9f7.tar.gz coreclr-dbcfd2f9d18a595757194202de518b62ae9eb9f7.tar.bz2 coreclr-dbcfd2f9d18a595757194202de518b62ae9eb9f7.zip |
Reflection: Fix DefaultValue for optional DateTime (#17877)
Querying the default value of an optional `DateTime` parameter using
`ParameterInfo.DefaultValue` can throw a `FormatException` if that
default value is a null constant in metadata, which is how the C#
compiler encodes a default value of `default(DateTime)`.
This commit fixes that error by adding the proper handling for null
metadata constants with `DateTime` parameters.
-rw-r--r-- | src/mscorlib/src/System/Reflection/MdConstant.cs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Reflection/MdConstant.cs b/src/mscorlib/src/System/Reflection/MdConstant.cs index 8e5b65724d..7337039908 100644 --- a/src/mscorlib/src/System/Reflection/MdConstant.cs +++ b/src/mscorlib/src/System/Reflection/MdConstant.cs @@ -94,6 +94,9 @@ namespace System.Reflection defaultValue = buffer; break; + case CorElementType.Class: + return null; + default: throw new FormatException(SR.Arg_BadLiteralFormat); #endregion |