Change: DisplayName of field with ShowAlchemySerializationData

This commit is contained in:
Akeit0 2024-03-21 11:48:50 +09:00
parent d9c9f4f809
commit af4832ea10
4 changed files with 12 additions and 12 deletions

View File

@ -153,9 +153,8 @@ namespace Alchemy.SourceGenerator
var typeGenerics = typeSymbol.IsGenericType
? "<" + string.Join(", ", typeSymbol.TypeParameters.Select(x => x.Name)) + ">"
: "";
var alchemySerializationDataName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)
.Replace("global::", "").Replace(".", "_");
var displayName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat).Replace("global::", "");
var alchemySerializationDataName = displayName.Replace(".", "_");
alchemySerializationDataName ="__alchemySerializationData_"+ ReplaceGenericsToCount(alchemySerializationDataName,genericsCount) ;
var inheritedOnBeforeSerialize = hasInheritedImplementation
@ -171,9 +170,9 @@ namespace Alchemy.SourceGenerator
or "Alchemy.Serialization.ShowAlchemySerializationDataAttribute");
var serializationDataAttributesCode = hasShowSerializationData
? "[global::Alchemy.Inspector.ReadOnly, global::UnityEngine.TextArea(3, 999), global::UnityEngine.SerializeField]"
? $"[global::Alchemy.Inspector.LabelText(\"Alchemy Serialization Data ({displayName})\"),global::Alchemy.Inspector.ReadOnly, global::UnityEngine.TextArea(3, 999), global::UnityEngine.SerializeField]"
: "[global::UnityEngine.HideInInspector, global::UnityEngine.SerializeField]";
// target class namespace
var ns = typeSymbol.ContainingNamespace.IsGlobalNamespace
? string.Empty

View File

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using Alchemy.Serialization;
using UnityEngine;
[AlchemySerialize]
public partial class InheritedSerializeTest : InheritedSerializeTestBase<string>
namespace Test
{
[AlchemySerializeField, NonSerialized] int? nullableInt;
[ShowAlchemySerializationData]
[AlchemySerialize]
public partial class InheritedSerializeTest : InheritedSerializeTestBase<string>
{
[AlchemySerializeField, NonSerialized] int? nullableInt;
}
}

View File

@ -3,11 +3,10 @@ using System.Collections.Generic;
using Alchemy.Serialization;
using UnityEngine;
[ShowAlchemySerializationData]
[AlchemySerialize]
public partial class InheritedSerializeTestBase<T> : MonoBehaviour
{
[AlchemySerializeField, NonSerialized] HashSet<T> set;
}