Skip to content

Commit 9ba33ae

Browse files
committed
feat: global prefix
1 parent ced0100 commit 9ba33ae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Runtime/USGFullNameOf.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public static class USGFullNameOf
66
{
77
///<summary>Refactor-ready full name generator.</summary>
88
///<remarks>Ex: usg&lt;MyClass.InnerClass&gt;(nameof(Something), "Generated")</remarks>
9-
///<returns>Full.Namespace.To.MyClass.InnerClass.Something.Generated</returns>
9+
///<returns>global::Full.Namespace.To.MyClass.InnerClass.Something.Generated</returns>
1010
public static string usg<T>(params string[] memberNames)
1111
{
1212
var ret = GetTypeDef(typeof(T), true);
@@ -15,7 +15,7 @@ public static string usg<T>(params string[] memberNames)
1515

1616
for (int i = 0; i < memberNames.Length; i++)
1717
{
18-
if (memberNames[i]?.Length is null or 0)
18+
if (memberNames[i] == null || memberNames[i].Length == 0)
1919
continue;
2020
ret += '.' + memberNames[i];
2121
}
@@ -63,7 +63,8 @@ public static string usg(object valueOrType, bool isFullName = true)
6363
t = t.GetElementType();
6464
}
6565

66-
if (!TryGetBuiltinDef(ref ret) && isFullName && ns.Length > 0)
66+
bool isBuiltinType = TryGetBuiltinDef(ref ret);
67+
if (!isBuiltinType && isFullName && ns.Length > 0)
6768
ret = ns + ret;
6869

6970
if (t.IsGenericType)
@@ -85,7 +86,7 @@ public static string usg(object valueOrType, bool isFullName = true)
8586
arrayDim--;
8687
}
8788

88-
if (isFullName)
89+
if (!isBuiltinType && isFullName)
8990
ret = "global::" + ret;
9091

9192
return ret;

0 commit comments

Comments
 (0)