Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing a C# unpackaged app trimmed causes TextBlock.Inlines collection items to loose type information #4722

Open
DHancock opened this issue Sep 16, 2024 · 1 comment
Assignees
Labels

Comments

@DHancock
Copy link

DHancock commented Sep 16, 2024

Describe the bug

I'm parsing a TextBlock.Inlines collection to see if it contains a Hyperlink. The code works for normal Debug and Release builds, but fails when published trimmed. It seems that the contents of the Inlines collection have lost some type information, now only ever containing items of type Microsoft.UI.Xaml.Documents.Inline

Steps to reproduce the bug

For example, with the following xaml:

<TextBlock>
  <Hyperlink NavigateUri="https://www.google.com">
    <Run Text="GoTo Google"/>
  </Hyperlink>      
</TextBlock>

When parsing the visual tree with:

switch (uielement)
{
  case TextBlock tb when tb.Inlines.Any(x => x is Hyperlink):
  {
    // code to add the Hyperlink area to the passthrough rectangles
    break;
  }
}

The code fails to find a Hyperlink inline when published trimmed using a publishing profile containing:

<PublishTrimmed>true</PublishTrimmed>

Expected behavior

Type information is preserved

Screenshots

No response

NuGet package version

Windows App SDK 1.6.0: 1.6.240829007

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

the project references

<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.3" />
@DHancock
Copy link
Author

DHancock commented Oct 12, 2024

Fixed in CsWinRT version 2.1.5

Edit: No it isn't. I was just too hung over to test it properly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants