Skip to content

fix: gracefully handle MAUI unavailability in non-MAUI Windows apps#264

Merged
tanderson-ld merged 1 commit into
mainfrom
ta/SDK-2410/default-handling-maui-failure
May 26, 2026
Merged

fix: gracefully handle MAUI unavailability in non-MAUI Windows apps#264
tanderson-ld merged 1 commit into
mainfrom
ta/SDK-2410/default-handling-maui-failure

Conversation

@tanderson-ld
Copy link
Copy Markdown
Contributor

@tanderson-ld tanderson-ld commented May 26, 2026

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.

PlatformConnectivity now sets _mauiAvailable in 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).

AppInfo and DeviceInfo MAUI helpers wrap MAUI API calls in try/catch and return null for 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.

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.
@tanderson-ld tanderson-ld requested a review from a team as a code owner May 26, 2026 14:18
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful to log the exceptions as a debug?

@tanderson-ld
Copy link
Copy Markdown
Contributor Author

tanderson-ld commented May 26, 2026

Would it be helpful to log the exceptions as a debug?

Kinda tricky to pipe a logger into this region, I am inclined to not.

@tanderson-ld tanderson-ld merged commit f51a123 into main May 26, 2026
19 checks passed
@tanderson-ld tanderson-ld deleted the ta/SDK-2410/default-handling-maui-failure branch May 26, 2026 14:44
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` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/LaunchDarkly.ClientSdk/5.7.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/LaunchDarkly.ClientSdk/5.7.1/5.7.2?slim=true) |
| [Syncfusion.Maui.Expander](https://www.syncfusion.com/maui-controls/?utm_source=nuget&utm_medium=listing) | `33.2.7` → `33.2.8` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Syncfusion.Maui.Expander/33.2.8?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Syncfusion.Maui.Expander/33.2.7/33.2.8?slim=true) |
| [Syncfusion.Maui.Inputs](https://www.syncfusion.com/maui-controls/?utm_source=nuget&utm_medium=listing) | `33.2.7` → `33.2.8` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Syncfusion.Maui.Inputs/33.2.8?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Syncfusion.Maui.Inputs/33.2.7/33.2.8?slim=true) |

---

### 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 ([#&#8203;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).
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.

2 participants