Skip to content

Commit

Permalink
Make code for this type resolution clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed May 9, 2021
1 parent e9d4b80 commit 6a1082b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Pose/IL/MethodRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public MethodBase Rewrite()
List<Type> parameterTypes = new List<Type>();
if (!m_method.IsStatic)
{
Type thisType = m_owningType.IsValueType ? m_owningType.MakeByRefType() : m_owningType;
thisType = m_isInterfaceDispatch ? typeof(object) : thisType;
Type thisType = m_isInterfaceDispatch ? typeof(object) : m_owningType;
if (!m_isInterfaceDispatch && m_owningType.IsValueType)
{
thisType = thisType.MakeByRefType();
}

parameterTypes.Add(thisType);
}

Expand Down
7 changes: 6 additions & 1 deletion src/Pose/IL/Stubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public static DynamicMethod GenerateStubForMethod(MethodInfo methodInfo)
List<Type> signatureParamTypes = new List<Type>();
if (!methodInfo.IsStatic)
{
Type thisType = methodInfo.DeclaringType.IsValueType ? methodInfo.DeclaringType.MakeByRefType() : methodInfo.DeclaringType;
Type thisType = methodInfo.DeclaringType;
if (thisType.IsValueType)
{
thisType = thisType.MakeByRefType();
}

signatureParamTypes.Add(thisType);
}

Expand Down

0 comments on commit 6a1082b

Please sign in to comment.