microsoft / microsoft/WindowsAppSDK
PushNotificationChannel variable calls different namespaces
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
Describe the bug
It took me a while to track down why the same .NET MAUI apps were behaving differently. One is newly created with net.8-preview while the other was upgraded to net.8-preview for net7.0.
When creating PushNotificationChannel object, the new app picks microsoft.windowsappsdk 1.2.230118.102 (with namespace Microsoft.Windows.PushNotifications) while the upgraded one picked microsoft.windows.sdk.net.ref\10.0.19041.28 (with namespace Windows.Networking.PushNotifications).
The new app fails to compile for a very strange reason: referring to a static field of type PushNotificationChannel in the Windows App constructor refers to Microsoft.Windows.PushNotifications namespace. However, the PushNotificationChannel field outside of the constructor, is not visible as Microsoft.Windows.PushNotifications; the reference is instead looking for Windows.Networking.PushNotifications hence compilation fails.
I can enforce the reference by declaring:
using PushNotificationChannel = Windows.Networking.PushNotifications.PushNotificationChannel;
and compilation will succeed.
Steps to reproduce the bug
- Declare a static filed or property of type
PushNotificationChannelin Windows App constructor. - Try to create the static field or property object outside of the constructor as:
channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
Expected behavior
Should compile but PushNotificationChannel is referred to with different namespaces depending on where the field or property is defined -- inside or outside the constructor.
Screenshots
No response
NuGet package version
Windows App SDK 1.2.5: 1.2.230313.1
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022-preview
Additional context
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reproducing the reported packaged .NET MAUI project with Windows App SDK 1.2.5, then compare the resolved package references and PushNotificationChannel namespaces between new and upgraded projects. Done means the same declaration and creation path compile consistently without the namespace alias workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100