fix: gracefully handle MAUI unavailability in non-MAUI Windows apps#264
Merged
Merged
Conversation
PlatformConnectivity, AppInfo, and DeviceInfo all call MAUI APIs that require platform initialization. In WPF/WinForms apps targeting net8.0-windows, MAUI is never initialized, causing a TypeInitializationException during LdClient.Init(). Guard the static constructor with a _mauiAvailable flag and fall back to safe defaults (assume connected, return null for app/device info) when MAUI is not available at runtime.
jsonbailey
approved these changes
May 26, 2026
Contributor
jsonbailey
left a comment
There was a problem hiding this comment.
Would it be helpful to log the exceptions as a debug?
Contributor
Author
Kinda tricky to pipe a logger into this region, I am inclined to not. |
tanderson-ld
pushed a commit
that referenced
this pull request
May 26, 2026
🤖 I have created a release *beep* *boop* --- ## [5.7.2](LaunchDarkly.ClientSdk-v5.7.1...LaunchDarkly.ClientSdk-v5.7.2) (2026-05-26) ### Bug Fixes * gracefully handle MAUI unavailability in non-MAUI Windows apps ([#264](#264)) ([f51a123](f51a123)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Mechanical version and changelog updates with no code in the diff; runtime change is a targeted compatibility fix already described in the release notes. > > **Overview** > This PR is a **Release Please** cut for **LaunchDarkly.ClientSdk 5.7.2**. It bumps the package version everywhere release tooling expects it: `.release-please-manifest.json`, `LaunchDarkly.ClientSdk.csproj`, `CHANGELOG.md`, and `PROVENANCE.md` (example `SDK_VERSION` for attestation verification). > > The changelog entry records the user-facing fix from [#264](#264): **gracefully handle MAUI unavailability in non-MAUI Windows apps**—so desktop/WinUI apps that target `net8.0-windows` without a full MAUI stack should not fail when MAUI APIs are absent. **No source changes appear in this diff**; only release metadata and version strings. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c9f96af. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
evgenygunko
pushed a commit
to evgenygunko/CopyWordsDA
that referenced
this pull request
May 27, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [LaunchDarkly.ClientSdk](https://github.com/launchdarkly/dotnet-core) | `5.7.1` → `5.7.2` |  |  | | [Syncfusion.Maui.Expander](https://www.syncfusion.com/maui-controls/?utm_source=nuget&utm_medium=listing) | `33.2.7` → `33.2.8` |  |  | | [Syncfusion.Maui.Inputs](https://www.syncfusion.com/maui-controls/?utm_source=nuget&utm_medium=listing) | `33.2.7` → `33.2.8` |  |  | --- ### Release Notes <details> <summary>launchdarkly/dotnet-core (LaunchDarkly.ClientSdk)</summary> ### [`v5.7.2`](https://github.com/launchdarkly/dotnet-core/releases/tag/LaunchDarkly.ClientSdk-v5.7.2): LaunchDarkly.ClientSdk: v5.7.2 [Compare Source](launchdarkly/dotnet-core@LaunchDarkly.ClientSdk-v5.7.1...LaunchDarkly.ClientSdk-v5.7.2) ##### Bug Fixes - gracefully handle MAUI unavailability in non-MAUI Windows apps ([#​264](launchdarkly/dotnet-core#264)) ([f51a123](launchdarkly/dotnet-core@f51a123)) *** This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!". 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
I have added test coverage for new or changed functionality.
Not worth the squeeze.
I have followed the repository's pull request submission guidelines
I have validated my changes against all supported platform versions
TODO
Describe the solution you've provided
PlatformConnectivity, AppInfo, and DeviceInfo all call MAUI APIs that require platform initialization. In WPF/WinForms apps targeting net8.0-windows, MAUI is never initialized, causing a TypeInitializationException during LdClient.Init(). Guard the static constructor with a _mauiAvailable flag and fall back to safe defaults (assume connected, return null for app/device info) when MAUI is not available at runtime.
Describe alternatives you've considered
A multilayer approach with default platform impls and a public API for overrides from another package. This could be a future improvement.
Note
Low Risk
Defensive fallbacks around optional MAUI metadata and connectivity; behavior matches existing netstandard stubs when MAUI is absent, with no auth or data-path changes.
Overview
Prevents
LdClient.Init()crashes on net8.0-windows desktop apps (WPF/WinForms) where MAUI is referenced but never initialized.PlatformConnectivitynow sets_mauiAvailablein a guarded static constructor; when MAUI fails, it assumes Internet connectivity, returns no connection profiles, and skips subscribing to MAUI connectivity events (aligned with the existing netstandard stub behavior).AppInfoandDeviceInfoMAUI helpers wrap MAUI API calls in try/catch and returnnullfor app/OS/device metadata when MAUI is unavailable, instead of throwing during init.Reviewed by Cursor Bugbot for commit 83e2f9b. Bugbot is set up for automated code reviews on this repo. Configure here.