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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Pull request validation: builds Release and runs the tests. Publishes nothing.
name: CI

on:
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.x'

- name: Restore workloads
run: dotnet workload restore DSoft.Messaging/DSoft.MessageBus.csproj

- name: Restore
run: dotnet restore MessageBus.slnx

- name: Build
run: dotnet build MessageBus.slnx --configuration Release --no-restore

- name: Test
run: dotnet test UnitTest/UnitTest.csproj --configuration Release --no-build
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Release: on every push to main, builds Release, runs the tests and pushes the
# DSoft.*.nupkg packages to nuget.org as 4.5.yyMM.<run number>, then tags the
# commit and creates a GitHub release with the packages attached.
# RELEASE_SUFFIX is empty for a stable version; set it to a suffix such as
# '-prerelease' to publish a prerelease.
# Signs in to nuget.org with Trusted Publishing (OIDC), so no API key is stored.
name: Release

on:
push:
branches: [main]
paths-ignore:
- '**.md'
- '.github/workflows/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: release
cancel-in-progress: false

env:
RELEASE_SUFFIX: ''

jobs:
release:
runs-on: windows-latest
environment: nuget
permissions:
contents: write # GitHub release and tag
id-token: write # Trusted Publishing
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.x'

- name: Version
id: version
shell: bash
run: |
version="4.5.$(date -u +%y%m).${{ github.run_number }}"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "package=$version$RELEASE_SUFFIX" >> "$GITHUB_OUTPUT"
echo "Version: $version$RELEASE_SUFFIX"

- name: Restore workloads
run: dotnet workload restore DSoft.Messaging/DSoft.MessageBus.csproj

- name: Restore
run: dotnet restore MessageBus.slnx

- name: Build
run: >
dotnet build MessageBus.slnx --configuration Release --no-restore
/p:Version=${{ steps.version.outputs.package }}
/p:AssemblyVersion=${{ steps.version.outputs.version }}
/p:FileVersion=${{ steps.version.outputs.version }}

- name: Test
run: dotnet test UnitTest/UnitTest.csproj --configuration Release --no-build

- name: Collect packages
shell: bash
run: |
mkdir -p artifacts
find . -path '*/bin/Release/*' -name 'DSoft.*.nupkg' -exec cp {} artifacts/ \;
ls artifacts

