You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A combination of generic Thread-Safe objects for .Net development.
9
12
13
+
---
14
+
15
+
<divalign="center">
16
+
17
+
<h2>🚀 <b>Now with .NET 8 support and built-in Source Generators!</b> 🚀</h2>
18
+
19
+
</div>
20
+
21
+
> -**.NET 8**: Take advantage of the latest .NET features and performance improvements.
22
+
> -**Source Generators**: Eliminate boilerplate and let the library generate thread-safe, bindable properties for you automatically!
23
+
>
24
+
> _Get started faster, write less code, and enjoy modern .NET development!_
25
+
10
26
----
11
27
12
28
A simple C# repository containing a few basic useful Thread-Safe Objects.
13
29
### Highlights include:
14
30
15
31
- Collections
16
-
- ObservableDictionaryThreadSafe
17
-
- ObservableCollectionThreadSafe
18
32
- CollectionThreadSafe
19
33
- DictionaryThreadSafe
20
-
- SortedListThreadSafe
34
+
- HashSetThreadSafe
35
+
- LinkedListThreadSafe
21
36
- ListThreadSafe
37
+
- ObservableCollectionThreadSafe
38
+
- ObservableDictionaryThreadSafe
22
39
- QueueThreadSafe
40
+
- SortedDictionaryThreadSafe
41
+
- SortedListThreadSafe
42
+
- StackThreadSafe
23
43
- DataCollections
24
-
- ObservableDataDictionary
25
44
- ObservableDataCollection
45
+
- ObservableDataDictionary
26
46
- DataObjects
27
47
- BindableDataObject
28
48
- DataObject
@@ -33,10 +53,118 @@ A simple C# repository containing a few basic useful Thread-Safe Objects.
33
53
- ObjectExtention
34
54
- HelperClasses
35
55
- ThreadHelper
56
+
- Interfaces
57
+
- IBindableCollection
58
+
- IBindableDataObject
59
+
- IBindableDataObject\<Key>
60
+
- IBindableObject
61
+
- ICollectionThreadSafe
62
+
- IDataObject
63
+
- IDataObject\<Key>
64
+
- IDictionaryThreadSafe
65
+
- IHashSetThreadSafe
66
+
- ILinkedListThreadSafe
67
+
- IListThreadSafe
68
+
- IObservableDataCollection
69
+
- IObservableDataCollection\<T>
70
+
- ISortedDictionaryThreadSafe
71
+
- IStackThreadSafe
36
72
- Objects
37
73
- BindableObject
38
74
- ThreadObject
39
75
76
+
----
77
+
78
+
## Source Generators
79
+
80
+
The `ThunderDesign.Net-PCL.SourceGenerators` project provides Roslyn-based source generators that automate the creation of common boilerplate code for thread-safe and bindable objects in this library. By including this package in your project, you can reduce repetitive code and ensure consistency across your data and collection classes.
81
+
82
+
### What does it do?
83
+
84
+
-**Automatic Property Generation:**
85
+
The source generator scans your code for fields marked with specific attributes (such as `[BindableProperty]` or `[Property]`) and automatically generates the corresponding properties, including thread-safe accessors and `INotifyPropertyChanged` support where appropriate.
86
+
-**Interface Implementation:**
87
+
If your class does not already implement interfaces like `IBindableObject`, the generator will add the necessary interface implementations and event wiring.
88
+
-**Thread Safety:**
89
+
Generated properties use locking patterns to ensure thread safety, matching the patterns used throughout the ThunderDesign.Net-PCL.Threading library.
90
+
91
+
### How to use
92
+
93
+
1.**Add the NuGet package:**
94
+
Reference the `ThunderDesign.Net-PCL.SourceGenerators` package in your project. If you are building from source, add a project reference to `ThunderDesign.Net-PCL.SourceGenerators.csproj`.
95
+
96
+
2.**Annotate your fields:**
97
+
Use `[BindableProperty]` or `[Property]` attributes on your fields to indicate which properties should be generated. The generator will handle the rest.
98
+
99
+
3.**Build your project:**
100
+
When you build, the source generator will automatically add the generated code to your compilation. You do not need to manually include or maintain the generated files.
101
+
102
+
4.**Enjoy less boilerplate:**
103
+
Your classes will have all the necessary properties, events, and thread-safety mechanisms without manual implementation.
104
+
105
+
> **Note:** Source generators require Visual Studio 2019 16.9+ or .NET SDK 5.0+ for full support.
106
+
107
+
### Example Usage
108
+
109
+
Suppose you want to create a thread-safe, bindable object with automatic property and notification support.
110
+
With the source generator, you only need to annotate your fields:
111
+
112
+
```csharp
113
+
usingThunderDesign.Net.Threading.Attributes;
114
+
publicpartialclassPerson
115
+
{
116
+
[BindableProperty]
117
+
privatestring_name;
118
+
119
+
[Property]
120
+
privateint_age;
121
+
}
122
+
```
123
+
124
+
**What gets generated:**
125
+
- A public `Name` property with thread-safe getter/setter and `INotifyPropertyChanged` support.
126
+
- A public `Age` property with thread-safe getter/setter.
0 commit comments