Skip to content
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

[linker] Handle ParameterInfos preserved from XML definitions. Fixes #60176. #2915

Merged
merged 1 commit into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/mtouch/LinkerTests.cs
Original file line number Diff line number Diff line change
@@ -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, @"
<linker>
<assembly fullname=""mscorlib"">
<type fullname=""System.Reflection.ParameterInfo"" />
</assembly>
</linker>");
mtouch.Linker = MTouchLinker.LinkAll;
mtouch.XmlDefinitions = new string [] { xml };
mtouch.CreateTemporaryApp ();
mtouch.AssertExecute (MTouchAction.BuildSim, "build");
}
}
}
}
1 change: 1 addition & 0 deletions tests/mtouch/mtouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<Compile Include="..\..\tools\common\StringUtils.cs">
<Link>StringUtils.cs</Link>
</Compile>
<Compile Include="LinkerTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
15 changes: 10 additions & 5 deletions tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down