declaration order sorting

This commit is contained in:
honzapatCZ
2021-03-04 19:46:27 +01:00
parent 9c80354acf
commit 4593e4c669
3 changed files with 35 additions and 2 deletions
@@ -75,6 +75,8 @@ namespace FlaxEditor.Content
}
}
public int MetadataToken => 0;
/// <inheritdoc />
public bool HasAttribute(Type attributeType, bool inherit)
{
@@ -195,6 +197,8 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public ScriptType ValueType => _returnType;
public int MetadataToken => 0;
/// <inheritdoc />
public bool HasAttribute(Type attributeType, bool inherit)
{
@@ -173,8 +173,16 @@ namespace FlaxEditor.CustomEditors.Editors
return string.Compare(Display.Group, other.Display.Group, StringComparison.InvariantCulture);
}
// By name
return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture);
// By declaration order
if (Info.MetadataToken > other.Info.MetadataToken)
return 1;
else if (Info.MetadataToken < other.Info.MetadataToken)
return -1;
else
{
// By name
return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture);
}
}
return 0;
+21
View File
@@ -40,6 +40,22 @@ namespace FlaxEditor.Scripting
/// </summary>
public string Name => _managed?.Name ?? _custom?.Name;
/// <summary>
/// Gets a metadata token for sorting so it may not be the actual token.
/// </summary>
public int MetadataToken
{
get
{
if (_managed != null && IsProperty)
{
ScriptMemberInfo finfo = DeclaringType.GetField(string.Format("<{0}>k__BackingField", Name), BindingFlags.Instance | BindingFlags.NonPublic);
return finfo.MetadataToken;
}
return _managed?.MetadataToken ?? _custom?.MetadataToken ?? 0;
}
}
/// <summary>
/// Gets a value indicating whether the type is declared public.
/// </summary>
@@ -1444,6 +1460,11 @@ namespace FlaxEditor.Scripting
/// </summary>
string Name { get; }
/// <summary>
/// Gets a metadata token for sorting so it may not be the actual token.
/// </summary>
int MetadataToken { get; }
/// <summary>
/// Gets a value indicating whether the type is declared public.
/// </summary>