Skip to content

Commit

Permalink
able to generate code into AssemblyCSharp.dll which is useful for l…
Browse files Browse the repository at this point in the history
…ibrary design (#7)
  • Loading branch information
quabug authored Jul 4, 2021
1 parent a66ef14 commit 525b182
Show file tree
Hide file tree
Showing 46 changed files with 796 additions and 438 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ Assets/Plugins/Animancer/Examples.meta
# OS
.DS_Store
.vsconfig
Packages/generic-serialize-reference/Test
Packages/generic-serialize-reference/Test.meta
4 changes: 2 additions & 2 deletions Assets/Sample/GenericSerializeReference.Sample.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"rootNamespace": "",
"references": [
"GUID:e68bcd447d2cc4be2b6d31311e6ca7e9",
"GUID:7db2c3edd9cbf4a0c84e314cca3ddf42"
"GUID:36fd0010d4685b4408721d3172136183"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": false,
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
Expand Down
3 changes: 2 additions & 1 deletion Assets/_.meta → Assets/Sample/Library.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "GenericSerializeReference.Sample.Library",
"rootNamespace": "",
"references": [
"GUID:e68bcd447d2cc4be2b6d31311e6ca7e9",
"GUID:bb7127c6ea4789d41b77cdef13d93652"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Sample/Library/Implement.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "GenericSerializeReference.Sample.Library.Implement",
"rootNamespace": "",
"references": [
"GUID:bb7127c6ea4789d41b77cdef13d93652"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Sample/Library/Implement/Implement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class LibIntObject : ILibInterface<int> {}
public class LibGenericObject<T> : ILibInterface<T> {}
public class LibGenericObject_2<T> : ILibInterface<T> {}
public class LibFloatObject : ILibInterface<float> {}
3 changes: 3 additions & 0 deletions Assets/Sample/Library/Implement/Implement.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Sample/Library/Interface.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "GenericSerializeReference.Sample.Library.Interface",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Sample/Library/Interface/Interface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public interface ILibInterface<T> {}
3 changes: 3 additions & 0 deletions Assets/Sample/Library/Interface/Interface.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Sample/Library/LibBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using GenericSerializeReference;
using UnityEngine;

[assembly: GenericSerializeReferenceLoggerAttribute(LogLevel.Debug)]
public class LibBehavior : MonoBehaviour
{
[GenericSerializeReference(mode: GenerateMode.AssemblyCSharp)]
public ILibInterface<int> Int { get; set; }

[GenericSerializeReference(mode: GenerateMode.AssemblyCSharp)]
public ILibInterface<float> Float { get; set; }

private void Awake()
{
Debug.Log($"{nameof(LibBehavior)}.{nameof(Int)} is {Int.GetType()}");
Debug.Log($"{nameof(LibBehavior)}.{nameof(Float)} is {Float.GetType()}");
}
}
11 changes: 11 additions & 0 deletions Assets/Sample/Library/LibBehavior.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Assets/Sample/MyMonoBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using GenericSerializeReference;
using UnityEngine;

Expand All @@ -7,10 +8,15 @@ public class MyGenericObject<T> : IMyInterface<T> {}
public struct StructWillNotShow : IMyInterface<int> {}
public class MyMonoBehavior : MonoBehaviour
{
[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public IMyInterface<int> Value { get; set; }
//
// [GenericSerializeReference("_serialized")]
// public IMyInterface<int> Foo { get; set; }
// private int __Foo;

private void Awake()
{
Debug.Log($"{name}.{nameof(Value)} is {Value.GetType()}");
}
}
35 changes: 26 additions & 9 deletions Assets/Sample/Test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -134,6 +134,7 @@ GameObject:
- component: {fileID: 366887100}
- component: {fileID: 366887099}
- component: {fileID: 366887101}
- component: {fileID: 366887102}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
Expand Down Expand Up @@ -174,12 +175,11 @@ MonoBehaviour:
data:
V: 0
00000001:
type: {class: TestMonoBehavior/<FloatInt>__generic_serialize_reference/SubObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
type: {class: TestMonoBehavior/<FloatInt>__generic_serialize_reference/PartialObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
data:
ValueT: 0
ValueU: 0
SubValueT: []
SubValueU:
ValueDouble: 0
00000002:
type: {class: TestMonoBehavior/<IntInt>__generic_serialize_reference/PartialObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
data:
Expand All @@ -191,10 +191,9 @@ MonoBehaviour:
data:
Value: 0
00000004:
type: {class: TestMonoBehavior/<Double>__generic_serialize_reference/SubObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
type: {class: TestMonoBehavior/<Double>__generic_serialize_reference/DoubleObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
data:
Value: 0
SubValue: []
00000005:
type: {class: TestMonoBehavior/<IntObject>__generic_serialize_reference/SubObject, ns: GenericSerializeReference.Sample, asm: GenericSerializeReference.Sample}
data:
Expand Down Expand Up @@ -235,11 +234,29 @@ MonoBehaviour:
m_EditorClassIdentifier:
__Value:
id: 0
_serializedFoo:
references:
version: 1
00000000:
type: {class: MyMonoBehavior/<Value>__generic_serialize_reference/MyGenericObject, ns: , asm: GenericSerializeReference.Sample}
--- !u!114 &366887102
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 366887098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66e141599402ff44f8de6aef9ccd07f2, type: 3}
m_Name:
m_EditorClassIdentifier:
__Int:
id: 0
__Float:
id: 1
references:
version: 1
00000000:
type: {class: MyMonoBehavior/<Value>__generic_serialize_reference/MyIntObject, ns: , asm: GenericSerializeReference.Sample}
type: {class: ILibInterface`1<System_Int32>/LibGenericObject, ns: <GenericSerializeReference>, asm: Assembly-CSharp}
00000001:
type: {class: MyMonoBehavior/<Foo>__generic_serialize_reference/MyIntObject, ns: , asm: GenericSerializeReference.Sample}
type: {class: ILibInterface`1<System_Single>/LibGenericObject_2, ns: <GenericSerializeReference>, asm: Assembly-CSharp}
14 changes: 7 additions & 7 deletions Assets/Sample/TestMonoBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ public class Object : MultipleGeneric.IInterface<int, float>
public int V;
}

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public MultipleGeneric.IInterface<int, float> IntFloat { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public MultipleGeneric.IInterface<float, int> FloatInt { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public MultipleGeneric.IInterface<int, int> IntInt { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public SingleGeneric.IInterface<int> Int { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public SingleGeneric.IInterface<double> Double { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public SingleGeneric.Object<int> IntObject { get; set; }

[GenericSerializeReference]
[GenericSerializeReference(mode: GenerateMode.Embed)]
public MultipleGeneric.Object<int, int> IntIntObject { get; set; }

private void Awake()
Expand Down
Empty file removed Assets/_
Empty file.
4 changes: 4 additions & 0 deletions Assets/__.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace GenericSerializeReference.Library.CodeGen
{
internal static class ___ {}
}
11 changes: 11 additions & 0 deletions Assets/__.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 525b182

Please sign in to comment.