- uses: actions/upload-artifact@v7
with:
name: drop
path: artifacts/*.nupkg

- name: NuGet login
id: nuget
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}

- name: Push to nuget.org
shell: bash
run: |
for package in artifacts/*.nupkg; do
dotnet nuget push "$package" --api-key "${{ steps.nuget.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
done

- name: GitHub release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.version.outputs.package }}" artifacts/*.nupkg \
--target "${{ github.sha }}" \
--title "${{ steps.version.outputs.package }}" \
--generate-notes \
${RELEASE_SUFFIX:+--prerelease}
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Solution file is `MessageBus.slnx` (new XML solution format — requires recent
```bash
dotnet restore MessageBus.slnx
dotnet build MessageBus.slnx --configuration Release
dotnet test UnitTest/UnitTest.csproj # tests target net9.0, MSTest
dotnet test UnitTest/UnitTest.csproj # tests target net10.0, MSTest
dotnet test UnitTest/UnitTest.csproj --filter "FullyQualifiedName~MessageBusTest.MethodName" # single test
```

Building the full `DSoft.Messaging` project requires platform workloads (`dotnet workload restore`) because it multi-targets iOS/Android/macOS/tvos/MacCatalyst/Windows. To iterate quickly without workloads, build/test against a single TFM via the UnitTest project (which references the main project but is consumed as `net9.0`). Note `Directory.Build.props` sets `GeneratePackageOnBuild=true` and signs assemblies with `DSoft.snk`.
Building the full `DSoft.Messaging` project requires platform workloads (`dotnet workload restore`) because it multi-targets iOS/Android/macOS/tvos/MacCatalyst/Windows. To iterate quickly without workloads, build/test against a single TFM via the UnitTest project (which references the main project but is consumed as `net10.0`). Note `Directory.Build.props` sets `GeneratePackageOnBuild=true` and signs assemblies with `DSoft.snk`.

## Architecture

Expand All @@ -41,12 +41,12 @@ Both routes hit the same `MessageBusService` logic.
### Platform-specific compilation
`DSoft.Messaging` uses **filename-suffix conventions** instead of one file per TFM — the `.csproj` includes files by suffix via `EnableDefaultCompileItems=false`:
- `*.shared.cs` — all targets
- `*.netstandard.cs` — netstandard/net8/net9/net10/net472
- `*.netstandard.cs` — netstandard/net8/net10/net472
- `*.wpf.cs` (windows7.0), `*.winui.cs` (windows10), `*.android.cs`, `*.ios.cs` (ios+maccatalyst), `*.mac.cs` (macos), `*.tvos.cs`

`ThreadControl` is the main example: `ThreadControl.shared.cs` defines the public API and calls `partial` members (`PlatformIsMainThread`, `PlatformBeginInvokeOnMainThread`) implemented per platform. When adding platform-specific code, add a new `*.<platform>.cs` partial rather than `#if`. (ThreadControl's `MainThread` logic is adapted from Xamarin.Essentials.)

## Conventions
- Keep `IMessageBusService`, the static `MessageBus` facade, and `MessageBusService` in sync — all three expose the same Post/Subscribe/Unsubscribe/Log surface.
- New public APIs need XML doc comments (`GenerateDocumentationFile=true`; many nullable/doc warnings are suppressed in `Directory.Build.props`).
- Version/release notes live in the `.csproj` PropertyGroups (`Version`, `AssemblyVersion`, `PackageReleaseNotes`); bump there for releases.
- Release notes live in `PackageReleaseNotes` in the `.csproj`. Package/assembly versions are set by CI: `.github/workflows/release.yml` builds `4.5.<yyMM>.<run number>` (plus `RELEASE_SUFFIX`) on every push to `main`, publishes to nuget.org via NuGet trusted publishing (OIDC, `NUGET_USER` secret), then tags `v<version>` and creates a GitHub release; `.github/workflows/ci.yml` builds and tests pull requests into `main`.
22 changes: 8 additions & 14 deletions DSoft.Messaging/DSoft.MessageBus.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net9.0;net9.0-ios;net9.0-macos;net9.0-maccatalyst;net9.0-tvos;net9.0-android;net10.0;net10.0-ios;net10.0-macos;net10.0-maccatalyst;net10.0-tvos;net10.0-android;</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net8.0;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net472;net9.0-windows7.0;net9.0-windows10.0.19041;net10.0-windows7.0;net10.0-windows10.0.19041;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net8.0-windows7.0;net8.0-windows10.0.19041;</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net8.0;net10.0;net10.0-ios;net10.0-macos;net10.0-maccatalyst;net10.0-tvos;net10.0-android;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net472;net8.0-windows7.0;net10.0-windows7.0;net10.0-windows10.0.19041;</TargetFrameworks>
<PackageId>DSoft.MessageBus</PackageId>
<ReleaseVersion>1.3.4</ReleaseVersion>
<AssemblyName>DSoft.MessageBus</AssemblyName>
<Company>DSoft Developments</Company>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Title>DSoft.MessageBus</Title>
<Description>MessageBus is a cross platform EventBus system similar to NSNoticationCenter on iOS and otto on Android</Description>
<Copyright>© DSoft Developments. All rights reserved.</Copyright>
<AssemblyVersion>1.3.5.0</AssemblyVersion>
<FileVersion>1.3.5.0</FileVersion>
<ConsolePause>false</ConsolePause>
<Version>1.3.4.0</Version>
<PackageTags>MessageBus</PackageTags>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DefineConstants>$(DefineConstants);</DefineConstants>
Expand All @@ -31,8 +25,8 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tvos'">14.0</SupportedOSPlatformVersion>
<NoWarn>$(NoWarn);NETSDK1206;CA1416;</NoWarn>
<PackageReleaseNotes>Re-Added .NET framework 4.7.2 support
Added generic "Post" method
<PackageReleaseNotes>Updated to .NET 10 and latest dependencies
Removed .NET 9 targets (.NET 8 and .NET 10 LTS remain supported)
</PackageReleaseNotes>
</PropertyGroup>

Expand Down Expand Up @@ -65,7 +59,7 @@
<Compile Include="**\*.shared.*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) Or $(TargetFramework) == 'net9.0' Or $(TargetFramework) == 'net8.0' Or $(TargetFramework) == 'net10.0' Or $(TargetFramework) == 'net472'">
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) Or $(TargetFramework) == 'net8.0' Or $(TargetFramework) == 'net10.0' Or $(TargetFramework) == 'net472'">
<Compile Include="**\*.netstandard.cs" />
<Compile Include="**\*.netstandard.*.cs" />
</ItemGroup>
Expand All @@ -76,8 +70,8 @@
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.Contains('windows10')) ">
<PackageReference Include="Microsoft.WindowsAppSDK" Version="2.2.0" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.28000.1839" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="2.5.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.28000.2705" />

<Compile Include="**\*.winui.cs" />
<Compile Include="**\*.winui.*.cs" />
Expand Down Expand Up @@ -105,7 +99,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 4 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/newky2k/MessageBus</PackageProjectUrl>
<RepositoryUrl>https://github.com/newky2k/MessageBus</RepositoryUrl>
Expand All @@ -24,16 +25,13 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup Condition=" '$(Configuration)'=='Release'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
<!-- sourcelink: Source Link for GitHub is included in the .NET SDK (8.0+) -->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true' Or '$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildProjectDirectory)\DSoft.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>$(MSBuildProjectDirectory)/DSoft.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions MessageBus.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<Platform Name="iPhoneSimulator" />
</Configurations>
<Folder Name="/.ci/">
<File Path="azure-pipelines-mergetest.yml" />
<File Path="azure-pipelines-release.yml" />
<File Path=".github/workflows/ci.yml" />
<File Path=".github/workflows/release.yml" />
<File Path="Directory.Build.props" />
<File Path="README.md" />
</Folder>
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MessageBus is a cross platform EventBus system similar to `NSNoticationCenter` o
# Features

* Cross-platform
* .NETStandard 2.1, .NET 8+ including iOS, TVOS, Android, UWP, Mac and Windows with support for WPF and WinUI
* .NETStandard 2.1, .NET Framework 4.7.2, .NET 8 and .NET 10 including iOS, tvOS, Android, Mac Catalyst, macOS and Windows with support for WPF and WinUI
* Small footprint
* Simple API
* Create custom events to easily pass additional data
Expand All @@ -26,6 +26,15 @@ You can then inject `IMessageBusService` into your own services.

Please check the Unit tests and sample WPF app for examples of usage

## Building and releasing

Builds run on GitHub Actions:

* `.github/workflows/ci.yml` validates every pull request into `main`: it builds Release and runs the tests, and publishes nothing.
* `.github/workflows/release.yml` runs on every push to `main` (or manually from the Actions tab). It builds, tests, pushes the packages to nuget.org as `4.5.<yyMM>.<run number>`, then tags the commit and creates a GitHub release with the packages attached. Set `RELEASE_SUFFIX` (e.g. `-prerelease`) to publish a prerelease.

Publishing uses [NuGet trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing), so no API key is stored: the nuget.org policy trusts workflow `release.yml` in environment `nuget`, and the `NUGET_USER` secret holds the nuget.org profile name.

### Attribution

`ThreadControl` contains portions of code from [Xamarin.Essentials](https://github.com/xamarin/Essentials/tree/master/Xamarin.Essentials/MainThread), specifically the `MainThread` functionality
2 changes: 1 addition & 1 deletion UnitTest/ConcurrencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static IMessageBusService NewBus()
/// underlying Collection&lt;T&gt; and threw "Collection was modified" /
/// IndexOutOfRange. Passing means no handler-collection corruption.
/// </summary>
[DataTestMethod]
[TestMethod]
[DataRow(1)]
[DataRow(2)]
[DataRow(3)]
Expand Down
12 changes: 6 additions & 6 deletions UnitTest/UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SignAssembly>False</SignAssembly>
Expand All @@ -11,14 +11,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.1">
<PackageReference Include="coverlet.collector" Version="10.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="4.2.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.4.1" />
<PackageReference Include="MSTest.TestFramework" Version="4.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion WPFSample/WPFSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<TargetFramework>net10.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<SignAssembly>False</SignAssembly>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand Down
51 changes: 0 additions & 51 deletions azure-pipelines-mergetest.yml

This file was deleted.

Loading