Skip to content

Commit ed2fba9

Browse files
committed
Make column attributes inherit Unity's RequiredMemberAttribute
This fixes managed code stripping removing getter/setter methods
1 parent 39bfe65 commit ed2fba9

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Plugins/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ lib/webgl/libgilzoide-sqlite-net.bc: $(SQLITE_SRC) | lib/webgl
9292

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

9797
$(SQLITE_NET_DEST)/License.txt: sqlite-net~/License.txt
9898
cp $< $@

Plugins/tools~/fix-library-path.sed

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ s/static string Quote/public static string Quote/
3030
# Make SQLite3 class partial, to extend in another file
3131
s/class SQLite3/partial class SQLite3/
3232

33-
# Add [RequiredMember] attribute to ColumnInfo.Name property
34-
# This fixes managed code stripping removing its setter method
35-
s/Column ("name")/Column ("name"), UnityEngine.Scripting.RequiredMember/
33+
# Make column attributes inherit Unity's RequiredMemberAttribute
34+
# This fixes managed code stripping removing getter/setter methods
35+
s/public class (PrimaryKey|AutoIncrement|Indexed|MaxLength|Collation|NotNull|StoreAsText)Attribute : Attribute/public class \1Attribute : UnityEngine.Scripting.RequiredMemberAttribute/
3636

3737
# Use main thread TaskScheduler in WebGL
3838
s/TaskScheduler\.Default/SQLiteAsyncExtensions.TaskScheduler/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ Third-party code:
113113
- `SQLiteConnection.Quote` is made public.
114114
This is useful for libraries making raw queries.
115115
- `SQLite3.SetDirectory` is only defined in Windows platforms.
116-
- Adds a `[RequiredMember]` attribute to `ColumnInfo.Name` property, fixing errors on columns when managed code stripping is enabled.
116+
- Makes all column related attributes inherit `RequiredMemberAttribute`, fixing errors on columns when managed code stripping is enabled.
117117
- Changes the `TaskScheduler` used by the async API on WebGL to one that executes tasks on Unity's main thread.
118118
- Fix support for struct return types in queries

Runtime/sqlite-net/SQLite.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ public class ColumnInfo
919919
{
920920
// public int cid { get; set; }
921921

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

925925
// [Column ("type")]
@@ -2465,17 +2465,17 @@ public ColumnAttribute (string name)
24652465
}
24662466

24672467
[AttributeUsage (AttributeTargets.Property)]
2468-
public class PrimaryKeyAttribute : Attribute
2468+
public class PrimaryKeyAttribute : UnityEngine.Scripting.RequiredMemberAttribute
24692469
{
24702470
}
24712471

24722472
[AttributeUsage (AttributeTargets.Property)]
2473-
public class AutoIncrementAttribute : Attribute
2473+
public class AutoIncrementAttribute : UnityEngine.Scripting.RequiredMemberAttribute
24742474
{
24752475
}
24762476

24772477
[AttributeUsage (AttributeTargets.Property, AllowMultiple = true)]
2478-
public class IndexedAttribute : Attribute
2478+
public class IndexedAttribute : UnityEngine.Scripting.RequiredMemberAttribute
24792479
{
24802480
public string Name { get; set; }
24812481
public int Order { get; set; }
@@ -2507,7 +2507,7 @@ public override bool Unique {
25072507
}
25082508

25092509
[AttributeUsage (AttributeTargets.Property)]
2510-
public class MaxLengthAttribute : Attribute
2510+
public class MaxLengthAttribute : UnityEngine.Scripting.RequiredMemberAttribute
25112511
{
25122512
public int Value { get; private set; }
25132513

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

@@ -2540,12 +2540,12 @@ public CollationAttribute (string collation)
25402540
}
25412541

25422542
[AttributeUsage (AttributeTargets.Property)]
2543-
public class NotNullAttribute : Attribute
2543+
public class NotNullAttribute : UnityEngine.Scripting.RequiredMemberAttribute
25442544
{
25452545
}
25462546

25472547
[AttributeUsage (AttributeTargets.Enum)]
2548-
public class StoreAsTextAttribute : Attribute
2548+
public class StoreAsTextAttribute : UnityEngine.Scripting.RequiredMemberAttribute
25492549
{
25502550
}
25512551

0 commit comments

Comments
 (0)