Hello
I have a problem declaring a C# method with Nullable parameters having
DefaultParameterValue attributes:
public void SomeMethod([DefaultParameterValue(1f)] float f) { } //works
public void SomeMethod([DefaultParameterValue(1f)] float? f) { } //fails
public void SomeMethod([DefaultParameterValue(null)] int? i) { } //fails
public void SomeMethod([DefaultParameterValue((byte?)1)] byte? f) { } //fails
The second and third fail with Compiler Error CS1908: "The type of the
argument to the DefaultValue attribute must match the parameter type",
the last one with CS0182: "An attribute argument must be a constant
expression, typeof expression or array creation expression of an
attribute parameter type"
Is that a bug in the compiler that he doesn't recognize "1f" or "null"
as valid values of "float?", or am I making a mistake?
I realize that it's not exactly OT, but I guess that many IronPython
users will use DefaultParameterValue attributes to get nice pythonic
C# methods exposed to IronPython, and maybe one of you has already
encountered this problem?
Best regards,
Korbinian
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com