diff --git a/CSharpRepl/TypeExtensions.cs b/CSharpRepl/TypeExtensions.cs index ee502f0..a0d097a 100644 --- a/CSharpRepl/TypeExtensions.cs +++ b/CSharpRepl/TypeExtensions.cs @@ -20,15 +20,12 @@ public static string ParseGenericArgs(this Type type) return returnTypeName.Replace($"`{args.Length}", $"<{string.Join(", ", returnArgs)}>"); } - [GeneratedRegex(@"\[,*\]")] - private static partial Regex ArrayRegex { get; } - private static string GetPrimitiveTypeName(Type type) { var typeName = type.Name; if (type.IsArray) { - typeName = ArrayRegex.Replace(typeName, ""); + typeName = ParseGenericArgs(type.GetElementType()!); } var returnValue = typeName switch @@ -47,6 +44,9 @@ private static string GetPrimitiveTypeName(Type type) "UInt16" => "ushort", "UInt32" => "uint", "UInt64" => "ulong", + "Object" => "object", + "IntPtr" => "nint", + "UIntPtr" => "nuint", _ => typeName };