Fix .NET generic class typename to match old mono style without inlined assembly name and ver

This commit is contained in:
Wojtek Figat
2023-03-27 17:30:48 +02:00
parent 510fc443e8
commit 4755c42d70
62 changed files with 133 additions and 65 deletions

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using FlaxEditor.Content;
using FlaxEngine.Utilities;
namespace FlaxEditor.Scripting
{

View File

@@ -8,6 +8,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using FlaxEditor.Content;
using FlaxEngine;
using FlaxEngine.Utilities;
namespace FlaxEditor.Scripting
{

View File

@@ -5,14 +5,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using FlaxEngine;
using FlaxEditor;
using FlaxEditor.Scripting;
namespace FlaxEditor.Scripting
namespace FlaxEngine.Utilities
{
/// <summary>
/// Editor scripting utilities and helper functions.
/// </summary>
public static class TypeUtils
partial class TypeUtils
{
/// <summary>
/// Custom list of scripting types containers. Can be used by custom scripting languages to provide types info for the editor.
@@ -35,34 +33,6 @@ namespace FlaxEditor.Scripting
return o != null ? new ScriptType(o.GetType()) : ScriptType.Null;
}
/// <summary>
/// Gets the typename full name.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The full typename of the type.</returns>
public static string GetTypeName(this Type type)
{
if (type.IsGenericType)
{
// For generic types (eg. Dictionary) FullName returns generic parameter types with fully qualified name so simplify it manually
var sb = new StringBuilder();
sb.Append(type.Namespace);
sb.Append('.');
sb.Append(type.Name);
sb.Append('[');
var genericArgs = type.GetGenericArguments();
for (var i = 0; i < genericArgs.Length; i++)
{
if (i != 0)
sb.Append(',');
sb.Append(genericArgs[i].GetTypeName());
}
sb.Append(']');
return sb.ToString();
}
return type.FullName;
}
/// <summary>
/// Gets the typename name for UI.
/// </summary>
@@ -131,7 +101,7 @@ namespace FlaxEditor.Scripting
if (type.IsValueType)
{
var value = type.CreateInstance();
Utilities.Utils.InitDefaultValues(value);
FlaxEditor.Utilities.Utils.InitDefaultValues(value);
return value;
}
if (ScriptType.Object.IsAssignableFrom(type))
@@ -139,7 +109,7 @@ namespace FlaxEditor.Scripting
if (type.CanCreateInstance)
{
var value = type.CreateInstance();
Utilities.Utils.InitDefaultValues(value);
FlaxEditor.Utilities.Utils.InitDefaultValues(value);
return value;
}
return null;
@@ -366,7 +336,7 @@ namespace FlaxEditor.Scripting
}
}
if (!Content.Settings.GameSettings.OptionalPlatformSettings.Contains(typeName))
if (!FlaxEditor.Content.Settings.GameSettings.OptionalPlatformSettings.Contains(typeName))
Editor.LogWarning($"Failed to find type '{typeName}'.");
return ScriptType.Null;
}