When accessing ParameterInfo.HasDefaultValue for a parameter of type System.DateTime, I
get an unexpected System.FormatException.
ParameterInfo.Attributes is correctly set to Optional | HasDefault.
If the parameter is of any other value type (e.g. decimal or some custom struct) the
property works as expected. There is something specific to DateTime in the implementation
of RuntimeParameterInfo.GetDefaultValueInternal() which is broken.
Code snippet to test:
public void Usage()
{
var type = typeof (Foo);
var ctor = type.GetConstructors ()[0];
var para = ctor.GetParameters ()[0];
// This throws an exception...
Assert.True (para.HasDefaultValue);
}
static class Foo
{
public Foo(System.DateTime value = default (System.DateTime)) { }
}
Exception:

When accessing
ParameterInfo.HasDefaultValuefor a parameter of typeSystem.DateTime, Iget an unexpected
System.FormatException.ParameterInfo.Attributesis correctly set toOptional | HasDefault.If the parameter is of any other value type (e.g.
decimalor some custom struct) theproperty works as expected. There is something specific to
DateTimein the implementationof
RuntimeParameterInfo.GetDefaultValueInternal()which is broken.Code snippet to test:
Exception: