A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.3 KiB

using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.Build.Utilities;
using Xunit;
namespace Avalonia.Build.Tasks.UnitTest;
public class CompileAvaloniaXamlTaskTest
{
[Fact]
public void Does_Not_Fail_When_Codebehind_Contains_DllImport()
{
using var engine = UnitTestBuildEngine.Start();
var basePath = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "Assets");
var assembly = new TaskItem(Path.Combine(basePath, "PInvoke.dll"));
assembly.SetMetadata(CompileAvaloniaXamlTask.AvaloniaCompileOutputMetadataName, Path.Combine(basePath, "Avalonia", Path.GetFileName(assembly.ItemSpec)));
var references = File.ReadAllLines(Path.Combine(basePath, "PInvoke.dll.refs")).Select(p => new TaskItem(p)).ToArray();
Assert.True(File.Exists(assembly.ItemSpec), $"The original {assembly.ItemSpec} don't exist.");
new CompileAvaloniaXamlTask()
{
AssemblyFile = assembly,
References = references,
RefAssemblyFile = null,
BuildEngine = engine,
ProjectDirectory = Directory.GetCurrentDirectory(),
VerifyIl = true
}.Execute();
Assert.Empty(engine.Errors);
}
}