Skip to content

When using TrimMode=link custom AndroidHttpClientHandlerType is not preserved #8797

Description

@jonathanpeppers

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

.NET 8, 9, etc.

Description

If you use the project settings:

<TrimMode>link</TrimMode>
<AndroidHttpClientHandlerType>MyNamespace.MyCustomHandler</AndroidHttpClientHandlerType>

In this case, nothing would preserve MyCustomHandler and it would be trimmed away.

Steps to Reproduce

Use project settings above.

Did you find any workaround?

You could use either [DynamicDependency] or [DynamicallyAccessedMembers] to preserve the type. You could also instantiate the handler in code.

Relevant log output

No response

Activity

  1. added
    bugComponent does not function as intended.
    Area: App+Library BuildIssues when building Library projects or Application projects.
    on Mar 7, 2024
  2. added this to the .NET 9 milestone on Mar 7, 2024
  3. jonpryor commented on Mar 20, 2024

    @jonpryor
    Contributor

    Related: whatever approach is used to preserve $(AndroidHttpClientHandlerType) -- likely a linker XML file -- should also be used to preserve View subclasses which are used within Android Layout .axml files.

    This is partially touched upon in #8805, which had to add [DynamicDependency(.All, typeof (Mono.Android_Test.Library.CustomTextView)) to ensure that the View subclass wasn't trimmed away. [DynamicDependency] should not be required, ideally.

  4. locked and limited conversation to collaborators on Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.bugComponent does not function as intended.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions