Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
TrimMode="$(TrimMode)"
DefaultAction="$(_TrimmerDefaultAction)"
RemoveSymbols="$(TrimmerRemoveSymbols)"
PreserveSymbolPaths="$(_TrimmerPreserveSymbolPaths)"
FeatureSettings="@(_TrimmerFeatureSettings)"
CustomData="@(_TrimmerCustomData)"

Expand All @@ -406,6 +407,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
UnusedInterfaces="$(_TrimmerUnusedInterfaces)"
IPConstProp="$(_TrimmerIPConstProp)"
Sealer="$(_TrimmerSealer)"
KeepMetadata="@(_TrimmerKeepMetadata)"

Warn="$(ILLinkWarningLevel)"
NoWarn="$(NoWarn)"
Expand Down
20 changes: 20 additions & 0 deletions tests/dotnet/TrimmerMetadata/Library/MetadataModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace TrimmerMetadataLibrary {
public class MetadataModel {
public int Identifier { get; }
public string Description { get; }

public MetadataModel (int identifier, string description)
{
Identifier = identifier;
Description = description;
}

public int WithValue (int value)
{
return Identifier + value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Copyright (c) Microsoft Corporation. -->
<!-- Licensed under the MIT License. -->

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions tests/dotnet/TrimmerMetadata/iOS/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

using TrimmerMetadataLibrary;

var model = new MetadataModel (1, "description");
Console.WriteLine (model.Description);
Console.WriteLine (model.WithValue (2));
19 changes: 19 additions & 0 deletions tests/dotnet/TrimmerMetadata/iOS/TrimmerMetadata.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Copyright (c) Microsoft Corporation. -->
<!-- Licensed under the MIT License. -->

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework>
<OutputType>Exe</OutputType>
<ApplicationTitle>TrimmerMetadata</ApplicationTitle>
<ApplicationId>com.xamarin.trimmermetadata</ApplicationId>
<ExcludeNUnitLiteReference>true</ExcludeNUnitLiteReference>
<ExcludeTouchUnitReference>true</ExcludeTouchUnitReference>
</PropertyGroup>

<Import Project="../../../common/shared-dotnet.csproj" />

<ItemGroup>
<ProjectReference Include="../Library/TrimmerMetadataLibrary.csproj" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions tests/dotnet/UnitTests/WindowsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,41 @@ public void BuildEmbeddedFrameworkInBindingProjectApp (ApplePlatform platform, s
DotNet.AssertBuild (project_path, properties, timeout: TimeSpan.FromMinutes (15));
}

[Category ("RemoteWindows")]
[TestCase (ApplePlatform.iOS, "ios-arm64")]
public void TrimmerKeepsParameterNamesWithRemoteMac (ApplePlatform platform, string runtimeIdentifiers)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
Configuration.IgnoreIfNotOnWindows ();

var projectPath = GetProjectPath ("TrimmerMetadata", platform: platform);
Clean (projectPath);

var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["Configuration"] = "Debug";
properties ["UseMonoRuntime"] = "false";
properties ["_CopyLinkerOutputToWindows"] = "true";

var result = DotNet.AssertBuild (projectPath, properties, timeout: TimeSpan.FromMinutes (15));
AssertThatLinkerExecuted (result);

var assemblyPath = Path.Combine (GetObjDir (projectPath, platform, runtimeIdentifiers), "linked", "TrimmerMetadataLibrary.dll");
Assert.That (assemblyPath, Does.Exist, "Linked library should be copied back to Windows");

using var assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly (assemblyPath);
var model = assembly.MainModule.GetType ("TrimmerMetadataLibrary.MetadataModel");
if (model is null) {
Assert.Fail ("Trimmable model should survive linking");
return;
}

var constructor = model.Methods.Single (method => method.IsConstructor && method.Parameters.Count == 2);
var withValue = model.Methods.Single (method => method.Name == "WithValue");
Assert.That (constructor.Parameters.Select (parameter => parameter.Name), Is.EqualTo (new [] { "identifier", "description" }), "Constructor parameter names");
Assert.That (withValue.Parameters.Select (parameter => parameter.Name), Is.EqualTo (new [] { "value" }), "Method parameter name");
}

static void AssertWarningsEqual (IList<string> expected, IList<string> actual, string message)
{
if (expected.Count == actual.Count) {
Expand Down
Loading