Skip to content

Target .NET 10, fix selection and children bugs, add tests and release CI - #118

Merged
1iveowl merged 1 commit into
masterfrom
feature/net10-tests-release-pipeline
Nov 10, 2026
Merged

1iveowl merged 1 commit into
masterfrom
feature/net10-tests-release-pipeline

Conversation

@1iveowl

@1iveowl 1iveowl commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • .NET 10: the library targets netstandard2.0 and net10.0, with Xamarin.Forms 5.0.0.2662. The solution is now src/main/SegCtlr.Netstandard.slnx.
  • Tests: new xUnit project src/test/SegCtlr.Tests with 49 tests covering the shared control. Line coverage is 92.6% and branch coverage 93.2%.
  • Code style: .editorconfig rules are enforced at build time through Directory.Build.props, using C# 14. The library and tests treat warnings as errors, and XML docs are required on public API.
  • Release: build.ps1 and the publish scripts are replaced with GitHub Actions, following the WebsocketClientLite.PCL model.

Behaviour changes for users

  • OnSegmentSelected and SegmentSelectedCommand are raised by the control once per SelectedSegment change, and no longer on page load. RaiseSelectionChanged is [Obsolete].
  • SelectedItem now selects its segment for string ItemsSource and for options with Item set. Items are compared with Equals.
  • Children defaults to an ObservableCollection, and runtime edits update the control. Segments get the control as Parent.
  • Setting ItemsSource to null clears the segments. Non-string items without TextPropertyName show ToString().
  • The macOS renderer assembly is now in the package. Earlier packages left it out.

Bug fixes

  • Replacing Children no longer clears or refills the previous list.
  • Items and collections no longer keep options or controls alive (weak subscriptions).
  • The control can be created before Forms.Init().
  • iOS, Android, macOS, UWP: renderers detach from the old element and the old segments.
  • Android:
    • Separate controls no longer share one set of colours.
    • Middle segments use the square background.
    • A disabled control ignores taps.
    • Clearing the selection no longer leaks a second RadioGroup.
    • DisabledColor is applied.
  • iOS:
    • Font changes reach the selected segment.
    • The border follows IsEnabled and DisabledColor.
    • A reused renderer rebuilds its segments.
  • UWP:
    • WidthRequest is applied per segment.
    • Fixed a crash when an old segment's text changed.
    • Changing DisabledColor no longer recolours enabled borders.
  • macOS:
    • A control that starts empty shows segments added later.
    • Child handlers are re-attached after Children changes.

Release pipeline

  • ci.yml builds the library and sample and runs the tests on GitHub-hosted Ubuntu.
  • build.yml ("Publish Package") runs when GitVersion.yml changes on a releases/** branch, or by hand. It:
    • sets the version with GitVersion and takes the release notes from the README;
    • builds the Android and UWP renderers on a self-hosted Windows runner, and the iOS and macOS renderers on a self-hosted macOS runner;
    • packs from the nuspec and fails if any platform has no binaries;
    • pushes to GitHub Packages and to NuGet.org via Trusted Publishing;
    • creates a draft GitHub release tagged v<version>.
  • It has no pull_request trigger, so the self-hosted runners never run code from a pull request.
  • Setup steps are in docs/releasing.md.

Not verified

  • The renderer changes have not been compiled or run. The legacy Xamarin projects don't build in the dev container. Every renderer file parses as C# 7.3.
  • The publish workflow has not run yet. It needs:
    • two self-hosted runners labelled xamarin;
    • a NuGet.org Trusted Publishing policy for this repo and build.yml;
    • confirmation that 1iveowl is the NuGet.org owner account.
  • The Windows runner may not build the library. The renderer projects compile the C# 14 library through a project reference. Check this first.

Test plan

  • dotnet build src/main/SegCtlr.Netstandard -c Release builds with no warnings
  • dotnet test src/test/SegCtlr.Tests -c Release passes all 49 tests
  • The shared sample builds
  • dotnet pack of the package project works with placeholder renderer binaries, and fails when one platform is missing
  • actionlint passes on both workflows
  • Build the renderers on Windows and macOS
  • Smoke test the sample apps on devices
  • Do a first release run on a releases/5.6.0 branch

…e CI

Build
- Library targets netstandard2.0 and net10.0; Xamarin.Forms 5.0.0.2662.
- C# 14, .editorconfig style rules enforced at build time (Directory.Build.props);
  library and tests treat warnings as errors; XML docs required on public API.
- Solution migrated to SegCtlr.Netstandard.slnx; global.json pins the .NET 10 SDK.

Shared control (covered by the new xUnit project, src/test/SegCtlr.Tests)
- SelectedItem selects its segment for string ItemsSource and XAML options;
  items are compared with Equals.
- Replacing Children no longer clears or refills the previous list.
- OnSegmentSelected and SegmentSelectedCommand are raised by the control,
  once per SelectedSegment change, not on page load; RaiseSelectionChanged
  is obsolete.
- ItemsSource: null clears the segments, non-string items fall back to
  ToString(), observable collections are followed.
- Children defaults to an ObservableCollection; edits reach the renderers;
  segments get Parent and BindingContext.
- Weak subscriptions so items and collections do not keep options or
  controls alive; FontSize default no longer needs Forms.Init().

Renderers (not compiled in this environment)
- Detach handlers from the old element and the old segments.
- Android: per-button drawable state (Mutate), middle-segment background,
  disabled control ignores taps, ClearCheck instead of re-inflating,
  DisabledColor, null checks.
- iOS: font and colors for both states, border on IsEnabled/DisabledColor,
  renderer reuse.
- UWP: per-segment WidthRequest, stale-option crash, DisabledColor border.
- macOS: rebuild from empty, re-attach child handlers, range checks.

Release
- Replace build.ps1/publish.ps1/publishLocal.ps1 with GitHub Actions:
  ci.yml (hosted) and build.yml (GitVersion, releases/** branches,
  self-hosted Xamarin runners, NuGet.org Trusted Publishing, GitHub Packages,
  draft GitHub release). See docs/releasing.md.
- Pack via src/build/Plugin.SegmentedControl.Package.csproj; a platform
  without binaries fails the pack.
- Include the macOS renderer assembly, which earlier packages left out.
@1iveowl
1iveowl merged commit 4e03ac4 into master Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant