Skip to content

Commit a669371

Browse files
committed
Add Preserve attribute.
1 parent 721dacc commit a669371

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace UnityMvvmToolkit.Core.Attributes
4+
{
5+
/// <summary>
6+
/// <para>PreserveAttribute prevents byte code stripping from removing a class, method, field, or property.</para>
7+
/// </summary>
8+
[AttributeUsage(
9+
AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
10+
AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field |
11+
AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
12+
public class PreserveAttribute : Attribute
13+
{
14+
}
15+
}

src/UnityMvvmToolkit.Core/Internal/ObjectWrappers/CommandWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using UnityMvvmToolkit.Core.Attributes;
34
using UnityMvvmToolkit.Core.Interfaces;
45
using UnityMvvmToolkit.Core.Internal.Interfaces;
56

@@ -15,6 +16,7 @@ internal sealed class CommandWrapper<TCommandValueType> : ICommandWrapper
1516

1617
private ICommand<TCommandValueType> _command;
1718

19+
[Preserve]
1820
public CommandWrapper(IParameterValueConverter<TCommandValueType> parameterConverter)
1921
{
2022
_commandId = -1;

src/UnityMvvmToolkit.Core/Internal/ObjectWrappers/PropertyWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Runtime.CompilerServices;
4+
using UnityMvvmToolkit.Core.Attributes;
45
using UnityMvvmToolkit.Core.Interfaces;
56
using UnityMvvmToolkit.Core.Internal.Interfaces;
67

@@ -16,6 +17,7 @@ internal sealed class PropertyWrapper<TSourceType, TValueType> : IProperty<TValu
1617
private TSourceType _sourceValue;
1718
private IProperty<TSourceType> _property;
1819

20+
[Preserve]
1921
public PropertyWrapper(IPropertyValueConverter<TSourceType, TValueType> valueConverter)
2022
{
2123
_converterId = -1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace UnityMvvmToolkit.Core.Attributes
4+
{
5+
/// <summary>
6+
/// <para>PreserveAttribute prevents byte code stripping from removing a class, method, field, or property.</para>
7+
/// </summary>
8+
[AttributeUsage(
9+
AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
10+
AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field |
11+
AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
12+
public class PreserveAttribute : Attribute
13+
{
14+
}
15+
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Core/Attributes/PreserveAttribute.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Core/Internal/ObjectWrappers/CommandWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using UnityMvvmToolkit.Core.Attributes;
34
using UnityMvvmToolkit.Core.Interfaces;
45
using UnityMvvmToolkit.Core.Internal.Interfaces;
56

@@ -15,6 +16,7 @@ internal sealed class CommandWrapper<TCommandValueType> : ICommandWrapper
1516

1617
private ICommand<TCommandValueType> _command;
1718

19+
[Preserve]
1820
public CommandWrapper(IParameterValueConverter<TCommandValueType> parameterConverter)
1921
{
2022
_commandId = -1;

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Core/Internal/ObjectWrappers/PropertyWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Runtime.CompilerServices;
4+
using UnityMvvmToolkit.Core.Attributes;
45
using UnityMvvmToolkit.Core.Interfaces;
56
using UnityMvvmToolkit.Core.Internal.Interfaces;
67

@@ -16,6 +17,7 @@ internal sealed class PropertyWrapper<TSourceType, TValueType> : IProperty<TValu
1617
private TSourceType _sourceValue;
1718
private IProperty<TSourceType> _property;
1819

20+
[Preserve]
1921
public PropertyWrapper(IPropertyValueConverter<TSourceType, TValueType> valueConverter)
2022
{
2123
_converterId = -1;

0 commit comments

Comments
 (0)