microsoft / microsoft/WindowsAppSDK

AppNotificationBuilder.BuildNotification fails with ComException when the character ' appears on an AppNotificationButton

Open
#4,996 0 comments 0 reactions 0 assignees View on GitHub
area-Notifications
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

When trying to create a AppNotificationBuilder, buttons can't contain the `'` character, or otherwhise when calling the builder.BuildNotification method the following COMException will be thrown:

```csharp
System.Runtime.InteropServices.COMException (0xC00CE509): Required white space was missing.
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.Windows.AppNotifications.Builder.IAppNotificationBuilderMethods.BuildNotification(IObjectReference _obj)
at Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.BuildNotification()
at C:\My\Path\MyFile.cs:line 128
```

### Steps to reproduce the bug

**IMPORTANT: This bug is only reproducable when the solution is built as "Release", as "Debug" builds will work without further issues**

The following code causes the issue:

```csharp

// This line will always work
AppNotificationBuilder builder = new AppNotificationBuilder()
.SetScenario(AppNotificationScenario.Default)
.SetTag("UpdatesNotifications")

.AddText("Adding a ' here is fine. They work as expected and don't crash")
.AddText("More text")
.SetAttributionText("Some attribution")

.AddButton(new AppNotificationButton("Adding a ' here causes the COMException"))
.AddArgument("action", "action1")
)
.AddButton(new AppNotificationButton("Another button")
.AddArgument("action", "action2")
)
.AddArgument("action", "action3");

// The COMException occurrs on the line below
AppNotification notification = builder.BuildNotification();

```

### Expected behavior

Notifications to support `'` characters on buttons.

### Screenshots

N/A

### NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

### Packaging type

Unpackaged

### Windows version

Windows 11 version 22H2 (22621, 2022 Update)

### IDE

Other

### Additional context

I have tried escaping the ' character by `\\'` with no luck,

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided Release-mode reproduction and the AppNotificationBuilder.BuildNotification call, focusing on AppNotificationButton text containing an apostrophe. Confirm the COMException on Windows App SDK 1.6.3, then trace the builder implementation; done means button labels containing apostrophes build notifications successfully without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
api, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.