Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Add XA1031 error (#7448)
Fixes: #7326 Commit d3e8767 added a requirement that, under .NET 6+, the `$(AndroidHttpClientHandlerType)` MUST inherit from [`System.Net.Http.HttpMessageHandler`][0]. This was unfortunately a change from Classic, which allowed/required that [`System.Net.Http.HttpClientHandler`][1] be the base class. Allowing `HttpClientHandler` to be in the inheritance hierarchy for `$(AndroidHttpClientHandlerType)` would result in a `NullReferenceException` at runtime under .NET 6. Commit d3e8767 contained a TODO: > TODO: [Emit a build-time warning][2] if > `$(AndroidHttpClientHandlerType)` is set to an invalid value Implement this TODO: add a build-time check that verifies that `$(AndroidHttpClientHandlerType)` is a valid type for the target, e.g. is an `HttpMessageHandler` subclass on .NET 6. If `$(AndroidHttpClientHandlerType)` is not a valid type, then an XA1031 error is raised: error XA1031: The 'AndroidHttpClientHandlerType' has an invalid value of '{0}' please check your project settings. Additionally, if `$(AndroidHttpClientHandlerType)` is `System.Net.Http.SocketsHttpHandler, System.Net.Http`, *and* `$(UseNativeHttpHandler)` isn't set, then set `$(UseNativeHttpHandler)` to false. This is necessary to ensure that `SocketsHttpHandler` is preserved by the linker. [0]: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpmessagehandler?view=net-6.0 [1]: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler?view=net-6.0 [2]: #7326
- Loading branch information
1 parent
e8f1f48
commit 311b41e
Showing
14 changed files
with
494 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: Xamarin.Android error XA1031 | ||
description: XA1031 error code | ||
ms.date: 10/10/2022 | ||
--- | ||
# Xamarin.Android error XA1031 | ||
|
||
## Example messages | ||
|
||
``` | ||
The 'AndroidHttpClientHandlerType' property value 'Foo.Bar.HttpHander, MyApp' must derive from 'System.Net.Http.HttpMessageHandler'. | ||
Please change the value to an assembly-qualifed type name which inherits from '{1}' or remove the property completely. | ||
``` | ||
|
||
## Solution | ||
|
||
Edit your csproj directly and change the 'AndroidHttpClientHandlerType' to | ||
a valid value. | ||
|
||
Valid values can be found at `~/android/deploy-test/building-apps/build-properties.md#AndroidHttpClientHandlerType`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Xamarin.Android error XA1032 | ||
description: XA1032 error code | ||
ms.date: 10/10/2022 | ||
--- | ||
# Xamarin.Android error XA1032 | ||
|
||
## Example messages | ||
|
||
``` | ||
Failed to resolve '{0}' from '{1}'. Please check your `AndroidHttpClientHandlerType` setting. | ||
``` | ||
|
||
## Solution | ||
|
||
Edit your csproj directly and change the 'AndroidHttpClientHandlerType' to | ||
a valid value. | ||
|
||
Valid values can be found at `~/android/deploy-test/building-apps/build-properties.md#AndroidHttpClientHandlerType`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Xamarin.Android error XA1033 | ||
description: XA1033 error code | ||
ms.date: 10/10/2022 | ||
--- | ||
# Xamarin.Android error XA1033 | ||
|
||
## Example messages | ||
|
||
``` | ||
Could not resolve '{0}'. Please check your `AndroidHttpClientHandlerType` setting. | ||
``` | ||
|
||
## Solution | ||
|
||
Edit your csproj directly and change the 'AndroidHttpClientHandlerType' to | ||
a valid value. | ||
|
||
Valid values can be found at `~/android/deploy-test/building-apps/build-properties.md#AndroidHttpClientHandlerType`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.