-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to show possible bug handling csc behavior quirk
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
linker/Tests/Mono.Linker.Tests.Cases/References/AssemblyOnlyUsedByUsingWithCsc.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
using Mono.Linker.Tests.Cases.References.Dependencies; | ||
|
||
namespace Mono.Linker.Tests.Cases.References { | ||
[SetupLinkerAction ("copy", "copied")] | ||
[SetupCompileBefore ("library.dll", new [] {"Dependencies/AssemblyOnlyUsedByUsing_Lib.cs"})] | ||
|
||
// When csc is used, `copied.dll` will have a reference to `library.dll` | ||
[SetupCompileBefore ("copied.dll", new [] {"Dependencies/AssemblyOnlyUsedByUsing_Copied.cs"}, new [] {"library.dll"}, compilerToUse: "csc")] | ||
|
||
// Here to assert that the test is setup correctly to copy the copied assembly. This is an important aspect of the bug | ||
[KeptMemberInAssembly ("copied.dll", typeof (AssemblyOnlyUsedByUsing_Copied), "Unused()")] | ||
|
||
// We need to keep library.dll because `copied.dll` references | ||
[KeptAssembly ("library.dll")] | ||
public class AssemblyOnlyUsedByUsingWithCsc { | ||
public static void Main () | ||
{ | ||
// Use something to keep the reference at compile time | ||
AssemblyOnlyUsedByUsing_Copied.UsedToKeepReference (); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
linker/Tests/Mono.Linker.Tests.Cases/References/AssemblyOnlyUsedByUsingWithMcs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
using Mono.Linker.Tests.Cases.References.Dependencies; | ||
|
||
namespace Mono.Linker.Tests.Cases.References { | ||
[SetupLinkerAction ("copy", "copied")] | ||
[SetupCompileBefore ("library.dll", new [] {"Dependencies/AssemblyOnlyUsedByUsing_Lib.cs"})] | ||
|
||
// When mcs is used, `copied.dll` will not have a reference to `library.dll` | ||
[SetupCompileBefore ("copied.dll", new [] {"Dependencies/AssemblyOnlyUsedByUsing_Copied.cs"}, new [] {"library.dll"}, compilerToUse: "mcs")] | ||
|
||
// Here to assert that the test is setup correctly to copy the copied assembly. This is an important aspect of the bug | ||
[KeptMemberInAssembly ("copied.dll", typeof (AssemblyOnlyUsedByUsing_Copied), "Unused()")] | ||
|
||
[RemovedAssembly ("library.dll")] | ||
public class AssemblyOnlyUsedByUsingWithMcs { | ||
public static void Main () | ||
{ | ||
// Use something to keep the reference at compile time | ||
AssemblyOnlyUsedByUsing_Copied.UsedToKeepReference (); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...r/Tests/Mono.Linker.Tests.Cases/References/Dependencies/AssemblyOnlyUsedByUsing_Copied.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
// This is what triggers the behavior difference between Roslyn and mcs. Roslyn will keep the reference | ||
// to this assembly because of this whereas mcs will not | ||
using ImportantForBug = Mono.Linker.Tests.Cases.References.Dependencies.AssemblyOnlyUsedByUsing_Lib; | ||
|
||
namespace Mono.Linker.Tests.Cases.References.Dependencies { | ||
public class AssemblyOnlyUsedByUsing_Copied { | ||
public static void UsedToKeepReference () | ||
{ | ||
} | ||
|
||
private static void Unused () | ||
{ | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
linker/Tests/Mono.Linker.Tests.Cases/References/Dependencies/AssemblyOnlyUsedByUsing_Lib.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Mono.Linker.Tests.Cases.References.Dependencies { | ||
public class AssemblyOnlyUsedByUsing_Lib { | ||
} | ||
} |