From 87b44060593ba89d72ab21169d012f1f36d5d885 Mon Sep 17 00:00:00 2001 From: Mike Voorhees Date: Wed, 29 May 2019 20:05:14 -0400 Subject: [PATCH] Add tests for mvid options and symbol files The test for mdb + deterministic mvid and portable pdb + deterministic mvid had to be ignored because they encounter https://github.com/jbevain/cecil/issues/583 --- .../Mono.Linker.Tests.Cases.csproj | 10 +++++- ...ymbolLinkingEnabledAndDeterministicMvid.cs | 20 +++++++++++ ...dedPdbAndSymbolLinkingEnabledAndNewMvid.cs | 20 +++++++++++ ...ymbolLinkingEnabledAndDeterministicMvid.cs | 34 ++++++++++++++++++ ...ithMdbAndSymbolLinkingEnabledAndNewMvid.cs | 33 +++++++++++++++++ ...ymbolLinkingEnabledAndDeterministicMvid.cs | 35 +++++++++++++++++++ ...ithPdbAndSymbolLinkingEnabledAndNewMvid.cs | 35 +++++++++++++++++++ ...ymbolLinkingEnabledAndDeterministicMvid.cs | 21 +++++++++++ ...blePdbAndSymbolLinkingEnabledAndNewMvid.cs | 20 +++++++++++ 9 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndNewMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndDeterministicMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndNewMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndDeterministicMvid.cs create mode 100644 test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndNewMvid.cs diff --git a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj index 47d01c180f92..46d68bd33f1b 100644 --- a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj +++ b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj @@ -1,4 +1,4 @@ - + true @@ -360,6 +360,14 @@ + + + + + + + + diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs new file mode 100644 index 000000000000..b8beb1abc689 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs @@ -0,0 +1,20 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [SetupCompileBefore ("LibraryWithEmbeddedPdbSymbols.dll", new[] { "Dependencies/LibraryWithEmbeddedPdbSymbols.cs" }, additionalArguments: "/debug:embedded", compilerToUse: "csc")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--deterministic")] + + [KeptSymbols ("LibraryWithEmbeddedPdbSymbols.dll")] + + [KeptMemberInAssembly ("LibraryWithEmbeddedPdbSymbols.dll", typeof (LibraryWithEmbeddedPdbSymbols), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithEmbeddedPdbSymbols.dll", typeof (LibraryWithEmbeddedPdbSymbols), "NotUsed()")] + public class ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndDeterministicMvid { + static void Main () + { + LibraryWithEmbeddedPdbSymbols.SomeMethod (); + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndNewMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndNewMvid.cs new file mode 100644 index 000000000000..17381c95497f --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndNewMvid.cs @@ -0,0 +1,20 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [SetupCompileBefore ("LibraryWithEmbeddedPdbSymbols.dll", new[] { "Dependencies/LibraryWithEmbeddedPdbSymbols.cs" }, additionalArguments: "/debug:embedded", compilerToUse: "csc")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--deterministic")] + + [KeptSymbols ("LibraryWithEmbeddedPdbSymbols.dll")] + + [KeptMemberInAssembly ("LibraryWithEmbeddedPdbSymbols.dll", typeof (LibraryWithEmbeddedPdbSymbols), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithEmbeddedPdbSymbols.dll", typeof (LibraryWithEmbeddedPdbSymbols), "NotUsed()")] + public class ReferenceWithEmbeddedPdbAndSymbolLinkingEnabledAndNewMvid { + static void Main () + { + LibraryWithEmbeddedPdbSymbols.SomeMethod (); + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndDeterministicMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndDeterministicMvid.cs new file mode 100644 index 000000000000..e304375b04ae --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndDeterministicMvid.cs @@ -0,0 +1,34 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [IgnoreTestCase ("Requires cecil updated with fix for https://github.com/jbevain/cecil/issues/583")] + [Reference ("Dependencies/LibraryWithMdb/LibraryWithMdb.dll")] + [ReferenceDependency ("Dependencies/LibraryWithMdb/LibraryWithMdb.dll.mdb")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--deterministic")] + + [KeptSymbols ("LibraryWithMdb.dll")] + + [KeptMemberInAssembly ("LibraryWithMdb.dll", typeof (LibraryWithMdb), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithMdb.dll", typeof (LibraryWithMdb), "NotUsed()")] + public class ReferenceWithMdbAndSymbolLinkingEnabledAndDeterministicMvid { + static void Main () + { + // Use some stuff so that we can verify that the linker output correct results + SomeMethod (); + + LibraryWithMdb.SomeMethod (); + } + + [Kept] + static void SomeMethod () + { + } + + static void NotUsed () + { + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndNewMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndNewMvid.cs new file mode 100644 index 000000000000..d1dd3ae5510b --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbAndSymbolLinkingEnabledAndNewMvid.cs @@ -0,0 +1,33 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [Reference ("Dependencies/LibraryWithMdb/LibraryWithMdb.dll")] + [ReferenceDependency ("Dependencies/LibraryWithMdb/LibraryWithMdb.dll.mdb")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--new-mvid", "true")] + + [KeptSymbols ("LibraryWithMdb.dll")] + + [KeptMemberInAssembly ("LibraryWithMdb.dll", typeof (LibraryWithMdb), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithMdb.dll", typeof (LibraryWithMdb), "NotUsed()")] + public class ReferenceWithMdbAndSymbolLinkingEnabledAndNewMvid { + static void Main () + { + // Use some stuff so that we can verify that the linker output correct results + SomeMethod (); + + LibraryWithMdb.SomeMethod (); + } + + [Kept] + static void SomeMethod () + { + } + + static void NotUsed () + { + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs new file mode 100644 index 000000000000..32f7fb568df9 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs @@ -0,0 +1,35 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [Reference ("Dependencies/LibraryWithPdb/LibraryWithPdb.dll")] + [ReferenceDependency ("Dependencies/LibraryWithPdb/LibraryWithPdb.pdb")] + [SetupLinkerLinkSymbols( "true")] + [SetupLinkerArgument ("--deterministic")] + +#if WIN32 + [KeptSymbols ("LibraryWithPdb.dll")] +#else + [RemovedSymbols ("LibraryWithPdb.dll")] +#endif + [KeptMemberInAssembly ("LibraryWithPdb.dll", typeof (LibraryWithPdb), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithPdb.dll", typeof (LibraryWithPdb), "NotUsed()")] + public class ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid { + static void Main () + { + // Use some stuff so that we can verify that the linker output correct results + SomeMethod(); + LibraryWithPdb.SomeMethod (); + } + + [Kept] + static void SomeMethod () + { + } + + static void NotUsed () + { + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid.cs new file mode 100644 index 000000000000..eda780122d6e --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid.cs @@ -0,0 +1,35 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [Reference ("Dependencies/LibraryWithPdb/LibraryWithPdb.dll")] + [ReferenceDependency ("Dependencies/LibraryWithPdb/LibraryWithPdb.pdb")] + [SetupLinkerLinkSymbols( "true")] + [SetupLinkerArgument ("--new-mvid", "true")] + +#if WIN32 + [KeptSymbols ("LibraryWithPdb.dll")] +#else + [RemovedSymbols ("LibraryWithPdb.dll")] +#endif + [KeptMemberInAssembly ("LibraryWithPdb.dll", typeof (LibraryWithPdb), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithPdb.dll", typeof (LibraryWithPdb), "NotUsed()")] + public class ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid { + static void Main () + { + // Use some stuff so that we can verify that the linker output correct results + SomeMethod(); + LibraryWithPdb.SomeMethod (); + } + + [Kept] + static void SomeMethod () + { + } + + static void NotUsed () + { + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndDeterministicMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndDeterministicMvid.cs new file mode 100644 index 000000000000..33e9cb8a663e --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndDeterministicMvid.cs @@ -0,0 +1,21 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [IgnoreTestCase ("Requires cecil updated with fix for https://github.com/jbevain/cecil/issues/583")] + [SetupCompileBefore ("LibraryWithPortablePdbSymbols.dll", new[] { "Dependencies/LibraryWithPortablePdbSymbols.cs" }, additionalArguments: "/debug:portable", compilerToUse: "csc")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--deterministic")] + + [KeptSymbols ("LibraryWithPortablePdbSymbols.dll")] + + [KeptMemberInAssembly ("LibraryWithPortablePdbSymbols.dll", typeof (LibraryWithPortablePdbSymbols), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithPortablePdbSymbols.dll", typeof (LibraryWithPortablePdbSymbols), "NotUsed()")] + public class ReferenceWithPortablePdbAndSymbolLinkingEnabledAndDeterministicMvid { + static void Main() + { + LibraryWithPortablePdbSymbols.SomeMethod (); + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndNewMvid.cs b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndNewMvid.cs new file mode 100644 index 000000000000..7245433f4c9d --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPortablePdbAndSymbolLinkingEnabledAndNewMvid.cs @@ -0,0 +1,20 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; +using Mono.Linker.Tests.Cases.Symbols.Dependencies; + +namespace Mono.Linker.Tests.Cases.Symbols { + [SetupCompileBefore ("LibraryWithPortablePdbSymbols.dll", new[] { "Dependencies/LibraryWithPortablePdbSymbols.cs" }, additionalArguments: "/debug:portable", compilerToUse: "csc")] + [SetupLinkerLinkSymbols ("true")] + [SetupLinkerArgument ("--new-mvid", "true")] + + [KeptSymbols ("LibraryWithPortablePdbSymbols.dll")] + + [KeptMemberInAssembly ("LibraryWithPortablePdbSymbols.dll", typeof (LibraryWithPortablePdbSymbols), "SomeMethod()")] + [RemovedMemberInAssembly ("LibraryWithPortablePdbSymbols.dll", typeof (LibraryWithPortablePdbSymbols), "NotUsed()")] + public class ReferenceWithPortablePdbAndSymbolLinkingEnabledAndNewMvid { + static void Main() + { + LibraryWithPortablePdbSymbols.SomeMethod (); + } + } +} \ No newline at end of file