Skip to content

Commit

Permalink
Change usage of RequiredMemberAttribute to PreserveAttribute
Browse files Browse the repository at this point in the history
Unity does not preserve members marked with attributes that inherit RequiredMemberAttribute, but do preserve members with attributes that inherit PreserveAttribute.
  • Loading branch information
gilzoide committed Feb 15, 2025
1 parent ed2fba9 commit 1543ded
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Plugins/tools~/fix-library-path.sed
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions Runtime/sqlite-net/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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; }
Expand Down Expand Up @@ -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; }

Expand All @@ -2529,7 +2529,7 @@ public sealed class PreserveAttribute : System.Attribute
/// "BINARY" is the default.
/// </summary>
[AttributeUsage (AttributeTargets.Property)]
public class CollationAttribute : UnityEngine.Scripting.RequiredMemberAttribute
public class CollationAttribute : UnityEngine.Scripting.PreserveAttribute
{
public string Value { get; private set; }

Expand All @@ -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
{
}

Expand Down

0 comments on commit 1543ded

Please sign in to comment.