├── .gitignore ├── .travis.yml ├── Assets ├── FullSerializer.meta └── FullSerializer │ ├── Source.meta │ ├── Source │ ├── Aot.meta │ ├── Aot │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── fsAotConfigurationEditor.cs │ │ │ └── fsAotConfigurationEditor.cs.meta │ │ ├── fsAotCompilationManager.cs │ │ ├── fsAotCompilationManager.cs.meta │ │ ├── fsAotConfiguration.cs │ │ ├── fsAotConfiguration.cs.meta │ │ ├── fsAotVersionInfo.cs │ │ ├── fsAotVersionInfo.cs.meta │ │ ├── fsIAotConverter.cs │ │ └── fsIAotConverter.cs.meta │ ├── Converters.meta │ ├── Converters │ │ ├── Unity.meta │ │ ├── Unity │ │ │ ├── AnimationCurve_DirectConverter.cs │ │ │ ├── AnimationCurve_DirectConverter.cs.meta │ │ │ ├── Bounds_DirectConverter.cs │ │ │ ├── Bounds_DirectConverter.cs.meta │ │ │ ├── GUIStyleState_DirectConverter.cs │ │ │ ├── GUIStyleState_DirectConverter.cs.meta │ │ │ ├── GUIStyle_DirectConverter.cs │ │ │ ├── GUIStyle_DirectConverter.cs.meta │ │ │ ├── Gradient_DirectConverter.cs │ │ │ ├── Gradient_DirectConverter.cs.meta │ │ │ ├── Keyframe_DirectConverter.cs │ │ │ ├── Keyframe_DirectConverter.cs.meta │ │ │ ├── LayerMask_DirectConverter.cs │ │ │ ├── LayerMask_DirectConverter.cs.meta │ │ │ ├── RectOffset_DirectConverter.cs │ │ │ ├── RectOffset_DirectConverter.cs.meta │ │ │ ├── Rect_DirectConverter.cs │ │ │ ├── Rect_DirectConverter.cs.meta │ │ │ ├── UnityEvent_Converter.cs │ │ │ └── UnityEvent_Converter.cs.meta │ │ ├── fsArrayConverter.cs │ │ ├── fsArrayConverter.cs.meta │ │ ├── fsDateConverter.cs │ │ ├── fsDateConverter.cs.meta │ │ ├── fsDictionaryConverter.cs │ │ ├── fsDictionaryConverter.cs.meta │ │ ├── fsEnumConverter.cs │ │ ├── fsEnumConverter.cs.meta │ │ ├── fsForwardConverter.cs │ │ ├── fsForwardConverter.cs.meta │ │ ├── fsGuidConverter.cs │ │ ├── fsGuidConverter.cs.meta │ │ ├── fsIEnumerableConverter.cs │ │ ├── fsIEnumerableConverter.cs.meta │ │ ├── fsKeyValuePairConverter.cs │ │ ├── fsKeyValuePairConverter.cs.meta │ │ ├── fsNullableConverter.cs │ │ ├── fsNullableConverter.cs.meta │ │ ├── fsPrimitiveConverter.cs │ │ ├── fsPrimitiveConverter.cs.meta │ │ ├── fsReflectedConverter.cs │ │ ├── fsReflectedConverter.cs.meta │ │ ├── fsTypeConverter.cs │ │ ├── fsTypeConverter.cs.meta │ │ ├── fsWeakReferenceConverter.cs │ │ └── fsWeakReferenceConverter.cs.meta │ ├── Internal.meta │ ├── Internal │ │ ├── fsCyclicReferenceManager.cs │ │ ├── fsCyclicReferenceManager.cs.meta │ │ ├── fsOption.cs │ │ ├── fsOption.cs.meta │ │ ├── fsPortableReflection.cs │ │ ├── fsPortableReflection.cs.meta │ │ ├── fsTypeExtensions.cs │ │ ├── fsTypeExtensions.cs.meta │ │ ├── fsVersionManager.cs │ │ ├── fsVersionManager.cs.meta │ │ ├── fsVersionedType.cs │ │ └── fsVersionedType.cs.meta │ ├── Reflection.meta │ ├── Reflection │ │ ├── fsMetaProperty.cs │ │ ├── fsMetaProperty.cs.meta │ │ ├── fsMetaType.cs │ │ ├── fsMetaType.cs.meta │ │ ├── fsReflectionUtility.cs │ │ ├── fsReflectionUtility.cs.meta │ │ ├── fsTypeCache.cs │ │ └── fsTypeCache.cs.meta │ ├── fsBaseConverter.cs │ ├── fsBaseConverter.cs.meta │ ├── fsConfig.cs │ ├── fsConfig.cs.meta │ ├── fsContext.cs │ ├── fsContext.cs.meta │ ├── fsConverter.cs │ ├── fsConverter.cs.meta │ ├── fsConverterRegistrar.cs │ ├── fsConverterRegistrar.cs.meta │ ├── fsData.cs │ ├── fsData.cs.meta │ ├── fsDirectConverter.cs │ ├── fsDirectConverter.cs.meta │ ├── fsExceptions.cs │ ├── fsExceptions.cs.meta │ ├── fsISerializationCallbacks.cs │ ├── fsISerializationCallbacks.cs.meta │ ├── fsIgnoreAttribute.cs │ ├── fsIgnoreAttribute.cs.meta │ ├── fsJsonParser.cs │ ├── fsJsonParser.cs.meta │ ├── fsJsonPrinter.cs │ ├── fsJsonPrinter.cs.meta │ ├── fsMemberSerialization.cs │ ├── fsMemberSerialization.cs.meta │ ├── fsObjectAttribute.cs │ ├── fsObjectAttribute.cs.meta │ ├── fsObjectProcessor.cs │ ├── fsObjectProcessor.cs.meta │ ├── fsPropertyAttribute.cs │ ├── fsPropertyAttribute.cs.meta │ ├── fsResult.cs │ ├── fsResult.cs.meta │ ├── fsSerializer.cs │ └── fsSerializer.cs.meta │ ├── Testing.meta │ └── Testing │ ├── Editor.meta │ ├── Editor │ ├── AbstractTypeRemappingTests.cs │ ├── AbstractTypeRemappingTests.cs.meta │ ├── ArrayTests.cs │ ├── ArrayTests.cs.meta │ ├── CallbackTests.cs │ ├── CallbackTests.cs.meta │ ├── CaseUnsensitiveDeserializationTests.cs │ ├── CaseUnsensitiveDeserializationTests.cs.meta │ ├── ConstructorTests.cs │ ├── ConstructorTests.cs.meta │ ├── CyclicReferenceTests.cs │ ├── CyclicReferenceTests.cs.meta │ ├── DateTimeTests.cs │ ├── DateTimeTests.cs.meta │ ├── DictionaryTests.cs │ ├── DictionaryTests.cs.meta │ ├── EnumTests.cs │ ├── EnumTests.cs.meta │ ├── ErrorRecoveryTests.cs │ ├── ErrorRecoveryTests.cs.meta │ ├── FloatJitterTests.cs │ ├── FloatJitterTests.cs.meta │ ├── IgnoreTypeTests.cs │ ├── IgnoreTypeTests.cs.meta │ ├── IndexerTests.cs │ ├── IndexerTests.cs.meta │ ├── InitialInstanceTests.cs │ ├── InitialInstanceTests.cs.meta │ ├── LegacyDataTests.cs │ ├── LegacyDataTests.cs.meta │ ├── MemberSerializationTests.cs │ ├── MemberSerializationTests.cs.meta │ ├── MinimalMetadataTests.cs │ ├── MinimalMetadataTests.cs.meta │ ├── ParseTests.cs │ ├── ParseTests.cs.meta │ ├── ProcessorTests.cs │ ├── ProcessorTests.cs.meta │ ├── PropertiesTests.cs │ ├── PropertiesTests.cs.meta │ ├── SpecifiedConverterTests.cs │ ├── SpecifiedConverterTests.cs.meta │ ├── VersionedTypeTests.cs │ ├── VersionedTypeTests.cs.meta │ ├── WarningPropagationTests.cs │ ├── WarningPropagationTests.cs.meta │ ├── fsForwardTests.cs │ └── fsForwardTests.cs.meta │ ├── RuntimeTests.meta │ ├── RuntimeTests │ ├── Providers.meta │ ├── Providers │ │ ├── CustomIEnumerableProvider.cs │ │ ├── CustomIEnumerableProvider.cs.meta │ │ ├── CustomListProvider.cs │ │ ├── CustomListProvider.cs.meta │ │ ├── CyclesProvider.cs │ │ ├── CyclesProvider.cs.meta │ │ ├── DateProvider.cs │ │ ├── DateProvider.cs.meta │ │ ├── EncodedDataProvider.cs │ │ ├── EncodedDataProvider.cs.meta │ │ ├── EnumProvider.cs │ │ ├── EnumProvider.cs.meta │ │ ├── GuidProvider.cs │ │ ├── GuidProvider.cs.meta │ │ ├── IDictionaryProvider.cs │ │ ├── IDictionaryProvider.cs.meta │ │ ├── KeyValuePairProvider.cs │ │ ├── KeyValuePairProvider.cs.meta │ │ ├── KeyedCollectionProvider.cs │ │ ├── KeyedCollectionProvider.cs.meta │ │ ├── NumberProvider.cs │ │ ├── NumberProvider.cs.meta │ │ ├── OptOutProvider.cs │ │ ├── OptOutProvider.cs.meta │ │ ├── PrivateFieldsProvider.cs │ │ ├── PrivateFieldsProvider.cs.meta │ │ ├── PropertiesProvider.cs │ │ ├── PropertiesProvider.cs.meta │ │ ├── QueueProvider.cs │ │ ├── QueueProvider.cs.meta │ │ ├── StackProvider.cs │ │ ├── StackProvider.cs.meta │ │ ├── TypeProvider.cs │ │ ├── TypeProvider.cs.meta │ │ ├── ValueHolder.cs │ │ └── ValueHolder.cs.meta │ ├── RuntimeTestRunner.cs │ └── RuntimeTestRunner.cs.meta │ ├── test_scene.unity │ └── test_scene.unity.meta ├── Automation ├── UnityEngine.UI.dll ├── UnityEngine.dll └── compile.sh ├── BuildFiles ├── ProjectFiles │ ├── CommonData.csproj │ ├── FullSerializer - NoUnity.csproj │ ├── FullSerializer - Unity - WinRT.csproj │ ├── FullSerializer - Unity.csproj │ └── FullSerializer.sln └── compile.sh ├── LICENSE.md ├── LICENSE.md.meta ├── LIMITATIONS.md ├── LIMITATIONS.md.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset ├── README.md ├── README.md.meta ├── Scripts ├── build.sh ├── install.sh ├── make_dlls.sh └── postinstall.js ├── VERSION.md ├── VERSION.md.meta ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Unity generated 2 | Temp/ 3 | Obj/ 4 | Build 5 | Library/ 6 | ProjectSettings/ 7 | 8 | # IDE / Tooling 9 | .vs/ 10 | .vscode/ 11 | /*.userprefs 12 | /*.csproj 13 | /*.pidb 14 | /*.suo 15 | /*.sln* 16 | /*.user 17 | /*.unityproj 18 | /*.booproj 19 | /.idea*/ 20 | 21 | # OS generated 22 | .DS_Store* 23 | ._* 24 | .Spotlight-V100 25 | .Trashes 26 | ehthumbs.db 27 | Thumbs.db 28 | Desktop.ini 29 | 30 | Assets/Editor 31 | Assets/Editor.meta 32 | Assets/Haste 33 | Assets/Haste.meta 34 | Assets/VSCode 35 | Assets/VSCode.meta 36 | Assets/MyTest.cs 37 | Assets/MyTest.cs.meta 38 | Assets/WSATestCertificate.pfx 39 | Assets/WSATestCertificate.pfx.meta 40 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: csharp 3 | before_install: 4 | - git submodule update --init --recursive 5 | script: 6 | - ./Automation/compile.sh 7 | deploy: 8 | provider: releases 9 | api_key: 10 | secure: PF8i4NWyg01RYa9ThMTviLpl96HYDDd7AHWKytg9XWKMy0T8pzhqL3NnjwDBk1QhcG69MaGSL1tU8BtxJPJQrBKGUtMHwZqb33oaaLNZ9lAbcm1J/oKywpCkBE+1eTCodwlYOl3U9htzacIhXt60HTO1bPVOboq0iBOdt5YGJ0Q+5D2CeBVr7QblVf7RbHGHmM28WArmmsCfEgyiQ+e8od9xyxijPSW5o6Jkg4/HYBUFV69G1TWIL61nbZLqlhrMu+YflAiL4Wt3/UyLKTICU5DP8LuBnabZYqKoXBxiR+262wytyM/jrLJ3CQQiU+0a0D5rxQMJiqdj2tGgHLqws/Xw+hiOkbolEZZGCugTVJOvkHeU92KuNd3aUtUkM2qURPnT2uhs/2oNa22JDR3rsI40kRttbTSFaO7cobOm1tFXGTAhkvCbBJvdOaQRIglrXxSTCjvBBctCD4oyaL1H3McXo2fUKpsl9HVh/BoTeze8dPZmIluPqxHBVoMXZ/qhXe4jDZBy/PSsruDKysXP6sxEKV3yvX9AmI5mlGPy+90vIl+IdTr6hXkMdJtbWJmNoSYS4iOSUFpq6jBQPpr7MkeywM8mOrj+9h1YrInCT5Jp1B7tGbbmJOFi54o/F4Ioxd5H0sI1YqN5OnFa4JqJ3hENjsoLPEfbwD+xIPKhsqI= 11 | file: 12 | - FullSerializer-DLLs.zip 13 | - FullSerializer-Source.zip 14 | on: 15 | repo: jacobdufault/fullserializer 16 | tags: true 17 | skip_cleanup: true 18 | -------------------------------------------------------------------------------- /Assets/FullSerializer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7b7078781dc3564484a8eedbabcd1e3 3 | folderAsset: yes 4 | timeCreated: 1425589568 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9272d2c06c7657b4ab1a48e59c71ca8b 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b31422f318c94997a2f2f4355171037 3 | folderAsset: yes 4 | timeCreated: 1480555092 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5531b3a648944071a3012cdcdba80fc 3 | folderAsset: yes 4 | timeCreated: 1480555092 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/Editor/fsAotConfigurationEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 037e28781aae34c1ca70be2bbeb83c7d 3 | timeCreated: 1480555092 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsAotCompilationManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2bc880fbc9d241329a22ff808ff7571 3 | timeCreated: 1480555092 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsAotConfiguration.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | [CreateAssetMenu(menuName = "Full Serializer AOT Configuration")] 8 | public class fsAotConfiguration : ScriptableObject { 9 | public enum AotState { 10 | Default, Enabled, Disabled 11 | } 12 | 13 | [Serializable] 14 | public struct Entry { 15 | public AotState State; 16 | public string FullTypeName; 17 | 18 | public Entry(Type type) { 19 | FullTypeName = type.FullName; 20 | State = AotState.Default; 21 | } 22 | 23 | public Entry(Type type, AotState state) { 24 | FullTypeName = type.FullName; 25 | State = state; 26 | } 27 | } 28 | public List aotTypes = new List(); 29 | public string outputDirectory = "Assets/AotModels"; 30 | 31 | public bool TryFindEntry(Type type, out Entry result) { 32 | string searchFor = type.FullName; 33 | foreach (Entry entry in aotTypes) { 34 | if (entry.FullTypeName == searchFor) { 35 | result = entry; 36 | return true; 37 | } 38 | } 39 | 40 | result = default(Entry); 41 | return false; 42 | } 43 | 44 | public void UpdateOrAddEntry(Entry entry) { 45 | for (int i = 0; i < aotTypes.Count; ++i) { 46 | if (aotTypes[i].FullTypeName == entry.FullTypeName) { 47 | aotTypes[i] = entry; 48 | return; 49 | } 50 | } 51 | 52 | aotTypes.Add(entry); 53 | } 54 | } 55 | } 56 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsAotConfiguration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8ec4e71611a049c195a9e7464f46334 3 | timeCreated: 1480555092 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsAotVersionInfo.cs: -------------------------------------------------------------------------------- 1 | using FullSerializer.Internal; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// Version information stored on an AOT model. This is used to determine 6 | /// if the AOT model is up to date. 7 | /// 8 | public struct fsAotVersionInfo { 9 | public struct Member { 10 | public string MemberName; 11 | public string JsonName; 12 | public string StorageType; 13 | public string OverrideConverterType; 14 | 15 | public Member(fsMetaProperty property) { 16 | MemberName = property.MemberName; 17 | JsonName = property.JsonName; 18 | StorageType = property.StorageType.CSharpName(true); 19 | OverrideConverterType = null; 20 | if (property.OverrideConverterType != null) 21 | OverrideConverterType = property.OverrideConverterType.CSharpName(); 22 | } 23 | 24 | public override bool Equals(object obj) { 25 | if (obj is Member == false) 26 | return false; 27 | return this == ((Member)obj); 28 | } 29 | public override int GetHashCode() { 30 | return 31 | MemberName.GetHashCode() + 32 | (17 * JsonName.GetHashCode()) + 33 | (17 * StorageType.GetHashCode()) + 34 | (string.IsNullOrEmpty(OverrideConverterType) ? 0 : 17 * OverrideConverterType.GetHashCode()); 35 | } 36 | public static bool operator ==(Member a, Member b) { 37 | return a.MemberName == b.MemberName && 38 | a.JsonName == b.JsonName && 39 | a.StorageType == b.StorageType && 40 | a.OverrideConverterType == b.OverrideConverterType; 41 | } 42 | public static bool operator !=(Member a, Member b) { 43 | return !(a == b); 44 | } 45 | } 46 | 47 | public bool IsConstructorPublic; 48 | public Member[] Members; 49 | } 50 | 51 | 52 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsAotVersionInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32c07201cc4594e4ba2d95970c54c705 3 | timeCreated: 1480555092 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsIAotConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// Interface that AOT generated converters extend. Used to check to see if 6 | /// the AOT converter is up to date. 7 | /// 8 | public interface fsIAotConverter { 9 | Type ModelType { get; } 10 | fsAotVersionInfo VersionInfo { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Aot/fsIAotConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4aeef439e364442ea22128e6bc172be 3 | timeCreated: 1480555092 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e294e082a4f8d4a43ae3e07ab9c0d52d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec452919b13057d47ba7b28425969b96 3 | folderAsset: yes 4 | timeCreated: 1427576137 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/AnimationCurve_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.AnimationCurve_DirectConverter Register_AnimationCurve_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class AnimationCurve_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(AnimationCurve model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "keys", model.keys); 18 | result += SerializeMember(serialized, null, "preWrapMode", model.preWrapMode); 19 | result += SerializeMember(serialized, null, "postWrapMode", model.postWrapMode); 20 | 21 | return result; 22 | } 23 | 24 | protected override fsResult DoDeserialize(Dictionary data, ref AnimationCurve model) { 25 | var result = fsResult.Success; 26 | 27 | var t0 = model.keys; 28 | result += DeserializeMember(data, null, "keys", out t0); 29 | model.keys = t0; 30 | 31 | var t1 = model.preWrapMode; 32 | result += DeserializeMember(data, null, "preWrapMode", out t1); 33 | model.preWrapMode = t1; 34 | 35 | var t2 = model.postWrapMode; 36 | result += DeserializeMember(data, null, "postWrapMode", out t2); 37 | model.postWrapMode = t2; 38 | 39 | return result; 40 | } 41 | 42 | public override object CreateInstance(fsData data, Type storageType) { 43 | return new AnimationCurve(); 44 | } 45 | } 46 | } 47 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/AnimationCurve_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de4871d163dc05c4e879ab3bd2d1b0a9 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Bounds_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.Bounds_DirectConverter Register_Bounds_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class Bounds_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(Bounds model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "center", model.center); 18 | result += SerializeMember(serialized, null, "size", model.size); 19 | 20 | return result; 21 | } 22 | 23 | protected override fsResult DoDeserialize(Dictionary data, ref Bounds model) { 24 | var result = fsResult.Success; 25 | 26 | var t0 = model.center; 27 | result += DeserializeMember(data, null, "center", out t0); 28 | model.center = t0; 29 | 30 | var t1 = model.size; 31 | result += DeserializeMember(data, null, "size", out t1); 32 | model.size = t1; 33 | 34 | return result; 35 | } 36 | 37 | public override object CreateInstance(fsData data, Type storageType) { 38 | return new Bounds(); 39 | } 40 | } 41 | } 42 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Bounds_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fe9630466a01c34fba9de74b67e17f6 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/GUIStyleState_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.GUIStyleState_DirectConverter Register_GUIStyleState_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class GUIStyleState_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(GUIStyleState model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "background", model.background); 18 | result += SerializeMember(serialized, null, "textColor", model.textColor); 19 | 20 | return result; 21 | } 22 | 23 | protected override fsResult DoDeserialize(Dictionary data, ref GUIStyleState model) { 24 | var result = fsResult.Success; 25 | 26 | var t0 = model.background; 27 | result += DeserializeMember(data, null, "background", out t0); 28 | model.background = t0; 29 | 30 | var t2 = model.textColor; 31 | result += DeserializeMember(data, null, "textColor", out t2); 32 | model.textColor = t2; 33 | 34 | return result; 35 | } 36 | 37 | public override object CreateInstance(fsData data, Type storageType) { 38 | return new GUIStyleState(); 39 | } 40 | } 41 | } 42 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/GUIStyleState_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67b4783438fecdb4399aa4737e11776b 3 | timeCreated: 1455511482 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/GUIStyle_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08c93192f19b1a74a91771d664d38f0b 3 | timeCreated: 1455511482 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Gradient_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.Gradient_DirectConverter Register_Gradient_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class Gradient_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(Gradient model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "alphaKeys", model.alphaKeys); 18 | result += SerializeMember(serialized, null, "colorKeys", model.colorKeys); 19 | 20 | return result; 21 | } 22 | 23 | protected override fsResult DoDeserialize(Dictionary data, ref Gradient model) { 24 | var result = fsResult.Success; 25 | 26 | var t0 = model.alphaKeys; 27 | result += DeserializeMember(data, null, "alphaKeys", out t0); 28 | model.alphaKeys = t0; 29 | 30 | var t1 = model.colorKeys; 31 | result += DeserializeMember(data, null, "colorKeys", out t1); 32 | model.colorKeys = t1; 33 | 34 | return result; 35 | } 36 | 37 | public override object CreateInstance(fsData data, Type storageType) { 38 | return new Gradient(); 39 | } 40 | } 41 | } 42 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Gradient_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 064742214cced30408a50448cc56cf32 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Keyframe_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.Keyframe_DirectConverter Register_Keyframe_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class Keyframe_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(Keyframe model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "time", model.time); 18 | result += SerializeMember(serialized, null, "value", model.value); 19 | result += SerializeMember(serialized, null, "tangentMode", model.tangentMode); 20 | result += SerializeMember(serialized, null, "inTangent", model.inTangent); 21 | result += SerializeMember(serialized, null, "outTangent", model.outTangent); 22 | 23 | return result; 24 | } 25 | 26 | protected override fsResult DoDeserialize(Dictionary data, ref Keyframe model) { 27 | var result = fsResult.Success; 28 | 29 | var t0 = model.time; 30 | result += DeserializeMember(data, null, "time", out t0); 31 | model.time = t0; 32 | 33 | var t1 = model.value; 34 | result += DeserializeMember(data, null, "value", out t1); 35 | model.value = t1; 36 | 37 | var t2 = model.tangentMode; 38 | result += DeserializeMember(data, null, "tangentMode", out t2); 39 | model.tangentMode = t2; 40 | 41 | var t3 = model.inTangent; 42 | result += DeserializeMember(data, null, "inTangent", out t3); 43 | model.inTangent = t3; 44 | 45 | var t4 = model.outTangent; 46 | result += DeserializeMember(data, null, "outTangent", out t4); 47 | model.outTangent = t4; 48 | 49 | return result; 50 | } 51 | 52 | public override object CreateInstance(fsData data, Type storageType) { 53 | return new Keyframe(); 54 | } 55 | } 56 | } 57 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Keyframe_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 685e0c3230dc4c1469af759c0cadadb0 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/LayerMask_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.LayerMask_DirectConverter Register_LayerMask_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class LayerMask_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(LayerMask model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "value", model.value); 18 | 19 | return result; 20 | } 21 | 22 | protected override fsResult DoDeserialize(Dictionary data, ref LayerMask model) { 23 | var result = fsResult.Success; 24 | 25 | var t0 = model.value; 26 | result += DeserializeMember(data, null, "value", out t0); 27 | model.value = t0; 28 | 29 | return result; 30 | } 31 | 32 | public override object CreateInstance(fsData data, Type storageType) { 33 | return new LayerMask(); 34 | } 35 | } 36 | } 37 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/LayerMask_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a480ab5fab4f3041a1dc7468d23ab7c 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/RectOffset_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.RectOffset_DirectConverter Register_RectOffset_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class RectOffset_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(RectOffset model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "bottom", model.bottom); 18 | result += SerializeMember(serialized, null, "left", model.left); 19 | result += SerializeMember(serialized, null, "right", model.right); 20 | result += SerializeMember(serialized, null, "top", model.top); 21 | 22 | return result; 23 | } 24 | 25 | protected override fsResult DoDeserialize(Dictionary data, ref RectOffset model) { 26 | var result = fsResult.Success; 27 | 28 | var t0 = model.bottom; 29 | result += DeserializeMember(data, null, "bottom", out t0); 30 | model.bottom = t0; 31 | 32 | var t2 = model.left; 33 | result += DeserializeMember(data, null, "left", out t2); 34 | model.left = t2; 35 | 36 | var t3 = model.right; 37 | result += DeserializeMember(data, null, "right", out t3); 38 | model.right = t3; 39 | 40 | var t4 = model.top; 41 | result += DeserializeMember(data, null, "top", out t4); 42 | model.top = t4; 43 | 44 | return result; 45 | } 46 | 47 | public override object CreateInstance(fsData data, Type storageType) { 48 | return new RectOffset(); 49 | } 50 | } 51 | } 52 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/RectOffset_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b6ebe5ce2ccdb4439953bd49e36ac3a 3 | timeCreated: 1455511482 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Rect_DirectConverter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | public static Internal.DirectConverters.Rect_DirectConverter Register_Rect_DirectConverter; 9 | } 10 | } 11 | 12 | namespace FullSerializer.Internal.DirectConverters { 13 | public class Rect_DirectConverter : fsDirectConverter { 14 | protected override fsResult DoSerialize(Rect model, Dictionary serialized) { 15 | var result = fsResult.Success; 16 | 17 | result += SerializeMember(serialized, null, "xMin", model.xMin); 18 | result += SerializeMember(serialized, null, "yMin", model.yMin); 19 | result += SerializeMember(serialized, null, "xMax", model.xMax); 20 | result += SerializeMember(serialized, null, "yMax", model.yMax); 21 | 22 | return result; 23 | } 24 | 25 | protected override fsResult DoDeserialize(Dictionary data, ref Rect model) { 26 | var result = fsResult.Success; 27 | 28 | var t0 = model.xMin; 29 | result += DeserializeMember(data, null, "xMin", out t0); 30 | model.xMin = t0; 31 | 32 | var t1 = model.yMin; 33 | result += DeserializeMember(data, null, "yMin", out t1); 34 | model.yMin = t1; 35 | 36 | var t2 = model.xMax; 37 | result += DeserializeMember(data, null, "xMax", out t2); 38 | model.xMax = t2; 39 | 40 | var t3 = model.yMax; 41 | result += DeserializeMember(data, null, "yMax", out t3); 42 | model.yMax = t3; 43 | 44 | return result; 45 | } 46 | 47 | public override object CreateInstance(fsData data, Type storageType) { 48 | return new Rect(); 49 | } 50 | } 51 | } 52 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/Rect_DirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06db9349c97ef41438333fe8ef2c2f70 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/UnityEvent_Converter.cs: -------------------------------------------------------------------------------- 1 | #if !NO_UNITY && UNITY_5_3_OR_NEWER 2 | using System; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | 6 | namespace FullSerializer { 7 | partial class fsConverterRegistrar { 8 | // Disable the converter for the time being. Unity's JsonUtility API 9 | // cannot be called from within a C# ISerializationCallbackReceiver 10 | // callback. 11 | 12 | // public static Internal.Converters.UnityEvent_Converter 13 | // Register_UnityEvent_Converter; 14 | } 15 | } 16 | 17 | namespace FullSerializer.Internal.Converters { 18 | // The standard FS reflection converter has started causing Unity to crash 19 | // when processing UnityEvent. We can send the serialization through 20 | // JsonUtility which appears to work correctly instead. 21 | // 22 | // We have to support legacy serialization formats so importing works as 23 | // expected. 24 | public class UnityEvent_Converter : fsConverter { 25 | public override bool CanProcess(Type type) { 26 | return typeof(UnityEvent).Resolve().IsAssignableFrom(type.Resolve()) && type.IsGenericType() == false; 27 | } 28 | 29 | public override bool RequestCycleSupport(Type storageType) { 30 | return false; 31 | } 32 | 33 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 34 | Type objectType = (Type)instance; 35 | 36 | fsResult result = fsResult.Success; 37 | instance = JsonUtility.FromJson(fsJsonPrinter.CompressedJson(data), objectType); 38 | return result; 39 | } 40 | 41 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 42 | fsResult result = fsResult.Success; 43 | serialized = fsJsonParser.Parse(JsonUtility.ToJson(instance)); 44 | return result; 45 | } 46 | } 47 | } 48 | #endif -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/Unity/UnityEvent_Converter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a695d8e2a84646fbb7db60dc4fbbbd4 3 | timeCreated: 1469719791 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsArrayConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8c61b81ee2d4ce41988db051d54e60a 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsDateConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace FullSerializer.Internal { 5 | /// 6 | /// Supports serialization for DateTime, DateTimeOffset, and TimeSpan. 7 | /// 8 | public class fsDateConverter : fsConverter { 9 | // The format strings that we use when serializing DateTime and 10 | // DateTimeOffset types. 11 | private const string DefaultDateTimeFormatString = @"o"; 12 | private const string DateTimeOffsetFormatString = @"o"; 13 | 14 | private string DateTimeFormatString { 15 | get { 16 | return Serializer.Config.CustomDateTimeFormatString ?? DefaultDateTimeFormatString; 17 | } 18 | } 19 | 20 | public override bool CanProcess(Type type) { 21 | return 22 | type == typeof(DateTime) || 23 | type == typeof(DateTimeOffset) || 24 | type == typeof(TimeSpan); 25 | } 26 | 27 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 28 | if (instance is DateTime) { 29 | var dateTime = (DateTime)instance; 30 | serialized = new fsData(dateTime.ToString(DateTimeFormatString)); 31 | return fsResult.Success; 32 | } 33 | 34 | if (instance is DateTimeOffset) { 35 | var dateTimeOffset = (DateTimeOffset)instance; 36 | serialized = new fsData(dateTimeOffset.ToString(DateTimeOffsetFormatString)); 37 | return fsResult.Success; 38 | } 39 | 40 | if (instance is TimeSpan) { 41 | var timeSpan = (TimeSpan)instance; 42 | serialized = new fsData(timeSpan.ToString()); 43 | return fsResult.Success; 44 | } 45 | 46 | throw new InvalidOperationException("FullSerializer Internal Error -- Unexpected serialization type"); 47 | } 48 | 49 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 50 | if (data.IsString == false) { 51 | return fsResult.Fail("Date deserialization requires a string, not " + data.Type); 52 | } 53 | 54 | if (storageType == typeof(DateTime)) { 55 | DateTime result; 56 | if (DateTime.TryParse(data.AsString, null, DateTimeStyles.RoundtripKind, out result)) { 57 | instance = result; 58 | return fsResult.Success; 59 | } 60 | 61 | // DateTime.TryParse can fail for some valid DateTime instances. 62 | // Try to use Convert.ToDateTime. 63 | if (fsGlobalConfig.AllowInternalExceptions) { 64 | try { 65 | instance = Convert.ToDateTime(data.AsString); 66 | return fsResult.Success; 67 | } 68 | catch (Exception e) { 69 | return fsResult.Fail("Unable to parse " + data.AsString + " into a DateTime; got exception " + e); 70 | } 71 | } 72 | 73 | return fsResult.Fail("Unable to parse " + data.AsString + " into a DateTime"); 74 | } 75 | 76 | if (storageType == typeof(DateTimeOffset)) { 77 | DateTimeOffset result; 78 | if (DateTimeOffset.TryParse(data.AsString, null, DateTimeStyles.RoundtripKind, out result)) { 79 | instance = result; 80 | return fsResult.Success; 81 | } 82 | 83 | return fsResult.Fail("Unable to parse " + data.AsString + " into a DateTimeOffset"); 84 | } 85 | 86 | if (storageType == typeof(TimeSpan)) { 87 | TimeSpan result; 88 | if (TimeSpan.TryParse(data.AsString, out result)) { 89 | instance = result; 90 | return fsResult.Success; 91 | } 92 | 93 | return fsResult.Fail("Unable to parse " + data.AsString + " into a TimeSpan"); 94 | } 95 | 96 | throw new InvalidOperationException("FullSerializer Internal Error -- Unexpected deserialization type"); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsDateConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 892fb7e848a12c74681de14331c8a072 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsDictionaryConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f364b62fa3618b438cf5dd61bd00a0f 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsEnumConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9b18d8643e0d0f45a42e7736c412559 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsForwardConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// This allows you to forward serialization of an object to one of its 6 | /// members. For example, 7 | /// 8 | /// [fsForward("Values")] 9 | /// struct Wrapper { 10 | /// public int[] Values; 11 | /// } 12 | /// 13 | /// Then `Wrapper` will be serialized into a JSON array of integers. It will 14 | /// be as if `Wrapper` doesn't exist. 15 | /// 16 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct)] 17 | public sealed class fsForwardAttribute : Attribute { 18 | /// 19 | /// The name of the member we should serialize as. 20 | /// 21 | public string MemberName; 22 | 23 | /// 24 | /// Forward object serialization to an instance member. See class 25 | /// comment. 26 | /// 27 | /// 28 | /// The name of the member that we should serialize this object as. 29 | /// 30 | public fsForwardAttribute(string memberName) { 31 | MemberName = memberName; 32 | } 33 | } 34 | } 35 | 36 | namespace FullSerializer.Internal { 37 | public class fsForwardConverter : fsConverter { 38 | private string _memberName; 39 | 40 | public fsForwardConverter(fsForwardAttribute attribute) { 41 | _memberName = attribute.MemberName; 42 | } 43 | 44 | public override bool CanProcess(Type type) { 45 | throw new NotSupportedException("Please use the [fsForward(...)] attribute."); 46 | } 47 | 48 | private fsResult GetProperty(object instance, out fsMetaProperty property) { 49 | var properties = fsMetaType.Get(Serializer.Config, instance.GetType()).Properties; 50 | for (int i = 0; i < properties.Length; ++i) { 51 | if (properties[i].MemberName == _memberName) { 52 | property = properties[i]; 53 | return fsResult.Success; 54 | } 55 | } 56 | 57 | property = default(fsMetaProperty); 58 | return fsResult.Fail("No property named \"" + _memberName + "\" on " + instance.GetType().CSharpName()); 59 | } 60 | 61 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 62 | serialized = fsData.Null; 63 | var result = fsResult.Success; 64 | 65 | fsMetaProperty property; 66 | if ((result += GetProperty(instance, out property)).Failed) return result; 67 | 68 | var actualInstance = property.Read(instance); 69 | return Serializer.TrySerialize(property.StorageType, actualInstance, out serialized); 70 | } 71 | 72 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 73 | var result = fsResult.Success; 74 | 75 | fsMetaProperty property; 76 | if ((result += GetProperty(instance, out property)).Failed) return result; 77 | 78 | object actualInstance = null; 79 | if ((result += Serializer.TryDeserialize(data, property.StorageType, ref actualInstance)).Failed) 80 | return result; 81 | 82 | property.Write(instance, actualInstance); 83 | return result; 84 | } 85 | 86 | public override object CreateInstance(fsData data, Type storageType) { 87 | return fsMetaType.Get(Serializer.Config, storageType).CreateInstance(); 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsForwardConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eccd27d395a3b445900ce1a85cc679a 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsGuidConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer.Internal { 4 | /// 5 | /// Serializes and deserializes guids. 6 | /// 7 | public class fsGuidConverter : fsConverter { 8 | public override bool CanProcess(Type type) { 9 | return type == typeof(Guid); 10 | } 11 | 12 | public override bool RequestCycleSupport(Type storageType) { 13 | return false; 14 | } 15 | 16 | public override bool RequestInheritanceSupport(Type storageType) { 17 | return false; 18 | } 19 | 20 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 21 | var guid = (Guid)instance; 22 | serialized = new fsData(guid.ToString()); 23 | return fsResult.Success; 24 | } 25 | 26 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 27 | if (data.IsString) { 28 | instance = new Guid(data.AsString); 29 | return fsResult.Success; 30 | } 31 | 32 | return fsResult.Fail("fsGuidConverter encountered an unknown JSON data type"); 33 | } 34 | 35 | public override object CreateInstance(fsData data, Type storageType) { 36 | return new Guid(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsGuidConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25223074bdc15f64c9c7c147346b40d0 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsIEnumerableConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9b9009ce07beeb4cab11ab8019d8f25 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsKeyValuePairConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace FullSerializer.Internal { 6 | public class fsKeyValuePairConverter : fsConverter { 7 | public override bool CanProcess(Type type) { 8 | return 9 | type.Resolve().IsGenericType && 10 | type.GetGenericTypeDefinition() == typeof(KeyValuePair<,>); 11 | } 12 | 13 | public override bool RequestCycleSupport(Type storageType) { 14 | return false; 15 | } 16 | 17 | public override bool RequestInheritanceSupport(Type storageType) { 18 | return false; 19 | } 20 | 21 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 22 | var result = fsResult.Success; 23 | 24 | fsData keyData, valueData; 25 | if ((result += CheckKey(data, "Key", out keyData)).Failed) return result; 26 | if ((result += CheckKey(data, "Value", out valueData)).Failed) return result; 27 | 28 | var genericArguments = storageType.GetGenericArguments(); 29 | Type keyType = genericArguments[0], valueType = genericArguments[1]; 30 | 31 | object keyObject = null, valueObject = null; 32 | result.AddMessages(Serializer.TryDeserialize(keyData, keyType, ref keyObject)); 33 | result.AddMessages(Serializer.TryDeserialize(valueData, valueType, ref valueObject)); 34 | 35 | instance = Activator.CreateInstance(storageType, keyObject, valueObject); 36 | return result; 37 | } 38 | 39 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 40 | PropertyInfo keyProperty = storageType.GetDeclaredProperty("Key"); 41 | PropertyInfo valueProperty = storageType.GetDeclaredProperty("Value"); 42 | 43 | object keyObject = keyProperty.GetValue(instance, null); 44 | object valueObject = valueProperty.GetValue(instance, null); 45 | 46 | var genericArguments = storageType.GetGenericArguments(); 47 | Type keyType = genericArguments[0], valueType = genericArguments[1]; 48 | 49 | var result = fsResult.Success; 50 | 51 | fsData keyData, valueData; 52 | result.AddMessages(Serializer.TrySerialize(keyType, keyObject, out keyData)); 53 | result.AddMessages(Serializer.TrySerialize(valueType, valueObject, out valueData)); 54 | 55 | serialized = fsData.CreateDictionary(); 56 | if (keyData != null) serialized.AsDictionary["Key"] = keyData; 57 | if (valueData != null) serialized.AsDictionary["Value"] = valueData; 58 | 59 | return result; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsKeyValuePairConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2611d96db6a6370458d57e180a2ffe30 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsNullableConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer.Internal { 4 | /// 5 | /// The reflected converter will properly serialize nullable types. However, 6 | /// we do it here instead as we can emit less serialization data. 7 | /// 8 | public class fsNullableConverter : fsConverter { 9 | public override bool CanProcess(Type type) { 10 | return 11 | type.Resolve().IsGenericType && 12 | type.GetGenericTypeDefinition() == typeof(Nullable<>); 13 | } 14 | 15 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 16 | // null is automatically serialized 17 | return Serializer.TrySerialize(Nullable.GetUnderlyingType(storageType), instance, out serialized); 18 | } 19 | 20 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 21 | // null is automatically deserialized 22 | return Serializer.TryDeserialize(data, Nullable.GetUnderlyingType(storageType), ref instance); 23 | } 24 | 25 | public override object CreateInstance(fsData data, Type storageType) { 26 | return storageType; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsNullableConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a18dfa892d8de7245824898c553a516b 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsPrimitiveConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14030fd201904564584a2639fafcdcfc 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsReflectedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | #if !UNITY_EDITOR && UNITY_WSA 5 | // For System.Reflection.TypeExtensions 6 | using System.Reflection; 7 | #endif 8 | 9 | namespace FullSerializer.Internal { 10 | public class fsReflectedConverter : fsConverter { 11 | public override bool CanProcess(Type type) { 12 | if (type.Resolve().IsArray || 13 | typeof(ICollection).IsAssignableFrom(type)) { 14 | return false; 15 | } 16 | 17 | return true; 18 | } 19 | 20 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 21 | serialized = fsData.CreateDictionary(); 22 | var result = fsResult.Success; 23 | 24 | fsMetaType metaType = fsMetaType.Get(Serializer.Config, instance.GetType()); 25 | metaType.EmitAotData(/*throwException:*/ false); 26 | 27 | for (int i = 0; i < metaType.Properties.Length; ++i) { 28 | fsMetaProperty property = metaType.Properties[i]; 29 | if (property.CanRead == false) continue; 30 | 31 | fsData serializedData; 32 | 33 | var itemResult = Serializer.TrySerialize(property.StorageType, property.OverrideConverterType, 34 | property.Read(instance), out serializedData); 35 | result.AddMessages(itemResult); 36 | if (itemResult.Failed) { 37 | continue; 38 | } 39 | 40 | serialized.AsDictionary[property.JsonName] = serializedData; 41 | } 42 | 43 | return result; 44 | } 45 | 46 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 47 | var result = fsResult.Success; 48 | 49 | // Verify that we actually have an Object 50 | if ((result += CheckType(data, fsDataType.Object)).Failed) { 51 | return result; 52 | } 53 | 54 | fsMetaType metaType = fsMetaType.Get(Serializer.Config, storageType); 55 | metaType.EmitAotData(/*throwException:*/ false); 56 | 57 | for (int i = 0; i < metaType.Properties.Length; ++i) { 58 | fsMetaProperty property = metaType.Properties[i]; 59 | if (property.CanWrite == false) continue; 60 | 61 | fsData propertyData; 62 | if (data.AsDictionary.TryGetValue(property.JsonName, out propertyData)) { 63 | object deserializedValue = null; 64 | 65 | // We have to read in the existing value, since we need to 66 | // support partial deserialization. However, this is bad for 67 | // perf. 68 | // TODO: Find a way to avoid this call when we are not doing 69 | // a partial deserialization Maybe through a new 70 | // property, ie, Serializer.IsPartialSerialization, 71 | // which just gets set when starting a new 72 | // serialization? We cannot pipe the information 73 | // through CreateInstance unfortunately. 74 | if (property.CanRead) { 75 | deserializedValue = property.Read(instance); 76 | } 77 | 78 | var itemResult = Serializer.TryDeserialize(propertyData, property.StorageType, 79 | property.OverrideConverterType, ref deserializedValue); 80 | result.AddMessages(itemResult); 81 | if (itemResult.Failed) continue; 82 | 83 | property.Write(instance, deserializedValue); 84 | } 85 | } 86 | 87 | return result; 88 | } 89 | 90 | public override object CreateInstance(fsData data, Type storageType) { 91 | fsMetaType metaType = fsMetaType.Get(Serializer.Config, storageType); 92 | return metaType.CreateInstance(); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsReflectedConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ff9fcf67634b1b448fa901325a9510d 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if !UNITY_EDITOR && UNITY_WSA 4 | // For System.Reflection.TypeExtensions 5 | using System.Reflection; 6 | #endif 7 | 8 | namespace FullSerializer.Internal { 9 | public class fsTypeConverter : fsConverter { 10 | public override bool CanProcess(Type type) { 11 | return typeof(Type).IsAssignableFrom(type); 12 | } 13 | 14 | public override bool RequestCycleSupport(Type type) { 15 | return false; 16 | } 17 | 18 | public override bool RequestInheritanceSupport(Type type) { 19 | return false; 20 | } 21 | 22 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 23 | var type = (Type)instance; 24 | serialized = new fsData(type.FullName); 25 | return fsResult.Success; 26 | } 27 | 28 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 29 | if (data.IsString == false) { 30 | return fsResult.Fail("Type converter requires a string"); 31 | } 32 | 33 | instance = fsTypeCache.GetType(data.AsString); 34 | if (instance == null) { 35 | return fsResult.Fail("Unable to find type " + data.AsString); 36 | } 37 | return fsResult.Success; 38 | } 39 | 40 | public override object CreateInstance(fsData data, Type storageType) { 41 | return storageType; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsTypeConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b7c8e9a78b8bb24d9cd168134ba2d3f 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsWeakReferenceConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer.Internal { 4 | /// 5 | /// Serializes and deserializes WeakReferences. 6 | /// 7 | public class fsWeakReferenceConverter : fsConverter { 8 | public override bool CanProcess(Type type) { 9 | return type == typeof(WeakReference); 10 | } 11 | 12 | public override bool RequestCycleSupport(Type storageType) { 13 | return false; 14 | } 15 | 16 | public override bool RequestInheritanceSupport(Type storageType) { 17 | return false; 18 | } 19 | 20 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 21 | var weakRef = (WeakReference)instance; 22 | 23 | var result = fsResult.Success; 24 | serialized = fsData.CreateDictionary(); 25 | 26 | if (weakRef.IsAlive) { 27 | fsData data; 28 | if ((result += Serializer.TrySerialize(weakRef.Target, out data)).Failed) { 29 | return result; 30 | } 31 | 32 | serialized.AsDictionary["Target"] = data; 33 | serialized.AsDictionary["TrackResurrection"] = new fsData(weakRef.TrackResurrection); 34 | } 35 | 36 | return result; 37 | } 38 | 39 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 40 | var result = fsResult.Success; 41 | 42 | if ((result += CheckType(data, fsDataType.Object)).Failed) return result; 43 | 44 | if (data.AsDictionary.ContainsKey("Target")) { 45 | var targetData = data.AsDictionary["Target"]; 46 | object targetInstance = null; 47 | 48 | if ((result += Serializer.TryDeserialize(targetData, typeof(object), ref targetInstance)).Failed) return result; 49 | 50 | bool trackResurrection = false; 51 | if (data.AsDictionary.ContainsKey("TrackResurrection") && data.AsDictionary["TrackResurrection"].IsBool) { 52 | trackResurrection = data.AsDictionary["TrackResurrection"].AsBool; 53 | } 54 | 55 | instance = new WeakReference(targetInstance, trackResurrection); 56 | } 57 | 58 | return result; 59 | } 60 | 61 | public override object CreateInstance(fsData data, Type storageType) { 62 | return new WeakReference(null); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Converters/fsWeakReferenceConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d522279c90b14504f9a25467442f9981 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae1efb8bd6dfa4040beb12118e625b35 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsCyclicReferenceManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace FullSerializer.Internal { 6 | public class fsCyclicReferenceManager { 7 | // We use the default ReferenceEquals when comparing two objects because 8 | // custom objects may override equals methods. These overriden equals may 9 | // treat equals differently; we want to serialize/deserialize the object 10 | // graph *identically* to how it currently exists. 11 | class ObjectReferenceEqualityComparator : IEqualityComparer { 12 | bool IEqualityComparer.Equals(object x, object y) { 13 | return ReferenceEquals(x, y); 14 | } 15 | 16 | int IEqualityComparer.GetHashCode(object obj) { 17 | return RuntimeHelpers.GetHashCode(obj); 18 | } 19 | 20 | public static readonly IEqualityComparer Instance = new ObjectReferenceEqualityComparator(); 21 | } 22 | 23 | private Dictionary _objectIds = new Dictionary(ObjectReferenceEqualityComparator.Instance); 24 | private int _nextId; 25 | 26 | private Dictionary _marked = new Dictionary(); 27 | private int _depth; 28 | 29 | public void Enter() { 30 | _depth++; 31 | } 32 | 33 | public bool Exit() { 34 | _depth--; 35 | 36 | if (_depth == 0) { 37 | _objectIds = new Dictionary(ObjectReferenceEqualityComparator.Instance); 38 | _nextId = 0; 39 | _marked = new Dictionary(); 40 | } 41 | 42 | if (_depth < 0) { 43 | _depth = 0; 44 | throw new InvalidOperationException("Internal Error - Mismatched Enter/Exit. Please report a bug at https://github.com/jacobdufault/fullserializer/issues with the serialization data."); 45 | } 46 | 47 | return _depth == 0; 48 | } 49 | 50 | public object GetReferenceObject(int id) { 51 | if (_marked.ContainsKey(id) == false) { 52 | throw new InvalidOperationException("Internal Deserialization Error - Object " + 53 | "definition has not been encountered for object with id=" + id + 54 | "; have you reordered or modified the serialized data? If this is an issue " + 55 | "with an unmodified Full Serializer implementation and unmodified serialization " + 56 | "data, please report an issue with an included test case."); 57 | } 58 | 59 | return _marked[id]; 60 | } 61 | 62 | public void AddReferenceWithId(int id, object reference) { 63 | _marked[id] = reference; 64 | } 65 | 66 | public int GetReferenceId(object item) { 67 | int id; 68 | if (_objectIds.TryGetValue(item, out id) == false) { 69 | id = _nextId++; 70 | _objectIds[item] = id; 71 | } 72 | return id; 73 | } 74 | 75 | public bool IsReference(object item) { 76 | return _marked.ContainsKey(GetReferenceId(item)); 77 | } 78 | 79 | public void MarkSerialized(object item) { 80 | int referenceId = GetReferenceId(item); 81 | 82 | if (_marked.ContainsKey(referenceId)) { 83 | throw new InvalidOperationException("Internal Error - " + item + 84 | " has already been marked as serialized"); 85 | } 86 | 87 | _marked[referenceId] = item; 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsCyclicReferenceManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c1dc6d180e2a624fb5ced24b343caac 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer.Internal { 4 | /// 5 | /// Simple option type. This is akin to nullable types. 6 | /// 7 | public struct fsOption { 8 | private bool _hasValue; 9 | private T _value; 10 | 11 | public bool HasValue { 12 | get { return _hasValue; } 13 | } 14 | public bool IsEmpty { 15 | get { return _hasValue == false; } 16 | } 17 | public T Value { 18 | get { 19 | if (IsEmpty) throw new InvalidOperationException("fsOption is empty"); 20 | return _value; 21 | } 22 | } 23 | 24 | public fsOption(T value) { 25 | _hasValue = true; 26 | _value = value; 27 | } 28 | 29 | public static fsOption Empty; 30 | } 31 | 32 | public static class fsOption { 33 | public static fsOption Just(T value) { 34 | return new fsOption(value); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsOption.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb4638b0e5989604ca0d3801ab74bb4f 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsPortableReflection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53f0d6faef1e74649a1d4ec87281ce9c 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsTypeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c3b8173faf686b44bdf5a3478f776cd 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsVersionManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39e37c86cc277f544a0860a95c73c4d6 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsVersionedType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer.Internal { 4 | public struct fsVersionedType { 5 | /// 6 | /// The direct ancestors that this type can import. 7 | /// 8 | public fsVersionedType[] Ancestors; 9 | 10 | /// 11 | /// The identifying string that is unique among all ancestors. 12 | /// 13 | public string VersionString; 14 | 15 | /// 16 | /// The modeling type that this versioned type maps back to. 17 | /// 18 | public Type ModelType; 19 | 20 | /// 21 | /// Migrate from an instance of an ancestor. 22 | /// 23 | public object Migrate(object ancestorInstance) { 24 | return Activator.CreateInstance(ModelType, ancestorInstance); 25 | } 26 | 27 | public override string ToString() { 28 | return "fsVersionedType [ModelType=" + ModelType + ", VersionString=" + VersionString + ", Ancestors.Length=" + Ancestors.Length + "]"; 29 | } 30 | 31 | public static bool operator ==(fsVersionedType a, fsVersionedType b) { 32 | return a.ModelType == b.ModelType; 33 | } 34 | 35 | public static bool operator !=(fsVersionedType a, fsVersionedType b) { 36 | return a.ModelType != b.ModelType; 37 | } 38 | 39 | public override bool Equals(object obj) { 40 | return 41 | obj is fsVersionedType && 42 | ModelType == ((fsVersionedType)obj).ModelType; 43 | } 44 | 45 | public override int GetHashCode() { 46 | return ModelType.GetHashCode(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Internal/fsVersionedType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac58601fa737f8048831c6bd75a6fca2 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4f755e4a106fd94a9053c5a49c3600f 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection/fsMetaProperty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bce2bac5e1b3d9043a6a4207280d7d71 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection/fsMetaType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dda7fa68f01f0e428c6d8090ae72532 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection/fsReflectionUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if !UNITY_EDITOR && UNITY_WSA 4 | // For System.Reflection.TypeExtensions 5 | using System.Reflection; 6 | #endif 7 | 8 | namespace FullSerializer.Internal { 9 | public static class fsReflectionUtility { 10 | /// 11 | /// Searches for a particular implementation of the given interface type 12 | /// inside of the type. This is particularly useful if the interface type 13 | /// is an open type, ie, typeof(IFace{}), because this method will then 14 | /// return IFace{} but with appropriate type parameters inserted. 15 | /// 16 | /// The base type to search for interface 17 | /// 18 | /// The interface type to search for. Can be an open generic type. 19 | /// 20 | /// 21 | /// The actual interface type that the type contains, or null if there is 22 | /// no implementation of the given interfaceType on type. 23 | /// 24 | public static Type GetInterface(Type type, Type interfaceType) { 25 | if (interfaceType.Resolve().IsGenericType && 26 | interfaceType.Resolve().IsGenericTypeDefinition == false) { 27 | throw new ArgumentException("GetInterface requires that if the interface " + 28 | "type is generic, then it must be the generic type definition, not a " + 29 | "specific generic type instantiation"); 30 | }; 31 | 32 | while (type != null) { 33 | foreach (var iface in type.GetInterfaces()) { 34 | if (iface.Resolve().IsGenericType) { 35 | if (interfaceType == iface.GetGenericTypeDefinition()) { 36 | return iface; 37 | } 38 | } 39 | else if (interfaceType == iface) { 40 | return iface; 41 | } 42 | } 43 | 44 | type = type.Resolve().BaseType; 45 | } 46 | 47 | return null; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection/fsReflectionUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2fe4e0d816d15145b26bd01d34c8b47 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/Reflection/fsTypeCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45c4a046c8137494c9fe68a832aa751d 3 | timeCreated: 1455068576 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsBaseConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 183143ebe6dd0124aac0741ff70e1fd2 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b59903dfb496d004d8f08677c027e7f6 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace FullSerializer { 5 | /// 6 | /// fsContext stores global metadata that can be used to customize how 7 | /// fsConverters operate during serialization. 8 | /// 9 | public sealed class fsContext { 10 | /// 11 | /// All of the context objects. 12 | /// 13 | private readonly Dictionary _contextObjects = new Dictionary(); 14 | 15 | /// 16 | /// Removes all context objects from the context. 17 | /// 18 | public void Reset() { 19 | _contextObjects.Clear(); 20 | } 21 | 22 | /// 23 | /// Sets the context object for the given type with the given value. 24 | /// 25 | public void Set(T obj) { 26 | _contextObjects[typeof(T)] = obj; 27 | } 28 | 29 | /// 30 | /// Returns true if there is a context object for the given type. 31 | /// 32 | public bool Has() { 33 | return _contextObjects.ContainsKey(typeof(T)); 34 | } 35 | 36 | /// 37 | /// Fetches the context object for the given type. 38 | /// 39 | public T Get() { 40 | object val; 41 | if (_contextObjects.TryGetValue(typeof(T), out val)) { 42 | return (T)val; 43 | } 44 | throw new InvalidOperationException("There is no context object of type " + typeof(T)); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dbf6cf73c266b14eba03d329717a810 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// The serialization converter allows for customization of the serialization 6 | /// process. 7 | /// 8 | public abstract class fsConverter : fsBaseConverter { 9 | /// 10 | /// Can this converter serialize and deserialize the given object type? 11 | /// 12 | /// The given object type. 13 | /// 14 | /// True if the converter can serialize it, false otherwise. 15 | /// 16 | public abstract bool CanProcess(Type type); 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77ed27c3d6b79c044ad5c52b7832d379 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsConverterRegistrar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using FullSerializer.Internal; 4 | 5 | namespace FullSerializer { 6 | /// 7 | /// This class allows arbitrary code to easily register global converters. To 8 | /// add a converter, simply declare a new field called "Register_*" that 9 | /// stores the type of converter you would like to add. Alternatively, you 10 | /// can do the same with a method called "Register_*"; just add the converter 11 | /// type to the `Converters` list. 12 | /// 13 | public partial class fsConverterRegistrar { 14 | static fsConverterRegistrar() { 15 | Converters = new List(); 16 | 17 | foreach (var field in typeof(fsConverterRegistrar).GetDeclaredFields()) { 18 | if (field.Name.StartsWith("Register_")) 19 | Converters.Add(field.FieldType); 20 | } 21 | 22 | foreach (var method in typeof(fsConverterRegistrar).GetDeclaredMethods()) { 23 | if (method.Name.StartsWith("Register_")) 24 | method.Invoke(null, null); 25 | } 26 | 27 | // Make sure we do not use any AOT Models which are out of date. 28 | var finalResult = new List(Converters); 29 | foreach (Type t in Converters) { 30 | object instance = null; 31 | try { 32 | instance = Activator.CreateInstance(t); 33 | } catch (Exception) {} 34 | 35 | var aotConverter = instance as fsIAotConverter; 36 | if (aotConverter != null) { 37 | var modelMetaType = fsMetaType.Get(new fsConfig(), aotConverter.ModelType); 38 | if (fsAotCompilationManager.IsAotModelUpToDate(modelMetaType, aotConverter) == false) { 39 | finalResult.Remove(t); 40 | } 41 | } 42 | } 43 | Converters = finalResult; 44 | } 45 | 46 | public static List Converters; 47 | 48 | // Example field registration: 49 | //public static AnimationCurve_DirectConverter Register_AnimationCurve_DirectConverter; 50 | 51 | // Example method registration: 52 | //public static void Register_AnimationCurve_DirectConverter() { 53 | // Converters.Add(typeof(AnimationCurve_DirectConverter)); 54 | //} 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsConverterRegistrar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa1f5994b782ae24db0ec14460b60dc4 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cc8656e43d482941b2b95d443c36174 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsDirectConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace FullSerializer { 5 | /// 6 | /// The direct converter is similar to a regular converter, except that it 7 | /// targets specifically only one type. This means that it can be used 8 | /// without performance impact when discovering converters. It is strongly 9 | /// recommended that you derive from fsDirectConverter{TModel}. 10 | /// 11 | /// 12 | /// Due to the way that direct converters operate, inheritance is *not* 13 | /// supported. Direct converters will only be used with the exact ModelType 14 | /// object. 15 | /// 16 | public abstract class fsDirectConverter : fsBaseConverter { 17 | public abstract Type ModelType { get; } 18 | } 19 | 20 | public abstract class fsDirectConverter : fsDirectConverter { 21 | public override Type ModelType { get { return typeof(TModel); } } 22 | 23 | public sealed override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 24 | var serializedDictionary = new Dictionary(); 25 | var result = DoSerialize((TModel)instance, serializedDictionary); 26 | serialized = new fsData(serializedDictionary); 27 | return result; 28 | } 29 | 30 | public sealed override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 31 | var result = fsResult.Success; 32 | if ((result += CheckType(data, fsDataType.Object)).Failed) return result; 33 | 34 | var obj = (TModel)instance; 35 | result += DoDeserialize(data.AsDictionary, ref obj); 36 | instance = obj; 37 | return result; 38 | } 39 | 40 | protected abstract fsResult DoSerialize(TModel model, Dictionary serialized); 41 | protected abstract fsResult DoDeserialize(Dictionary data, ref TModel model); 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsDirectConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01d299a12e9acb74ea4725bd6158642a 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsExceptions.cs: -------------------------------------------------------------------------------- 1 | // note: This file contains exceptions used by FullSerializer. Exceptions are 2 | // never used at runtime in FullSerializer; they are only used when 3 | // validating annotations and code-based models. 4 | 5 | using System; 6 | 7 | namespace FullSerializer { 8 | public sealed class fsMissingVersionConstructorException : Exception { 9 | public fsMissingVersionConstructorException(Type versionedType, Type constructorType) : 10 | base(versionedType + " is missing a constructor for previous model type " + constructorType) { } 11 | } 12 | 13 | public sealed class fsDuplicateVersionNameException : Exception { 14 | public fsDuplicateVersionNameException(Type typeA, Type typeB, string version) : 15 | base(typeA + " and " + typeB + " have the same version string (" + version + "); please change one of them.") { } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsExceptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38269c00973f4f64db007f13af5acbf4 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsISerializationCallbacks.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff5a6a4a9df9cfc43b04b16bbc045902 3 | timeCreated: 1451205262 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsIgnoreAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// The given property or field annotated with [JsonIgnore] will not be 6 | /// serialized. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct)] 9 | public sealed class fsIgnoreAttribute : Attribute { 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsIgnoreAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 040c5c9958137624c91fc44ec697d76f 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsJsonParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76da27fbb0fa3c4459921ceb0782a604 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsJsonPrinter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be309c30e4f28364cadc2d0b014a5333 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsMemberSerialization.cs: -------------------------------------------------------------------------------- 1 | namespace FullSerializer { 2 | /// 3 | /// Controls how the reflected converter handles member serialization. 4 | /// 5 | public enum fsMemberSerialization { 6 | /// 7 | /// Only members with [SerializeField] or [fsProperty] attributes are 8 | /// serialized. 9 | /// 10 | OptIn, 11 | 12 | /// 13 | /// Only members with [NotSerialized] or [fsIgnore] will not be 14 | /// serialized. 15 | /// 16 | OptOut, 17 | 18 | /// 19 | /// The default member serialization behavior is applied. 20 | /// 21 | Default 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsMemberSerialization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2d6fed6217d35c49868389b28b49050 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsObjectAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// This attribute controls some serialization behavior for a type. See the 6 | /// comments on each of the fields for more information. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] 9 | public sealed class fsObjectAttribute : Attribute { 10 | /// 11 | /// The previous model that should be used if an old version of this 12 | /// object is encountered. Using this attribute also requires that the 13 | /// type have a public constructor that takes only one parameter, an 14 | /// object instance of the given type. Use of this parameter *requires* 15 | /// that the VersionString parameter is also set. 16 | /// 17 | public Type[] PreviousModels; 18 | 19 | /// 20 | /// The version string to use for this model. This should be unique among 21 | /// all prior versions of this model that is supported for importation. 22 | /// If PreviousModel is set, then this attribute must also be set. A good 23 | /// valid example for this is "v1", "v2", "v3", ... 24 | /// 25 | public string VersionString; 26 | 27 | /// 28 | /// This controls the behavior for member serialization. The default 29 | /// behavior is fsMemberSerialization.Default. 30 | /// 31 | public fsMemberSerialization MemberSerialization = fsMemberSerialization.Default; 32 | 33 | /// 34 | /// Specify a custom converter to use for serialization. The converter 35 | /// type needs to derive from fsBaseConverter. This defaults to null. 36 | /// 37 | public Type Converter; 38 | 39 | /// 40 | /// Specify a custom processor to use during serialization. The processor 41 | /// type needs to derive from fsObjectProcessor and the call to 42 | /// CanProcess is not invoked. This defaults to null. 43 | /// 44 | public Type Processor; 45 | 46 | public fsObjectAttribute() { 47 | } 48 | public fsObjectAttribute(string versionString, params Type[] previousModels) { 49 | VersionString = versionString; 50 | PreviousModels = previousModels; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsObjectAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0824334ca5c07d49b5c390bd38781cf 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsObjectProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// 6 | /// Enables injecting code before/after an object has been serialized. This 7 | /// is most useful if you want to run the default serialization process but 8 | /// apply a pre/post processing step. 9 | /// 10 | /// 11 | /// Multiple object processors can be active at the same time. When running 12 | /// they are called in a "nested" fashion - if we have processor1 and 13 | /// process2 added to the serializer in that order (p1 then p2), then the 14 | /// execution order will be p1#Before p2#Before /serialization/ p2#After 15 | /// p1#After. 16 | /// 17 | /// 18 | public abstract class fsObjectProcessor { 19 | /// 20 | /// Is the processor interested in objects of the given type? 21 | /// 22 | /// The given type. 23 | /// 24 | /// True if the processor should be applied, false otherwise. 25 | /// 26 | public virtual bool CanProcess(Type type) { throw new NotImplementedException(); } 27 | 28 | /// 29 | /// Called before serialization. 30 | /// 31 | /// 32 | /// The field/property type that is storing the instance. 33 | /// 34 | /// The type of the instance. 35 | public virtual void OnBeforeSerialize(Type storageType, object instance) { } 36 | 37 | /// 38 | /// Called after serialization. 39 | /// 40 | /// 41 | /// The field/property type that is storing the instance. 42 | /// 43 | /// The type of the instance. 44 | /// The data that was serialized. 45 | public virtual void OnAfterSerialize(Type storageType, object instance, ref fsData data) { } 46 | 47 | /// 48 | /// Called before deserialization. 49 | /// 50 | /// 51 | /// The field/property type that is storing the instance. 52 | /// 53 | /// 54 | /// The data that will be used for deserialization. 55 | /// 56 | public virtual void OnBeforeDeserialize(Type storageType, ref fsData data) { } 57 | 58 | /// 59 | /// Called before deserialization has begun but *after* the object 60 | /// instance has been created. This will get invoked even if the user 61 | /// passed in an existing instance. 62 | /// 63 | /// 64 | /// **IMPORTANT**: The actual instance that gets passed here is *not* 65 | /// guaranteed to be an a subtype of storageType, since the value for 66 | /// instance is whatever the active converter returned for 67 | /// CreateInstance() - ie, some converters will return dummy types in 68 | /// CreateInstance() if instance creation cannot be separated from 69 | /// deserialization (ie, KeyValuePair). 70 | /// 71 | /// 72 | /// The field/property type that is storing the instance. 73 | /// 74 | /// 75 | /// The created object instance. No deserialization has been applied to 76 | /// it. 77 | /// 78 | /// 79 | /// The data that will be used for deserialization. 80 | /// 81 | public virtual void OnBeforeDeserializeAfterInstanceCreation(Type storageType, object instance, ref fsData data) { } 82 | 83 | /// 84 | /// Called after deserialization. 85 | /// 86 | /// 87 | /// The field/property type that is storing the instance. 88 | /// 89 | /// The type of the instance. 90 | public virtual void OnAfterDeserialize(Type storageType, object instance) { } 91 | } 92 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsObjectProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4f4c2fbbdaec5046adaaa0bb47036a6 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsPropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FullSerializer { 4 | /// 5 | /// Explicitly mark a property to be serialized. This can also be used to 6 | /// give the name that the property should use during serialization. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public sealed class fsPropertyAttribute : Attribute { 10 | /// 11 | /// The name of that the property will use in JSON serialization. 12 | /// 13 | public string Name; 14 | 15 | /// 16 | /// Use a custom converter for the given type. Specify the converter to 17 | /// use using typeof. 18 | /// 19 | public Type Converter; 20 | 21 | public fsPropertyAttribute() 22 | : this(string.Empty) { 23 | } 24 | 25 | public fsPropertyAttribute(string name) { 26 | Name = name; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsPropertyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b366ee3695fdf924495750c204ea426a 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54393a5534ff6c74f905d6be1770a1ba 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Source/fsSerializer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b904dc26e957fde4fb90a0d405d710ee 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bb31112ff4d8b946b25b049887b0ae2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f958fe0e27242f149901dc2c80ee71da 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/AbstractTypeRemappingTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | public class AbstractTypeRemappingTests { 6 | public string Serialize(T value) { 7 | fsData data; 8 | (new fsSerializer()).TrySerialize(value, out data).AssertSuccessWithoutWarnings(); 9 | return fsJsonPrinter.PrettyJson(data); 10 | } 11 | 12 | public T Deserialize(string content) { 13 | fsData data; 14 | fsJsonParser.Parse(content, out data).AssertSuccessWithoutWarnings(); 15 | var result = default(T); 16 | (new fsSerializer()).TryDeserialize(data, ref result).AssertSuccessWithoutWarnings(); 17 | return result; 18 | } 19 | 20 | [Test] 21 | public void IListDeserializedAsList() { 22 | var value = new List { 1, 2, 3 }; 23 | string serialized = Serialize>(value); 24 | IList deserialized = Deserialize>(serialized); 25 | Assert.IsInstanceOf>(deserialized); 26 | CollectionAssert.AreEquivalent(value, deserialized); 27 | } 28 | 29 | [Test] 30 | public void ICollectionDeserializedAsList() { 31 | var value = new List { 1, 2, 3 }; 32 | string serialized = Serialize>(value); 33 | ICollection deserialized = Deserialize>(serialized); 34 | Assert.IsInstanceOf>(deserialized); 35 | CollectionAssert.AreEquivalent(value, deserialized); 36 | } 37 | 38 | [Test] 39 | public void IDictionaryDeserializedAsDictionary() { 40 | var value = new Dictionary { { "1", 1 }, { "2", 2 }, { "3", 3 } }; 41 | string serialized = Serialize>(value); 42 | IDictionary deserialized = Deserialize>(serialized); 43 | Assert.IsInstanceOf>(deserialized); 44 | CollectionAssert.AreEquivalent(value, deserialized); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/AbstractTypeRemappingTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 875c54b88e8c64000856c73b8bc12e58 3 | timeCreated: 1480205739 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ArrayTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests.ArrayTest { 5 | public class ArrayTests { 6 | [Test] 7 | public void TestArray1D() 8 | { 9 | int[] before = new int[ 10 ]; 10 | DoTest( before ); 11 | } 12 | 13 | [Test] 14 | public void TestArray2D() 15 | { 16 | int[,] before = new int[ 10,20 ]; 17 | DoTest( before ); 18 | } 19 | 20 | 21 | private void DoTest( T expected ) { 22 | fsData serializedData; 23 | new fsSerializer().TrySerialize( expected, out serializedData ).AssertSuccessWithoutWarnings(); 24 | 25 | var actual = default( T ); 26 | new fsSerializer().TryDeserialize( serializedData, ref actual ); 27 | 28 | Assert.AreEqual( expected, actual ); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ArrayTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27bc807b34c9ef346b1080db0eac75b1 3 | timeCreated: 1455211069 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CallbackTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | public class ClassModel : fsISerializationCallbacks { 6 | [fsIgnore] 7 | public int beforeSerialize; 8 | [fsIgnore] 9 | public int afterSerialize; 10 | [fsIgnore] 11 | public int beforeDeserialize; 12 | [fsIgnore] 13 | public int afterDeserialize; 14 | 15 | void fsISerializationCallbacks.OnBeforeSerialize(Type storageType) { ++beforeSerialize; } 16 | void fsISerializationCallbacks.OnAfterSerialize(Type storageType, ref fsData data) { ++afterSerialize; } 17 | void fsISerializationCallbacks.OnBeforeDeserialize(Type storageType, ref fsData data) { ++beforeDeserialize; } 18 | void fsISerializationCallbacks.OnAfterDeserialize(Type storageType) { ++afterDeserialize; } 19 | } 20 | 21 | public struct StructModel : fsISerializationCallbacks { 22 | [fsIgnore] 23 | public int beforeSerialize; 24 | [fsIgnore] 25 | public int afterSerialize; 26 | [fsIgnore] 27 | public int beforeDeserialize; 28 | [fsIgnore] 29 | public int afterDeserialize; 30 | 31 | void fsISerializationCallbacks.OnBeforeSerialize(Type storageType) { ++beforeSerialize; } 32 | void fsISerializationCallbacks.OnAfterSerialize(Type storageType, ref fsData data) { ++afterSerialize; } 33 | void fsISerializationCallbacks.OnBeforeDeserialize(Type storageType, ref fsData data) { ++beforeDeserialize; } 34 | void fsISerializationCallbacks.OnAfterDeserialize(Type storageType) { ++afterDeserialize; } 35 | } 36 | 37 | public class CallbackTests { 38 | [Test] 39 | public void TestSerializationCallbacksOnStruct() { 40 | var original = new StructModel(); 41 | var dup = Clone(original); 42 | // not possible since we don't box original 43 | //Assert.AreEqual(1, original.beforeSerialize); 44 | //Assert.AreEqual(1, original.afterSerialize); 45 | Assert.AreEqual(1, dup.beforeDeserialize); 46 | Assert.AreEqual(1, dup.afterDeserialize); 47 | } 48 | 49 | [Test] 50 | public void TestSerializationCallbacksOnClass() { 51 | var original = new ClassModel(); 52 | var dup = Clone(original); 53 | Assert.AreEqual(1, original.beforeSerialize); 54 | Assert.AreEqual(1, original.afterSerialize); 55 | Assert.AreEqual(1, dup.beforeDeserialize); 56 | Assert.AreEqual(1, dup.afterDeserialize); 57 | } 58 | 59 | [Test] 60 | public void TestSerializationCallbacksOnNullInstances() { 61 | ClassModel original = null; 62 | var dup = Clone( original ); 63 | Assert.AreEqual( original, dup ); 64 | } 65 | 66 | private T Clone(T expected) { 67 | fsData serializedData; 68 | new fsSerializer().TrySerialize(expected, out serializedData).AssertSuccessWithoutWarnings(); 69 | var actual = default(T); 70 | new fsSerializer().TryDeserialize(serializedData, ref actual); 71 | return actual; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CallbackTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c86615a0bbec7c443939f1389ab69e8a 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CaseUnsensitiveDeserializationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NUnit.Framework; 3 | using UnityEngine; 4 | 5 | namespace FullSerializer.Tests { 6 | public struct Model { 7 | public int aaaAAA; 8 | public int bbbBBB; 9 | 10 | public override string ToString() { 11 | return "Model [aaaAAA = " + aaaAAA + ", bbbBBB = " + bbbBBB + "]"; 12 | } 13 | } 14 | 15 | public class CaseUnsensitiveDeserializationTests { 16 | [Test] 17 | public void TestCaseUnsensitiveDeserialization() { 18 | try { 19 | fsGlobalConfig.IsCaseSensitive = false; 20 | 21 | DoTest(new Model()); 22 | DoTest(new Model { 23 | aaaAAA = 1, 24 | bbbBBB = 2 25 | }); 26 | } 27 | finally { 28 | fsGlobalConfig.IsCaseSensitive = true; 29 | } 30 | } 31 | 32 | private void DoTest(T expected) { 33 | fsData serializedData; 34 | new fsSerializer().TrySerialize(expected, out serializedData).AssertSuccessWithoutWarnings(); 35 | 36 | foreach (var entry in serializedData.AsDictionary.ToArray()) { 37 | serializedData.AsDictionary.Remove(entry.Key); 38 | serializedData.AsDictionary[entry.Key.ToLower()] = entry.Value; 39 | } 40 | 41 | var actual = default(T); 42 | new fsSerializer().TryDeserialize(serializedData, ref actual); 43 | 44 | Debug.Log("Lowercase was " + fsJsonPrinter.PrettyJson(serializedData)); 45 | Assert.AreEqual(expected, actual); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CaseUnsensitiveDeserializationTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4048a7688d47bd540b1f9a7693246ad2 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ConstructorTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace FullSerializer.Tests { 4 | public class ConstructorTests { 5 | private class ClassWithNoPublicDefaultConstructor { 6 | public int a = 1; 7 | 8 | [fsIgnore] 9 | public bool constructorCalled; 10 | 11 | public ClassWithNoPublicDefaultConstructor(int dummy) { 12 | a = 2; 13 | constructorCalled = true; 14 | } 15 | } 16 | 17 | [Test] 18 | public void TestClassWithNoPublicDefaultConstructor() { 19 | var serialized = fsData.CreateDictionary(); 20 | serialized.AsDictionary["a"] = new fsData(3); 21 | 22 | var serializer = new fsSerializer(); 23 | 24 | ClassWithNoPublicDefaultConstructor result = null; 25 | Assert.IsTrue(serializer.TryDeserialize(serialized, ref result).Succeeded); 26 | 27 | // We expect the original value, but not for the constructor to have been called. 28 | Assert.AreEqual(3, result.a); 29 | Assert.IsFalse(result.constructorCalled); 30 | } 31 | 32 | private class ClassWithNoPublicDefaultConstructorButImplicitStatic { 33 | public int a = 1; 34 | public static int b = 2; 35 | 36 | [fsIgnore] 37 | public bool constructorCalled; 38 | 39 | public ClassWithNoPublicDefaultConstructorButImplicitStatic(int dummy) { 40 | a = 2; 41 | constructorCalled = true; 42 | } 43 | } 44 | 45 | [Test] 46 | public void TestClassWithNoPublicDefaultConstructorButImplicitStatic() { 47 | var serialized = fsData.CreateDictionary(); 48 | serialized.AsDictionary["a"] = new fsData(3); 49 | 50 | var serializer = new fsSerializer(); 51 | 52 | ClassWithNoPublicDefaultConstructorButImplicitStatic result = null; 53 | Assert.IsTrue(serializer.TryDeserialize(serialized, ref result).Succeeded); 54 | 55 | // We expect the original value, but not for the constructor to have been called, 56 | // DESPITE the presence of an implicit public static parameterless constructor. 57 | Assert.AreEqual(3, result.a); 58 | Assert.IsFalse(result.constructorCalled); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ConstructorTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daaa047bf7621b34fa771d4b5343779f 3 | timeCreated: 1484837888 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CyclicReferenceTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace FullSerializer.Tests { 4 | public class Base { 5 | public int id; 6 | public Base reference; 7 | 8 | public override bool Equals(object obj) { 9 | return ((Base)obj).id == id; 10 | } 11 | 12 | public override int GetHashCode() { 13 | return id; 14 | } 15 | } 16 | 17 | public class Derived1 : Base { 18 | } 19 | 20 | public class Derived2 : Base { 21 | } 22 | 23 | public struct Holder { 24 | public object value; 25 | } 26 | 27 | 28 | public class CyclicReferenceTests { 29 | private static T Clone(T obj) { 30 | fsData data; 31 | (new fsSerializer()).TrySerialize(obj, out data).AssertSuccessWithoutWarnings(); 32 | (new fsSerializer()).TryDeserialize(data, ref obj).AssertSuccessWithoutWarnings(); 33 | return obj; 34 | } 35 | 36 | [Test] 37 | public void SharedReferenceAcrossDifferentSerializationsAreNotKept() { 38 | var obj = new object(); 39 | var holder = new Holder { value = obj }; 40 | 41 | fsData data; 42 | var serializer = new fsSerializer(); 43 | 44 | // Try serializing once. 45 | serializer.TrySerialize(holder, out data).AssertSuccessWithoutWarnings(); 46 | Assert.AreEqual("{\"value\":{}}", fsJsonPrinter.CompressedJson(data)); 47 | 48 | // Serialize the same thing again to verify we don't preseve the reference. 49 | serializer.TrySerialize(holder, out data).AssertSuccessWithoutWarnings(); 50 | Assert.AreEqual("{\"value\":{}}", fsJsonPrinter.CompressedJson(data)); 51 | 52 | // Serialize an array of Holders to verify references are maintained across an array. 53 | var arrayOfHolders = new Holder[] { 54 | new Holder { value = obj }, 55 | new Holder { value = obj } 56 | }; 57 | serializer.TrySerialize(arrayOfHolders, out data).AssertSuccessWithoutWarnings(); 58 | Assert.AreEqual("[{\"value\":{\"$id\":\"0\"}},{\"value\":{\"$ref\":\"0\"}}]", fsJsonPrinter.CompressedJson(data)); 59 | } 60 | 61 | [Test] 62 | public void TestCyclicReferenceWithDifferentTypes() { 63 | // this verifies that cyclic reference detection will not 64 | // only treat objects of the same type as part of a cycle; 65 | // this supports some (broken) equals implementations 66 | 67 | var original = new Derived1 { 68 | reference = new Derived2() 69 | }; 70 | var cloned = Clone(original); 71 | 72 | Assert.IsInstanceOf(cloned); 73 | Assert.IsInstanceOf(cloned.reference); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/CyclicReferenceTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70f6fd9da0081b642890e117e51afd8b 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/DateTimeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FullSerializer; 3 | using NUnit.Framework; 4 | 5 | public class DateTimeTests { 6 | [Test] 7 | public void StrangeFormatTests() { 8 | var serializer = new fsSerializer(); 9 | DateTime time = DateTime.Now; 10 | serializer.TryDeserialize(new fsData("2016-01-22T12:06:57.503005Z"), ref time).AssertSuccessWithoutWarnings(); 11 | 12 | Assert.AreEqual(Convert.ToDateTime("2016-01-22T12:06:57.503005Z"), time); 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/DateTimeTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f813b45e966434a8ea0b3e9d4f790600 3 | timeCreated: 1453941028 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/DictionaryTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | 6 | public class DictionaryTests { 7 | [Test] 8 | public void TestEmitStringDictionary() { 9 | var model = new Dictionary(); 10 | model["t"] = true; 11 | model["0"] = 0; 12 | 13 | fsData actual; 14 | (new fsSerializer().TrySerialize(model, out actual)).AssertSuccessWithoutWarnings(); 15 | 16 | var expected = fsData.CreateDictionary(); 17 | expected.AsDictionary["t"] = fsData.CreateDictionary(); 18 | expected.AsDictionary["t"].AsDictionary["$type"] = new fsData("System.Boolean"); 19 | expected.AsDictionary["t"].AsDictionary["$content"] = fsData.True; 20 | expected.AsDictionary["0"] = fsData.CreateDictionary(); 21 | expected.AsDictionary["0"].AsDictionary["$type"] = new fsData("System.Int32"); 22 | expected.AsDictionary["0"].AsDictionary["$content"] = new fsData(0); 23 | 24 | Assert.AreEqual(expected, actual); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/DictionaryTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c804850638ce7d549b8b94d7d3e4de5b 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/EnumTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | 6 | [Flags] 7 | public enum DefinedFlags { 8 | A = 1 << 0, 9 | B = 1 << 1, 10 | C = 1 << 5 11 | } 12 | 13 | [Flags] 14 | public enum DefinedFlagsUint : uint { 15 | A = 1 << 0, 16 | B = 1 << 1, 17 | C = 1 << 5 18 | } 19 | 20 | [Flags] 21 | public enum RegularFlags { 22 | A, 23 | B, 24 | C 25 | } 26 | 27 | [Flags] 28 | public enum RegularFlagsUint : uint { 29 | A, 30 | B, 31 | C 32 | } 33 | 34 | public enum NotFlags { 35 | A = 10, 36 | B = 0, 37 | C = 1, 38 | D = 20 39 | } 40 | 41 | public enum NotFlagsUint : uint { 42 | A = 10, 43 | B = 0, 44 | C = 1, 45 | D = 20 46 | } 47 | 48 | public class EnumTests { 49 | [Test] 50 | public void TestDefinedFlagsEnum() { 51 | DoTest(DefinedFlags.A); 52 | DoTest(DefinedFlags.B); 53 | DoTest(DefinedFlags.C); 54 | DoTest(DefinedFlags.A | DefinedFlags.B); 55 | DoTest(DefinedFlags.A | DefinedFlags.C); 56 | DoTest(DefinedFlags.A | DefinedFlags.B | DefinedFlags.C); 57 | } 58 | 59 | [Test] 60 | public void TestRegularFlagsEnum() { 61 | DoTest(RegularFlags.A); 62 | DoTest(RegularFlags.B); 63 | DoTest(RegularFlags.C); 64 | DoTest(RegularFlags.A | RegularFlags.B); 65 | DoTest(RegularFlags.A | RegularFlags.C); 66 | DoTest(RegularFlags.A | RegularFlags.B | RegularFlags.C); 67 | } 68 | 69 | [Test] 70 | public void TestEnum() { 71 | DoTest(NotFlags.A); 72 | DoTest(NotFlags.B); 73 | DoTest(NotFlags.C); 74 | DoTest(NotFlags.D); 75 | DoTest(NotFlags.A & NotFlags.B); 76 | } 77 | 78 | [Test] 79 | public void TestDefinedFlagsEnumUint() { 80 | DoTest(DefinedFlagsUint.A); 81 | DoTest(DefinedFlagsUint.B); 82 | DoTest(DefinedFlagsUint.C); 83 | DoTest(DefinedFlagsUint.A | DefinedFlagsUint.B); 84 | DoTest(DefinedFlagsUint.A | DefinedFlagsUint.C); 85 | DoTest(DefinedFlagsUint.A | DefinedFlagsUint.B | DefinedFlagsUint.C); 86 | } 87 | 88 | [Test] 89 | public void TestRegularFlagsEnumUint() { 90 | DoTest(RegularFlagsUint.A); 91 | DoTest(RegularFlagsUint.B); 92 | DoTest(RegularFlagsUint.C); 93 | DoTest(RegularFlagsUint.A | RegularFlagsUint.B); 94 | DoTest(RegularFlagsUint.A | RegularFlagsUint.C); 95 | DoTest(RegularFlagsUint.A | RegularFlagsUint.B | RegularFlagsUint.C); 96 | } 97 | 98 | [Test] 99 | public void TestEnumUint() { 100 | DoTest(NotFlagsUint.A); 101 | DoTest(NotFlagsUint.B); 102 | DoTest(NotFlagsUint.C); 103 | DoTest(NotFlagsUint.D); 104 | DoTest(NotFlagsUint.A & NotFlagsUint.B); 105 | } 106 | 107 | private void DoTest(T expected) { 108 | fsData serializedData; 109 | new fsSerializer().TrySerialize(expected, out serializedData).AssertSuccessWithoutWarnings(); 110 | 111 | var actual = default(T); 112 | new fsSerializer().TryDeserialize(serializedData, ref actual); 113 | 114 | Assert.AreEqual(expected, actual); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/EnumTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bf594f8ce0753a45a48a9399b0becee 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ErrorRecoveryTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2ba5ec56c3553b4eb229e547fa275ef 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/FloatJitterTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2867955dba7f54936a47c19a8d94ba2e 3 | timeCreated: 1454378263 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/IgnoreTypeTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | public class IgnoreTypeTests { 6 | [fsIgnore] 7 | private class IgnoredClass { 8 | } 9 | private class NotIgnoredClass { 10 | } 11 | [fsIgnore] 12 | private struct IgnoredStruct { 13 | } 14 | private struct NotIgnoredStruct { 15 | } 16 | private class Model { 17 | public IgnoredClass IgnoredClass; 18 | public NotIgnoredClass NotIgnoredClass; 19 | public IgnoredStruct IgnoredStruct; 20 | public NotIgnoredStruct NotIgnoredStruct; 21 | } 22 | 23 | [Test] 24 | public void TestSerializeReadOnlyProperty() { 25 | var model = new Model(); 26 | 27 | fsData data; 28 | 29 | var serializer = new fsSerializer(); 30 | Assert.IsTrue(serializer.TrySerialize(model, out data).Succeeded); 31 | 32 | var expected = fsData.CreateDictionary(); 33 | expected.AsDictionary["NotIgnoredClass"] = new fsData(); 34 | expected.AsDictionary["NotIgnoredStruct"] = fsData.CreateDictionary(); 35 | Assert.AreEqual(expected, data); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/IgnoreTypeTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa9e814e86d3cf641acc4bb8546cc109 3 | timeCreated: 1484568717 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/IndexerTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace FullSerializer.Tests { 4 | public class IndexerTests { 5 | class IndexerType { 6 | private int[] arr = new int[2]; 7 | 8 | [fsProperty] 9 | public int this[int i] { 10 | get { return arr[i]; } 11 | set { arr[i] = value; } 12 | } 13 | } 14 | 15 | [Test] 16 | public void TestIndexerType() { 17 | var original = new IndexerType(); 18 | original[0] = 1; 19 | original[1] = 5; 20 | var dup = Clone(original); 21 | 22 | // Silly test really; in an ideal world the below would succeed, 23 | // but serializing indexers is very hard so instead we test that FullSerializer doesn't crash while processing types with indexers! 24 | //Assert.AreEqual(original[0], dup[0]); 25 | //Assert.AreEqual(original[1], dup[1]); 26 | 27 | Assert.IsNotNull(dup); 28 | } 29 | 30 | private T Clone(T expected) { 31 | fsData serializedData; 32 | new fsSerializer().TrySerialize(expected, out serializedData).AssertSuccessWithoutWarnings(); 33 | var actual = default(T); 34 | new fsSerializer().TryDeserialize(serializedData, ref actual); 35 | return actual; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/IndexerTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 274b80356efac474792adcd540f717c7 3 | timeCreated: 1455211036 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/InitialInstanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | public class SimpleModel { 6 | public int A; 7 | public List B; 8 | } 9 | 10 | public class InitialInstanceTests { 11 | [Test] 12 | public void TestPopulateObject() { 13 | // This test verifies that when we pass in an existing object 14 | // instance that same instance is used to deserialize into, ie, 15 | // we can do the equivalent of Json.NET's PopulateObject 16 | 17 | SimpleModel model1 = new SimpleModel { A = 3, B = new List { 1, 2, 3 } }; 18 | 19 | fsData data; 20 | 21 | var serializer = new fsSerializer(); 22 | Assert.IsTrue(serializer.TrySerialize(model1, out data).Succeeded); 23 | 24 | model1.A = 1; 25 | model1.B = new List { 1 }; 26 | SimpleModel model2 = model1; 27 | Assert.AreEqual(1, model1.A); 28 | Assert.AreEqual(1, model2.A); 29 | CollectionAssert.AreEqual(new List { 1 }, model1.B); 30 | CollectionAssert.AreEqual(new List { 1 }, model2.B); 31 | 32 | Assert.IsTrue(serializer.TryDeserialize(data, ref model2).Succeeded); 33 | 34 | // If the same instance was not used, then model2.A will equal 1 35 | Assert.AreEqual(3, model1.A); 36 | Assert.AreEqual(3, model2.A); 37 | CollectionAssert.AreEqual(new List { 1, 2, 3 }, model1.B); 38 | CollectionAssert.AreEqual(new List { 1, 2, 3 }, model2.B); 39 | Assert.IsTrue(ReferenceEquals(model1, model2)); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/InitialInstanceTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3734fe2a0241efe40a0ebfaa08c4a3e9 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/LegacyDataTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace FullSerializer.Tests { 4 | public class LegacyDataTests { 5 | [Test] 6 | public void ImportLegacyInheritance() { 7 | fsData data = fsData.CreateDictionary(); 8 | data.AsDictionary["Type"] = new fsData("System.Int32"); 9 | data.AsDictionary["Data"] = new fsData(32); 10 | 11 | object o = null; 12 | var serializer = new fsSerializer(); 13 | Assert.IsTrue(serializer.TryDeserialize(data, ref o).Succeeded); 14 | 15 | Assert.IsTrue(o.GetType() == typeof(int)); 16 | Assert.IsTrue((int)o == 32); 17 | } 18 | 19 | public class Cycle { 20 | public Cycle Ref; 21 | public int Value; 22 | } 23 | 24 | [Test] 25 | public void ImportLegacyCycle() { 26 | fsData data = fsData.CreateDictionary(); 27 | data.AsDictionary["SourceId"] = new fsData("0"); 28 | data.AsDictionary["Data"] = fsData.CreateDictionary(); 29 | data.AsDictionary["Data"].AsDictionary["Value"] = new fsData(3); 30 | data.AsDictionary["Data"].AsDictionary["Ref"] = fsData.CreateDictionary(); 31 | data.AsDictionary["Data"].AsDictionary["Ref"].AsDictionary["ReferenceId"] = new fsData("0"); 32 | 33 | UnityEngine.Debug.Log(fsJsonPrinter.PrettyJson(data)); 34 | 35 | Cycle c = null; 36 | var serializer = new fsSerializer(); 37 | Assert.IsTrue(serializer.TryDeserialize(data, ref c).Succeeded); 38 | Assert.AreEqual(3, c.Value); 39 | Assert.AreEqual(c, c.Ref); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/LegacyDataTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 153713a4b7c491743b9e74af29151ac5 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/MemberSerializationTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UnityEngine; 3 | 4 | namespace FullSerializer.Tests { 5 | public class MemberSerializationTests { 6 | public class Base { 7 | public int Serialized0; 8 | } 9 | 10 | [fsObject(MemberSerialization = fsMemberSerialization.OptIn)] 11 | public class SimpleModel : Base { 12 | public int NotSerialized0; 13 | 14 | [fsProperty] 15 | public int Serialized1; 16 | [SerializeField] 17 | public int Serialized2; 18 | } 19 | 20 | [Test] 21 | public void TestOptIn() { 22 | var model1 = new SimpleModel { 23 | Serialized0 = 1, 24 | Serialized1 = 1, 25 | Serialized2 = 1, 26 | NotSerialized0 = 1 27 | }; 28 | 29 | fsData data; 30 | 31 | var serializer = new fsSerializer(); 32 | Assert.IsTrue(serializer.TrySerialize(model1, out data).Succeeded); 33 | 34 | SimpleModel model2 = null; 35 | Assert.IsTrue(serializer.TryDeserialize(data, ref model2).Succeeded); 36 | 37 | Debug.Log(fsJsonPrinter.PrettyJson(data)); 38 | 39 | Assert.AreEqual(model1.Serialized0, model2.Serialized0); 40 | Assert.AreEqual(model1.Serialized1, model2.Serialized1); 41 | Assert.AreEqual(model1.Serialized2, model2.Serialized2); 42 | Assert.AreEqual(0, model2.NotSerialized0); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/MemberSerializationTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d7cd18a9fc0fb647b9c0aecb57f3cf4 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/MinimalMetadataTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.RegularExpressions; 3 | using NUnit.Framework; 4 | 5 | namespace FullSerializer.Tests { 6 | public class MinimalMetadata { 7 | [fsObject(MemberSerialization = fsMemberSerialization.OptIn)] 8 | public class TestContents { 9 | [fsProperty] 10 | public int Number { get; set; } 11 | 12 | public override string ToString() { 13 | return string.Format("Number={0}", Number); 14 | } 15 | } 16 | 17 | [fsObject(MemberSerialization = fsMemberSerialization.OptIn)] 18 | public class TestContainer { 19 | 20 | [fsProperty] 21 | public string Id { get; set; } 22 | 23 | [fsProperty] 24 | public List Contents { get; set; } 25 | 26 | public TestContainer() { 27 | Id = "C1"; 28 | Contents = new List(); 29 | } 30 | 31 | public override string ToString() { 32 | return string.Format("Id={0}, Contents.Count={1}", Id, Contents.Count); 33 | } 34 | } 35 | 36 | [Test] 37 | public void JsonSerializerDoesNotEmitMetadata() { 38 | var container = new TestContainer() { Id = "C7" }; 39 | fsData data; 40 | (new fsSerializer()).TrySerialize(container, out data); 41 | var json = fsJsonPrinter.CompressedJson(data); 42 | 43 | // {"Id":"C7","Contents":{"$content":[]}} 44 | Assert.True(Regex.IsMatch(json, @"C7")); 45 | Assert.False(Regex.IsMatch(json, @"\$content")); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/MinimalMetadataTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7864cb6bb30e5d94e8a9a0e25ca7f66e 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ParseTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6aa79a1c0e637440b0c87d94ec95820 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ProcessorTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | public class OrderedProcessor : fsObjectProcessor { 6 | public override bool CanProcess(Type type) { 7 | return true; 8 | } 9 | 10 | public static int NextId; 11 | public int onBeforeSerialize, onAfterSerialize, onBeforeDeserialize, onAfterDeserialize; 12 | 13 | public override void OnBeforeSerialize(Type storageType, object instance) { 14 | onBeforeSerialize = ++NextId; 15 | } 16 | 17 | public override void OnAfterSerialize(Type storageType, object instance, ref fsData data) { 18 | onAfterSerialize = ++NextId; 19 | } 20 | 21 | public override void OnBeforeDeserialize(Type storageType, ref fsData data) { 22 | onBeforeDeserialize = ++NextId; 23 | } 24 | 25 | public override void OnAfterDeserialize(Type storageType, object instance) { 26 | onAfterDeserialize = ++NextId; 27 | } 28 | } 29 | 30 | public class ProcessorTests { 31 | [Test] 32 | public void TestProcessorOrdering() { 33 | DoTest(null); 34 | DoTest(3); 35 | DoTest(new fsData()); 36 | } 37 | 38 | private static void DoTest(T obj) { 39 | var serializer = new fsSerializer(); 40 | 41 | var processor1 = new OrderedProcessor(); 42 | var processor2 = new OrderedProcessor(); 43 | 44 | serializer.AddProcessor(processor1); 45 | serializer.AddProcessor(processor2); 46 | 47 | int id = 0; 48 | fsData data; 49 | OrderedProcessor.NextId = 0; 50 | 51 | serializer.TrySerialize(obj, out data).AssertSuccessWithoutWarnings(); 52 | Assert.AreEqual(++id, processor1.onBeforeSerialize); 53 | Assert.AreEqual(++id, processor2.onBeforeSerialize); 54 | Assert.AreEqual(++id, processor2.onAfterSerialize); 55 | Assert.AreEqual(++id, processor1.onAfterSerialize); 56 | 57 | 58 | id = 0; 59 | var deserialized = default(T); 60 | OrderedProcessor.NextId = 0; 61 | 62 | serializer.TryDeserialize(data, ref deserialized).AssertSuccessWithoutWarnings(); 63 | Assert.AreEqual(++id, processor1.onBeforeDeserialize); 64 | Assert.AreEqual(++id, processor2.onBeforeDeserialize); 65 | Assert.AreEqual(++id, processor2.onAfterDeserialize); 66 | Assert.AreEqual(++id, processor1.onAfterDeserialize); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/ProcessorTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be84c9b1c9135364ebbf9a03c18d41ea 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/PropertiesTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace FullSerializer.Tests { 4 | public class PropertiesTests { 5 | public class Model { 6 | [fsProperty] 7 | public int Getter { get { return 3; } } 8 | 9 | [fsIgnore] 10 | public int _setValue; 11 | 12 | [fsProperty] 13 | public int Setter { set { _setValue = value; } } 14 | } 15 | 16 | [Test] 17 | public void TestSerializeReadOnlyProperty() { 18 | var model = new Model(); 19 | 20 | fsData data; 21 | 22 | var serializer = new fsSerializer(); 23 | Assert.IsTrue(serializer.TrySerialize(model, out data).Succeeded); 24 | 25 | var expected = fsData.CreateDictionary(); 26 | expected.AsDictionary["Getter"] = new fsData(model.Getter); 27 | Assert.AreEqual(expected, data); 28 | } 29 | 30 | [Test] 31 | public void TestDeserializeWriteOnlyProperty() { 32 | var data = fsData.CreateDictionary(); 33 | data.AsDictionary["Getter"] = new fsData(111); // not used, but somewhat verifies that we do not try to deserialize into a R/O property 34 | data.AsDictionary["Setter"] = new fsData(222); 35 | 36 | var model = default(Model); 37 | var serializer = new fsSerializer(); 38 | Assert.IsTrue(serializer.TryDeserialize(data, ref model).Succeeded); 39 | 40 | Assert.AreEqual(222, model._setValue); 41 | } 42 | 43 | [Test] 44 | public void TestOptOutOfProperties() { 45 | var model = new Model(); 46 | 47 | fsData data; 48 | 49 | var serializer = new fsSerializer(); 50 | serializer.Config.EnablePropertySerialization = false; 51 | Assert.IsTrue( serializer.TrySerialize( model, out data ).Succeeded ); 52 | 53 | var expected = fsData.CreateDictionary(); // Should just be empty dictionary. 54 | Assert.AreEqual( expected, data ); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/PropertiesTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68632fac46cb1354fa368e1278cea3fb 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/SpecifiedConverterTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace FullSerializer.Tests { 5 | [fsObject(Converter = typeof(MyConverter))] 6 | public class MyModel { 7 | } 8 | 9 | public class ModelWithPropertyConverter { 10 | [fsProperty(Converter = typeof(MyConverter))] 11 | public object a; 12 | } 13 | 14 | public class MyConverter : fsConverter { 15 | public static bool DidSerialize = false; 16 | public static bool DidDeserialize = false; 17 | 18 | public override bool CanProcess(Type type) { 19 | throw new NotSupportedException(); 20 | } 21 | 22 | public override object CreateInstance(fsData data, Type storageType) { 23 | return new MyModel(); 24 | } 25 | 26 | public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) { 27 | DidSerialize = true; 28 | serialized = fsData.CreateDictionary(); 29 | return fsResult.Success; 30 | } 31 | 32 | public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) { 33 | DidDeserialize = true; 34 | return fsResult.Success; 35 | } 36 | } 37 | 38 | public class SpecifiedConverterTests { 39 | [Test] 40 | public void VerifyPropertyConverter() { 41 | MyConverter.DidDeserialize = false; 42 | MyConverter.DidSerialize = false; 43 | 44 | var serializer = new fsSerializer(); 45 | 46 | // Make sure to set |a| to some value, otherwise we will short-circuit serialize it to null. 47 | fsData result; 48 | serializer.TrySerialize(new ModelWithPropertyConverter { a = 3 }, out result); 49 | Assert.IsTrue(MyConverter.DidSerialize); 50 | Assert.IsFalse(MyConverter.DidDeserialize); 51 | 52 | MyConverter.DidSerialize = false; 53 | object resultObj = null; 54 | serializer.TryDeserialize(result, typeof(ModelWithPropertyConverter), ref resultObj); 55 | Assert.IsFalse(MyConverter.DidSerialize); 56 | Assert.IsTrue(MyConverter.DidDeserialize); 57 | } 58 | 59 | [Test] 60 | public void VerifyConversion() { 61 | MyConverter.DidDeserialize = false; 62 | MyConverter.DidSerialize = false; 63 | 64 | var serializer = new fsSerializer(); 65 | 66 | fsData result; 67 | serializer.TrySerialize(new MyModel(), out result); 68 | Assert.IsTrue(MyConverter.DidSerialize); 69 | Assert.IsFalse(MyConverter.DidDeserialize); 70 | 71 | MyConverter.DidSerialize = false; 72 | object resultObj = null; 73 | serializer.TryDeserialize(result, typeof (MyModel), ref resultObj); 74 | Assert.IsFalse(MyConverter.DidSerialize); 75 | Assert.IsTrue(MyConverter.DidDeserialize); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/SpecifiedConverterTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b5e25acaef2bda46aa7f94c04384d54 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/VersionedTypeTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ad4acbcbbd989948a7add264668c289 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/WarningPropagationTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using NUnit.Framework; 5 | 6 | namespace FullSerializer.Tests { 7 | [fsObject(Converter = typeof(ModelDirectConverter))] 8 | public class WarningModel {} 9 | 10 | public class ModelDirectConverter : fsDirectConverter { 11 | protected override fsResult DoDeserialize(Dictionary data, ref WarningModel model) { 12 | return fsResult.Warn("Warning"); 13 | } 14 | 15 | protected override fsResult DoSerialize(WarningModel model, Dictionary serialized) { 16 | return fsResult.Warn("Warning"); 17 | } 18 | 19 | public override object CreateInstance(fsData data, Type storageType) { 20 | return new WarningModel(); 21 | } 22 | } 23 | 24 | public class WarningPropagationTests { 25 | [Test] 26 | public void TestWarningsFromDirectConverters() { 27 | fsData data; 28 | var serializer = new fsSerializer(); 29 | 30 | fsResult result = serializer.TrySerialize(new WarningModel(), out data); 31 | Assert.AreEqual(1, result.RawMessages.Count()); 32 | Assert.AreEqual("Warning", result.RawMessages.First()); 33 | 34 | WarningModel model = null; 35 | result = serializer.TryDeserialize(data, ref model); 36 | Assert.AreEqual(1, result.RawMessages.Count()); 37 | Assert.AreEqual("Warning", result.RawMessages.First()); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/WarningPropagationTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bc111533d3d244039ad977f250d9b46 3 | timeCreated: 1453880036 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/fsForwardTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using NUnit.Framework; 5 | 6 | namespace FullSerializer.Tests { 7 | [fsForward("a")] 8 | struct ForwardInt { 9 | public int a; 10 | } 11 | [fsForward("a")] 12 | struct ForwardArray { 13 | public int[] a; 14 | 15 | public override int GetHashCode() { 16 | return base.GetHashCode(); 17 | } 18 | public override bool Equals(object obj) { 19 | int[] oa = ((ForwardArray)obj).a; 20 | return Enumerable.SequenceEqual(a, oa); 21 | } 22 | } 23 | [fsForward("a")] 24 | struct ForwardList { 25 | public List a; 26 | 27 | public override int GetHashCode() { 28 | return base.GetHashCode(); 29 | } 30 | public override bool Equals(object obj) { 31 | List oa = ((ForwardList)obj).a; 32 | return Enumerable.SequenceEqual(a, oa); 33 | } 34 | } 35 | [fsForward("ok")] 36 | struct ForwardBadRef { 37 | } 38 | 39 | public class fsForwardTests { 40 | [Test] 41 | public void TestForwarding() { 42 | DoTest(new ForwardInt { a = 1 }, "1"); 43 | DoTest(new ForwardArray { a = new[] { 1, 2, 3 } }, "[1,2,3]"); 44 | DoTest(new ForwardList { a = new List() { 1, 2, 3 } }, "[1,2,3]"); 45 | 46 | Assert.Throws(typeof(Exception), () => { 47 | DoTest(new ForwardBadRef(), "{}"); 48 | }); 49 | } 50 | 51 | private void DoTest(T instance, string expectedJson) { 52 | fsData expected = fsJsonParser.Parse(expectedJson); 53 | 54 | fsData serializedData; 55 | new fsSerializer().TrySerialize(instance, out serializedData).AssertSuccessWithoutWarnings(); 56 | Assert.AreEqual(expected, serializedData); 57 | 58 | var actual = default(T); 59 | new fsSerializer().TryDeserialize(serializedData, ref actual); 60 | 61 | Assert.AreEqual(instance, actual); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/Editor/fsForwardTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b55487ff44e5684fbbf750d51c9e0a3 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6bbc8497b0613e4aa7cfd1d4cd2f8c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48e584ffd30107244aa6144603ea4126 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/CustomIEnumerableProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using FullSerializer; 5 | 6 | public class MyEnumerableTypeWithoutAdd : IEnumerable { 7 | public int A; 8 | 9 | public IEnumerator GetEnumerator() { 10 | throw new NotImplementedException(); 11 | } 12 | } 13 | 14 | public class MyEnumerableTypeWithAdd : IEnumerable { 15 | [fsIgnore] 16 | public List items = new List(); 17 | 18 | public void Add(int item) { 19 | items.Add(item); 20 | } 21 | 22 | public IEnumerator GetEnumerator() { 23 | return items.GetEnumerator(); 24 | } 25 | } 26 | 27 | public class CustomIEnumerableProviderWithoutAdd : TestProvider { 28 | public override bool Compare(MyEnumerableTypeWithoutAdd before, MyEnumerableTypeWithoutAdd after) { 29 | return before.A == after.A; 30 | } 31 | 32 | public override IEnumerable GetValues() { 33 | yield return new MyEnumerableTypeWithoutAdd { A = -1 }; 34 | yield return new MyEnumerableTypeWithoutAdd { A = 0 }; 35 | yield return new MyEnumerableTypeWithoutAdd { A = 1 }; 36 | } 37 | } 38 | 39 | public class CustomIEnumerableProviderWithAdd : TestProvider { 40 | public override bool Compare(MyEnumerableTypeWithAdd before, MyEnumerableTypeWithAdd after) { 41 | if (before.items.Count != after.items.Count) return false; 42 | for (int i = 0; i < before.items.Count; ++i) { 43 | if (before.items[i] != after.items[i]) return false; 44 | } 45 | return true; 46 | } 47 | 48 | public override IEnumerable GetValues() { 49 | yield return new MyEnumerableTypeWithAdd(); 50 | yield return new MyEnumerableTypeWithAdd { 1 }; 51 | yield return new MyEnumerableTypeWithAdd { 1, 2, 3 }; 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/CustomIEnumerableProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16e2d067c7cc9e74db948ff2313c2200 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/CustomListProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public interface IListType : IList { 6 | } 7 | 8 | public class MyList : IListType { 9 | public List _backing; 10 | 11 | public MyList() { 12 | _backing = new List(); 13 | } 14 | 15 | public MyList(List list) { 16 | _backing = new List(list); 17 | } 18 | 19 | public IEnumerator GetEnumerator() { 20 | return _backing.GetEnumerator(); 21 | } 22 | 23 | IEnumerator IEnumerable.GetEnumerator() { 24 | return GetEnumerator(); 25 | } 26 | 27 | public void Add(int item) { 28 | _backing.Add(item); 29 | } 30 | 31 | public void Clear() { 32 | throw new NotImplementedException(); 33 | } 34 | 35 | public bool Contains(int item) { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public void CopyTo(int[] array, int arrayIndex) { 40 | throw new NotImplementedException(); 41 | } 42 | 43 | public bool Remove(int item) { 44 | throw new NotImplementedException(); 45 | } 46 | 47 | public int Count { 48 | get { return _backing.Count; } 49 | } 50 | 51 | public bool IsReadOnly { 52 | get { throw new NotImplementedException(); } 53 | } 54 | 55 | public int IndexOf(int item) { 56 | throw new NotImplementedException(); 57 | } 58 | 59 | public void Insert(int index, int item) { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | public void RemoveAt(int index) { 64 | throw new NotImplementedException(); 65 | } 66 | 67 | public int this[int index] { 68 | get { return _backing[index]; } 69 | set { _backing[index] = value; } 70 | } 71 | } 72 | 73 | public struct Wrapper { 74 | public IListType container; 75 | } 76 | 77 | public class CustomListProvider : TestProvider { 78 | public override bool Compare(IListType before, IListType after) { 79 | if (before.Count != after.Count) return false; 80 | for (int i = 0; i < before.Count; ++i) { 81 | if (before[i] != after[i]) return false; 82 | } 83 | return true; 84 | } 85 | 86 | public override IEnumerable GetValues() { 87 | yield return new MyList(); 88 | yield return new MyList { 1, 2, 3, 4, 5, 6, 7 }; 89 | } 90 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/CustomListProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ba29e473b8f73544865838b05d3cc42 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/CyclesProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2366837dca31e6f408ad57b89b966c7d 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/DateProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | 5 | public class DateTimeProvider : TestProvider { 6 | public override bool Compare(DateTime original, DateTime deserialized) { 7 | return original == deserialized; 8 | } 9 | 10 | public override IEnumerable GetValues() { 11 | yield return new DateTime(2009, 2, 15, 0, 0, 0, DateTimeKind.Utc); 12 | yield return DateTime.Now; 13 | yield return DateTime.MaxValue.Subtract(TimeSpan.FromTicks(1)); 14 | yield return DateTime.MinValue; 15 | yield return new DateTime(); 16 | yield return DateTime.UtcNow; 17 | yield return DateTime.Now.AddDays(5).AddHours(3).AddTicks(1); 18 | yield return Convert.ToDateTime("2016-01-22T12:06:57.503005Z"); 19 | } 20 | } 21 | 22 | public class DateTimeOffsetProvider : TestProvider { 23 | public override bool Compare(DateTimeOffset original, DateTimeOffset deserialized) { 24 | return original == deserialized; 25 | } 26 | 27 | public override IEnumerable GetValues() { 28 | #if !UNITY_WINRT 29 | yield return new DateTimeOffset(5500, 2, 15, 0, 0, 0, 5, new HebrewCalendar(), new TimeSpan()); 30 | #endif 31 | yield return DateTimeOffset.Now; 32 | yield return DateTimeOffset.MaxValue.Subtract(TimeSpan.FromTicks(1)); 33 | yield return DateTimeOffset.MinValue; 34 | yield return new DateTimeOffset(); 35 | yield return DateTimeOffset.UtcNow; 36 | 37 | // TODO: why is this invalid? 38 | //yield return DateTimeOffset.Now.AddDays(5).AddHours(3).AddTicks(1); 39 | } 40 | } 41 | 42 | public class TimeSpanProvider : TestProvider { 43 | public override bool Compare(TimeSpan original, TimeSpan deserialized) { 44 | return original == deserialized; 45 | } 46 | 47 | public override IEnumerable GetValues() { 48 | yield return TimeSpan.MaxValue; 49 | yield return TimeSpan.MinValue; 50 | 51 | yield return new TimeSpan(); 52 | 53 | yield return new TimeSpan() 54 | .Add(TimeSpan.FromDays(3)) 55 | .Add(TimeSpan.FromHours(2)) 56 | .Add(TimeSpan.FromMinutes(33)) 57 | .Add(TimeSpan.FromSeconds(35)) 58 | .Add(TimeSpan.FromMilliseconds(35)) 59 | .Add(TimeSpan.FromTicks(250)); 60 | } 61 | } 62 | 63 | public class NullableDateTimeProvider : TestProvider> { 64 | public override bool Compare(ValueHolder before, ValueHolder after) { 65 | return before.Value == after.Value; 66 | } 67 | 68 | public override IEnumerable> GetValues() { 69 | yield return new ValueHolder(null); 70 | yield return new ValueHolder(DateTime.UtcNow); 71 | } 72 | } 73 | 74 | public class NullableDateTimeOffsetProvider : TestProvider> { 75 | public override bool Compare(ValueHolder before, ValueHolder after) { 76 | return before.Value == after.Value; 77 | } 78 | 79 | public override IEnumerable> GetValues() { 80 | yield return new ValueHolder(null); 81 | yield return new ValueHolder(DateTimeOffset.UtcNow); 82 | } 83 | } 84 | 85 | public class NullableTimeSpanProvider : TestProvider> { 86 | public override bool Compare(ValueHolder before, ValueHolder after) { 87 | return before.Value == after.Value; 88 | } 89 | 90 | public override IEnumerable> GetValues() { 91 | yield return new ValueHolder(null); 92 | yield return new ValueHolder(TimeSpan.FromSeconds(35)); 93 | } 94 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/DateProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da96c0f79c2760d49b41977f1e490c63 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/EncodedDataProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class MyEncodedData { 4 | private MyEncodedData() { } 5 | 6 | public static MyEncodedData Make(string value) { return new MyEncodedData { value = value }; } 7 | public string value; 8 | } 9 | 10 | public class EncodedDataProvider : TestProvider { 11 | 12 | public override bool Compare(MyEncodedData before, MyEncodedData after) { 13 | return before.value == after.value; 14 | } 15 | 16 | public override IEnumerable GetValues() { 17 | yield return MyEncodedData.Make(@"P:\UnityProjects"); 18 | yield return MyEncodedData.Make(@"P:\\UnityProjects"); 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/EncodedDataProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a75851211daad2d4596d11afe86898e4 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/EnumProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public enum SimpleEnum { 5 | A, B, C, D, E 6 | } 7 | 8 | [Flags] 9 | public enum SimpleFlagsEnum { 10 | A = 1, B = 2, C = 4, D = 8, E = 16 11 | } 12 | 13 | public class SimpleEnumProvider : TestProvider { 14 | public override bool Compare(SimpleEnum before, SimpleEnum after) { 15 | return before == after; 16 | } 17 | 18 | public override IEnumerable GetValues() { 19 | yield return SimpleEnum.A; 20 | yield return SimpleEnum.C; 21 | yield return SimpleEnum.D; 22 | } 23 | } 24 | 25 | public class FlagsEnumProvider : TestProvider { 26 | public override bool Compare(SimpleFlagsEnum before, SimpleFlagsEnum after) { 27 | return before == after; 28 | } 29 | 30 | public override IEnumerable GetValues() { 31 | yield return SimpleFlagsEnum.A; 32 | yield return SimpleFlagsEnum.A | SimpleFlagsEnum.B; 33 | yield return SimpleFlagsEnum.B | SimpleFlagsEnum.C | SimpleFlagsEnum.D | SimpleFlagsEnum.E; 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/EnumProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3250318838a1fc84ea392424b568d43b 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/GuidProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class GuidProvider : TestProvider { 5 | public override bool Compare(Guid before, Guid after) { 6 | return before == after; 7 | } 8 | 9 | public override IEnumerable GetValues() { 10 | yield return new Guid(); 11 | yield return Guid.NewGuid(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/GuidProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73998f88888d301459056d101f3e8e10 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/IDictionaryProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aed0a5f2527183d40b3e55c4e84c5499 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/KeyValuePairProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class KeyValuePairProvider : TestProvider { 5 | private static KeyValuePair Make(TKey key, TValue value) { 6 | return new KeyValuePair(key, value); 7 | } 8 | 9 | public override bool Compare(object before, object after) { 10 | if (before is List>) { 11 | var beforeA = (List>)before; 12 | var afterA = (List>)after; 13 | 14 | return 15 | beforeA.Except(afterA).Count() == 0 && 16 | afterA.Except(beforeA).Count() == 0; 17 | } 18 | 19 | return EqualityComparer.Default.Equals(before, after); 20 | } 21 | 22 | public override IEnumerable GetValues() { 23 | yield return Make(1, 2); 24 | yield return Make("yes", 2); 25 | yield return Make("1", "2"); 26 | yield return Make(Make(1, 2), Make("1", "2")); 27 | yield return new List>() { 28 | Make(1, 2), 29 | Make(2, 3), 30 | Make(4, 5) 31 | }; 32 | yield return Make(null, string.Empty); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/KeyValuePairProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37b659aa849b9344fa9f97a1f95f69c7 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/KeyedCollectionProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | public class TestCollection : KeyedCollection { 5 | protected override TestEnum GetKeyForItem(TestClass item) { 6 | return item == null ? TestEnum.Null : item.TestEnum; 7 | } 8 | 9 | public bool TryGetValue(TestEnum key, out TestClass item) { 10 | if (Dictionary == null) { 11 | item = default(TestClass); 12 | return false; 13 | } 14 | 15 | return Dictionary.TryGetValue(key, out item); 16 | } 17 | 18 | public new bool Contains(TestClass item) { 19 | return base.Contains(GetKeyForItem(item)); 20 | } 21 | } 22 | 23 | public enum TestEnum { 24 | Null, 25 | Value1, 26 | Value2, 27 | Value3 28 | } 29 | 30 | public class TestClass { 31 | public TestEnum TestEnum { get; set; } 32 | } 33 | 34 | public class KeyedCollectionProvider : TestProvider { 35 | public override bool Compare(TestCollection before, TestCollection after) { 36 | if (before.Count != after.Count) return false; 37 | for (int i = 0; i < before.Count; ++i) { 38 | if (before[i].TestEnum != after[i].TestEnum) return false; 39 | } 40 | return true; 41 | } 42 | 43 | public override IEnumerable GetValues() { 44 | yield return new TestCollection(); 45 | yield return new TestCollection { 46 | new TestClass { TestEnum = TestEnum.Null } 47 | }; 48 | yield return new TestCollection { 49 | new TestClass { TestEnum = TestEnum.Null }, 50 | new TestClass { TestEnum = TestEnum.Value1 }, 51 | }; 52 | yield return new TestCollection { 53 | new TestClass { TestEnum = TestEnum.Null }, 54 | new TestClass { TestEnum = TestEnum.Value1 }, 55 | new TestClass { TestEnum = TestEnum.Value2 }, 56 | }; 57 | yield return new TestCollection { 58 | new TestClass { TestEnum = TestEnum.Null }, 59 | new TestClass { TestEnum = TestEnum.Value1 }, 60 | new TestClass { TestEnum = TestEnum.Value2}, 61 | new TestClass { TestEnum = TestEnum.Value3 }, 62 | }; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/KeyedCollectionProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79f7a8e481276ba40a5af5e5baa7f0b5 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/NumberProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class NumberProvider : TestProvider { 5 | public override bool Compare(object before, object after) { 6 | return EqualityComparer.Default.Equals(before, after); 7 | } 8 | 9 | public override IEnumerable GetValues() { 10 | yield return (Single)(-2.5f); 11 | yield return Single.MaxValue; 12 | yield return Single.MinValue; 13 | 14 | yield return (Double)(-2.5); 15 | //yield return Double.MaxValue; // Mono errors on Double.Parse(Double.MaxValue.ToString()) 16 | //yield return Double.MinValue; // Mono errors on Double.Parse(Double.MinValue.ToString()) 17 | 18 | yield return (Decimal).2; 19 | //yield return Decimal.MaxValue; 20 | //yield return Decimal.MinValue; 21 | 22 | yield return (Byte)2; 23 | yield return Byte.MinValue; 24 | yield return Byte.MaxValue; 25 | 26 | yield return (SByte)2; 27 | yield return SByte.MinValue; 28 | yield return SByte.MaxValue; 29 | 30 | yield return (UInt16)2; 31 | yield return UInt16.MinValue; 32 | yield return UInt16.MaxValue; 33 | 34 | yield return (Int16)4; 35 | yield return Int16.MinValue; 36 | yield return Int16.MaxValue; 37 | 38 | yield return (UInt32)5; 39 | yield return UInt32.MinValue; 40 | yield return UInt32.MaxValue; 41 | 42 | yield return (Int32)6; 43 | yield return Int32.MinValue; 44 | yield return Int32.MaxValue; 45 | 46 | yield return (UInt64)7; 47 | yield return UInt64.MinValue; 48 | //yield return UInt64.MaxValue; 49 | 50 | yield return (Int64)8; 51 | yield return Int64.MinValue; 52 | yield return Int64.MaxValue; 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/NumberProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a685b06245d1fd43840a5844b44d91d 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/OptOutProvider.cs: -------------------------------------------------------------------------------- 1 | using FullSerializer; 2 | using System.Collections.Generic; 3 | 4 | [fsObject(MemberSerialization = fsMemberSerialization.OptOut)] 5 | public class OptOut { 6 | public OptOut() { } 7 | public OptOut(int publicField, int publicAutoProperty, int publicManualProperty, int privateField, int privateAutoProperty, int ignoredField, int ignoredAutoProperty) { 8 | this.publicField = publicField; 9 | this.publicAutoProperty = publicAutoProperty; 10 | this.publicManualProperty = publicManualProperty; 11 | this.privateField = privateField; 12 | this.privateAutoProperty = privateAutoProperty; 13 | this.ignoredField = ignoredField; 14 | this.ignoredAutoProperty = ignoredAutoProperty; 15 | } 16 | 17 | public int publicField; 18 | public int publicAutoProperty { get; set; } 19 | public int publicManualProperty { get { return publicField; } set { publicField = value; } } 20 | private int privateField; 21 | private int privateAutoProperty { get; set; } 22 | public int GetPrivateField() { return privateField; } 23 | public int GetPrivateAutoProperty() { return privateAutoProperty; } 24 | 25 | [fsIgnore] 26 | private int ignoredField; 27 | 28 | [fsIgnore] 29 | private int ignoredAutoProperty { get; set; } 30 | 31 | public int GetIgnoredField() { return ignoredField; } 32 | public int GetIgnoredAutoProperty() { return ignoredAutoProperty; } 33 | } 34 | 35 | public class OptOutProvider : TestProvider { 36 | public override bool Compare(OptOut before, OptOut after) { 37 | return 38 | before.publicField == after.publicField && 39 | before.publicAutoProperty == after.publicAutoProperty && 40 | before.publicManualProperty == after.publicManualProperty && 41 | before.GetPrivateField() == after.GetPrivateField() && 42 | before.GetPrivateAutoProperty() == after.GetPrivateAutoProperty() && 43 | 44 | before.GetIgnoredField() != after.GetIgnoredField() && 45 | before.GetIgnoredAutoProperty() != after.GetIgnoredAutoProperty(); 46 | } 47 | 48 | public override IEnumerable GetValues() { 49 | yield return new OptOut(1, 1, 1, 1, 1, 1, 1); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/OptOutProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e32e78f7a54f9545b81579b66c4eb46 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/PrivateFieldsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using FullSerializer; 3 | 4 | public class PrivateHolder { 5 | public PrivateHolder() { } 6 | 7 | public void Setup() { 8 | SerializedField = 1; 9 | SerializedProperty = 2; 10 | } 11 | 12 | [fsProperty] 13 | private int SerializedField; 14 | 15 | [fsProperty] 16 | private int SerializedProperty { get; set; } 17 | 18 | public override bool Equals(object obj) { 19 | var other = obj as PrivateHolder; 20 | if (other == null) return false; 21 | 22 | return 23 | SerializedField == other.SerializedField && 24 | SerializedProperty == other.SerializedProperty; 25 | } 26 | 27 | public override int GetHashCode() { 28 | return SerializedField.GetHashCode() + (17 * SerializedProperty.GetHashCode()); 29 | } 30 | } 31 | 32 | public class PrivateFieldsProvider : TestProvider { 33 | public override bool Compare(PrivateHolder before, PrivateHolder after) { 34 | return before.Equals(after); 35 | } 36 | 37 | public override IEnumerable GetValues() { 38 | var holder = new PrivateHolder(); 39 | holder.Setup(); 40 | yield return holder; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/PrivateFieldsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 947556f752da91044bd5cb2ad96a4977 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/PropertiesProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using FullSerializer; 4 | 5 | public class PropertiesProvider : TestProvider { 6 | public struct PublicGetPublicSet { 7 | public PublicGetPublicSet(int value) : this() { Value = value; } 8 | public int Value { get; set; } 9 | } 10 | 11 | public struct PrivateGetPublicSet { 12 | public PrivateGetPublicSet(int value) : this() { Value = value; } 13 | [fsProperty] 14 | public int Value { private get; set; } 15 | 16 | public static bool Compare(PrivateGetPublicSet a, PrivateGetPublicSet b) { 17 | return a.Value == b.Value; 18 | } 19 | } 20 | 21 | public struct PublicGetPrivateSet { 22 | public PublicGetPrivateSet(int value) : this() { Value = value; } 23 | public int Value { get; private set; } 24 | } 25 | 26 | public struct PrivateGetPrivateSet { 27 | public PrivateGetPrivateSet(int value) : this() { Value = value; } 28 | private int Value { get; set; } 29 | 30 | public bool Verify() { 31 | if (Value != 0) { 32 | throw new Exception("Private autoproperty was deserialized"); 33 | } 34 | 35 | return true; 36 | } 37 | } 38 | 39 | public override bool Compare(object before, object after) { 40 | if (before is PublicGetPublicSet) { 41 | var beforeA = (PublicGetPublicSet)before; 42 | var afterA = (PublicGetPublicSet)after; 43 | 44 | return beforeA.Value == afterA.Value; 45 | } 46 | 47 | if (before is PrivateGetPublicSet) { 48 | var beforeA = (PrivateGetPublicSet)before; 49 | var afterA = (PrivateGetPublicSet)after; 50 | 51 | return PrivateGetPublicSet.Compare(beforeA, afterA); 52 | } 53 | 54 | if (before is PublicGetPrivateSet) { 55 | var beforeA = (PublicGetPrivateSet)before; 56 | var afterA = (PublicGetPrivateSet)after; 57 | 58 | return beforeA.Value == afterA.Value; 59 | } 60 | 61 | if (after is PrivateGetPrivateSet) { 62 | return ((PrivateGetPrivateSet)after).Verify(); 63 | } 64 | 65 | throw new Exception("Unknown type"); 66 | } 67 | 68 | public override IEnumerable GetValues() { 69 | for (int i = -1; i <= 1; ++i) { 70 | yield return new PublicGetPublicSet(i); 71 | yield return new PrivateGetPublicSet(i); 72 | yield return new PublicGetPrivateSet(i); 73 | yield return new PrivateGetPrivateSet(i); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/PropertiesProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28313dccfa1a2d84c92dd11405ff1504 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/QueueProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class QueueProvider : TestProvider> { 5 | public override bool Compare(Queue before, Queue after) { 6 | return 7 | before.Except(after).Count() == 0 && 8 | after.Except(before).Count() == 0; 9 | } 10 | 11 | public override IEnumerable> GetValues() { 12 | yield return new Queue(); 13 | 14 | var q = new Queue(); 15 | q.Enqueue(1); 16 | yield return q; 17 | 18 | q = new Queue(); 19 | q.Enqueue(1); 20 | q.Enqueue(5); 21 | q.Enqueue(3); 22 | yield return q; 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/QueueProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb9fca80f20cdac4ba12fe1f7249f4a1 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/StackProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class StackProvider : TestProvider> { 5 | public override bool Compare(Stack before, Stack after) { 6 | return 7 | before.Except(after).Count() == 0 && 8 | after.Except(before).Count() == 0; 9 | } 10 | 11 | public override IEnumerable> GetValues() { 12 | yield return new Stack(); 13 | 14 | var s = new Stack(); 15 | s.Push(1); 16 | yield return s; 17 | 18 | s = new Stack(); 19 | s.Push(1); 20 | s.Push(5); 21 | s.Push(3); 22 | yield return s; 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/StackProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 419e39fd4405fdb4baf85ab256b647c5 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/TypeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class TypeProvider : TestProvider { 6 | public override bool Compare(Type before, Type after) { 7 | return before == after; 8 | } 9 | 10 | public override IEnumerable GetValues() { 11 | yield return typeof(int); 12 | yield return typeof(TestProvider<>); 13 | yield return typeof(TestProvider); 14 | } 15 | } 16 | 17 | public class TypeListProvider : TestProvider> { 18 | public override bool Compare(List before, List after) { 19 | return 20 | before.Except(after).Count() == 0 && 21 | after.Except(before).Count() == 0; 22 | } 23 | 24 | public override IEnumerable> GetValues() { 25 | // This verifies that cycle detection is disabled 26 | yield return new List { 27 | typeof(int), typeof(int), typeof(float), typeof(int) 28 | }; 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/TypeProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93ad1e2952f63a44c9493fd5e3ced5ef 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/ValueHolder.cs: -------------------------------------------------------------------------------- 1 | public class ValueHolder { 2 | public T Value; 3 | 4 | public ValueHolder() { } 5 | 6 | public ValueHolder(T value) { 7 | Value = value; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/Providers/ValueHolder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55cfe7bf0d5ee5b418142bceba6f3746 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/RuntimeTests/RuntimeTestRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4232785b1853b34e9828cd2a24af45c 3 | timeCreated: 1451205258 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/test_scene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/Assets/FullSerializer/Testing/test_scene.unity -------------------------------------------------------------------------------- /Assets/FullSerializer/Testing/test_scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d980f48cf88544b994526e5811a780 3 | timeCreated: 1451205257 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Automation/UnityEngine.UI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/Automation/UnityEngine.UI.dll -------------------------------------------------------------------------------- /Automation/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/Automation/UnityEngine.dll -------------------------------------------------------------------------------- /Automation/compile.sh: -------------------------------------------------------------------------------- 1 | ROOT_DIR=$(pwd) 2 | WORK_DIR="Output" 3 | SOURCE_DIR="$ROOT_DIR/Assets/FullSerializer" 4 | UNITY_DLL_FOLDER="$ROOT_DIR/Automation" 5 | 6 | # Output DLL names. 7 | OUTPUT_NAME=FullSerializer 8 | 9 | mkdir "$WORK_DIR" 10 | cd "$WORK_DIR" 11 | 12 | # Fetch sources to use. 13 | ALL_SOURCES=$(find $SOURCE_DIR -name \*.cs | grep -v 'Editor/') 14 | 15 | # Common compilation settings. 16 | COMPILER="mcs 17 | /lib:$UNITY_DLL_FOLDER 18 | /reference:UnityEngine.dll 19 | /reference:UnityEngine.UI.dll 20 | /nowarn:1591 21 | /target:library /debug /sdk:2" 22 | 23 | # Compile runtime and editor DLLs. 24 | $COMPILER \ 25 | /out:"$OUTPUT_NAME.dll" /doc:"$OUTPUT_NAME.xml" \ 26 | $ALL_SOURCES 27 | 28 | zip -r "$ROOT_DIR/FullSerializer-DLLs.zip" $(find . -type f) 29 | 30 | cd $ROOT_DIR/Assets 31 | zip -r "$ROOT_DIR/FullSerializer-Source.zip" $(find FullSerializer -name \*.cs) 32 | 33 | cd $ROOT_DIR 34 | rm -rf "$WORK_DIR" 35 | -------------------------------------------------------------------------------- /BuildFiles/ProjectFiles/CommonData.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | C:\Program Files\Unity 5.0.0f4\Editor 8 | 9 | 10 | ..\..\Assets\FullSerializer 11 | 12 | 13 | 14 | Library 15 | Build 16 | v3.5 17 | 18 | 512 19 | 20 | $(UnityInstallFolder)\Data\Managed;$(UnityInstallFolder)\Data\PlaybackEngines\wp8support\Managed 21 | $(UnityInstallFolder)\Data\MonoBleedingEdge\lib\mono\4.0\pdb2mdb.exe 22 | 23 | prompt 24 | 4 25 | 26 | 27 | 28 | 29 | AnyCPU 30 | true 31 | full 32 | false 33 | DEBUG 34 | 35 | 36 | 37 | 38 | AnyCPU 39 | pdbonly 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /BuildFiles/ProjectFiles/FullSerializer - NoUnity.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | {59861E1D-6E26-4851-9B1B-A31D7D3825AB} 8 | FullSerializer-NoUnity 9 | $(OutputPath)\$(AssemblyName).xml 10 | 11 | NO_UNITY 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /BuildFiles/ProjectFiles/FullSerializer - Unity - WinRT.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | v4.6 9 | Profile32 10 | 11 | 12 | 13 | 14 | 15 | {71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7} 16 | FullSerializer-Unity-WinRT 17 | $(OutputPath)\$(AssemblyName).xml 18 | 19 | UNITY_METRO 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /BuildFiles/ProjectFiles/FullSerializer - Unity.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7} 8 | FullSerializer-Unity 9 | $(OutputPath)\$(AssemblyName).xml 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /BuildFiles/ProjectFiles/FullSerializer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FullSerializer - Unity", "FullSerializer - Unity.csproj", "{61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FullSerializer - Unity - WinRT", "FullSerializer - Unity - WinRT.csproj", "{71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FullSerializer - NoUnity", "FullSerializer - NoUnity.csproj", "{59861E1D-6E26-4851-9B1B-A31D7D3825AB}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {61A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {71A89EEC-36B9-49ED-8431-D6A7DBDD9EA7}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {59861E1D-6E26-4851-9B1B-A31D7D3825AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {59861E1D-6E26-4851-9B1B-A31D7D3825AB}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {59861E1D-6E26-4851-9B1B-A31D7D3825AB}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {59861E1D-6E26-4851-9B1B-A31D7D3825AB}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /BuildFiles/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Compiles Full Serializer into the current directory. This includes: 4 | # - runtime/editor DLL files 5 | # - XML docs 6 | # - mdb debugging information 7 | 8 | # This script can be directly run 9 | # 10 | # $ ./compile.sh 11 | # 12 | # Make sure the script is marked executable: 13 | # 14 | # $ chmod +x compile.sh 15 | 16 | # This script can be customized when calling it. For example, to use a local C# 17 | # compiler instead of the one Unity ships with, the script can be called like: 18 | # 19 | # mcs_path=mcs ./compile.sh 20 | 21 | unity_path=${unity_root:-"/Applications/Unity/Unity.app/Contents"} 22 | mcs_path=${mcs_path:-"$unity_path/Frameworks/MonoBleedingEdge/bin/mcs"} 23 | 24 | dll_output_path=${dll_file:-"FullSerializer.dll"} 25 | doc_output_path=${doc_file:-"FullSerializer.xml"} 26 | 27 | # script_dir is the path to the directory containing this script file. 28 | script_dir="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" 29 | source_dir=${source_dir:-"$script_dir/../Assets/FullSerializer/Source"} 30 | input_files=$(find $source_dir -name \*.cs) 31 | 32 | echo "unity_path: '$unity_path'" 33 | echo "mcs_path (C# compiler): '$mcs_path'" 34 | echo "source_dir: '$source_dir'" 35 | echo "Compiling DLLs (output_dll_file: $dll_output_path,"\ 36 | "output_doc_file: $doc_output_path)" 37 | 38 | # TODO: Remove warning suppressions (all of them are for missing XML docs) 39 | $mcs_path \ 40 | /lib:$unity_path/Frameworks/Managed \ 41 | /reference:UnityEngine.dll \ 42 | /target:library /debug /sdk:2 \ 43 | /nowarn:1570 \ 44 | /nowarn:1572 \ 45 | /nowarn:1573 \ 46 | /nowarn:1587 \ 47 | /nowarn:1591 \ 48 | /out:$dll_output_path /doc:$doc_output_path \ 49 | $input_files 50 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jacob Dufault 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d083366be98d43c4abc990b8d8ce9f3 3 | timeCreated: 1451207124 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LIMITATIONS.md: -------------------------------------------------------------------------------- 1 | # Limitations 2 | Full Serializer tries hard to prevent any serialization restrictions, but some them of are simply unavoidable. Depending on your export platform, certain features in Full Serializer may not be available. 3 | 4 | If you know of a way to remove any of these limitations, please make sure to bring it up. 5 | 6 | ## WebPlayer 7 | 8 | - All serialized types need to have a default constructor (`FormatterServices.GetUninitializedObject` is not available - `Activator.CreateInstance` must be used instead). 9 | -------------------------------------------------------------------------------- /LIMITATIONS.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ed6c162d743d4c5489e2e592dafe135 3 | timeCreated: 1451207124 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.1f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobdufault/fullserializer/dbea7d57dbab4b8494e8614ee6b27343ba263806/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32f2663d56dd84407b5f9dea10e984fa 3 | timeCreated: 1451207124 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Exit if any (simple) command fails. 4 | #set -e 5 | 6 | # Inspired from https://github.com/JonathanPorta/ci-build 7 | 8 | project="FullSerializer" 9 | version=$(cat VERSION.md) 10 | 11 | log_dir=$(pwd)/Logs 12 | output_dir=$(pwd)/Output 13 | project_path=$(pwd) 14 | unity=/Applications/Unity/Unity.app/Contents/MacOS/Unity 15 | 16 | mkdir $log_dir 17 | mkdir $output_dir 18 | 19 | # Modify the directory structure so that we have a clean Unity package export. 20 | mv *.md* Assets/FullSerializer/ 21 | mv Assets/FullSerializer/Testing Assets-FullSerializer-Testing 22 | mv Assets/FullSerializer/Testing.meta Assets-FullSerializer-Testing.meta 23 | 24 | #### Run tests 25 | #echo "Attempting to run tests for $project" 26 | #$unity \ 27 | # -batchmode \ 28 | # -nographics \ 29 | # -silent-crashes \ 30 | # -logFile $log_dir/unity_tests.log \ 31 | # -projectPath $project_path \ 32 | # -runEditorTests \ 33 | # -editorTestsResultsFile="$log_dir/unity_test_results.xml" 34 | 35 | #### Build DLL export. 36 | echo "Attempting to export $project DLLs" 37 | mv Assets/FullSerializer/Source Assets-FullSerializer-Source 38 | mv Assets/FullSerializer/Source.meta Assets-FullSerializer-Source.meta 39 | 40 | dll_file="Assets/FullSerializer/FullSerializer.dll" \ 41 | doc_file="Assets/FullSerializer/FullSerializer.xml" \ 42 | source_dir="Assets-FullSerializer-Source/" ./Scripts/make_dlls.sh 43 | $unity \ 44 | -batchmode \ 45 | -nographics \ 46 | -silent-crashes \ 47 | -logFile $log_dir/unity_export_package_dll.log \ 48 | -projectPath $project_path \ 49 | -exportPackage "Assets/FullSerializer" "$output_dir/FullSerializer-DLLs.unitypackage" \ 50 | -quit 51 | 52 | rm Assets/FullSerializer/FullSerializer.dll 53 | rm Assets/FullSerializer/FullSerializer.dll.meta 54 | rm Assets/FullSerializer/FullSerializer.dll.mdb 55 | rm Assets/FullSerializer/FullSerializer.dll.mdb.meta 56 | rm Assets/FullSerializer/FullSerializer.xml 57 | rm Assets/FullSerializer/FullSerializer.xml.meta 58 | 59 | mv Assets-FullSerializer-Source Assets/FullSerializer/Source 60 | mv Assets-FullSerializer-Source.meta Assets/FullSerializer/Source.meta 61 | 62 | #### Build Source export. 63 | echo "Attempting to export $project Source" 64 | $unity \ 65 | -batchmode \ 66 | -nographics \ 67 | -silent-crashes \ 68 | -logFile $log_dir/unity_export_package_source.log \ 69 | -projectPath $project_path \ 70 | -exportPackage "Assets/FullSerializer" "$output_dir/FullSerializer-Source.unitypackage" \ 71 | -quit 72 | 73 | # Restore directory structure. 74 | mv Assets/FullSerializer/*.md* . 75 | mv Assets-FullSerializer-Testing Assets/FullSerializer/Testing 76 | mv Assets-FullSerializer-Testing.meta Assets/FullSerializer/Testing.meta 77 | 78 | exit 79 | 80 | # -executeMethod UnityTest.Batch.RunUnitTests \ 81 | # -executeMethod FullSerializer.fsContinuousIntegration.ExportPackages \ 82 | 83 | echo "Attempting to build $project for Windows" 84 | $unity \ 85 | -batchmode \ 86 | -nographics \ 87 | -silent-crashes \ 88 | -logFile $(pwd)/unity.log \ 89 | -projectPath $(pwd) \ 90 | -buildWindowsPlayer "$(pwd)/Build/windows/$project.exe" \ 91 | -quit 92 | 93 | echo "Attempting to build $project for OS X" 94 | $unity \ 95 | -batchmode \ 96 | -nographics \ 97 | -silent-crashes \ 98 | -logFile $(pwd)/unity.log \ 99 | -projectPath $(pwd) \ 100 | -buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app" \ 101 | -quit 102 | 103 | echo "Attempting to build $project for Linux" 104 | $unity \ 105 | -batchmode \ 106 | -nographics \ 107 | -silent-crashes 108 | -logFile $(pwd)/unity.log \ 109 | -projectPath $(pwd) \ 110 | -buildLinuxUniversalPlayer "$(pwd)/Build/linux/$project" \ 111 | -quit 112 | 113 | echo 'Logs from build' 114 | cat $(pwd)/unity.log 115 | -------------------------------------------------------------------------------- /Scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Inspired from https://github.com/JonathanPorta/ci-build 4 | 5 | # This link changes from time to time. I haven't found a reliable hosted 6 | # installer package for doing regular installs like this. You will probably need 7 | # to grab a current link from: http://unity3d.com/get-unity/download/archive 8 | 9 | URL=$"http://netstorage.unity3d.com/unity/cc9cbbcc37b4/MacEditorInstaller/Unity-5.3.1f1.pkg" 10 | echo "Downloading from $URL" 11 | curl -o Unity.pkg $URL 12 | 13 | echo "Installing Unity.pkg" 14 | sudo installer -dumplog -package Unity.pkg -target / 15 | -------------------------------------------------------------------------------- /Scripts/make_dlls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # These options are configurable. You can configure them before invoking the 4 | # script by using environment variables. For example, 5 | # 6 | # dll_file="MyProj.dll" doc_file="MyProj.xml" ./Scripts/make_dlls.sh 7 | # 8 | unity_root=${unity_root:-"/Applications/Unity/Unity.app/Contents/Frameworks"} 9 | source_dir=${source_dir:-"../Assets/FullSerializer/Source"} 10 | dll_file=${dll_file:-"FullSerializer.dll"} 11 | doc_file=${doc_file:-"FullSerializer.xml"} 12 | 13 | all_cs_files=$(find $source_dir -name \*.cs) 14 | 15 | echo "Compiling DLLs (dll_file: $dll_file, doc_file: $doc_file)" 16 | $unity_root/MonoBleedingEdge/bin/mcs \ 17 | /lib:$unity_root/Managed /reference:UnityEngine.dll \ 18 | /nowarn:1591 \ 19 | /target:library /debug /sdk:2 \ 20 | /out:$dll_file /doc:$doc_file \ 21 | $all_cs_files 22 | -------------------------------------------------------------------------------- /Scripts/postinstall.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('mkdirp'); 2 | var path = require('path'); 3 | var ncp = require('ncp'); 4 | 5 | // Package name 6 | var package = "TEMPLATE"; 7 | 8 | // Paths 9 | var src = path.join(__dirname, '..', 'Assets', 'FullSerializer', 'Source'); 10 | var dir = path.join(__dirname, '..', '..', '..', 'Assets', 'packages', 'fullserializer'); 11 | 12 | // Create folder if missing 13 | mkdirp(dir, function (err) { 14 | if (err) { 15 | console.error(err) 16 | process.exit(1); 17 | } 18 | 19 | // Copy files 20 | ncp(src, dir, function (err) { 21 | if (err) { 22 | console.error(err); 23 | process.exit(1); 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /VERSION.md: -------------------------------------------------------------------------------- 1 | 1.1.0 2 | -------------------------------------------------------------------------------- /VERSION.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afb4fa5b329104c119715f532b901087 3 | timeCreated: 1451248360 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { throw new Error('Not a javascript module'); }; 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unity-fullserializer", 3 | "version": "1.1.0", 4 | "description": "Full Serializer is an easy to use and robust JSON serializer that just works.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/jacobdufault/fullserializer.git" 9 | }, 10 | "files": [ 11 | "index.js", 12 | "Scripts", 13 | "Assets" 14 | ], 15 | "author": "jacobdufault", 16 | "license": "MIT", 17 | "bugs": { 18 | "url": "https://github.com/jacobdufault/fullserializer/issues" 19 | }, 20 | "homepage": "https://github.com/jacobdufault/fullserializer", 21 | "scripts": { 22 | "postinstall": "node Scripts/postinstall.js" 23 | }, 24 | "dependencies": { 25 | "ncp": "^2.0.0", 26 | "mkdirp": "^0.5.1" 27 | } 28 | } 29 | --------------------------------------------------------------------------------