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

Utils.cs « ILLink.Tasks « src - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bbaf45613ec9fbd77e76bfb821ecbc02e561339d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using Mono.Cecil;
using System.Linq;

public static class Utils
{
	public static bool IsManagedAssembly (string fileName)
	{
		try {
			ModuleDefinition module = ModuleDefinition.ReadModule (fileName);
			return !IsCPPCLIAssembly (module);
		} catch (BadImageFormatException) {
			return false;
		}
	}

	private static bool IsCPPCLIAssembly (ModuleDefinition module)
	{
		return module.Types.Any (t =>
			 t.Namespace == "<CppImplementationDetails>" ||
			 t.Namespace == "<CrtImplementationDetails>");
	}
}