Skip to content

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

Open
@DHancock

Description

@DHancock

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" />

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions