Skip to content

fix: Trimming of CommunicationToast constructor when publishing #4068

Closed

Description

🐛 Bug Report

Locally when running in debug or production mode, using the CommunicationToast is working completely fine, however after deploying to our IIS machine it does not work anymore. It looks like the constructor is being trimmed from the assembly. We have for now disabled trimming which resolved the issue, but ideally we would love to have it on. Tried several approaches to workaround but each was giving other errors.

Pre workaround:
Image

With a workaround (dummy CommunicationToast in own assembly):

Image

💻 Repro or Code Sample

I'm finding it hard to reproduce, publishing locally does not seem to have the same error, but I am working on a MAC compared to the IIS windows deployment. Maybe that could be the culprit between the 2?

The code looks something like this:

@page "/"
@using Microsoft.FluentUI.AspNetCore.Components
@inject IToastService ToastService

<PageTitle>Home</PageTitle>

@if (RendererInfo.IsInteractive)
{
    <FluentButton OnClick="ShowCommunicationToast">Show toast</FluentButton>
    <FluentToastProvider/>
}

@code {
    private void ShowCommunicationToast()
    {
        ToastService.ShowCommunicationToast(new ToastParameters<CommunicationToastContent>()
        {
            Intent = ToastIntent.Error,
            Title = "Title",
            TopCTAType = ToastTopCTAType.Timestamp,
            Timeout = 8000,
            Content = new CommunicationToastContent()
            {
                Subtitle = "Sub title",
                Details = "Some details about the toast",
            },
        });
    }
}

🌍 Your Environment

  • OS & Device: Windows
  • Browser Tried both Chrome and Safari, both not working
  • .NET 9.0.8 and Fluent UI 4.12.1

It is worth noting that we are providing the Fluent UI packages to our projects through our own (internal) packages, could it possibly have anything to do with that?

Activity

  1. added
    triage
    on Aug 13, 2025
  2. DanielCordell commented on Aug 13, 2025

    @DanielCordell

    We have the same issue, using net8 but same FluentUI version.

  3. Tyme-Bleyaert commented on Aug 14, 2025

    @Tyme-Bleyaert
    Contributor

    I wonder if [method: DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors, typeof(CommunicationToast))] preserves primary constructors for DynamicComponent to use.

  4. PascalVorwerk commented on Aug 14, 2025

    @PascalVorwerk
    ContributorAuthor

    This could potentially be fixed with the 4.12.2 prerelease package, but i am unable to pull this package into our deployed environment, so i can't test it :(. I can start testing once 4.12.2 is released completely to see if that solves it.

  5. added
    status:needs-investigation
    and removed
    triage
    on Aug 15, 2025
  6. vnbaaij commented on Sep 2, 2025

    @vnbaaij
    Collaborator

    With PR mentioned, I've changed DynamicDependency from using DynamicallyAccessedMemberTypes.PublicConstructors to DynamicallyAccessedMemberTypes.All (in line with usage in rest of the code base).

    Tyme-Bleyaert for Toasts we are not using DynamicComponent. Happy to hear any other input you might have...
    Pascal Vorwerk (@PascalVorwerk) Once this PR is in, you can perhaps try a local build with the preview package?

  7. added
    status:in-progress
    and removed
    status:needs-investigation
    on Sep 2, 2025
  8. PascalVorwerk commented on Sep 2, 2025

    @PascalVorwerk
    ContributorAuthor

    Vincent Baaij (@vnbaaij) Hope you had a nice holiday 😄 . Sadly, in our internal builds, there is select list of packages i can pull and for some reason i can't replicate it locally on my own machine.. I will ask if the nuget package can be added to the internal nuget repository, but I am not sure if it will be allowed.

    If not, i will communicate my findings once we build with the full release itself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:in-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions