diff options
Diffstat (limited to 'test/Mono.Linker.Tests/TestCasesRunner/LinkXmlHelpers.cs')
-rw-r--r-- | test/Mono.Linker.Tests/TestCasesRunner/LinkXmlHelpers.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/LinkXmlHelpers.cs b/test/Mono.Linker.Tests/TestCasesRunner/LinkXmlHelpers.cs new file mode 100644 index 000000000..c7e70cf71 --- /dev/null +++ b/test/Mono.Linker.Tests/TestCasesRunner/LinkXmlHelpers.cs @@ -0,0 +1,30 @@ +using System.Text; +using Mono.Cecil; +using Mono.Linker.Tests.Extensions; + +namespace Mono.Linker.Tests.TestCasesRunner { + public static class LinkXmlHelpers { + public static void WriteXmlFileToPreserveEntryPoint (NPath targetProgram, NPath xmlFile) + { + using (var assembly = AssemblyDefinition.ReadAssembly (targetProgram.ToString ())) { + var method = assembly.EntryPoint; + + var sb = new StringBuilder (); + sb.AppendLine ("<linker>"); + + sb.AppendLine (" <assembly fullname=\"" + assembly.FullName + "\">"); + + if (method != null) { + sb.AppendLine (" <type fullname=\"" + method.DeclaringType.FullName + "\">"); + sb.AppendLine (" <method name=\"" + method.Name + "\"/>"); + sb.AppendLine (" </type>"); + } + + sb.AppendLine (" </assembly>"); + + sb.AppendLine ("</linker>"); + xmlFile.WriteAllText (sb.ToString ()); + } + } + } +}
\ No newline at end of file |