Skip to content

[Mono.Android] update return type of GetHttpMessageHandler() #10212

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

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

jonathanpeppers
Copy link
Member

Context: dotnet/runtime#116707

To prevent a #if TARGET_ANDROID in dotnet/runtime:

#if TARGET_ANDROID
using GetHttpMessageHandlerReturnType = object;
#elif TARGET_IOS || TARGET_MACCATALYST || TARGET_TVOS
using GetHttpMessageHandlerReturnType = System.Net.Http.HttpMessageHandler;
#endif

Let's unify and use System.Net.Http.HttpMessageHandler as the return type for GetHttpMessageHandler().

Context: dotnet/runtime#116707

To prevent a `#if TARGET_ANDROID` in dotnet/runtime:

    #if TARGET_ANDROID
    using GetHttpMessageHandlerReturnType = object;
    #elif TARGET_IOS || TARGET_MACCATALYST || TARGET_TVOS
    using GetHttpMessageHandlerReturnType = System.Net.Http.HttpMessageHandler;
    #endif

Let's unify and use `System.Net.Http.HttpMessageHandler` as the return
type for `GetHttpMessageHandler()`.
@@ -355,7 +356,7 @@ static object GetHttpMessageHandler ()
httpMessageHandlerType = handlerType;
}

return Activator.CreateInstance (httpMessageHandlerType)
return (HttpMessageHandler) Activator.CreateInstance (httpMessageHandlerType)
Copy link
Member

Choose a reason for hiding this comment

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

There's a comment a bit above that says "We don't do any type checking or casting here to avoid dependency on System.Net.Http in Mono.Android.dll" - this sounds like something from Mono days, when we wouldn't want a cyclic reference between Mono.Android.dll and System.Net.Http.dll. This shouldn't be a problem anymore (so maybe remove the comment?)

@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 17, 2025 12:51
@jonathanpeppers jonathanpeppers enabled auto-merge (squash) June 17, 2025 14:20
@jonathanpeppers jonathanpeppers merged commit 8972395 into main Jun 17, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/GetHttpMessageHandler branch June 17, 2025 14:57
jkoritzinsky added a commit to jkoritzinsky/runtime that referenced this pull request Jun 17, 2025
github-actions bot pushed a commit to dotnet/runtime that referenced this pull request Jun 17, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2025
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.

2 participants