Skip to content

Activator.CreateInstance fails to call constructor for value types #6536

Closed
@gafter

Description

@gafter

See dotnet/roslyn#1029 and http://roslyn.codeplex.com/workitem/465 for some context.

The issue is basically an optimization introduced in Activator.CreateInstance around CLR 4.0 and present ever since. The optimization assumes that parameterless instantiation of generic T type does not cause sideeffects if T is found to be a struct and therefore instances can be cached. Parameterless struct constructors (which are permitted by spec) violate such assumptions and make optimization observable.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions