Esempio n. 1
0
        protected virtual void DrawBuild(ProjectBuilder builder)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginDisabledGroup(!builder.BuildApplication);

                // Build.
                if (GUILayout.Button(
                        new GUIContent("Build",
                                       EditorGUIUtility.FindTexture("preAudioPlayOff")), "LargeButton"))
                {
                    EditorApplication.delayCall += () => ProjectBuilderUtil.StartBuild(builder, false, false);
                }

                // Open output.
                var r = EditorGUILayout.GetControlRect(false, GUILayout.Width(15));

                if (GUI.Button(new Rect(r.x - 2, r.y + 5, 20, 20), contentOpen, EditorStyles.label))
                {
                    string outputFullPath = BuildPathUtils.GetOutputPath(builder);
                    ProjectBuilderUtil.RevealOutputInFinder(outputFullPath);
                }

                EditorGUI.EndDisabledGroup();
            }
        }
Esempio n. 2
0
        protected override BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            // Handle pending events to ensure that files get saved right before the project is built
            DispatchService.RunPendingEvents();

            // Build projects this project is depending on
            if (alreadyBuiltProjects.Contains(ItemId))
            {
                return new BuildResult()
                       {
                           FailedBuildCount = 1, CompilerOutput = "Circular dependency detected!"
                       }
            }
            ;

            alreadyBuiltProjects.Add(ItemId);

            BuildResult bs;

            foreach (var prj in DependingProjects)
            {
                if ((bs = prj.Build(monitor, configuration)) == null || bs.Failed)
                {
                    return bs ?? new BuildResult {
                               FailedBuildCount = 1
                    }
                }
            }
            ;

            alreadyBuiltProjects.Remove(ItemId);

            return(ProjectBuilder.CompileProject(monitor, this, configuration));
        }
Esempio n. 3
0
        protected virtual void DrawBuildAssetBundles(ProjectBuilder builder)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginDisabledGroup(!builder.BuildAssetBundle);
                // Build.
                if (GUILayout.Button(
                        new GUIContent("Build AssetBundles",
                                       EditorGUIUtility.FindTexture("buildsettings.editor.small")), "LargeButton"))
                {
                    EditorApplication.delayCall += () => ProjectBuilderUtil.StartBuild(builder, false, true);
                }

                // Open output.
                var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(15));

                if (GUI.Button(new Rect(rect.x - 2, rect.y + 5, 20, 20), contentOpen, EditorStyles.label))
                {
                    Directory.CreateDirectory(builder.BundleOutputPath);
                    ProjectBuilderUtil.RevealOutputInFinder(builder.BundleOutputPath);
                }

                EditorGUI.EndDisabledGroup();
            }
        }
        void AssertJarInBuildOutput(ProjectBuilder builder, string itemGroup, string jar)
        {
            bool added = false, inItemGroup = false;

            foreach (var line in builder.LastBuildOutput)
            {
                if (line.Contains("Added Item(s)"))
                {
                    added = true;
                }
                else if (added && line.Contains(itemGroup))
                {
                    inItemGroup = true;
                }
                else if (added && inItemGroup)
                {
                    var jarPath = line.Trim();
                    if (jarPath.EndsWith(".jar", StringComparison.OrdinalIgnoreCase) && Path.GetFileName(jarPath) == jar)
                    {
                        Assert.IsTrue(Path.IsPathRooted(jarPath), $"{jarPath} should be a full path!");
                        return;
                    }
                }
                else
                {
                    added       = false;
                    inItemGroup = false;
                }
            }
            Assert.Fail($"Did not find {jar} in {itemGroup}!");
        }
Esempio n. 5
0
        static string GetCommandArgs(string baseCommandArgs, string filePath, DProject project, DProjectConfiguration conf)
        {
            var compiler = project.Compiler;

            ProjectBuilder.PrjPathMacroProvider prjPath = new ProjectBuilder.PrjPathMacroProvider {
                slnPath = project.ParentSolution != null?ProjectBuilder.EnsureCorrectPathSeparators(project.ParentSolution.BaseDirectory) : ""
            };

            List <string> includes = new List <string>(project.IncludePaths);

            includes.Add(project.BaseDirectory.FullPath);

            string[] src = { filePath };
            OneStepBuildArgumentMacroProvider compilerMacro = new OneStepBuildArgumentMacroProvider
            {
                ObjectsStringPattern  = compiler.ArgumentPatterns.ObjectFileLinkPattern,
                IncludesStringPattern = compiler.ArgumentPatterns.IncludePathPattern,

                SourceFiles = src,
                Includes    = ProjectBuilder.FillInMacros(includes, prjPath),
                Libraries   = ProjectBuilder.GetLibraries(conf, compiler),
            };

            return(ProjectBuilder.FillInMacros(baseCommandArgs, compilerMacro, prjPath));
        }
        public void GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch([Values(false, true)] bool isRelease)
        {
            AssertHasDevices();

            string expectedLogcatOutput = "Bug 29730: GlobalLayout event handler called!";

            proj = new XamarinAndroidApplicationProject()
            {
                IsRelease        = isRelease,
                MinSdkVersion    = "23",
                TargetSdkVersion = null,
            };
            if (isRelease || !CommercialBuildAvailable)
            {
                proj.SetAndroidSupportedAbis("armeabi-v7a", "arm64-v8a", "x86");
            }
            proj.MainActivity = proj.DefaultMainActivity.Replace("//${AFTER_ONCREATE}",
                                                                 $@"button.ViewTreeObserver.GlobalLayout += Button_ViewTreeObserver_GlobalLayout;
		}}
		void Button_ViewTreeObserver_GlobalLayout (object sender, EventArgs e)
		{{
			Android.Util.Log.Debug (""BugzillaTests"", ""{expectedLogcatOutput}"");
");
            builder = CreateApkBuilder(Path.Combine("temp", $"Bug29730-{isRelease}"));
            Assert.IsTrue(builder.Install(proj), "Install should have succeeded.");
            ClearAdbLogcat();
            AdbStartActivity($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity");
            Assert.IsTrue(MonitorAdbLogcat((line) => {
                return(line.Contains(expectedLogcatOutput));
            }, Path.Combine(Root, builder.ProjectDirectory, "startup-logcat.log"), 45), $"Output did not contain {expectedLogcatOutput}!");
        }
Esempio n. 7
0
        public async Task UpdatesAfterAddingIt()
        {
            // Arrange
            // add an item
            var repository   = GetEfRepository();
            var initialTitle = Guid.NewGuid().ToString();
            var item         = new ProjectBuilder().SetCode(initialTitle).SetName("Nothing").Build();

            await repository.AddAsync(item);

            // detach the item so we get a different instance
            AppDbContext.Entry(item).State = EntityState.Detached;

            // fetch the item and update its title
            var newItem = (await repository.ListAsync <Project>())
                          .FirstOrDefault(i => i.Code == initialTitle);

            Assert.NotNull(newItem);
            Assert.NotSame(item, newItem);
            var newCode = Guid.NewGuid().ToString();

            newItem.Code = newCode;

            // Act
            // Update the item
            await repository.UpdateAsync(newItem);

            // Assert
            var updatedItem = (await repository.ListAsync <Project>())
                              .FirstOrDefault(i => i.Code == newCode);

            Assert.NotNull(updatedItem);
            Assert.NotEqual(item.Code, updatedItem.Code);
            Assert.Equal(newItem.Id, updatedItem.Id);
        }
        public void CheckIfErrorOutputCapturedCorrectly()
        {
            sampleOutput = "Restoring packages for C:\\Users\\ukmaug\\Downloads\no - to - interview" + Environment.NewLine +
                           "Restoring packages for C:\\Users\\ukmaug\\Downloads\no - to - interview" + Environment.NewLine +
                           "Restoring packages for C:\\Users\\ukmaug\\Downloads\no - to - interview" + Environment.NewLine +
                           "Restore completed in 813.89 ms for C:\\Users\\ukmaug\\Downloads\no -" + Environment.NewLine +
                           "Generating MSBuild file C:\\Users\\ukmaug\\Downloads\no" + Environment.NewLine +
                           "Generating MSBuild file C:\\Users\\ukmaug\\Downloads\no" + Environment.NewLine +
                           "Generating MSBuild file C:\\Users\\ukmaug\\Downloads\no" + Environment.NewLine +
                           "Restore completed in 1.13 sec for C:\\Users" + Environment.NewLine +
                           "UnitConverterWebApp->C:\\Us" + Environment.NewLine +
                           "Tests.cs(22, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                           "Tests.cs(46, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                           "Tests.cs(68, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine + Environment.NewLine +

                           "Build FAILED." + Environment.NewLine + Environment.NewLine +
                           "Tests.cs(22, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                           "Tests.cs(46, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                           "Tests.cs(68, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +

                           "    56 Warning(s)" + Environment.NewLine +
                           "    3 Error(s)" + Environment.NewLine + Environment.NewLine +

                           "Time Elapsed 00:00:03.44";

            string sampleErrorOutput = "Tests.cs(22, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                                       "Tests.cs(46, 11): error CS0117: 'Assert' does not contain a definition" + Environment.NewLine +
                                       "Tests.cs(68, 11): error CS0117: 'Assert' does not contain a definition";

            ProjectBuilder.GetErrorOutput(sampleOutput).Should().BeEquivalentTo(sampleErrorOutput);
        }
Esempio n. 9
0
        public override IEnumerable <string> GetSourcePaths(ConfigurationSelector sel)
        {
            var dirs = new List <string>();
            List <DubBuildSetting> l;
            string d;
            bool   returnedOneItem = false;

            foreach (var sett in GetBuildSettings(sel))
            {
                if (sett.TryGetValue(DubBuildSettings.SourcePathsProperty, out l))
                {
                    returnedOneItem = true;
                    foreach (var setting in l)
                    {
                        foreach (var directory in setting.Values)
                        {
                            d = ProjectBuilder.EnsureCorrectPathSeparators(directory);
                            if (!Path.IsPathRooted(d))
                            {
                                if (this is DubSubPackage)
                                {
                                    (this as DubSubPackage).useOriginalBasePath = true;
                                }
                                d = Path.GetFullPath(Path.Combine(BaseDirectory.ToString(), d));
                                if (this is DubSubPackage)
                                {
                                    (this as DubSubPackage).useOriginalBasePath = false;
                                }
                            }

                            // Ignore os/arch/version constraints for now

                            if (dirs.Contains(d) || !Directory.Exists(d))
                            {
                                continue;
                            }

                            dirs.Add(d);
                        }
                    }
                }
            }

            if (!returnedOneItem)
            {
                d = BaseDirectory.Combine("source").ToString();
                if (Directory.Exists(d))
                {
                    dirs.Add(d);
                }

                d = BaseDirectory.Combine("src").ToString();
                if (Directory.Exists(d))
                {
                    dirs.Add(d);
                }
            }

            return(dirs);
        }
Esempio n. 10
0
 private void CreateAggregateImportProject(string project)
 {
     Directory.CreateDirectory(Path.GetDirectoryName(project));
     ProjectBuilder.Create()
     .AddProperty("CBTAggregatePackage=NuGetPath_Microsoft_Build=src1|src2")
     .Save(project);
 }
Esempio n. 11
0
        public MappedDataAttributeTests()
        {
            var project = ProjectBuilder.InputOutput();
            var model   = project.Models.First(x => x.Id == "input");

            entity = model.FindEntity("Person");
        }
Esempio n. 12
0
        static Dictionary <string, string> ValuesFromLog(ProjectBuilder b)
        {
            var values = new Dictionary <string, string> ();

            foreach (var line in b.LastBuildOutput)
            {
                foreach (var key in messages)
                {
                    int index = line.IndexOf(key + ":", StringComparison.OrdinalIgnoreCase);
                    if (index != -1)
                    {
                        index += key.Length + 1;
                        var value = line.Substring(index, line.Length - index).Trim();
                        // The log line might also include a message such as: (TaskId:7)
                        index = value.IndexOf("(", StringComparison.OrdinalIgnoreCase);
                        if (index != -1)
                        {
                            value = value.Substring(0, index).Trim();
                        }
                        values [key] = value;
                    }
                }
            }
            return(values);
        }
        public void InvalidProjectsLogGoodInfo()
        {
            var projectA = ProjectBuilder
                           .Create()
                           .AddImport(new Import(@"$(Foo)\foo.props"))
                           .Save(GetTempFileName());

            var dirsProj = ProjectBuilder
                           .Create()
                           .AddProperty("IsTraversal=true")
                           .AddItem($"ProjectFile={projectA.FullPath}")
                           .Save(GetTempFileName());

            MSBuildProjectLoader loader = new MSBuildProjectLoader(null, MSBuildToolsVersion, Log);

            loader.LoadProjectsAndReferences(new[] { dirsProj.FullPath });

            var errorEventArgs = _buildEngine.Errors.ShouldHaveSingleItem();

            errorEventArgs.Code.ShouldBe("MSB4019");
            errorEventArgs.ColumnNumber.ShouldBe(3);
            errorEventArgs.HelpKeyword.ShouldBe("MSBuild.ImportedProjectNotFound");
            errorEventArgs.LineNumber.ShouldBe(3);
            errorEventArgs.File.ShouldBe(projectA.FullPath);
        }
Esempio n. 14
0
        private static void ProjectBuilder()
        {
            var project = new ProjectBuilder()
                          .WithName("Sıfır Atık")
                          .WithStartDate(new DateTime(2018, 10, 1))
                          .WithDueDate(new DateTime(2019, 2, 1))
                          .WithSourceCount(5)
                          .WithBudget(4000000)
                          .Build();

            var builder = new ProjectBuilder();

            Console.Write("Proje Adı.................: ");
            builder.WithName(Console.ReadLine());

            Console.Write("Kaynak Sayısı.............: ");
            builder.WithSourceCount(int.Parse(Console.ReadLine()));

            Console.Write("Başlangıç Tarihi..........: ");
            builder.WithStartDate(DateTime.Parse(Console.ReadLine()));

            Console.Write("Bitiş Tarihi..............: ");
            builder.WithDueDate(DateTime.Parse(Console.ReadLine()));

            Console.Write("Bütçesi...................: ");
            builder.WithBudget(decimal.Parse(Console.ReadLine()));

            var p = builder.Build();
        }
Esempio n. 15
0
        double GetDurationFromBinLog(ProjectBuilder builder)
        {
            var duration = TimeSpan.Zero;
            var binlog   = Path.Combine(Root, builder.ProjectDirectory, "msbuild.binlog");

            FileAssert.Exists(binlog);

            using (var fileStream = File.OpenRead(binlog))
                using (var gzip = new GZipStream(fileStream, CompressionMode.Decompress))
                    using (var binaryReader = new BinaryReader(gzip)) {
                        int            fileFormatVersion = binaryReader.ReadInt32();
                        var            buildReader       = new BuildEventArgsReader(binaryReader, fileFormatVersion);
                        BuildEventArgs args;
                        var            started = new Stack <DateTime> ();
                        while ((args = buildReader.Read()) != null)
                        {
                            if (args is ProjectStartedEventArgs projectStarted)
                            {
                                started.Push(projectStarted.Timestamp);
                            }
                            else if (args is ProjectFinishedEventArgs projectFinished)
                            {
                                duration += projectFinished.Timestamp - started.Pop();
                            }
                        }
                    }

            if (duration == TimeSpan.Zero)
            {
                throw new InvalidDataException($"No project build duration found in {binlog}");
            }

            return(duration.TotalMilliseconds);
        }
    public InterfaceBuilder CreateInterface(ProjectBuilder proj, FeatureBuilder feature)
    {
        var builder = new InterfaceBuilder(proj, feature);

        Builders.Add(builder);
        return(builder);
    }
Esempio n. 17
0
        public static void Build(string projectFile, string[] extraClasspaths, bool noTrace)
        {
            Project        project = Project.Load(projectFile);
            ProjectBuilder builder = new ProjectBuilder(project);

            builder.Build(extraClasspaths, noTrace);
        }
Esempio n. 18
0
        /// <summary>
        /// Builds an array of all global version id definitions.
        /// Used for code completion.
        /// </summary>
        public void UpdateGlobalVersionIdentifiers(DProject prjOverride = null)
        {
            if (prjOverride == null)
            {
                if ((prjOverride = Project) == null)
                {
                    return;
                }
            }

            var cmp = prjOverride.Compiler;

            // Compiler args + cfg args + extra args
            var cmpArgs = ProjectBuilder.BuildOneStepBuildString(prjOverride, new string[0], Selector);

            //TODO: Distinguish between D1/D2 and probably later versions?
            gVersionIds /*var a*/ = D_Parser.Misc.VersionIdEvaluation.GetVersionIds(cmp.PredefinedVersionConstant, cmpArgs, UnittestMode);

            /*var res = new string[(a== null ? 0 : a.Length) + (CustomVersionIdentifiers == null ? 0: CustomVersionIdentifiers.Length)];
             * if(a!=null)
             *      Array.Copy(a,res,a.Length);
             * if(CustomVersionIdentifiers!=null)
             *      Array.Copy(CustomVersionIdentifiers,0,res,res.Length - CustomVersionIdentifiers.Length,CustomVersionIdentifiers.Length);
             * gVersionIds = res;*/
        }
    public ApiDefBuilder CreateApiDef(ProjectBuilder proj, FeatureBuilder feature)
    {
        var builder = new ApiDefBuilder(proj, feature);

        Builders.Add(builder);
        return(builder);
    }
        public async Task GetWithoutIdReturnsAllProjectEntries()
        {
            // Arrange
            var project1 = new ProjectBuilder().WithId().WithDescription("Greetings from Project 1.").Build();
            var project2 = new ProjectBuilder().WithId().WithDescription("Greetings from Project 2.").Build();

            var projectSet = new HashSet <Project>
            {
                project1,
                project2
            };

            this.projectService.CreateMany(projectSet);

            // Act
            var response = await this.Client.GetAsync("/api/project").ConfigureAwait(false);

            // Assert
            Assert.NotNull(response);
            var body           = response.Content.ReadAsStringAsync().Result;
            var json           = JObject.Parse(body);
            var data           = json["data"].AsJEnumerable();
            var createdEntity1 = data.SingleOrDefault(j => j["id"].ToString() == project1.Id.ToString());
            var createdEntity2 = data.SingleOrDefault(j => j["id"].ToString() == project2.Id.ToString());

            Assert.NotNull(createdEntity1);
            Assert.NotNull(createdEntity2);

            Assert.Equal("Greetings from Project 1.", createdEntity1["attributes"]["description"]);
            Assert.Equal("Greetings from Project 2.", createdEntity2["attributes"]["description"]);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Esempio n. 21
0
        public void AddImport()
        {
            string expectedOutput =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
  <Import Project=""build.props"" />
</Project>";

            ProjectBuilder.Create()
            .AddImport("build.props")
            .ProjectRoot
            .RawXmlShouldBe(expectedOutput);

            expectedOutput =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
  <Import Project=""build.props"" Condition=""Condition"" Label=""Label"" />
  <Import Project=""build2.props"" Condition=""Condition2"" Label=""Label2"" />
  <ItemGroup />
  <PropertyGroup />
  <Import Project=""test.props"" />
</Project>";
            ProjectBuilder.Create()
            .AddImport(new[] { new Import("build.props", "Condition", "Label") })
            .AddImport(new[] { new Import("build2.props", "Condition2", "Label2") })
            .AddItemGroup()
            .AddPropertyGroup()
            .AddImport("test.props")
            .ProjectRoot
            .RawXmlShouldBe(expectedOutput);
        }
        public void CalculateProjectData()
        {
            var technologicalConditions = Mapper
                                          .MapCollection <
                TechnologicalConditionDTO,
                TechnologicalCondition,
                ObservableCollection <TechnologicalConditionDTO>,
                ObservableCollection <TechnologicalCondition> >
                                              (TechnologicalConditionDTOs).ToList();

            var resources = Mapper
                            .MapCollection <
                ResourceDTO,
                Resource,
                ObservableCollection <ResourceDTO>,
                ObservableCollection <Resource> >
                                (ResourceDTOs).ToList();

            try
            {
                var timeCharacteristicCalculator = new TimeCharacteristicCalculator(technologicalConditions);
                var timeCharacteristics          = timeCharacteristicCalculator.Calculate().ToList();

                var variableParameterCalculator = new VariableParameterCalculator(technologicalConditions);
                var cycleCount         = timeCharacteristics.Max(p => p.EarlyFinish);
                var variableParameters = variableParameterCalculator.Calculate(cycleCount);

                foreach (var item in timeCharacteristics)
                {
                    var timeCharacteristicDTO = Mapper.Map <TimeCharacteristic, TimeCharacteristicDTO>(item);
                    TimeCharacteristicDTOs.Add(timeCharacteristicDTO);
                }

                foreach (var parameter in variableParameters)
                {
                    var variableParameterDTO = Mapper.Map <VariableParameter, VariableParameterDTO>(parameter);

                    var buffer = string.Empty;
                    foreach (var item in parameter.CycleNumberConsumptions)
                    {
                        buffer += $"{item} ";
                    }

                    variableParameterDTO.CycleNumberConsumptions = buffer;
                    VariableParameterDTOs.Add(variableParameterDTO);
                }

                Project = new ProjectBuilder()
                          .SetTitle(ProjectDTO.Title)
                          .SetWorkCount(ProjectDTO.WorkCount)
                          .SetTechnologicalConditions(technologicalConditions)
                          .SetResources(resources)
                          .SetTimeCharacteristics(timeCharacteristics)
                          .Build();
            }
            catch (ArgumentNullException ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
Esempio n. 23
0
        public void BeforeDeploymentTests()
        {
            if (!HasDevices)
            {
                Assert.Ignore("Skipping Test. No devices available.");
            }
            string debuggable = RunAdbCommand("shell getprop ro.debuggable");

            if (debuggable != "1")
            {
                Assert.Ignore("TimeZone tests need to use `su root` and this device does not support that feature. Try using an emulator.");
            }

            proj = new XamarinFormsAndroidApplicationProject();
            proj.SetProperty(KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86");
            var mainPage = proj.Sources.First(x => x.Include() == "MainPage.xaml.cs");
            var source   = mainPage.TextContent().Replace("InitializeComponent ();", @"InitializeComponent ();
			Console.WriteLine ($""TimeZoneInfo={TimeZoneInfo.Local.DisplayName}"");
");

            mainPage.TextContent = () => source;
            builder = CreateApkBuilder(Path.Combine("temp", "DeploymentTests"));
            string apiLevel;

            proj.TargetFrameworkVersion = builder.LatestTargetFrameworkVersion(out apiLevel);
            proj.PackageName            = "Xamarin.TimeZoneTest";
            proj.AndroidManifest        = $@"<?xml version=""1.0"" encoding=""utf-8""?>
<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" android:versionCode=""1"" android:versionName=""1.0"" package=""Xamarin.TimeZoneTest"">
	<uses-sdk android:minSdkVersion=""24"" android:targetSdkVersion=""{apiLevel}"" />
	<application android:label=""${{PROJECT_NAME}}"">
	</application >
</manifest> ";
            Assert.IsTrue(builder.Build(proj), "Build should have succeeded.");
            Assert.IsTrue(builder.Install(proj), "Install should have succeeded.");
        }
Esempio n. 24
0
 public AnalyzeCommand(IAnsiConsole console)
 {
     _console  = console ?? throw new ArgumentNullException(nameof(console));
     _builder  = new ProjectBuilder(console);
     _analyzer = new ProjectAnalyzer();
     _reporter = new ProjectReporter(console);
 }
        [Category("DotNetIgnore")]          // TODO: UnhandledException not firing: https://github.com/dotnet/runtime/issues/44526
        public void SubscribeToAppDomainUnhandledException()
        {
            AssertHasDevices();

            proj = new XamarinAndroidApplicationProject()
            {
                IsRelease = true,
            };
            proj.SetAndroidSupportedAbis("armeabi-v7a", "arm64-v8a", "x86", "x86_64");
            proj.MainActivity = proj.DefaultMainActivity.Replace("//${AFTER_ONCREATE}",
                                                                 @"			AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
				Console.WriteLine (""# Unhandled Exception: sender={0}; e.IsTerminating={1}; e.ExceptionObject={2}"",
					sender, e.IsTerminating, e.ExceptionObject);
			};
			throw new Exception (""CRASH"");
");
            builder = CreateApkBuilder();
            Assert.IsTrue(builder.Install(proj), "Install should have succeeded.");
            ClearAdbLogcat();
            if (CommercialBuildAvailable)
            {
                Assert.True(builder.RunTarget(proj, "_Run"), "Project should have run.");
            }
            else
            {
                AdbStartActivity($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity");
            }

            string expectedLogcatOutput = "# Unhandled Exception: sender=RootDomain; e.IsTerminating=True; e.ExceptionObject=System.Exception: CRASH";

            Assert.IsTrue(MonitorAdbLogcat((line) => {
                return(line.Contains(expectedLogcatOutput));
            }, Path.Combine(Root, builder.ProjectDirectory, "startup-logcat.log"), 45), $"Output did not contain {expectedLogcatOutput}!");
        }
Esempio n. 26
0
 public static void OpenAssetBundlesBuilder()
 {
     EditorWindow.GetWindow <PlayerBuilder>();
     csvVersion  = ProjectBuilder.GetLastestCSVVersion();
     luaVersion  = ProjectBuilder.GetLastestLuaVersion();
     lastVersion = ProjectBuilder.GetLastestResVersion();
     csvVersions = ProjectBuilder.GetCSVVersions();
     luaVersions = ProjectBuilder.GetLuaVersions();
     version     = lastVersion;
     platformTypes.Clear();
     platformTypeFlags.Clear();
     platformTypeArray = System.Enum.GetValues(typeof(PlatformType)) as PlatformType[];
     foreach (PlatformType p in platformTypeArray)
     {
         if (p == PlatformType.None)
         {
             continue;
         }
         platformTypeFlags.Add(false);
     }
     csvIndex      = 0;
     luaIndex      = 0;
     newCSVVersion = newLuaVersion = false;
     csvGitMessage = luaGitMessage = string.Empty;
 }
Esempio n. 27
0
 public void Dispose()
 {
     if (this.nuproj != null)
     {
         ProjectBuilder.Cleanup(this.nuproj);
     }
 }
Esempio n. 28
0
        public void AddItemGroup()
        {
            string expectedOutput =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
  <ItemGroup Label=""test label"" Condition=""test Condition"" />
</Project>";

            ProjectBuilder.Create()
            .AddItemGroup("test Condition", "test label")
            .ProjectRoot
            .RawXmlShouldBe(expectedOutput);

            expectedOutput =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
  <ItemGroup />
  <ItemGroup Label=""test label"" Condition=""test Condition"" />
  <ItemGroup Condition=""New Condition"" />
</Project>";
            ProjectBuilder.Create()
            .AddItemGroup()
            .AddItemGroup("test Condition", "test label")
            .AddItemGroup("New Condition")
            .ProjectRoot
            .RawXmlShouldBe(expectedOutput);
        }
Esempio n. 29
0
        public static void Run(string filePath, DProject project, DProjectConfiguration conf)
        {
            if (manager == null)
            {
                manager = new ProgressMonitorManager();
                monitor = manager.GetOutputProgressMonitor("Run Unittest", Stock.RunProgramIcon, true, true);
            }

            Pad pad = manager.GetPadForMonitor(monitor);

            if (pad != null)
            {
                pad.BringToFront();
            }

            monitor.BeginTask("start unittest...", 1);

            new System.Threading.Thread(delegate(){
                string[] cmdParts = GetCmdParts(project);
                string args       = GetCommandArgs(cmdParts.Length >= 2 ?cmdParts[1] : "", filePath, project, conf);
                string errorOutput;
                string stdOutput;
                string execDir = GetExecDir(project, conf);

                ProjectBuilder.ExecuteCommand(cmdParts[0], args, execDir, monitor, out stdOutput, out errorOutput);

                monitor.Log.WriteLine("unittest done.");
                monitor.EndTask();
            }).Start();
        }
Esempio n. 30
0
        public async Task CanParseMappingWithIgnores(string filename)
        {
            // Arrange
            var path = FileFinder.FindMapFile(filename);

            MapParserContext context = null;

            exampleLoader.Setup(x => x.LoadAsync(It.IsAny <MapParserContext>())).Callback <MapParserContext>(x => context = x);

            var project = ProjectBuilder.InputOutput();

            var input       = project.Models.First(x => x.Id == "input");
            var personName  = input.FindEntity("Person").FindAttribute("Name");
            var personFirst = input.FindEntity("Person").FindAttribute("FirstName");
            var cityName    = input.FindEntity("City").FindAttribute("Name");

            // Act
            var map = await parser.ParseAsync(path.FullName, project.Models);

            // Assert
            context.Should().NotBeNull();

            context.MapList.IsIgnored(personName).Should().BeTrue();
            context.MapList.IsIgnored(personFirst).Should().BeFalse();
            context.MapList.IsIgnored(cityName).Should().BeTrue();
        }
        private ProjectBuilder ProjectBuilderAfterBuildHasBegun(IVsSolutionBuildManager2 buildManager)
        {
            var project = Substitute.For<Project>();

            var projectBuilder = new ProjectBuilder(buildManager);
            projectBuilder.BuildAsync(new List<Project> { project });

            return projectBuilder;
        }
        public void Build_BuildCompletedSuccessfully_TaskResultSetTrue()
        {
            var buildManager = BuildManagerWhichReturns(VSConstants.S_OK);
            var project = Substitute.For<Project>();
            var projectBuilder = new ProjectBuilder(buildManager);
            uint pdwCookie;

            var buildTask = projectBuilder.BuildAsync(new List<Project> { project });

            // Checking that we are subscribed to build events
            buildManager.ReceivedWithAnyArgs(1)
                .AdviseUpdateSolutionEvents(Arg.Any<IVsUpdateSolutionEvents>(), out pdwCookie);
        }
 public ProjectAnalyzer(
     IVsApiPortAnalyzer analyzer,
     Microsoft.VisualStudio.Shell.ErrorListProvider errorList,
     ISourceLineMapper sourceLineMapper,
     IFileWriter reportWriter,
     IFileSystem fileSystem,
     ProjectBuilder builder)
 {
     _analyzer = analyzer;
     _sourceLineMapper = sourceLineMapper;
     _reportWriter = reportWriter;
     _fileSystem = fileSystem;
     _builder = builder;
     _errorList = errorList;
 }
        public void Build_VsFailsToStartBuild_TaskResultSetFalse()
        {
            var buildManager = BuildManagerWhichReturns(VSConstants.S_FALSE);
            var project = Substitute.For<Project>();
            var projectBuilder = new ProjectBuilder(buildManager);
            uint pdwCookie;

            var result = projectBuilder.BuildAsync(new List<Project> { project }).Result;

            Assert.False(result);

            // Checking that we are not listening to build events 
            // if starting a build was not successful
            buildManager.DidNotReceiveWithAnyArgs()
                .AdviseUpdateSolutionEvents(null, out pdwCookie);
        }
        public void BeforeAll()
        {
            _projectFilePath = @"C:\myproject\myproject.csproj";
            _projectDirectory = @"C:\myproject";
            _projectName = "What I am called";

            _dependencies = Builder<NuGetPackageDependency>.CreateListOfSize(2).Build();
            _expectedPackageFilePath = @"C:\myproject\packages.config";

            var fileSystem = new Mock<IFileSystem>();
            fileSystem.Setup(fs => fs.GetDirectory(_projectFilePath)).Returns(_projectDirectory);

            var packageBuilder = new Mock<IBuilder<ICollection<NuGetPackageDependency>, string>>();
            packageBuilder.Setup(b => b.Build(_expectedPackageFilePath)).Returns(_dependencies);

            var builder = new ProjectBuilder(fileSystem.Object, packageBuilder.Object);
            var request = new BuildProjectRequest()
                .WithProjectFilePath(_projectFilePath)
                .WithName(_projectName);

            _project = builder.Build(request);
        }
 public static void Build(string projectFile, string[] extraClasspaths, bool noTrace)
 {
     Project project = Project.Load(projectFile);
     ProjectBuilder builder = new ProjectBuilder(project);
     builder.Build(extraClasspaths, noTrace);
 }