Skip to content

[Tests] Remove dead GetInnerHandlerType helper - #11665

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/remove-dead-getinnerhandlertype
Jun 16, 2026
Merged

[Tests] Remove dead GetInnerHandlerType helper#11665
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/remove-dead-getinnerhandlertype

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Jun 16, 2026

Copy link
Copy Markdown
Member

Description

AndroidHandlerTestBase.GetInnerHandlerType is a private static test helper with zero callers (confirmed via find-references — it appears only at its own declaration). It is dead code.

When did it become dead? Its last caller was removed by #6678 ("[Mono.Android-Tests] Stop using tls-test.internalx.com", merged 2022-01-28), which deleted the TLS handler tests whose Assert.AreEqual ("SocketsHttpHandler", GetInnerHandlerType (c).Name, …) assertion was the only thing using it. It has been unused ever since.

It also:

  • reflected into BCL private fields (HttpMessageInvoker._handler / _delegatingHandler), which is fragile across runtime versions, and
  • contained a copy-paste assertion bug (it null-checked handlerField twice instead of innerHandlerField),
  • all guarded by an [UnconditionalSuppressMessage ("Trimming", "IL2075")].

Since the method is unreachable, this removes:

  • the method,
  • its [UnconditionalSuppressMessage],
  • the now-unused using System.Reflection; and using System.Diagnostics.CodeAnalysis;.

Why

Contributes to #10794 ("[TrimmableTypeMap] Address all trimming and AOT warnings", which includes "No [UnconditionalSuppressMessage] used in the dotnet/android repo") by removing one more [UnconditionalSuppressMessage] — here the cleanest fix is simply deleting the dead code rather than annotating it.

No behavioral change: the method has been unreachable since #6678.

AndroidHandlerTestBase.GetInnerHandlerType is a private static helper with zero
callers (confirmed via find-references) — dead code. It also reflected into BCL
private fields (HttpMessageInvoker._handler / _delegatingHandler) and had a buggy
copy-paste assertion (it null-checked handlerField twice instead of checking
innerHandlerField), all guarded by an [UnconditionalSuppressMessage("Trimming",
"IL2075")].

Delete the method, its suppression, and the now-unused System.Reflection /
System.Diagnostics.CodeAnalysis usings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes an unused private test helper (AndroidHandlerTestBase.GetInnerHandlerType) from the Mono.Android test suite. This helps the ongoing effort to reduce trimming/AOT-warning suppressions by deleting unreachable reflection code and its associated [UnconditionalSuppressMessage].

Changes:

  • Deleted the dead GetInnerHandlerType (HttpClient) helper (no callers).
  • Removed the now-unneeded [UnconditionalSuppressMessage ("Trimming", "IL2075")].
  • Dropped unused using System.Reflection; and using System.Diagnostics.CodeAnalysis;.
Show a summary per file
File Description
tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidHandlerTestBase.cs Removes unreachable reflection-based helper and related trimming suppression + unused usings.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@simonrozsival

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jonathanpeppers
jonathanpeppers merged commit 760c141 into main Jun 16, 2026
39 of 41 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/remove-dead-getinnerhandlertype branch June 16, 2026 13:18
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants