Allow private parameterless constructors to be called

Vote for new features, or make your own requests here.
Post Reply

Allow private parameterless constructors to be called

Yes, I would like this feature.
0
No votes
No, I would not like this feature.
0
No votes
 
Total votes: 0

User avatar
Joel
Moodkie Staff
Posts: 5037
Joined: Wed Nov 07, 2012 10:32 pm

Allow private parameterless constructors to be called

Post by Joel »

Status

Requested

Complexity

7/10

Description

Allow private parameterless constructors to be called instead of just public parameterless constructors.

Note that private constructors have special meaning in CSharp and they are not necessarily designed for this purpose.

This would also require a custom implementation of Activator.CreateInstance for .NET Core platforms (e.g. Universal Windows) as this does not allow private constructors to be called. Instead the constructor would need to be invoked via reflection, and all error handling associated with that would also need to be coded.

Useful anecdote from Falondrian via Unity thread:
Also look for private parameterless constructors. Private constructors is a common pattern for serializer support, so in "normal" code the constructor doesnt get exposed. Right now I have to create ES3 types for these classes which is a bit tedious.
Note that it may be simpler to implement GetUninitializedObject so that there isn't a requirement for parameterless constructors.
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply