blob: 404169b3ff8653e35418d01e78672c34b0058d99 (
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;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms.Build.Tasks;
namespace Xamarin.Forms.Xaml.UnitTests
{
public static class MockCompiler
{
public static void Compile(Type type)
{
var assembly = type.Assembly.Location;
var refs = from an in type.Assembly.GetReferencedAssemblies()
let a = System.Reflection.Assembly.Load(an)
select a.Location;
var xamlc = new XamlCTask {
Assembly = assembly,
ReferencePath = string.Join(";", refs),
KeepXamlResources = true,
Type = type.FullName
};
var exceptions = new List<Exception>();
if (!xamlc.Compile(exceptions) && exceptions.Any())
throw exceptions [0];
}
}
}
|