[mtouch] Make MT2015 (invalid HttpMessageHandler) a warning for known http message handlers on watchOS. Fixes #46552. (#1134)
Earlier versions of Xamarin Studio stored an invalid http message handler in watchOS project files, which would cause a build error. In addition Xamarin Studio removed the UI to set the http message handler (since only one value is valid), which meant that the user had to edit the project file by hand to get around this build error. So make it a warning instead (and document what the user has to do to fix the warning). https://bugzilla.xamarin.com/show_bug.cgi?id=46552
This commit is contained in:
Родитель
8a77ba5708
Коммит
d42a9f4909
|
@ -841,6 +841,12 @@ This generally indicates that there is a problem with your Xamarin.iOS installat
|
|||
|
||||
<h3><a name="MT2015"/>MT2015: Invalid HttpMessageHandler `*` for watchOS. The only valid value is NSUrlSessionHandler.</h3>
|
||||
|
||||
This is a warning that occurs because the project file specifies an invalid HttpMessageHandler.
|
||||
|
||||
Earlier versions of our preview tools generated by default an invalid value in the project file.
|
||||
|
||||
To fix this warning, open the project file in a text editor, and remove all HttpMessageHandler nodes from the XML.
|
||||
|
||||
<h3><a name="MT202x"/>MT202x: Binding Optimizer failed processing `...`.</h3>
|
||||
|
||||
Something unexpected occured when trying to optimize generated binding code. The element causing the issue is named in the error message. In order to fix this issue the assembly named (or containing the type or method named) will need to be provided in a [bug report](http://bugzilla.xamarin.com) along with a complete build log with verbosity enabled (i.e. `-v -v -v -v` in the **Additional mtouch arguments**).
|
||||
|
|
|
@ -68,12 +68,16 @@ namespace XamCore.ObjCRuntime {
|
|||
return HttpClientHandlerValue;
|
||||
case CFNetworkHandlerValue:
|
||||
case HttpClientHandlerValue:
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS)
|
||||
throw ErrorHelper.CreateError (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", value);
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS) {
|
||||
ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", value);
|
||||
return NSUrlSessionHandlerValue;
|
||||
}
|
||||
return value;
|
||||
case NSUrlSessionHandlerValue:
|
||||
return value;
|
||||
default:
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS) // This is value we don't know about at all, show as error instead of warning.
|
||||
throw ErrorHelper.CreateError (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", value);
|
||||
throw ErrorHelper.CreateError (2010, "Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler", value);
|
||||
}
|
||||
}
|
||||
|
@ -185,14 +189,20 @@ namespace XamCore.ObjCRuntime {
|
|||
break;
|
||||
#else
|
||||
case HttpClientHandlerValue:
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS)
|
||||
throw ErrorHelper.CreateError (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler);
|
||||
type = httpModule.GetType ("System.Net.Http", "HttpClientHandler");
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS) {
|
||||
ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler);
|
||||
type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler");
|
||||
} else {
|
||||
type = httpModule.GetType ("System.Net.Http", "HttpClientHandler");
|
||||
}
|
||||
break;
|
||||
case CFNetworkHandlerValue:
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS)
|
||||
throw ErrorHelper.CreateError (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler);
|
||||
type = httpModule.GetType ("System.Net.Http", "CFNetworkHandler");
|
||||
if (Driver.App.Platform == Utils.ApplePlatform.WatchOS) {
|
||||
ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler);
|
||||
type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler");
|
||||
} else {
|
||||
type = httpModule.GetType ("System.Net.Http", "CFNetworkHandler");
|
||||
}
|
||||
break;
|
||||
case NSUrlSessionHandlerValue:
|
||||
type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler");
|
||||
|
|
|
@ -2146,6 +2146,42 @@ class C {
|
|||
}
|
||||
}
|
||||
|
||||
[TestCase (Profile.Unified)]
|
||||
[TestCase (Profile.TVOS)]
|
||||
public void MT2010 (Profile profile)
|
||||
{
|
||||
using (var mtouch = new MTouchTool ()) {
|
||||
mtouch.Profile = profile;
|
||||
mtouch.CreateTemporaryApp ();
|
||||
|
||||
mtouch.HttpMessageHandler = "Dummy";
|
||||
Assert.AreEqual (1, mtouch.Execute (MTouchAction.BuildSim));
|
||||
mtouch.AssertError (2010, "Unknown HttpMessageHandler `Dummy`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MT2015 ()
|
||||
{
|
||||
using (var mtouch = new MTouchTool ()) {
|
||||
mtouch.Profile = Profile.WatchOS;
|
||||
mtouch.CreateTemporaryWatchKitExtension ();
|
||||
mtouch.Extension = true;
|
||||
|
||||
mtouch.HttpMessageHandler = "HttpClientHandler";
|
||||
mtouch.AssertExecute (MTouchAction.BuildSim);
|
||||
mtouch.AssertError (2015, "Invalid HttpMessageHandler `HttpClientHandler` for watchOS. The only valid value is NSUrlSessionHandler.");
|
||||
|
||||
mtouch.HttpMessageHandler = "CFNetworkHandler";
|
||||
mtouch.AssertExecute (MTouchAction.BuildSim);
|
||||
mtouch.AssertError (2015, "Invalid HttpMessageHandler `CFNetworkHandler` for watchOS. The only valid value is NSUrlSessionHandler.");
|
||||
|
||||
mtouch.HttpMessageHandler = "Dummy";
|
||||
mtouch.AssertExecuteFailure (MTouchAction.BuildSim);
|
||||
mtouch.AssertError (2015, "Invalid HttpMessageHandler `Dummy` for watchOS. The only valid value is NSUrlSessionHandler.");
|
||||
}
|
||||
}
|
||||
|
||||
#region Helper functions
|
||||
static string CompileUnifiedTestAppExecutable (string targetDirectory, string code = null, string extraArg = "")
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace Xamarin
|
|||
public bool? Extension;
|
||||
public List<string> AppExtensions = new List<string> ();
|
||||
public List<string> Frameworks = new List<string> ();
|
||||
public string HttpMessageHandler;
|
||||
#pragma warning restore 649
|
||||
|
||||
// These are a bit smarter
|
||||
|
@ -125,6 +126,11 @@ namespace Xamarin
|
|||
NUnit.Framework.Assert.AreEqual (0, Execute (action), message);
|
||||
}
|
||||
|
||||
public void AssertExecuteFailure (MTouchAction action, string message = null)
|
||||
{
|
||||
NUnit.Framework.Assert.AreEqual (1, Execute (action), message);
|
||||
}
|
||||
|
||||
string BuildArguments (MTouchAction action)
|
||||
{
|
||||
var sb = new StringBuilder ();
|
||||
|
@ -195,6 +201,9 @@ namespace Xamarin
|
|||
foreach (var framework in Frameworks)
|
||||
sb.Append (" --framework ").Append (MTouch.Quote (framework));
|
||||
|
||||
if (!string.IsNullOrEmpty (HttpMessageHandler))
|
||||
sb.Append (" --http-message-handler=").Append (MTouch.Quote (HttpMessageHandler));
|
||||
|
||||
if (Dlsym.HasValue)
|
||||
sb.Append (" --dlsym:").Append (Dlsym.Value ? "true" : "false");
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace Xamarin.Bundler {
|
|||
// MT2012 ** reserved Xamarin.Mac **
|
||||
// MT2013 ** reserved Xamarin.Mac **
|
||||
// MT2014 ** reserved Xamarin.Mac **
|
||||
// MT2015 Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.
|
||||
// Warning MT2015 Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.
|
||||
// MT202x Binding Optimizer failed processing `...`.
|
||||
// MT203x Removing User Resources failed processing `...`.
|
||||
// MT3xxx AOT
|
||||
|
|
Загрузка…
Ссылка в новой задаче