Windowscommunitytoolkit: Microsoft.Toolkit.Uwp.Notifications.dll needs to be included in .NET Native runtime directives

Created on 4 Jan 2020  路  14Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

Describe the bug

When a UWP app is linked using .NET Native and shipped to the store, toast notifications built using Microsoft.Toolkit.Uwp.Notifications.dll stop working. They still appear, but they lose all context provided by the user and show up as:

$AppName
New Notification

The workaround is to include the notifications assembly in rd.xml, like so:

<Assembly Name="Microsoft.Toolkit.Uwp.Notifications" Dynamic="Required All" />

  • [x] Is this bug a regression in the toolkit?

Yes, because this used to work without unnatural acts. But unclear when that was.

Steps to Reproduce

  1. Build a simple app that uses Microsoft.Toolkit.Uwp.Notifications to trigger notifications
  2. Confirm it works
  3. Compile it with .NET Native (debug builds are fine)
  4. Confirm all context is lost in notifications
  5. Add the directive mentioned above. Confirm it works again.

Expected behavior

The Toolkit NuGet package should provide an rd.xml that just works, so apps don't have to figure this out themselves.

cf https://devblogs.microsoft.com/dotnet/net-native-deep-dive-making-your-library-great/

Screenshots

image

Environment

Package Version(s): 6.0.0

Windows 10 Build Number:

  • [ ] Fall Creators Update (16299)
  • [ ] April 2018 Update (17134)
  • [ ] October 2018 Update (17763)
  • [x] May 2019 Update (18362)
  • [ ] Insider Build (build number: )

App min and target version:

  • [ ] Fall Creators Update (16299)
  • [x] April 2018 Update (17134)
  • [ ] October 2018 Update (17763)
  • [ ] May 2019 Update (18362)
  • [ ] Insider Build (xxxxx)

Device form factor:

  • [x] Desktop
  • [ ] Xbox
  • [ ] Surface Hub
  • [ ] IoT

Visual Studio

  • [ ] 2017 (version: )
  • [ ] 2019 (version: )
  • [x] 2019 (version: 16.4.2)
bug help wanted notifications

All 14 comments

@andrewleader any thoughts on what may have happened here?

@michael-hawker no idea, and I'm not aware of or familiar with rd.xml and the new .NET Native runtime directives :/

Anything I can do to help with this one?

@mfeingol there are new changes in the PR #3256, but I don't think they'd be related to this, so not sure if it's worth testing this scenario again with those.

_But do you happen to know which version you used before where it last worked?_ Knowing if you have a version of the toolkit and NetCore base NuGet packages that do work would give us a comparison point to see what might have changed since then.

@MattWhilden any advice/thoughts here on what might have changed? I'm assuming we may have upgraded the NetCore package, so is there some config change we need to make on our end?

Unfortunately, I don't, sorry. There was a stretch of maybe 2-3 months before the moment I filed this GHI where the notifications feature wasn't really being used by anyone. I tend to stay current on toolkit updates, so that may provide you with a rough timeline.

Best guess is something in the library started using reflection that wasn't before.

If it helps, btw, I could put together a small repro project for you.

@mfeingol a small repo project would be super valuable, especially if we need to get insight from another team about other parts of the platform, makes it easy to hand-off to them without them needing to understand how to build the full toolkit.

Here you go:

https://github.com/mfeingol/repros/tree/master/NotificationsRepro-3093

Note the difference between the toasts when .NET Native is enabled vs disabled. You can enable .NET Native in project build properties on the debug build, or just compare debug vs. release.

@azchohfi is this something you could take a look at?

I'll look at this now.

I could not repro this with v6.0.0 using UniversalWindowsPlatform 6.2.10. A Release build showed the notification exactly the same as a Debug build.
image
I tried both x86 as well as x64.
@michael-hawker or @Kyaa-dost , can you test this?

@azchohfi: I'm still seeing a repro here.

Untitled

Please make sure you're using .NET Native.

I am using .Net Native. That box is marked by default on Release Builds, but I did double check.

I'm not sure how to explain the difference then. It's 100% repro here, release or debug, as long as .NET Native is enabled.

@azchohfi I see the repro on my box (x64, 2004/19041 with VS 2019 16.5.5) when switching from Debug to Release, are you on Insiders?

Debug
image

Release
image

I downgraded the Toolkit NuGet to 5.1.1 and saw the same issue though (as well as our latest 6.1 preview bits):
image

I tried changing the NetCore UWP package, even all the way back to 6.0.1, but saw the same behavior.

@MichalStrehovsky & @TomMcDon any thoughts on what's going on here?

Was this page helpful?
0 / 5 - 0 ratings