diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index af59714..d65cd18 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,6 +11,7 @@ on: - main paths: - src/** + workflow_dispatch: jobs: build: @@ -25,7 +26,6 @@ jobs: with: dotnet-version: | 9.x - 6.x - name: Restore dependencies run: dotnet restore src/WeakEvent.sln diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index eabbb78..66ec0db 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,7 @@ on: - src/** schedule: - cron: '20 6 * * 5' + workflow_dispatch: jobs: analyze: @@ -36,7 +37,6 @@ jobs: with: dotnet-version: | 9.x - 6.x - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 7a73c23..290779f 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -18,7 +18,6 @@ jobs: with: dotnet-version: | 9.x - 6.x - name: 'Get Version' id: version diff --git a/README.md b/README.md index c62b150..5f3cda8 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,7 @@ In the context of Blazor components, this functionality is particularly valuable ## Features -![.NET 9.0](https://img.shields.io/badge/.NET-9.0-brightgreen) -![.NET 6.0](https://img.shields.io/badge/.NET-6.0-brightgreen) +![.NET Standard 2.0](https://img.shields.io/badge/.NET_Standard-2.0-brightgreen) - **Weak References:** Subscribers are held via weak references, allowing the garbage collector to reclaim them when they are no longer needed. - **Events With or Without Data:** Use `WeakEvent` when you need to pass event data to subscribers, or `WeakEvent` for simple notifications that don't require additional information. diff --git a/src/WeakEvent.Tests/WeakEvent.Tests.csproj b/src/WeakEvent.Tests/WeakEvent.Tests.csproj index c85678b..d890460 100644 --- a/src/WeakEvent.Tests/WeakEvent.Tests.csproj +++ b/src/WeakEvent.Tests/WeakEvent.Tests.csproj @@ -1,7 +1,7 @@  - net9.0;net6.0 + net9.0 latest enable enable diff --git a/src/WeakEvent/WeakEvent.cs b/src/WeakEvent/WeakEvent.cs index 27e2d6a..156f484 100644 --- a/src/WeakEvent/WeakEvent.cs +++ b/src/WeakEvent/WeakEvent.cs @@ -160,7 +160,10 @@ public abstract class WeakEventBase /// Thrown when is null. protected void Subscribe(Delegate handler) { - ArgumentNullException.ThrowIfNull(handler); + if (handler is null) + { + throw new ArgumentNullException(nameof(handler)); + } _handlers.Add(new WeakEventHandler(handler)); } @@ -172,7 +175,10 @@ protected void Subscribe(Delegate handler) /// Thrown when is null. protected bool Unsubscribe(Delegate handler) { - ArgumentNullException.ThrowIfNull(handler); + if (handler is null) + { + throw new ArgumentNullException(nameof(handler)); + } return _handlers.RemoveAll(weh => weh.Matches(handler)) > 0; } diff --git a/src/WeakEvent/WeakEvent.csproj b/src/WeakEvent/WeakEvent.csproj index 4b95873..da993fc 100644 --- a/src/WeakEvent/WeakEvent.csproj +++ b/src/WeakEvent/WeakEvent.csproj @@ -2,7 +2,7 @@ Library - net9.0;net6.0 + netstandard2.0 latest enable enable