Skip to content

Commit 824ec66

Browse files
Merge pull request #36 from ShawnLaMountain/main
Added static properties and supports nullable fields
2 parents c7e31ad + 24b03c1 commit 824ec66

File tree

5 files changed

+314
-57
lines changed

5 files changed

+314
-57
lines changed

.github/workflows/CD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ jobs:
6161
shell: pwsh
6262

6363
- name: Create NuGet Package
64-
# run: nuget pack ThunderDesign.Net-PCL.nuspec -Version 2.0.17 -OutputDirectory ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
64+
# run: nuget pack ThunderDesign.Net-PCL.nuspec -Version 2.1.0.5 -OutputDirectory ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
6565
run: nuget pack ThunderDesign.Net-PCL.nuspec -Version ${{ github.event.release.tag_name }} -OutputDirectory ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
6666

6767
- name: Archive NuGet Package
6868
uses: actions/upload-artifact@v4
6969
with:
70-
# name: Package_${{ env.FILE_NAME}}.2.0.17
71-
# path: ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.2.0.17.nupkg
70+
# name: Package_${{ env.FILE_NAME}}.2.1.0.5
71+
# path: ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.2.1.0.5.nupkg
7272
name: Package_${{ env.FILE_NAME}}.${{ github.event.release.tag_name }}
7373
path: ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.${{ github.event.release.tag_name }}.nupkg
7474

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,52 @@ public partial class Person : IBindableObject, INotifyPropertyChanged
275275
276276
---
277277

278+
### Advanced: Static Properties
279+
280+
The `[Property]` attribute now supports static fields, allowing you to generate thread-safe static properties with automatic locking mechanisms.
281+
282+
#### Example
283+
```csharp
284+
using ThunderDesign.Net.Threading.Attributes;
285+
286+
public partial class AppSettings
287+
{
288+
[Property]
289+
private static string _applicationName = "MyApp";
290+
291+
[Property(getter: AccessorAccessibility.Internal)]
292+
private static readonly string _version = "1.0.0";
293+
}
294+
```
295+
296+
**What gets generated:**
297+
298+
```csharp
299+
public partial class AppSettings
300+
{
301+
static readonly object _StaticLocker = new object();
302+
303+
public static string ApplicationName
304+
{
305+
get { return GetStaticProperty(ref _applicationName, _StaticLocker); }
306+
set { SetStaticProperty(ref _applicationName, value, _StaticLocker); }
307+
}
308+
309+
internal static string Version
310+
{
311+
get { return GetStaticProperty(ref _version, _StaticLocker); }
312+
}
313+
314+
// Helper methods for static property access
315+
public static T GetStaticProperty<T>(ref T backingStore, object? lockObj = null) { /* ... */ }
316+
public static bool SetStaticProperty<T>(ref T backingStore, T value, object? lockObj = null) { /* ... */ }
317+
}
318+
```
319+
320+
> **Note:** Static properties are only supported with the `[Property]` attribute. Use the `readonly` field modifier to create read-only static properties.
321+
322+
---
323+
278324
## Installation
279325

280326
Grab the latest [ThunderDesign.Net-PCL.Threading NuGet](https://www.nuget.org/packages/ThunderDesign.Net-PCL.Threading) package and install in your solution.

0 commit comments

Comments
 (0)