-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Activator.CreateInstance fails to call constructor for value types #6536
Comments
This code makes incorrect assumption that value types have no default constructor. |
@gkhanna79 Could you please reassign it as appropriate? |
@ramarag PTAL |
I read an article earlier today about Wire Serialiser where one of the optimisations was able to determine whether the constructor of a type had any side effects by counting the number of IL instructions. The author intelligently determined that any constructor with fewer than 8 IL bytes, accessed through GetILAsByteArray(), must have no side effects. I am not familiar with the coreclr code based but I presume that the same optimisation can be used such that instead of
we can have
For reference: This would then also provide a benefit to reference types which do not override the default constructor, although I am not sure whether you would also need to check all base types and whether that would be more expensive. Maybe it could be an optimisation only for those types inheriting from Object or ValueType? |
@ramarag Did you take a look at this? |
@kouvel Can you PTAL? |
Fixes #6843 - Disabled caching struct types that have custom parameterless constructors in `ActivatorCache` - Removed some things relevant to security, which don't apply to CoreCLR
…10778) Fixes #6843 - Disabled caching struct types that have custom parameterless constructors in `ActivatorCache` - Removed some things relevant to security, which don't apply to CoreCLR
…otnet#10778) Fixes #6843 - Disabled caching struct types that have custom parameterless constructors in `ActivatorCache` - Removed some things relevant to security, which don't apply to CoreCLR
See dotnet/roslyn#1029 and http://roslyn.codeplex.com/workitem/465 for some context.
The text was updated successfully, but these errors were encountered: