Repository: dotnet/runtime
File: src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs (C#)

Code before:

            Utf8String mangledName;

            switch (type.Category)
            {
                case TypeFlags.Array:
                    mangledName = new Utf8StringBuilder().Append("__MDArray"u8)
                                  .Append(EnterNameScopeSequence)
                                  .Append(GetMangledTypeName(((ArrayType)type).ElementType))
                                  .Append(DelimitNameScopeSequence)
                                  .Append(((ArrayType)type).Rank.ToStringInvariant())
                                  .Append(ExitNameScopeSequence).ToUtf8String();
                    break;
                case TypeFlags.SzArray:
                    mangledName = new Utf8StringBuilder().Append("__Array"u8)
                        .Append('<').Append(GetMangledTypeName(((ArrayType)type).ElementType)).Append('>').ToUtf8String();
                    break;
                case TypeFlags.ByRef:
                    mangledName = new Utf8StringBuilder()
                        .Append(GetMangledTypeName(((ByRefType)type).ParameterType))
                        .Append('<').Append("ByRef"u8).Append('>').ToUtf8String();
                    break;
                case TypeFlags.Pointer:
                    mangledName = new Utf8StringBuilder()
                        .Append(GetMangledTypeName(((PointerType)type).ParameterType))
                        .Append('<').Append("Pointer"u8).Append('>').ToUtf8String();
                    break;
                case TypeFlags.FunctionPointer:
                {
                    var fnPtrType = (FunctionPointerType)type;
                    var sb = new Utf8StringBuilder();
                    sb.Append("__FnPtr_"u8).Append(((int)fnPtrType.Signature.Flags).ToString("X2")).Append(EnterNameScopeSequence);
                    sb.Append(GetMangledTypeName(fnPtrType.Signature.ReturnType));

                    sb.Append(EnterNameScopeSequence);
                    for (int i = 0; i < fnPtrType.Signature.Length; i++)
                    {
                        if (i != 0)
                            sb.Append(DelimitNameScopeSequence);
                        sb.Append(GetMangledTypeName(fnPtrType.Signature[i]));
                    }
                    sb.Append(ExitNameScopeSequence);

                    sb.Append(ExitNameScopeSequence);
                    mangledName = sb.ToUtf8String();
                    break;
                }
                default:
                    // Case of a generic type. If `type' is a type definition we use the type name
                    // for mangling, otherwise we use the mangling of the type and its generic type
                    // parameters, e.g. A <B> becomes A_<___B_>_.

Review comment (suggestion):
```suggestion
                        .Append(EnterNameScopeSequence).Append("Pointer"u8).Append(ExitNameScopeSequence).ToUtf8String();
```

Code after:

            Utf8String mangledName;

            switch (type.Category)
            {
                case TypeFlags.Array:
                    mangledName = new Utf8StringBuilder().Append("__MDArray"u8)
                                  .Append(EnterNameScopeSequence)
                                  .Append(GetMangledTypeName(((ArrayType)type).ElementType))
                                  .Append(DelimitNameScopeSequence)
                                  .Append(((ArrayType)type).Rank.ToStringInvariant())
                                  .Append(ExitNameScopeSequence).ToUtf8String();
                    break;
                case TypeFlags.SzArray:
                    mangledName = new Utf8StringBuilder().Append("__Array"u8)
                        .Append(EnterNameScopeSequence).Append(GetMangledTypeName(((ArrayType)type).ElementType)).Append(ExitNameScopeSequence).ToUtf8String();
                    break;
                case TypeFlags.ByRef:
                    mangledName = new Utf8StringBuilder()
                        .Append(GetMangledTypeName(((ByRefType)type).ParameterType))
                        .Append(EnterNameScopeSequence).Append("ByRef"u8).Append(ExitNameScopeSequence).ToUtf8String();
                    break;
                case TypeFlags.Pointer:
                    mangledName = new Utf8StringBuilder()
                        .Append(GetMangledTypeName(((PointerType)type).ParameterType))
                        .Append(EnterNameScopeSequence).Append("Pointer"u8).Append(ExitNameScopeSequence).ToUtf8String();
                    break;
                case TypeFlags.FunctionPointer:
                {
                    var fnPtrType = (FunctionPointerType)type;
                    var sb = new Utf8StringBuilder();
                    sb.Append("__FnPtr_"u8).Append(((int)fnPtrType.Signature.Flags).ToString("X2")).Append(EnterNameScopeSequence);
                    sb.Append(GetMangledTypeName(fnPtrType.Signature.ReturnType));

                    sb.Append(EnterNameScopeSequence);
                    for (int i = 0; i < fnPtrType.Signature.Length; i++)
                    {
                        if (i != 0)
                            sb.Append(DelimitNameScopeSequence);
                        sb.Append(GetMangledTypeName(fnPtrType.Signature[i]));
                    }
                    sb.Append(ExitNameScopeSequence);

                    sb.Append(ExitNameScopeSequence);
                    mangledName = sb.ToUtf8String();
                    break;
                }
                default:
                    // Case of a generic type. If `type' is a type definition we use the type name
                    // for mangling, otherwise we use the mangling of the type and its generic type
                    // parameters, e.g. A <B> becomes A_<___B_>_.