Skip to content

Make column attributes inherit Unity's PreserveAttribute #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ lib/webgl/libgilzoide-sqlite-net.bc: $(SQLITE_SRC) | lib/webgl

# Source
$(SQLITE_NET_DEST)/%.cs: sqlite-net~/src/%.cs $(SQLITE_NET_SED_SCRIPT)
cat $< | sed -f $(SQLITE_NET_SED_SCRIPT) > $@
cat $< | sed -E -f $(SQLITE_NET_SED_SCRIPT) > $@

$(SQLITE_NET_DEST)/License.txt: sqlite-net~/License.txt
cp $< $@
Expand Down
6 changes: 3 additions & 3 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/

# Add [RequiredMember] attribute to ColumnInfo.Name property
# This fixes managed code stripping removing its setter method
s/Column ("name")/Column ("name"), UnityEngine.Scripting.RequiredMember/
# Make column attributes inherit Unity's PreserveAttribute
# This fixes managed code stripping removing getter/setter methods
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.
- Adds a `[RequiredMember]` attribute to `ColumnInfo.Name` property, 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
18 changes: 9 additions & 9 deletions Runtime/sqlite-net/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public class ColumnInfo
{
// public int cid { get; set; }

[Column ("name"), UnityEngine.Scripting.RequiredMember]
[Column ("name")]
public string Name { get; set; }

// [Column ("type")]
Expand Down 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 : Attribute
public class PrimaryKeyAttribute : UnityEngine.Scripting.PreserveAttribute
{
}

[AttributeUsage (AttributeTargets.Property)]
public class AutoIncrementAttribute : Attribute
public class AutoIncrementAttribute : UnityEngine.Scripting.PreserveAttribute
{
}

[AttributeUsage (AttributeTargets.Property, AllowMultiple = true)]
public class IndexedAttribute : Attribute
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 : Attribute
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 : Attribute
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 : Attribute
public class NotNullAttribute : UnityEngine.Scripting.PreserveAttribute
{
}

[AttributeUsage (AttributeTargets.Enum)]
public class StoreAsTextAttribute : Attribute
public class StoreAsTextAttribute : UnityEngine.Scripting.PreserveAttribute
{
}

Expand Down
Loading