CompileAvaloniaXamlTaskTest.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using Xunit;
  5. namespace Avalonia.Build.Tasks.UnitTest;
  6. public class CompileAvaloniaXamlTaskTest
  7. {
  8. [Fact]
  9. public void Does_Not_Fail_When_Codebehind_Contains_DllImport()
  10. {
  11. using var engine = UnitTestBuildEngine.Start();
  12. var basePath = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "Assets");
  13. var originalAssemblyPath = Path.Combine(basePath,
  14. "PInvoke.dll");
  15. var referencesPath = Path.Combine(basePath,
  16. "PInvoke.dll.refs");
  17. var compiledAssemblyPath = "PInvoke.dll";
  18. Assert.True(File.Exists(originalAssemblyPath), $"The original {originalAssemblyPath} don't exists.");
  19. new CompileAvaloniaXamlTask()
  20. {
  21. AssemblyFile = originalAssemblyPath,
  22. ReferencesFilePath = referencesPath,
  23. OutputPath = compiledAssemblyPath,
  24. RefAssemblyFile = null,
  25. BuildEngine = engine,
  26. ProjectDirectory = Directory.GetCurrentDirectory(),
  27. VerifyIl = true
  28. }.Execute();
  29. Assert.Equal(0, engine.Errors.Count);
  30. }
  31. }