Skip to content
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

Allows non-public noargs constructors to be used when deserializing objects #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions hessiancsharp/io/CObjectDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class CObjectDeserializer : AbstractDeserializer
/// <summary>
/// Object type
/// </summary>
private Type m_type;
private readonly Type m_type;
/// <summary>
/// Hashmap with class fields (&lt;field name&gt;&lt;field info instance&gt;)
/// </summary>
Expand All @@ -67,7 +67,7 @@ public class CObjectDeserializer : AbstractDeserializer
/// deserialized</param>
public CObjectDeserializer(Type type)
{
this.m_type = type;
m_type = type;
for (; type!=null; type = type.BaseType)
{
FieldInfo [] fields = type.GetFields(
Expand Down Expand Up @@ -111,17 +111,22 @@ public override object ReadMap(AbstractHessianInput abstractHessianInput)
#if COMPACT_FRAMEWORK
object result = Activator.CreateInstance(this.m_type);
#else
object result = Activator.CreateInstance(this.m_type.Assembly.FullName, this.m_type.FullName).Unwrap();
// object result = Activator.CreateInstance(this.m_type);
// object result = null;
object result = Activator.CreateInstance(
m_type.Assembly.FullName,
m_type.FullName,
false,
BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
null,
null,
null,
null,
null)
.Unwrap();
#endif


return ReadMap(abstractHessianInput, result);

}


/// <summary>
/// Reads map
/// </summary>
Expand Down