Skip to content

Commit f38c606

Browse files
committed
Allow fields to be ignored
1 parent 9963313 commit f38c606

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Il2CppInterop.Runtime/Attributes/HideFromIl2CppAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Il2CppInterop.Runtime.Attributes;
66
/// This attribute indicates that the target should not be exposed to IL2CPP in injected classes
77
/// </summary>
88
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property |
9-
AttributeTargets.Event)]
9+
AttributeTargets.Event | AttributeTargets.Field)]
1010
public class HideFromIl2CppAttribute : Attribute
1111
{
1212
}

Il2CppInterop.Runtime/Injection/ClassInjector.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ private static bool IsTypeSupported(Type type)
533533

534534
private static bool IsFieldEligible(FieldInfo field)
535535
{
536+
if (field.CustomAttributes.Any(it => typeof(HideFromIl2CppAttribute).IsAssignableFrom(it.AttributeType)))
537+
return false;
536538
if (field.DeclaringType.IsValueType)
537539
return IsTypeSupported(field.FieldType);
538540
if (!field.FieldType.IsGenericType) return field.FieldType == typeof(Il2CppStringField);

0 commit comments

Comments
 (0)