From 1543ded3fe2c10bd40647c38541e5c4c38f1af61 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Sat, 15 Feb 2025 08:51:14 -0300 Subject: [PATCH] Change usage of RequiredMemberAttribute to PreserveAttribute Unity does not preserve members marked with attributes that inherit RequiredMemberAttribute, but do preserve members with attributes that inherit PreserveAttribute. --- Plugins/tools~/fix-library-path.sed | 4 ++-- README.md | 2 +- Runtime/sqlite-net/SQLite.cs | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Plugins/tools~/fix-library-path.sed b/Plugins/tools~/fix-library-path.sed index 5595392..3545579 100644 --- a/Plugins/tools~/fix-library-path.sed +++ b/Plugins/tools~/fix-library-path.sed @@ -30,9 +30,9 @@ s/static string Quote/public static string Quote/ # Make SQLite3 class partial, to extend in another file s/class SQLite3/partial class SQLite3/ -# Make column attributes inherit Unity's RequiredMemberAttribute +# Make column attributes inherit Unity's PreserveAttribute # This fixes managed code stripping removing getter/setter methods -s/public class (PrimaryKey|AutoIncrement|Indexed|MaxLength|Collation|NotNull|StoreAsText)Attribute : Attribute/public class \1Attribute : UnityEngine.Scripting.RequiredMemberAttribute/ +s/public class (Column|PrimaryKey|AutoIncrement|Indexed|MaxLength|Collation|NotNull|StoreAsText)Attribute : Attribute/public class \1Attribute : UnityEngine.Scripting.PreserveAttribute/ # Use main thread TaskScheduler in WebGL s/TaskScheduler\.Default/SQLiteAsyncExtensions.TaskScheduler/ diff --git a/README.md b/README.md index dee01f5..bd22fbf 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,6 @@ Third-party code: - `SQLiteConnection.Quote` is made public. This is useful for libraries making raw queries. - `SQLite3.SetDirectory` is only defined in Windows platforms. -- Makes all column related attributes inherit `RequiredMemberAttribute`, fixing errors on columns when managed code stripping is enabled. +- Makes all column related attributes inherit `PreserveAttribute`, fixing errors on columns when managed code stripping is enabled. - Changes the `TaskScheduler` used by the async API on WebGL to one that executes tasks on Unity's main thread. - Fix support for struct return types in queries diff --git a/Runtime/sqlite-net/SQLite.cs b/Runtime/sqlite-net/SQLite.cs index 78c4ce9..5136a69 100644 --- a/Runtime/sqlite-net/SQLite.cs +++ b/Runtime/sqlite-net/SQLite.cs @@ -2454,7 +2454,7 @@ public TableAttribute (string name) } [AttributeUsage (AttributeTargets.Property)] - public class ColumnAttribute : Attribute + public class ColumnAttribute : UnityEngine.Scripting.PreserveAttribute { public string Name { get; set; } @@ -2465,17 +2465,17 @@ public ColumnAttribute (string name) } [AttributeUsage (AttributeTargets.Property)] - public class PrimaryKeyAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class PrimaryKeyAttribute : UnityEngine.Scripting.PreserveAttribute { } [AttributeUsage (AttributeTargets.Property)] - public class AutoIncrementAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class AutoIncrementAttribute : UnityEngine.Scripting.PreserveAttribute { } [AttributeUsage (AttributeTargets.Property, AllowMultiple = true)] - public class IndexedAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class IndexedAttribute : UnityEngine.Scripting.PreserveAttribute { public string Name { get; set; } public int Order { get; set; } @@ -2507,7 +2507,7 @@ public override bool Unique { } [AttributeUsage (AttributeTargets.Property)] - public class MaxLengthAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class MaxLengthAttribute : UnityEngine.Scripting.PreserveAttribute { public int Value { get; private set; } @@ -2529,7 +2529,7 @@ public sealed class PreserveAttribute : System.Attribute /// "BINARY" is the default. /// [AttributeUsage (AttributeTargets.Property)] - public class CollationAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class CollationAttribute : UnityEngine.Scripting.PreserveAttribute { public string Value { get; private set; } @@ -2540,12 +2540,12 @@ public CollationAttribute (string collation) } [AttributeUsage (AttributeTargets.Property)] - public class NotNullAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class NotNullAttribute : UnityEngine.Scripting.PreserveAttribute { } [AttributeUsage (AttributeTargets.Enum)] - public class StoreAsTextAttribute : UnityEngine.Scripting.RequiredMemberAttribute + public class StoreAsTextAttribute : UnityEngine.Scripting.PreserveAttribute { }