microsoft / microsoft/WindowsAppSDK

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

Open
#4,722 1 comment 0 reactions 1 assignee View on GitHub

@manodasanW is already working on this.

Since Sep 26, 2024.

area-AOT
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### 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:

````xml



````

When parsing the visual tree with:

````c#
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:

````xml
true
````

### 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
````xml

````

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.