Skip to content

Commit 2d4832b

Browse files
BindablePropertyAttribute, PropertyAttribute and Accessorccessibility now only compile if .Net Standard 2.0 or higher and .Net 6.0 or higher
1 parent 1a9597b commit 2d4832b

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/ThunderDesign.Net-PCL.Threading.Shared/Attributes/BindablePropertyAttribute.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace ThunderDesign.Net.Threading.Attributes
77
{
8+
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
89
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
910
public sealed class BindablePropertyAttribute : Attribute
1011
{
@@ -22,56 +23,57 @@ public BindablePropertyAttribute(
2223
AccessorAccessibility getter = AccessorAccessibility.Public,
2324
AccessorAccessibility setter = AccessorAccessibility.Public)
2425
{
25-
ApplyBindablePropertyAttribute(readOnly, threadSafe, notify, new string[0], getter, setter);
26+
ApplyBindablePropertyAttribute(Array.Empty<string>(), readOnly, threadSafe, notify, getter, setter);
2627
}
2728

2829
public BindablePropertyAttribute(
30+
string alsoNotify,
2931
bool readOnly = false,
3032
bool threadSafe = true,
3133
bool notify = true,
32-
string alsoNotify = null,
3334
AccessorAccessibility getter = AccessorAccessibility.Public,
3435
AccessorAccessibility setter = AccessorAccessibility.Public)
3536
{
36-
ApplyBindablePropertyAttribute(readOnly, threadSafe, notify, string.IsNullOrEmpty(alsoNotify) ? new string[0] : new string[] { alsoNotify }, getter, setter);
37+
ApplyBindablePropertyAttribute(string.IsNullOrEmpty(alsoNotify) ? Array.Empty<string>() : new string[1] { alsoNotify }, readOnly, threadSafe, notify, getter, setter);
3738
}
3839

3940
public BindablePropertyAttribute(
40-
string[] alsoNotify = null,
41+
string[] alsoNotify,
4142
bool readOnly = false,
4243
bool threadSafe = true,
4344
bool notify = true,
4445
AccessorAccessibility getter = AccessorAccessibility.Public,
4546
AccessorAccessibility setter = AccessorAccessibility.Public)
4647
{
47-
ApplyBindablePropertyAttribute(readOnly, threadSafe, notify, alsoNotify ?? new string[0], getter, setter);
48+
ApplyBindablePropertyAttribute(alsoNotify ?? Array.Empty<string>(), readOnly, threadSafe, notify, getter, setter);
4849
}
4950

5051
public BindablePropertyAttribute(
52+
IEnumerable<string> alsoNotify,
5153
bool readOnly = false,
5254
bool threadSafe = true,
53-
IEnumerable<string> alsoNotify = null,
5455
AccessorAccessibility getter = AccessorAccessibility.Public,
5556
AccessorAccessibility setter = AccessorAccessibility.Public,
5657
bool notify = true)
5758
{
58-
ApplyBindablePropertyAttribute(readOnly, threadSafe, notify, alsoNotify?.ToArray() ?? new string[0], getter, setter);
59+
ApplyBindablePropertyAttribute(alsoNotify?.ToArray() ?? Array.Empty<string>(), readOnly, threadSafe, notify, getter, setter);
5960
}
6061

61-
public void ApplyBindablePropertyAttribute(
62-
bool readOnly = false,
63-
bool threadSafe = true,
64-
bool notify = true,
65-
string[] alsoNotify = null,
66-
AccessorAccessibility getter = AccessorAccessibility.Public,
67-
AccessorAccessibility setter = AccessorAccessibility.Public)
62+
private void ApplyBindablePropertyAttribute(
63+
string[] alsoNotify,
64+
bool readOnly,
65+
bool threadSafe,
66+
bool notify,
67+
AccessorAccessibility getter,
68+
AccessorAccessibility setter)
6869
{
6970
ReadOnly = readOnly;
7071
ThreadSafe = threadSafe;
7172
Notify = notify;
72-
AlsoNotify = alsoNotify ?? new string[0];
73+
AlsoNotify = alsoNotify;
7374
Getter = getter;
7475
Setter = setter;
7576
}
7677
}
78+
#endif
7779
}

src/ThunderDesign.Net-PCL.Threading.Shared/Attributes/PropertyAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace ThunderDesign.Net.Threading.Attributes
55
{
6+
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
67
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
78
public sealed class PropertyAttribute : Attribute
89
{
@@ -23,4 +24,5 @@ public PropertyAttribute(
2324
Setter = setter;
2425
}
2526
}
27+
#endif
2628
}

src/ThunderDesign.Net-PCL.Threading.Shared/Enums/AccessorAccessibility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace ThunderDesign.Net.Threading.Enums
22
{
3+
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
34
public enum AccessorAccessibility
45
{
56
Public,
@@ -9,4 +10,5 @@ public enum AccessorAccessibility
910
ProtectedInternal,
1011
PrivateProtected
1112
}
13+
#endif
1214
}

0 commit comments

Comments
 (0)