Giter Club home page Giter Club logo

Comments (5)

jonorossi avatar jonorossi commented on August 16, 2024

The exception only occurs in the .NET 4.5 build because the code that sets the default value for optional parameters is conditionally compiled out in prior framework builds because the SetConstant method wouldn't have been available:

This looks like a bug in the .NET Framework 4.5 because the TypeBuilder doesn't handle decimal, and I'm not even sure which CorElementType would be reported for decimals:

Looks like GetCorElementType will return CorElementType.ValueType for System.Decimal:

from core.

fknx avatar fknx commented on August 16, 2024

I agree that it is pretty weird that a decimal may not be passed to the SetConstant method, but I am not sure that it is a bug. At least it is documented on MSDN:

defaultValue is restricted to the following types: Boolean, SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, UInt64, Single, Double, DateTime, Char, String, and Enum.

I am not sure about the consequences as I am not familiar with the TypeBuilder, but would it be possible to simply omit the SetConstant call for all decimals?

from core.

jonorossi avatar jonorossi commented on August 16, 2024

Ah yer, that method would have been there since early .NET days because the CLR has always supported optional parameters for COM interop.

I suspect that the documentation was written from the code. If you look at the doco for .NET Framework 2.0 it actually explicitly calls out Decimal should be null, however I think that has been fixed in later revisions of the documentation because passing null would actually throw an exception.

defaultValue is restricted to the following types: Boolean, SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, UInt64, Single, Double, DateTime, Char, String, and Enum. If the type of the parameter is Decimal or Object, defaultValue can only be null.

I see no reason why DP shouldn't just omit calls to SetConstant for decimals with a big glaring comment referring to the fact that the framework code can't handle them so it'll have to do. We work around a big pile of defects right through DP's code, so another one is no problem.

from core.

fknx avatar fknx commented on August 16, 2024

Sorry for responding this late, but I have now commited a fix for this issue and issued a pull request. Right now the issue does not affect us (as we are stuck with .NET 4.0) but it would be great if the fix could be added to a future release :)

Thank you for your help!

from core.

jonorossi avatar jonorossi commented on August 16, 2024

Fixed by #91. Thanks.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.