diff --git a/tests/mtouch/LinkerTests.cs b/tests/mtouch/LinkerTests.cs
new file mode 100644
index 000000000000..8e32ef720400
--- /dev/null
+++ b/tests/mtouch/LinkerTests.cs
@@ -0,0 +1,29 @@
+using System;
+using System.IO;
+
+using NUnit.Framework;
+
+namespace Xamarin.Linker
+{
+ [TestFixture]
+ public partial class Preservation
+ {
+ [Test]
+ public void PreserveParameterInfoInXml ()
+ {
+ using (var mtouch = new MTouchTool ()) {
+ var xml = Path.Combine (mtouch.CreateTemporaryDirectory (), "extra.xml");
+ File.WriteAllText (xml, @"
+
+
+
+
+");
+ mtouch.Linker = MTouchLinker.LinkAll;
+ mtouch.XmlDefinitions = new string [] { xml };
+ mtouch.CreateTemporaryApp ();
+ mtouch.AssertExecute (MTouchAction.BuildSim, "build");
+ }
+ }
+ }
+}
diff --git a/tests/mtouch/mtouch.csproj b/tests/mtouch/mtouch.csproj
index de5943c69615..8a6ff116c449 100644
--- a/tests/mtouch/mtouch.csproj
+++ b/tests/mtouch/mtouch.csproj
@@ -52,6 +52,7 @@
StringUtils.cs
+
diff --git a/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs b/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs
index d01a56b04178..3ac37e8fdcda 100644
--- a/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs
+++ b/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs
@@ -102,11 +102,16 @@ protected override MethodDefinition MarkMethod (MethodReference reference)
// we need to track who's calling ParameterInfo.Name property getter, if it comes from
// user code then it's not possible to remove the parameters from the assemblies metadata
if (!parameter_info && (method.Name == "get_Name") && method.DeclaringType.Is ("System.Reflection", "ParameterInfo")) {
- var a = current_method.DeclaringType.Module.Assembly;
- if (!Profile.IsSdkAssembly (a) && !Profile.IsProductAssembly (a)) {
- // see MetadataReducerSubStep for the consumer part of the data
- Annotations.GetCustomAnnotations ("ParameterInfo").Add (method, current_method);
- parameter_info = true;
+ if (current_method == null) {
+ // This can happen if ParameterInfo.get_Name is preserved in an xml file
+ Annotations.GetCustomAnnotations ("ParameterInfo").Add (method, null);
+ } else {
+ var a = current_method.DeclaringType.Module.Assembly;
+ if (!Profile.IsSdkAssembly (a) && !Profile.IsProductAssembly (a)) {
+ // see MetadataReducerSubStep for the consumer part of the data
+ Annotations.GetCustomAnnotations ("ParameterInfo").Add (method, current_method);
+ parameter_info = true;
+ }
}
}