Ejemplo n.º 1
0
        public void Designtime_builds_of_NXPorts_enabled_projects_do_not_error()
        {
            using (var testEnv = new TestEnvironment())
            {
                testEnv.SetupNXPortsProject("./sdknet48.csproj").Save();
                testEnv.CopyFileFromTestFiles("Simple.cs");

                var(AnalyzerResults, _) = testEnv.Build("./sdknet48.csproj", true);

                Assert.IsTrue(AnalyzerResults.OverallSuccess, "The designtime build failed.");
            }
        }
Ejemplo n.º 2
0
 public void Projects_with_empty_PlatformTarget_throw_an_error_during_build()
 {
     using (var testEnv = new TestEnvironment())
     {
         testEnv.SetupNXPortsProject("./sdknet48.csproj").Property("PlatformTarget", "").Save();
         testEnv.CopyFileFromTestFiles("SimpleWithoutExports.cs");
         var(AnalyzerResults, Log) = testEnv.Build("./sdknet48.csproj");
         Log.Errors.Should().HaveCountGreaterOrEqualTo(1);
         Log.ErrorEvents.Should().Contain(
             x => x.Message.Contains("Cannot use NXPorts without specifying the 'PlatformTarget'")
             );
     }
 }
Ejemplo n.º 3
0
 public void Projects_without_any_exports_annotated_method_produce_a_warning()
 {
     using (var testEnv = new TestEnvironment())
     {
         testEnv.SetupNXPortsProject("./sdknet48.csproj").Save();
         testEnv.CopyFileFromTestFiles("SimpleWithoutExports.cs");
         var(AnalyzerResults, Log) = testEnv.Build("./sdknet48.csproj");
         Log.Warnings.Should().HaveCountGreaterOrEqualTo(1);
         Log.WarningEvents.Should().Contain(
             x => x.Message.Equals("No method annotations for export reweaving were found.")
             );
     }
 }
Ejemplo n.º 4
0
        public void The_attributes_assembly_file_does_not_end_up_in_the_build_output()
        {
            using (var testEnv = new TestEnvironment())
            {
                testEnv.SetupNXPortsProject("./sdknet48.csproj").Save();
                testEnv.CopyFileFromTestFiles("Simple.cs");

                var(AnalyzerResults, _) = testEnv.Build("./sdknet48.csproj");
                Assert.IsTrue(AnalyzerResults.OverallSuccess, "The build failed.");
                if (AnalyzerResults.TryGetTargetFramework("net48", out var net48results))
                {
                    Assert.IsFalse(
                        File.Exists(Path.Combine(Path.GetDirectoryName(net48results.Properties["TargetDir"]), "NXPorts.Attributes.dll")),
                        "NXPorts wasn't removed the from the build output."
                        );
                }
                else
                {
                    Assert.Inconclusive("Failed to retrieve build results");
                }
            }
        }
Ejemplo n.º 5
0
        public void Building_a_simple_SDK_based_project_with_exports_succeeds()
        {
            using (var testEnv = new TestEnvironment())
            {
                testEnv.SetupNXPortsProject("./sdknet48.csproj").Save();
                testEnv.CopyFileFromTestFiles("Simple.cs");

                var(AnalyzerResults, _) = testEnv.Build("./sdknet48.csproj");

                Assert.IsTrue(AnalyzerResults.OverallSuccess, "The build failed.");
                if (AnalyzerResults.TryGetTargetFramework("net48", out var net48results))
                {
                    var buildOutputFile = new PeFile(net48results.Properties["TargetPath"]);
                    Assert.AreEqual(1, buildOutputFile.ExportedFunctions.Length, "There is more or less than one export function listed in the resulting dll.");
                    Assert.AreEqual("DoSomething", buildOutputFile.ExportedFunctions[0].Name);
                }
                else
                {
                    Assert.Inconclusive("Failed to retrieve build results");
                }
            }
        }