From d7d79e7e036f291a6fac87193c1c93833596ac4c Mon Sep 17 00:00:00 2001
From: Aaron Robinson <aaronrobin1234@gmail.com>
Date: Tue, 12 Nov 2024 20:58:07 -0600
Subject: [PATCH] Improve the array handling of ParseGenericArgs

---
 CSharpRepl/TypeExtensions.cs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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
             };