Skip to content
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
76 changes: 76 additions & 0 deletions .github/workflows/CD-Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CD_Test

on:
workflow_dispatch:
# release:
# types: [published]

env:
TITLE: "Thread-Safe Objects"
DESCRIPTION: "A combination of generic Thread-Safe objects for .Net development."
TAGS: "thunderdesign threading thread%2Dsafe thread%2Dsafety threadsafe maui maui%2Dapp c%2Dsharp dotnet%2Dstandard dotnet%2Dframework dotnet%2Dcore cross%2Dplatform pcl%2Dlibrary xamarin unity csharp net dotnet bindable binding"
FILE_NAME: ex: "ThunderDesign.Net-PCL.Threading"
# FILE_NAME: "${{ github.event.repository.name }}"
REPOSITORY_NAME: ex: "ThunderDesign.Net-PCL.Threading"
# REPOSITORY_NAME: ${{ github.event.repository.name }}
REPOSITORY_OWNER: ex: "ThunderDesign"
# REPOSITORY_OWNER: ${{ github.repository_owner }}
GITHUB_URL: ex: "https://github.com/ThunderDesign"
# GITHUB_URL: ${{ github.server_url }}/${{ github.repository_owner }}
REPOSITORY_URL: ex: "https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading"
# REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.event.repository.name }}

PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}\output

jobs:
pack:
runs-on: [windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET 10
uses: actions/setup-dotnet@v1
with:
dotnet-version: 10.0.x

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5

- name: Restore NuGet packages.sln
run: nuget restore ./src/${{ env.FILE_NAME}}.sln

- name: Build Solution
run: msbuild ./src/${{ env.FILE_NAME}}.sln /p:Configuration=Release

- name: Prepare .nuspec
run: |
$nuspecPath = "src/${{ env.FILE_NAME }}.nuspec.in"
$nuspec = Get-Content $nuspecPath
$nuspec = $nuspec -replace '\$\{\{ env.FILE_NAME \}\}', '${{ env.FILE_NAME }}'
$nuspec = $nuspec -replace '\$\{\{ env.TITLE \}\}', '${{ env.TITLE }}'
$nuspec = $nuspec -replace '\$\{\{ env.DESCRIPTION \}\}', '${{ env.DESCRIPTION }}'
$nuspec = $nuspec -replace '\$\{\{ env.TAGS \}\}', '${{ env.TAGS }}'
$nuspec = $nuspec -replace '\$\{\{ env.GITHUB_URL \}\}', '${{ env.GITHUB_URL }}'
$nuspec = $nuspec -replace '\$\{\{ env.REPOSITORY_URL \}\}', '${{ env.REPOSITORY_URL }}'
Set-Content ThunderDesign.Net-PCL.nuspec $nuspec
shell: pwsh

- name: Create NuGet Package
run: nuget pack ThunderDesign.Net-PCL.nuspec -Version 3.0.0.0 -OutputDirectory ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
# run: nuget pack ThunderDesign.Net-PCL.nuspec -Version ${{ github.event.release.tag_name }} -OutputDirectory ${{ env.PACKAGE_OUTPUT_DIRECTORY }}

- name: Archive NuGet Package
uses: actions/upload-artifact@v4
with:
name: Package_${{ env.FILE_NAME}}.3.0.0.0
path: ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.3.0.0.0.nupkg
# name: Package_${{ env.FILE_NAME}}.${{ github.event.release.tag_name }}
# path: ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.${{ github.event.release.tag_name }}.nupkg

# - name: Publish NuGet Package
# run: nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY}}\${{ env.FILE_NAME}}.${{ github.event.release.tag_name }}.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
4 changes: 2 additions & 2 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET 8
- name: Setup .NET 10
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET 8
- name: Setup .NET 10
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
Expand Down
81 changes: 78 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
[![Nuget](https://img.shields.io/nuget/v/ThunderDesign.Net-PCL.Threading)](https://www.nuget.org/packages/ThunderDesign.Net-PCL.Threading)
[![License](https://img.shields.io/github/license/ThunderDesign/ThunderDesign.Net-PCL.Threading)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/LICENSE)
[![NetStandard](https://img.shields.io/badge/.net%20standard-v1.0%20--%20v2.1-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/README.md)
[![Net](https://img.shields.io/badge/.net%20-v6.0%20--%20v8.0-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/README.md)
[![Net](https://img.shields.io/badge/.net%20-v6.0%20--%20v10.0-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/README.md)

---

A combination of generic Thread-Safe objects for .Net development.

---

## 🚀 Now with .NET 8 support and built-in Source Generators! 🚀
## 🚀 Now with .NET 10 support and built-in Source Generators! 🚀

> - **.NET 8**: Take advantage of the latest .NET features and performance improvements.
> - **.NET 10**: Take advantage of the latest .NET features and performance improvements.
> - **Source Generators**: Eliminate boilerplate and let the library generate thread-safe, bindable properties for you automatically!
>
> _Get started faster, write less code, and enjoy modern .NET development!_
Expand Down Expand Up @@ -275,6 +275,81 @@ public partial class Person : IBindableObject, INotifyPropertyChanged

---

### Advanced: Call Method After Property Changes

You can call a method when a specific property changes by using the `callMethodAfterSet` parameter in the `[Property]` or `[BindableProperty]` attributes.

#### Example
```csharp
using ThunderDesign.Net.Threading.Attributes;

public partial class Person
{
[BindableProperty(callMethodAfterSet: "OnNameChanged")]
private string _name;

[Property(callMethodAfterSet:"OnAgeChanged")]
private int _age;

private void OnNameChanged()
{
// This method is called whenever the value of _name changes.
// You can add any logic here that needs to run when the name changes.
//Console.WriteLine($"Name changed from '{oldValue}' to '{newValue}'");
}

private void OnAgeChanged()
{
// This method is called whenever the value of _age changes.
// You can add any logic here that needs to run when the age changes.
//Console.WriteLine($"Age changed from '{oldValue}' to '{newValue}'");
}
}
```

**What gets generated:**

```csharp
public partial class Person : IBindableObject
{
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected readonly object _Locker = new object();

public virtual void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
{
this.NotifyPropertyChanged(PropertyChanged, propertyName);
}

public string Name
{
get { return this.GetProperty(ref _name, _Locker); }
set
{
if (this.SetProperty(ref _name, value, _Locker, true))
{
this.OnNameChanged();
}
}
}

public int Age
{
get { return this.GetProperty(ref _age, _Locker); }
set
{
if (this.SetProperty(ref _age, value, _Locker))
{
this.OnAgeChanged();
}
}
}
}
```

> This feature is particularly useful if you need to run some code after it updates. This will only get called if value was updated to the property.

---

### Advanced: Static Properties

The `[Property]` attribute now supports static fields, allowing you to generate thread-safe static properties with automatic locking mechanisms.
Expand Down
Loading
Loading