Skip to content

Commit

Permalink
Fix issues with type resolver not finding some Udon types and methods
Browse files Browse the repository at this point in the history
- Fix special case on constructor construction for 0 length constructors where Udon adds an additional __ to the constructor name
- Fix issues with finding nested array types
- Fix issues in cases where the full name on a type is null
- Add special case for IEnumerableT
  • Loading branch information
MerlinVR committed Mar 3, 2020
1 parent a9c4d87 commit 2e8d35d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Assets/UdonSharp/Editor/UdonSharpResolverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ public string GetUdonTypeName(System.Type externType)

string externTypeName = externType.GetNameWithoutGenericArity();
string typeNamespace = externType.Namespace;
if (typeNamespace == null && externType.IsArray)
{
externType = externType.GetElementType();
typeNamespace = externType.Namespace;
}

// Handle nested type names (+ sign in names)
if (externType.DeclaringType != null)
Expand Down Expand Up @@ -347,6 +352,10 @@ public string GetUdonTypeName(System.Type externType)
{
fullTypeName = "ListT";
}
else if (fullTypeName == "SystemCollectionsGenericIEnumerableT")
{
fullTypeName = "IEnumerableT";
}

fullTypeName = fullTypeName.Replace("VRCUdonUdonBehaviour", "VRCUdonCommonInterfacesIUdonEventReceiver");

Expand Down Expand Up @@ -380,7 +389,7 @@ public string GetUdonMethodName(MethodBase externMethod, bool validate = true, L
isUdonSharpBehaviour = true;
}

string functionNamespace = SanitizeTypeName(methodSourceType.FullName).Replace("VRCUdonUdonBehaviour", "VRCUdonCommonInterfacesIUdonEventReceiver");
string functionNamespace = SanitizeTypeName(methodSourceType.FullName ?? methodSourceType.Namespace + methodSourceType.Name).Replace("VRCUdonUdonBehaviour", "VRCUdonCommonInterfacesIUdonEventReceiver");

string methodName = $"__{externMethod.Name.Trim('_').TrimStart('.')}";
ParameterInfo[] methodParams = externMethod.GetParameters();
Expand All @@ -403,6 +412,8 @@ public string GetUdonMethodName(MethodBase externMethod, bool validate = true, L
paramStr += $"_{GetUdonTypeName(parameterInfo.ParameterType)}";
}
}
else if (externMethod is ConstructorInfo)
paramStr += "__";

string returnStr = "";

Expand Down

0 comments on commit 2e8d35d

Please sign in to comment.