Change: naming of generated fields and functions.

This commit is contained in:
Akeit0 2024-03-21 11:29:46 +09:00
parent cb32709324
commit d9c9f4f809
4 changed files with 20 additions and 38 deletions

View File

@ -156,12 +156,14 @@ namespace Alchemy.SourceGenerator
var alchemySerializationDataName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)
.Replace("global::", "").Replace(".", "_");
alchemySerializationDataName = ReplaceGenericsToCount(alchemySerializationDataName,genericsCount) + "_alchemySerializationData";
alchemySerializationDataName ="__alchemySerializationData_"+ ReplaceGenericsToCount(alchemySerializationDataName,genericsCount) ;
var inheritedSerializationCallback = hasInheritedImplementation
? "base.SerializationCallback_AlchemyImpl(isBeforeSerialize);"
var inheritedOnBeforeSerialize = hasInheritedImplementation
? "base.__AlchemyOnBeforeSerialize();"
: string.Empty;
var inheritedOnAfterDeserialize = hasInheritedImplementation
? "base.__AlchemyOnAfterDeserialize();"
: string.Empty;
var hasShowSerializationData = typeSymbol.GetAttributes().Any(x => x.AttributeClass.Name
is "ShowAlchemySerializationData"
or "ShowAlchemySerializationDataAttribute"
@ -218,29 +220,28 @@ catch (global::System.Exception ex)
{{
void global::UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize()
{{
SerializationCallback_AlchemyImpl(false);
__AlchemyOnAfterDeserialize();
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnAfterDeserialize();
}}
void global::UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize()
{{
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnBeforeSerialize();
SerializationCallback_AlchemyImpl(true);
__AlchemyOnBeforeSerialize();
}}
protected {(hasInheritedImplementation ? "new" : "")} void SerializationCallback_AlchemyImpl(bool isBeforeSerialize = false)
{{
{inheritedSerializationCallback}
if (isBeforeSerialize)
{{
{alchemySerializationDataName}.UnityObjectReferences.Clear();
{onBeforeSerializeCodeBuilder}
}}
else
{{
{onAfterDeserializeCodeBuilder}
}}
protected {(hasInheritedImplementation ? "new" : "")} void __AlchemyOnAfterDeserialize()
{{
{inheritedOnAfterDeserialize}
{onAfterDeserializeCodeBuilder}
}}
protected {(hasInheritedImplementation ? "new" : "")} void __AlchemyOnBeforeSerialize()
{{
{inheritedOnBeforeSerialize}
{alchemySerializationDataName}.UnityObjectReferences.Clear();
{onBeforeSerializeCodeBuilder}
}}
[global::System.Serializable]

View File

@ -246,7 +246,7 @@ namespace Alchemy.Editor
{
declaredType = declaredType.GetGenericTypeDefinition();
}
var dataName = declaredType.FullName.Replace("`","").Replace(".", "_") + "_alchemySerializationData";
var dataName ="__alchemySerializationData_"+ declaredType.FullName.Replace("`","").Replace(".", "_") ;
SerializedProperty GetProperty() => findPropertyFunc?.Invoke(dataName)
.FindPropertyRelative(memberInfo.Name);

View File

@ -18,21 +18,11 @@ PluginImporter:
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
AndroidSharedLibraryType: Executable
CPU: ARMv7
- first:
Any:
second:
@ -76,15 +66,6 @@ PluginImporter:
enabled: 0
settings:
CPU: AnyCPU
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant: