Ejemplo n.º 1
0
        public void ShouldAddAssemblyToIncludedAssemblies()
        {
            //Act
            var included = new IncludedAssemblies();
            var result   = included.Assembly(Assembly.GetAssembly(GetType()));

            //Assert
            Assert.AreSame(included, result);
            Assert.IsTrue(result.Assemblies.Contains(Assembly.GetAssembly(GetType())));
        }
Ejemplo n.º 2
0
        public void ShouldReturnEmpyListOfAssemblies()
        {
            //Act
            var result = new IncludedAssemblies().Assemblies;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(List <Assembly>));
            Assert.IsFalse(result.Any());
        }
Ejemplo n.º 3
0
        public void ShouldAddAssemblyToIncludedAssembliesUsingAndAssembly()
        {
            //Act
            var included = new IncludedAssemblies();
            var result   = included.Assembly(Assembly.GetAssembly(typeof(Bootstrapper))).
                           AndAssembly(Assembly.GetAssembly(typeof(AutoMapperExtension)));

            //Assert
            Assert.AreSame(included, result);
            Assert.IsTrue(result.Assemblies.Contains(Assembly.GetAssembly(typeof(Bootstrapper))));
            Assert.IsTrue(result.Assemblies.Contains(Assembly.GetAssembly(typeof(AutoMapperExtension))));
        }
Ejemplo n.º 4
0
        public void ShouldCreateANewIncludedAssemblies()
        {
            //Act
            var result = new IncludedAssemblies();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IIncludedAssemblies));
            Assert.IsInstanceOfType(result, typeof(IncludedAssemblies));
            Assert.IsInstanceOfType(result, typeof(IBootstrapperOption));
            Assert.IsInstanceOfType(result, typeof(BootstrapperOption));
        }
Ejemplo n.º 5
0
        public void ShouldAddAssemblyRangeToIncludedAssemblies()
        {
            //Act
            var included      = new IncludedAssemblies();
            var assemblyRange = new List <Assembly>
            {
                Assembly.GetAssembly(typeof(Bootstrapper)),
                Assembly.GetAssembly(typeof(AutoMapperExtension))
            };
            var result = included.AssemblyRange(assemblyRange);

            //Assert
            Assert.AreSame(included, result);
            Assert.IsTrue(result.Assemblies.Contains(Assembly.GetAssembly(typeof(Bootstrapper))));
            Assert.IsTrue(result.Assemblies.Contains(Assembly.GetAssembly(typeof(AutoMapperExtension))));
        }
Ejemplo n.º 6
0
        public bool UploadAssemblies()
        {
            if (IncludedAssemblies == null)
            {
                return(false);
            }

            foreach (var assembly in IncludedAssemblies.Where(a => !a.Sent))
            {
                var data = File.ReadAllBytes(assembly.FullPath);
                var b64  = Convert.ToBase64String(data);

                var req = XenMessage.Create <LoadProjectRequest>();
                req.AssemblyData = b64;

                ToolboxApp.SocketManager.Socket.Send(req);
                assembly.Sent = true;
            }

            return(true);
        }
Ejemplo n.º 7
0
        public void Save()
        {
            try
            {
                var proj = new XenProjectFile(_fs)
                {
                    Schema     = XenFormsEnvironment.ProjectFileSchema,
                    Assemblies = IncludedAssemblies?.ToArray() ?? new ProjectAssembly[] {}
                };

                proj.Save(ToolboxApp.Project.State.XenProjectFilePath);
            }
            catch (Exception ex)
            {
                ToolboxApp.Log.Error(ex, $"Error saving file: {ToolboxApp.Project.State.XenProjectFilePath}.");

                MessageBox.Show(Application.Instance.MainForm,
                                "There was an error saving the project file. Please check the log for more information.",
                                "XenForms",
                                MessageBoxButtons.OK,
                                MessageBoxType.Error);
            }
        }
Ejemplo n.º 8
0
        public AOTOptions(string options)
        {
            // Syntax - all,core,sdk,none or "" if explicit then optional list of +/-'ed assemblies
            // Sections seperated by ,
            string [] optionParts = options.Split(',');
            for (int i = 0; i < optionParts.Length; ++i)
            {
                string option = optionParts [i];

                AOTKind kind = AOTKind.Default;
                // Technically '|' is valid in a file name, so |hybrid.dll would be as well.
                // So check the left hand side for a valid option and pass if not
                if (option.Contains("|"))
                {
                    string [] optionTypeParts = option.Split('|');
                    if (optionTypeParts.Length != 2)
                    {
                        throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
                    }
                    switch (optionTypeParts [0])
                    {
                    case "none":
                    case "core":
                    case "sdk":
                    case "all": {
                        option = optionTypeParts [0];
                        switch (optionTypeParts [1])
                        {
                        case "hybrid":
                            if (option != "all")
                            {
                                throw new MonoMacException(114, true, "Hybrid AOT compilation requires all assemblies to be AOT compiled");
                            }
                            kind = AOTKind.Hybrid;
                            break;

                        case "standard":
                            kind = AOTKind.Standard;
                            break;

                        default:
                            throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }

                switch (option)
                {
                case "none":
                    CompilationType = AOTCompilationType.None;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "all":
                    CompilationType = AOTCompilationType.All;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "sdk":
                    CompilationType = AOTCompilationType.SDK;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "core":
                    CompilationType = AOTCompilationType.Core;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;
                }

                if (option.StartsWith("+", StringComparison.Ordinal))
                {
                    if (CompilationType == AOTCompilationType.Default)
                    {
                        CompilationType = AOTCompilationType.Explicit;
                    }
                    IncludedAssemblies.Add(option.Substring(1));
                    continue;
                }
                if (option.StartsWith("-", StringComparison.Ordinal))
                {
                    if (CompilationType == AOTCompilationType.Default)
                    {
                        CompilationType = AOTCompilationType.Explicit;
                    }
                    ExcludedAssemblies.Add(option.Substring(1));
                    continue;
                }
                throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
            }
            if (CompilationType == AOTCompilationType.Default)
            {
                throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
            }
        }
Ejemplo n.º 9
0
 private static void InitializeExcludedAndIncludedAssemblies()
 {
     Excluding     = new ExcludedAssemblies();
     Including     = new IncludedAssemblies();
     IncludingOnly = new IncludedOnlyAssemblies();
 }