Example #1
0
        public void UnifiedWithDepNativeRefLib_ShouldHaveItRemoved_OnceInBundle()
        {
            RunMMPTest(tmpDir =>
            {
                TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName           = "MobileBinding.csproj",
                    ItemGroup             = string.Format(NativeReferenceTemplate, Path.GetFullPath(SimpleDylibPath), "Dynamic"),
                    StructsAndEnumsConfig = "public class UnifiedWithDepNativeRefLibTestClass {}"
                };

                string projectPath = TI.GenerateBindingLibraryProject(test);
                TI.BuildProject(projectPath, true);

                string referenceCode = string.Format(@"<Reference Include=""MobileBinding""><HintPath>{0}</HintPath></Reference>", Path.Combine(tmpDir, "bin/Debug", "MobileBinding.dll"));

                test = new TI.UnifiedTestConfig(tmpDir)
                {
                    References = referenceCode, TestCode = "System.Console.WriteLine (typeof (ExampleBinding.UnifiedWithDepNativeRefLibTestClass));"
                };
                TI.TestUnifiedExecutable(test);

                string libPath = Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MonoBundle/MobileBinding.dll");
                Assert.True(File.Exists(libPath));
                string monoDisResults = TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/monodis", new StringBuilder("--presources " + libPath), "monodis");
                Assert.IsFalse(monoDisResults.Contains("SimpleClassDylib.dylib"));
            });
        }
Example #2
0
        public void MultipleDependencyChain(bool useProjectReference)
        {
            // App can depend on Lib that depends on binding lib with native reference and everything gets packaged in correctly
            MMPTests.RunMMPTest(tmpDir => {
                TI.UnifiedTestConfig binding = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "MobileBinding.csproj"
                };
                binding.ItemGroup           += NativeReferenceTests.CreateSingleNativeRef(NativeReferenceTests.SimpleDylibPath, "Dynamic");
                binding.APIDefinitionConfig += @"[BaseType (typeof (NSObject))]
  interface SimpleClass {
    [Export (""doIt"")]
    int DoIt ();
  }";
                BindingProjectTests.SetNoEmbedding(binding);

                TI.GenerateBindingLibraryProject(binding);
                TI.BuildProject(Path.Combine(tmpDir, "MobileBinding.csproj"), true);


                TI.UnifiedTestConfig library = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedLibrary"
                };
                library.TestCode = "public class MyClass { public static void Go () { var c = new ExampleBinding.SimpleClass (); c.DoIt (); } }";

                if (useProjectReference)
                {
                    library.References = $@"<ProjectReference Include=""MobileBinding.csproj"" />";
                }
                else
                {
                    library.References = $@"<Reference Include=""MobileBinding""><HintPath>{Path.Combine (tmpDir, "bin/Debug", "MobileBinding.dll")}</HintPath></Reference>";
                }

                TI.GenerateUnifiedLibraryProject(library);
                TI.BuildProject(Path.Combine(tmpDir, "UnifiedLibrary.csproj"), true);

                TI.UnifiedTestConfig project = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedExample.csproj"
                };
                project.TestCode = "MyClass.Go ();";

                if (useProjectReference)
                {
                    project.References = $@"<ProjectReference Include=""UnifiedLibrary.csproj"" />";
                }
                else
                {
                    project.References = $@"<Reference Include=""UnifiedLibrary""><HintPath>{Path.Combine (tmpDir, "bin/Debug", "UnifiedLibrary.dll")}</HintPath></Reference>";
                }

                TI.GenerateUnifiedExecutableProject(project);
                TI.BuildProject(Path.Combine(tmpDir, "UnifiedExample.csproj"), true);
            });
        }
Example #3
0
 public void Build_BindingLibrary_SmokeTest(string projectName)
 {
     RunMSBuildTest(tmpDir => {
         TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
         {
             ProjectName = projectName
         };
         string projectPath = TI.GenerateBindingLibraryProject(test);
         TI.BuildProject(projectPath);
     });
 }
        internal static string SetupAndBuildBindingProject(TI.UnifiedTestConfig binding, bool setupDefaultNativeReference, bool shouldFail = false)
        {
            if (setupDefaultNativeReference)
            {
                binding.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(Path.GetFullPath(NativeReferenceTests.SimpleDylibPath), "Dynamic");
            }

            binding.StructsAndEnumsConfig = "public class UnifiedWithDepNativeRefLibTestClass {}";

            string projectPath = TI.GenerateBindingLibraryProject(binding);

            return(TI.BuildProject(projectPath, shouldFail: shouldFail));
        }
Example #5
0
 public void Build_BindingLibrary_SmokeTest()
 {
     RunMSBuildTest(tmpDir => {
         foreach (string projectName in new [] { "XM45Binding.csproj", "MobileBinding.csproj", "BindingProjectWithNoTag.csproj" })
         {
             TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
             {
                 ProjectName = projectName
             };
             string projectPath = TI.GenerateBindingLibraryProject(test);
             TI.BuildProject(projectPath);
         }
     });
 }
        static Tuple <string, string> BuildLinkedTestProjects(TI.UnifiedTestConfig binding, TI.UnifiedTestConfig project, string tmpDir)
        {
            binding.ItemGroup             = NativeReferenceTests.CreateSingleNativeRef(Path.GetFullPath(NativeReferenceTests.SimpleDylibPath), "Dynamic");
            binding.StructsAndEnumsConfig = "public class UnifiedWithDepNativeRefLibTestClass {}";

            string projectPath     = TI.GenerateBindingLibraryProject(binding);
            string bindingBuildLog = TI.BuildProject(projectPath, true);

            string bindingName = RemoveCSProj(binding.ProjectName);

            project.References = string.Format(@"<Reference Include=""{0}""><HintPath>{1}</HintPath></Reference>", bindingName, Path.Combine(tmpDir, "bin/Debug", bindingName + ".dll"));
            project.TestCode   = "System.Console.WriteLine (typeof (ExampleBinding.UnifiedWithDepNativeRefLibTestClass));";

            string appBuildLog = TI.TestUnifiedExecutable(project).BuildOutput;

            return(new Tuple <string, string> (bindingBuildLog, appBuildLog));
        }
Example #7
0
        public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes(string project)
        {
            const string nativeRefItemGroup = "<ItemGroup><NativeReference Include = \"\\usr\\lib\\libz.dylib\"><Kind>Dynamic</Kind><SmartLink>False</SmartLink></NativeReference></ItemGroup>";

            RunMSBuildTest(tmpDir => {
                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = project, ItemGroup = nativeRefItemGroup
                };
                string projectPath = TI.GenerateBindingLibraryProject(config);
                string buildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsTrue(buildOutput.Contains(@"Building target ""CoreCompile"""));

                string secondBuildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsFalse(secondBuildOutput.Contains(@"Building target ""CoreCompile"""));
            });
        }
Example #8
0
        public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes(string project)
        {
            var    dylib = Path.GetFullPath(Path.Combine(TI.TestDirectory, "test-libraries", ".libs", "macos", "libtest.dylib"));
            string nativeRefItemGroup = $"<ItemGroup><NativeReference Include = \"{dylib}\"><Kind>Dynamic</Kind><SmartLink>False</SmartLink></NativeReference></ItemGroup>";

            RunMSBuildTest(tmpDir => {
                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = project, ItemGroup = nativeRefItemGroup
                };
                string projectPath = TI.GenerateBindingLibraryProject(config);
                string buildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsTrue(buildOutput.Contains(@"Building target ""CoreCompile"""));

                string secondBuildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsFalse(secondBuildOutput.Contains(@"Building target ""CoreCompile"""));
            });
        }
Example #9
0
        public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes()
        {
            const string nativeRefItemGroup = "<ItemGroup><NativeReference Include = \"\\usr\\lib\\libz.dylib\"><Kind>Dynamic</Kind><SmartLink>False</SmartLink></NativeReference></ItemGroup>";

            RunMSBuildTest(tmpDir =>
            {
                foreach (string project in new[] { "XM45Binding.csproj", "MobileBinding.csproj", "BindingProjectWithNoTag.csproj" })
                {
                    var config = new TI.UnifiedTestConfig(tmpDir)
                    {
                        ProjectName = project, ItemGroup = nativeRefItemGroup
                    };
                    string projectPath = TI.GenerateBindingLibraryProject(config);
                    string buildOutput = TI.BuildProject(projectPath, isUnified: true, diagnosticMSBuild: true);
                    Assert.IsTrue(buildOutput.Contains("Target CoreCompile needs to be built"));

                    string secondBuildOutput = TI.BuildProject(projectPath, isUnified: true, diagnosticMSBuild: true);
                    Assert.IsFalse(secondBuildOutput.Contains("Target CoreCompile needs to be built"));
                }
            });
        }