Welcome to mirror list, hosted at ThFree Co, Russian Federation.

LinkXmlHelpers.cs « TestCasesRunner « Tests « linker - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c7e70cf710fd68ccb168c0c8ddbe72cd4ac2ee9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 ());
			}
		}
	}
}