/// <summary>
        /// Creates bitmaps for the texture
        /// </summary>
        private static Bitmap[] CreateTextureBitmaps( IProgressMonitor progressMonitor, ISpherePlanet planet )
        {
            Bitmap[] faceBitmaps = new Bitmap[ 6 ];
            int width = 256;
            int height = 256;
            progressMonitor.UpdateProgress( 0 );

            ISpherePlanetTerrainRenderer renderer = planet.Renderer.GetRenderer<ISpherePlanetTerrainRenderer>( );
            if ( renderer == null )
            {
                throw new InvalidOperationException( "Expected a valid ISpherePlanetTerrainRenderer to be available" );
            }

            faceBitmaps[ ( int )CubeMapFace.PositiveX ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveX, width, height ); progressMonitor.UpdateProgress( 1 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeX ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeX, width, height ); progressMonitor.UpdateProgress( 2 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.PositiveY ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveY, width, height ); progressMonitor.UpdateProgress( 3 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeY ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeY, width, height ); progressMonitor.UpdateProgress( 4 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.PositiveZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveZ, width, height ); progressMonitor.UpdateProgress( 5 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeZ, width, height );
            progressMonitor.UpdateProgress( 1 );

            foreach ( object cubeMapFace in Enum.GetValues( typeof( CubeMapFace ) ) )
            {
                faceBitmaps[ ( int )cubeMapFace ].Save( "PlanetCubeMap" + cubeMapFace + ".png" );
            }

            return faceBitmaps;
        }
		protected override SolutionEntityItem LoadSolutionItem (IProgressMonitor monitor, string fileName)
		{
			SolutionEntityItem entry = base.LoadSolutionItem (monitor, fileName);
			if (entry == null)
				return null;
			
			Project project = entry as Project;
			if (project == null)
				return entry;

			//Project
			MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null)
				return entry;

			monitor.BeginTask (GettextCatalog.GetString ("Updating project from Makefile"), 1);
			try { 
				data.OwnerProject = project;
				if (data.SupportsIntegration)
					data.UpdateProject (monitor, false);
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString (
					"Error loading Makefile for project {0}", project.Name), e);
			} finally {
				monitor.EndTask ();
			}

			entry.SetNeedsBuilding (false);
			return entry;
		}
		protected override void LoadProject (IProgressMonitor monitor, MSBuildProject msproject)
		{
			var doc = msproject.Document;
			projitemsFile = null;
			foreach (var no in doc.DocumentElement.ChildNodes) {
				var im = no as XmlElement;
				if (im != null && im.LocalName == "Import" && im.GetAttribute ("Label") == "Shared") {
					projitemsFile = im.GetAttribute ("Project");
					break;
				}
			}
			if (projitemsFile == null)
				return;

			// TODO: load the type from msbuild
			((SharedAssetsProject)EntityItem).LanguageName = "C#";

			projitemsFile = Path.Combine (Path.GetDirectoryName (msproject.FileName), projitemsFile);

			MSBuildProject p = new MSBuildProject ();
			p.Load (projitemsFile);

			MSBuildSerializer ser = CreateSerializer ();
			ser.SerializationContext.BaseFile = EntityItem.FileName;
			ser.SerializationContext.ProgressMonitor = monitor;

			Item.SetItemHandler (this);

			var cp = p.PropertyGroups.FirstOrDefault (g => g.Label == "Configuration");
			if (cp != null)
				((SharedAssetsProject)EntityItem).DefaultNamespace = cp.GetPropertyValue ("Import_RootNamespace");

			LoadProjectItems (p, ser, ProjectItemFlags.None);
		}
        public object ReadFile(string file, IProgressMonitor monitor)
        {
            XmlTextReader reader = new XmlTextReader (new StreamReader (file));
            reader.MoveToContent ();

            string version = reader.GetAttribute ("version");
            if (version == null) version = reader.GetAttribute ("fileversion");

            DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, file);
            ICombineReader combineReader = null;

            if (version == "1.0" || version == "1") {
                combineReader = new CombineReaderV1 (serializer, monitor);
                monitor.ReportWarning (string.Format (GettextCatalog.GetString ("The file '{0}' is using an old combine file format. It will be automatically converted to the current format."), file));
            }
            else if (version == "2.0")
                combineReader = new CombineReaderV2 (serializer, monitor);

            try {
                if (combineReader != null)
                    return combineReader.ReadCombine (reader);
                else
                    throw new UnknownProjectVersionException (file, version);
            } finally {
                reader.Close ();
            }
        }
        protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
            {
                // Note: We do not check options.SkipTestExecution here because we want to build up
                // the tree of data-driven test steps.  So we actually check it later on in the
                // PatternTestExecutor.  This is different from framework adapters
                // at this time (because they do not generally support dynamically generated data-driven tests).
                Sandbox sandbox = new Sandbox();
                EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
                try
                {
                    progressMonitor.Canceled += canceledHandler;

                    TestAssemblyExecutionParameters.Reset();

                    PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);

                    // Inlined to minimize stack depth.
                    var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
                    action.Run();
                    return action.Result;
                }
                finally
                {
                    progressMonitor.Canceled -= canceledHandler;
                    sandbox.Dispose();
                }
            }
        }
		public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type, IProgressMonitor monitor)
		{
			switch (type) {
				case DocumentIteratorType.CurrentDocument:
				case DocumentIteratorType.CurrentSelection:
					return new CurrentDocumentIterator();
				case DocumentIteratorType.Directory:
					try {
						if (!Directory.Exists(SearchOptions.LookIn)) {
							if (monitor != null) monitor.ShowingDialog = true;
							MessageService.ShowMessageFormatted("${res:Dialog.NewProject.SearchReplace.SearchStringNotFound.Title}", "${res:Dialog.NewProject.SearchReplace.LookIn.DirectoryNotFound}", FileUtility.NormalizePath(SearchOptions.LookIn));
							if (monitor != null) monitor.ShowingDialog = false;
							return new DummyDocumentIterator();
						}
					} catch (Exception ex) {
						if (monitor != null) monitor.ShowingDialog = true;
						MessageService.ShowMessage(ex.Message);
						if (monitor != null) monitor.ShowingDialog = false;
						return new DummyDocumentIterator();
					}
					return new DirectoryDocumentIterator(SearchOptions.LookIn,
					                                     SearchOptions.LookInFiletypes,
					                                     SearchOptions.IncludeSubdirectories);
				case DocumentIteratorType.AllOpenFiles:
					return new AllOpenDocumentIterator();
				case DocumentIteratorType.WholeProject:
					return new WholeProjectDocumentIterator();
				case DocumentIteratorType.WholeSolution:
					return new WholeSolutionDocumentIterator();
				default:
					throw new System.NotImplementedException("CreateDocumentIterator for type " + type);
			}
		}
Esempio n. 7
0
		public void WriteFile (string file, object obj, MSBuildFileFormat format, bool saveProjects, IProgressMonitor monitor)
		{
			Solution sol = (Solution) obj;

			string tmpfilename = String.Empty;
			try {
				monitor.BeginTask (GettextCatalog.GetString ("Saving solution: {0}", file), 1);
				try {
					if (File.Exists (file))
						tmpfilename = Path.GetTempFileName ();
				} catch (IOException) {
				}

				string baseDir = Path.GetDirectoryName (file);
				if (tmpfilename == String.Empty) {
					WriteFileInternal (file, sol, baseDir, format, saveProjects, monitor);
				} else {
					WriteFileInternal (tmpfilename, sol, baseDir, format, saveProjects, monitor);
					FileService.SystemRename (tmpfilename, file);
				}
			} catch (Exception ex) {
				monitor.ReportError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
				LoggingService.LogError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);

				if (!String.IsNullOrEmpty (tmpfilename) && File.Exists (tmpfilename))
					File.Delete (tmpfilename);
				throw;
			} finally {
				monitor.EndTask ();
			}
		}
		public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files,
		                                           FilePath outputRoot)
		{
			var result = new BuildResult ();
			var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList ();
			
			if (ibfiles.Count > 0) {
				monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0);	
				foreach (var file in ibfiles) {
					file.EnsureOutputDirectory ();
					var args = new ProcessArgumentBuilder ();
					args.AddQuoted (file.Input);
					args.Add ("--compile");
					args.AddQuoted (file.Output);
					var psi = new ProcessStartInfo ("ibtool", args.ToString ());
					monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments);
					psi.WorkingDirectory = outputRoot;
					string errorOutput;
					int code;
					try {
					code = ExecuteCommand (monitor, psi, out errorOutput);
					} catch (System.ComponentModel.Win32Exception ex) {
						LoggingService.LogError ("Error running ibtool", ex);
						result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
						return result;
					}
					if (code != 0) {
						//FIXME: parse the plist that ibtool returns
						result.AddError (null, 0, 0, null, "ibtool returned error code " + code);
					}
				}
				monitor.EndTask ();
			}
			return result;
		}
		internal void Initialize1(IProgressMonitor progressMonitor)
		{
			ICollection<ProjectItem> items = project.Items;
			ProjectService.ProjectItemAdded   += OnProjectItemAdded;
			ProjectService.ProjectItemRemoved += OnProjectItemRemoved;
			UpdateDefaultImports(items);
			// TODO: Translate me
//			progressMonitor.TaskName = "Resolving references for " + project.Name + "...";
			AbstractProject abstractProject = project as AbstractProject;
			if (abstractProject != null) {
				foreach (var reference in abstractProject.ResolveAssemblyReferences(progressMonitor.CancellationToken)) {
					if (!initializing) return; // abort initialization
					AddReference(reference, false, progressMonitor.CancellationToken);
				}
			} else {
				project.ResolveAssemblyReferences();
				AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib);
				foreach (ProjectItem item in items) {
					if (!initializing) return; // abort initialization
					progressMonitor.CancellationToken.ThrowIfCancellationRequested();
					if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) {
						ReferenceProjectItem reference = item as ReferenceProjectItem;
						if (reference != null) {
							AddReference(reference, false, progressMonitor.CancellationToken);
						}
					}
				}
			}
			UpdateReferenceInterDependencies();
			OnReferencedContentsChanged(EventArgs.Empty);
		}
 protected internal override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
     {
         return RunTest(rootTestCommand, parentTestStep, options, progressMonitor);
     }
 }
Esempio n. 11
0
		public override IEnumerable<MemberReference> FindReferences (MonoDevelop.Projects.Project project, IProjectContent content, IEnumerable<FilePath> files, IProgressMonitor monitor, IEnumerable<object> searchedMembers)
		{ // TODO: Type system conversion.
			yield break;
//			var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
//			AspNetAppProject project = dom.Project as AspNetAppProject;
//			if (project == null)
//				yield break;
//			
//			var unit = AspNetParserService.GetCompileUnit (project, fileName, true);
//			if (unit == null)
//				yield break;
//			var refman = new DocumentReferenceManager (project);
//			
//			var parsedAspDocument = (AspNetParsedDocument)new AspNetParser ().Parse (dom, fileName, editor.Text);
//			refman.Doc = parsedAspDocument;
//			
//			var usings = refman.GetUsings ();
//			var documentInfo = new DocumentInfo (dom, unit, usings, refman.GetDoms ());
//			
//			var builder = new AspLanguageBuilder ();
//			
//			
//			var buildDocument = new Mono.TextEditor.TextDocument ();
//			var offsetInfos = new List<LocalDocumentInfo.OffsetInfo> ();
//			buildDocument.Text = builder.BuildDocumentString (documentInfo, editor, offsetInfos, true);
//			var parsedDocument = AspLanguageBuilder.Parse (dom, fileName, buildDocument.Text);
//			foreach (var member in searchedMembers) {
//				foreach (var reference in SearchMember (member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument)) {
//					yield return reference;
//				}
//			}
		}
		public override void LoadProject (IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject msproject)
		{
			base.LoadProject (monitor, item, msproject);

			var dnp = item as DotNetProject;
			if (dnp == null)
				return;

			// Convert .projitems imports into project references

			foreach (var sp in msproject.Imports.Where (im => im.Label == "Shared" && im.Project.EndsWith (".projitems"))) {
				var projitemsFile = sp.Project;
				if (!string.IsNullOrEmpty (projitemsFile)) {
					projitemsFile = MSBuildProjectService.FromMSBuildPath (item.ItemDirectory, projitemsFile);
					projitemsFile = Path.Combine (Path.GetDirectoryName (msproject.FileName), projitemsFile);
					if (File.Exists (projitemsFile)) {
						MSBuildSerializer iser = Handler.CreateSerializer ();
						iser.SerializationContext.BaseFile = projitemsFile;
						iser.SerializationContext.ProgressMonitor = monitor;
						MSBuildProject p = new MSBuildProject ();
						p.Load (projitemsFile);
						Handler.LoadProjectItems (p, iser, ProjectItemFlags.Hidden | ProjectItemFlags.DontPersist);
						var r = new ProjectReference (ReferenceType.Project, Path.GetFileNameWithoutExtension (projitemsFile));
						r.Flags = ProjectItemFlags.DontPersist;
						r.SetItemsProjectPath (projitemsFile);
						dnp.References.Add (r);
					}
				}
			}
		}
		/// <summary>
		/// Finds all references to the specified entity.
		/// The results are reported using the callback.
		/// FindReferences may internally use parallelism, and may invoke the callback on multiple
		/// threads in parallel.
		/// </summary>
		public static async Task FindReferencesAsync(IEntity entity, IProgressMonitor progressMonitor, Action<SearchedFile> callback)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");
			if (progressMonitor == null)
				throw new ArgumentNullException("progressMonitor");
			if (callback == null)
				throw new ArgumentNullException("callback");
			SD.MainThread.VerifyAccess();
			if (SD.ParserService.LoadSolutionProjectsThread.IsRunning) {
				progressMonitor.ShowingDialog = true;
				MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}");
				progressMonitor.ShowingDialog = false;
				return;
			}
			double totalWorkAmount;
			List<ISymbolSearch> symbolSearches = PrepareSymbolSearch(entity, progressMonitor.CancellationToken, out totalWorkAmount);
			double workDone = 0;
			ParseableFileContentFinder parseableFileContentFinder = new ParseableFileContentFinder();
			foreach (ISymbolSearch s in symbolSearches) {
				progressMonitor.CancellationToken.ThrowIfCancellationRequested();
				using (var childProgressMonitor = progressMonitor.CreateSubTask(s.WorkAmount / totalWorkAmount)) {
					await s.FindReferencesAsync(new SymbolSearchArgs(childProgressMonitor, parseableFileContentFinder), callback);
				}
				
				workDone += s.WorkAmount;
				progressMonitor.Progress = workDone / totalWorkAmount;
			}
		}
		public Dictionary<string, List<NSObjectTypeInfo>> GetTypeUpdates (IProgressMonitor monitor, CodeDomProvider provider,
			out Dictionary<string, NSObjectTypeInfo> newTypes,
			out Dictionary<string, ProjectFile> newFiles)
		{
			Dictionary<string, List<NSObjectTypeInfo>> designerFiles = new Dictionary<string, List<NSObjectTypeInfo>> ();
			string defaultNamespace;
			
			// First, we need to name any new user-defined types.
			foreach (var job in TypeSyncJobs) {
				if (!job.IsFreshlyAdded) {
					monitor.Log.WriteLine ("Found updated class: {0}", job.Type.CliName);
					continue;
				}
				
				defaultNamespace = Project.GetDefaultNamespace (job.RelativePath);
				job.Type.CliName = defaultNamespace + "." + provider.CreateValidIdentifier (job.Type.ObjCName);
				monitor.Log.WriteLine ("Found newly-added class: {0}", job.Type.CliName);
				ProjectInfo.InsertUpdatedType (job.Type);
			}
			
			// Next we can resolve base-types, outlet types, and action parameter types for each of our user-defined types.
			foreach (var job in TypeSyncJobs) {
				defaultNamespace = Project.GetDefaultNamespace (job.RelativePath);
				ProjectInfo.ResolveObjcToCli (monitor, job.Type, provider, defaultNamespace);
			}
			
			AggregateTypeUpdates (monitor, provider, designerFiles, out newTypes, out newFiles);
			MergeExistingTypes (designerFiles);
			
			return designerFiles;
		}
Esempio n. 15
0
		public CustomToolContext(IProject project, IProgressMonitor progressMonitor)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			this.project = project;
			this.ProgressMonitor = progressMonitor;
		}
Esempio n. 16
0
 private void SetTestPackage(IProgressMonitor progressMonitor)
 {
     using (progressMonitor.CreateSubProgressMonitor(10))
     {
         testController.SetTestPackage(projectController.TestPackage);
     }
 }
		public SearchProgressMonitor (Pad pad)
		{
			outputPad = (SearchResultPad) pad.Content;
			outputPad.AsyncOperation = AsyncOperation;
			outputPad.BeginProgress (pad.Title);
			statusMonitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Searching..."), Stock.StatusSearch, false, true, false, pad);
		}
		public static bool ReplaceNextInSelection(IProgressMonitor monitor)
		{
			if (lastResult != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
				ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as ITextEditorControlProvider;
				if (provider != null) {
					TextEditorControl textarea = provider.TextEditorControl;
					SelectionManager selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;
					
					if (selectionManager.SelectionCollection.Count == 1
					    && selectionManager.SelectionCollection[0].Offset == lastResult.Offset
					    && selectionManager.SelectionCollection[0].Length == lastResult.Length
					    && lastResult.FileName == textarea.FileName)
					{
						string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);
						
						textarea.BeginUpdate();
						selectionManager.ClearSelection();
						textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
						textarea.ActiveTextAreaControl.Caret.Position = textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
						textarea.EndUpdate();
						
						textSelection.Length -= lastResult.Length - replacePattern.Length;
					}
				}
			}
			return FindNextInSelection(monitor);
		}
Esempio n. 19
0
 private void ExploreTests(IProgressMonitor progressMonitor)
 {
     using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(90))
     {
         testController.Explore(subProgressMonitor, projectController.TestRunnerExtensionSpecifications);
     }
 }
Esempio n. 20
0
		public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel)
		{
			var br = new BuildResult();

			// Skip building sourceLibraries
			string targetType = null;
			var cfg = prj.GetConfiguration (sel) as DubProjectConfiguration;
			if (cfg != null){
				cfg.BuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType);
				if(string.IsNullOrWhiteSpace(targetType))
					prj.CommonBuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType);

				if (targetType != null && targetType.ToLower ().Contains("sourcelibrary")) {
					br.BuildCount = 1;
					return br;
				}
			}

			var args = new StringBuilder("build");

			BuildCommonArgAppendix(args, prj, sel);

			string output;
			string errDump;

			int status = ProjectBuilder.ExecuteCommand(DubSettings.Instance.DubCommand, args.ToString(), prj.BaseDirectory, 
				mon, out errDump, out output);
			br.CompilerOutput = output;

			ErrorExtracting.HandleReturnCode (mon, br, status);
			ErrorExtracting.HandleCompilerOutput(prj, br, output);
			ErrorExtracting.HandleCompilerOutput(prj, br, errDump);

			return br;
		}
        public override void Install(IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Installing TestDriven.Net Runner", testFrameworkManager.TestFrameworkHandles.Count + 2))
            {
                // Remove old registrations.
                RemoveExistingRegistryKeys(progressMonitor);
                progressMonitor.Worked(1);

                // Register Icarus
                string icarusPath = FindIcarusPath();
                if (icarusPath != null)
                    InstallRegistryKeysForIcarus(icarusPath, progressMonitor);
                progressMonitor.Worked(1);

                // Register frameworks
                foreach (ComponentHandle<ITestFramework, TestFrameworkTraits> testFrameworkHandle in testFrameworkManager.TestFrameworkHandles)
                {
                    TestFrameworkTraits testFrameworkTraits = testFrameworkHandle.GetTraits();
                    TDNetRunnerInstallationMode installationMode = preferenceManager.GetInstallationModeForFramework(testFrameworkHandle.Id);

                    if (installationMode != TDNetRunnerInstallationMode.Disabled)
                    {
                        int priority = installationMode == TDNetRunnerInstallationMode.Default ? 25 : 5;
                        foreach (AssemblySignature frameworkAssembly in testFrameworkTraits.FrameworkAssemblies)
                        {
                            InstallRegistryKeysForFramework(testFrameworkTraits.Name, frameworkAssembly, priority,
                                progressMonitor);
                        }
                    }

                    progressMonitor.Worked(1);
                }
            }
        }
		static void GenerateInternal (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
		{
			if (file.Project.SupportedLanguages.All (l => l != "C#")) {
				const string msg = "Razor templates are only supported in C# projects";
				result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg));
				monitor.Log.WriteLine (msg);
				return;
			}

			var host = new PreprocessedRazorHost (file.FilePath);

			var defaultOutputName = file.FilePath.ChangeExtension (".cs");

			var ns = CustomToolService.GetFileNamespace (file, defaultOutputName);
			host.DefaultNamespace = ns;

			CompilerErrorCollection errors;
			var code = host.GenerateCode (out errors);
			result.Errors.AddRange (errors);

			var writer = new MonoDevelop.DesignerSupport.CodeBehindWriter ();
			writer.WriteFile (defaultOutputName, code);
			writer.WriteOpenFiles ();

			result.GeneratedFilePath = defaultOutputName;

			foreach (var err in result.Errors) {
				monitor.Log.WriteLine (err);
			}
		}
Esempio n. 23
0
        public override void ApplyPendingSettingsChanges(IElevationContext elevationContext, IProgressMonitor progressMonitor)
        {
            base.ApplyPendingSettingsChanges(elevationContext, progressMonitor);

            optionsController.AutoSaveProject = autoSave.Checked;
            optionsController.Save();
        }
 void OnCancel(IProgressMonitor m)
 {
     lock (list) {
         foreach (IAsyncOperation operation in list)
             operation.Cancel ();
     }
 }
 public void SetUp()
 {
     testController = MockRepository.GenerateStub<ITestController>();
     projectController = MockRepository.GenerateStub<IProjectController>();
     loadPackageCommand = new LoadPackageCommand(testController, projectController);
     progressMonitor = MockProgressMonitor.Instance;
 }
        private static bool InstallOrUninstallWithElevationContext(IEnumerable<ComponentHandle<IInstaller, InstallerTraits>> installerHandles,
            IElevationContext elevationContext, IProgressMonitor progressMonitor,
            InstallerOperation operation)
        {
            foreach (var installerHandle in installerHandles)
            {
                if (progressMonitor.IsCanceled)
                    return false;

                IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1);
                if (elevationContext != null && installerHandle.GetTraits().RequiresElevation)
                {
                    elevationContext.Execute(InstallerElevatedCommand.ElevatedCommandId,
                        new InstallerElevatedCommand.Arguments(installerHandle.Id, operation),
                        subProgressMonitor);
                }
                else
                {
                    IInstaller installer = installerHandle.GetComponent();

                    if (operation == InstallerOperation.Install)
                        installer.Install(progressMonitor.CreateSubProgressMonitor(1));
                    else
                        installer.Uninstall(progressMonitor.CreateSubProgressMonitor(1));
                }
            }

            return true;
        }
Esempio n. 27
0
        protected override void Execute(IntPtr bridgeFunc, IProgressMonitor subMonitor)
        {
            using (subMonitor.BeginTask("Exploring " + File.Name, 100))
            {
                BoostTestExploreDelegate bridge =
                    (BoostTestExploreDelegate)Marshal.GetDelegateForFunctionPointer(
                        bridgeFunc,
                        typeof(BoostTestExploreDelegate)
                    );

                VisitorDelegate visitTestCase = new VisitorDelegate(VisitTestCase);
                VisitorDelegate beginVisitTestSuite = new VisitorDelegate(BeginVisitTestSuite);
                VisitorDelegate endVisitTestSuite = new VisitorDelegate(EndVisitTestSuite);

                ErrorReporterDelegate errorReporter =
                    new ErrorReporterDelegate((text) => Logger.Log(LogSeverity.Error, text));

                bridge(
                    File.FullName,

                    visitTestCase,
                    beginVisitTestSuite,
                    endVisitTestSuite,

                    errorReporter
                );

                TestModelSerializer.PublishTestModel(TestModel, MessageSink);
            }
        }
        /// <inheritdoc />
        protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            ThrowIfDisposed();

            using (progressMonitor.BeginTask(Resources.MbUnit2TestController_RunningMbUnitTests, 1))
            {
                if (progressMonitor.IsCanceled)
                    return new TestResult(TestOutcome.Canceled);

                if (options.SkipTestExecution)
                {
                    return SkipAll(rootTestCommand, parentTestStep);
                }
                else
                {
                    IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands();

                    using (InstrumentedFixtureRunner fixtureRunner = new InstrumentedFixtureRunner(fixtureExplorer,
                        testCommands, progressMonitor, parentTestStep))
                    {
                        return fixtureRunner.Run();
                    }
                }
            }
        }
Esempio n. 29
0
        protected override TestResult RunImpl( ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor )
        {
            using(progressMonitor.BeginTask( "Verifying Specifications", rootTestCommand.TestCount ) )
            {
                if( options.SkipTestExecution )
                {
                    return SkipAll( rootTestCommand, parentTestStep );
                }
                else
                {
                    ITestContext rootContext = rootTestCommand.StartPrimaryChildStep( parentTestStep );
                    TestStep rootStep = rootContext.TestStep;
                    TestOutcome outcome = TestOutcome.Passed;

                    foreach( ITestCommand command in rootTestCommand.Children )
                    {
                        NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
                        if( assemblyTest == null )
                            continue;

                        var assemblyResult = this.RunAssembly( command, rootStep );
                        outcome = outcome.CombineWith( assemblyResult.Outcome );
                    }

                    return rootContext.FinishStep( outcome, null );
                }
            }
        }
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			BuildResult res = base.Build (monitor, entry, configuration);
			if (res.ErrorCount > 0 || !(entry is DotNetProject))
				return res;
			
			DotNetProject project = (DotNetProject) entry;
			AddinData data = AddinData.GetAddinData (project);
			if (data == null)
				return res;
			
			monitor.Log.WriteLine (AddinManager.CurrentLocalizer.GetString ("Verifying add-in description..."));
			string fileName = data.AddinManifestFileName;
			ProjectFile file = data.Project.Files.GetFile (fileName);
			if (file == null)
				return res;
			
			string addinFile;
			if (file.BuildAction == BuildAction.EmbeddedResource)
				addinFile = project.GetOutputFileName (ConfigurationSelector.Default);
			else
				addinFile = file.FilePath;
			
			AddinDescription desc = data.AddinRegistry.GetAddinDescription (new ProgressStatusMonitor (monitor), addinFile);
			StringCollection errors = desc.Verify ();
			
			foreach (string err in errors) {
				res.AddError (data.AddinManifestFileName, 0, 0, "", err);
				monitor.Log.WriteLine ("ERROR: " + err);
			}
			
			return res;
		}
Esempio n. 31
0
 public void RevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
 {
     ClearCachedVersionInfo(localPath);
     OnRevertToRevision(localPath, revision, monitor);
 }
Esempio n. 32
0
 // Adds a file or directory to the repository
 public void Add(FilePath localPath, bool recurse, IProgressMonitor monitor)
 {
     Add(new FilePath[] { localPath }, recurse, monitor);
 }
Esempio n. 33
0
 protected virtual void OnMoveDirectory(FilePath localSrcPath, FilePath localDestPath, bool force, IProgressMonitor monitor)
 {
     FileService.SystemDirectoryRename(localSrcPath, localDestPath);
 }
Esempio n. 34
0
 // Moves a directory. This method may be called for versioned and unversioned
 // files. The default implementetions performs a system file move.
 public void MoveDirectory(FilePath localSrcPath, FilePath localDestPath, bool force, IProgressMonitor monitor)
 {
     ClearCachedVersionInfo(localSrcPath, localDestPath);
     OnMoveDirectory(localSrcPath, localDestPath, force, monitor);
 }
Esempio n. 35
0
 protected virtual void OnMoveFile(FilePath localSrcPath, FilePath localDestPath, bool force, IProgressMonitor monitor)
 {
     File.Move(localSrcPath, localDestPath);
 }
Esempio n. 36
0
 protected abstract void OnAdd(FilePath[] localPaths, bool recurse, IProgressMonitor monitor);
Esempio n. 37
0
 public void Add(FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
 {
     OnAdd(localPaths, recurse, monitor);
     ClearCachedVersionInfo(localPaths);
 }
Esempio n. 38
0
 public void Revert(FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
 {
     ClearCachedVersionInfo(localPaths);
     OnRevert(localPaths, recurse, monitor);
 }
Esempio n. 39
0
 protected abstract void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor);
Esempio n. 40
0
 public void Checkout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor)
 {
     ClearCachedVersionInfo(targetLocalPath);
     OnCheckout(targetLocalPath, rev, recurse, monitor);
 }
Esempio n. 41
0
 public void Revert(FilePath localPath, bool recurse, IProgressMonitor monitor)
 {
     Revert(new FilePath[] { localPath }, recurse, monitor);
 }
Esempio n. 42
0
 protected abstract void OnCommit(ChangeSet changeSet, IProgressMonitor monitor);
Esempio n. 43
0
 protected abstract void OnCheckout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor);
Esempio n. 44
0
 // Updates a local file or directory from the repository
 // Returns a list of updated files
 public void Update(FilePath localPath, bool recurse, IProgressMonitor monitor)
 {
     Update(new FilePath[] { localPath }, recurse, monitor);
 }
Esempio n. 45
0
 // Gets the contents of this repositories into the specified local path
 public void Checkout(FilePath targetLocalPath, bool recurse, IProgressMonitor monitor)
 {
     Checkout(targetLocalPath, null, recurse, monitor);
 }
Esempio n. 46
0
        // Imports a directory into the repository. 'serverPath' is the relative path in the repository.
        // 'localPath' is the local directory to publish. 'files' is the list of files to add to the new
        // repository directory (must use absolute local paths).
        public Repository Publish(string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor)
        {
            var res = OnPublish(serverPath, localPath, files, message, monitor);

            ClearCachedVersionInfo(localPath);
            return(res);
        }
Esempio n. 47
0
 // Commits changes in a set of files or directories into the repository
 public void Commit(ChangeSet changeSet, IProgressMonitor monitor)
 {
     ClearCachedVersionInfo(changeSet.BaseLocalPath);
     OnCommit(changeSet, monitor);
 }
Esempio n. 48
0
 protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
 {
     return(null);
 }
Esempio n. 49
0
 protected abstract Repository OnPublish(string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor);
Esempio n. 50
0
        public override void Clean(ProjectFileCollection projectFiles, CProjectConfiguration configuration, IProgressMonitor monitor)
        {
            //clean up object files
            foreach (string oFile in ObjectFiles(projectFiles, configuration, false))
            {
                if (File.Exists(oFile))
                {
                    File.Delete(oFile);
                }

                string dFile = Path.ChangeExtension(oFile, ".d");

                if (File.Exists(dFile))
                {
                    File.Delete(dFile);
                }
            }

            CleanPrecompiledHeaders(configuration);
        }
Esempio n. 51
0
 protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
 }
Esempio n. 52
0
        public override BuildResult Compile(
            Project project,
            ProjectFileCollection projectFiles,
            ProjectPackageCollection packages,
            CProjectConfiguration configuration,
            IProgressMonitor monitor)
        {
            if (!appsChecked)
            {
                appsChecked   = true;
                compilerFound = CheckApp(compilerCommand);
                linkerFound   = CheckApp(linkerCommand);
            }

            if (!compilerFound)
            {
                BuildResult cres = new BuildResult();
                cres.AddError("Compiler not found: " + compilerCommand);
                return(cres);
            }

            if (!linkerFound)
            {
                BuildResult cres = new BuildResult();
                cres.AddError("Linker not found: " + linkerCommand);
                return(cres);
            }

            CompilerResults cr           = new CompilerResults(new TempFileCollection());
            bool            success      = true;
            string          compilerArgs = GetCompilerFlags(project, configuration) + " " + GeneratePkgCompilerArgs(packages);

            string outputName = Path.Combine(configuration.OutputDirectory,
                                             configuration.CompiledOutputName);

            // Precompile header files and place them in .prec/<config_name>/
            if (configuration.PrecompileHeaders)
            {
                string precDir       = Path.Combine(configuration.SourceDirectory, ".prec");
                string precConfigDir = Path.Combine(precDir, configuration.Id);
                if (!Directory.Exists(precDir))
                {
                    Directory.CreateDirectory(precDir);
                }
                if (!Directory.Exists(precConfigDir))
                {
                    Directory.CreateDirectory(precConfigDir);
                }

                if (!PrecompileHeaders(projectFiles, configuration, compilerArgs, monitor, cr))
                {
                    success = false;
                }
            }
            else
            {
                //old headers could interfere with the build
                CleanPrecompiledHeaders(configuration);
            }

            //compile source to object files
            monitor.BeginTask(GettextCatalog.GetString("Compiling source to object files"), 1);
            foreach (ProjectFile f in projectFiles)
            {
                if (!success)
                {
                    break;
                }
                if (f.Subtype == Subtype.Directory || f.BuildAction != BuildAction.Compile || CProject.IsHeaderFile(f.FilePath))
                {
                    continue;
                }

                if (configuration.UseCcache || NeedsCompiling(f, configuration))
                {
                    success = DoCompilation(f, configuration, compilerArgs, monitor, cr, configuration.UseCcache);
                }
            }
            if (success)
            {
                monitor.Step(1);
            }
            monitor.EndTask();

            if (success)
            {
                switch (configuration.CompileTarget)
                {
                case CBinding.CompileTarget.Bin:
                    MakeBin(project, projectFiles, configuration, packages, cr, monitor, outputName);
                    break;

                case CBinding.CompileTarget.StaticLibrary:
                    MakeStaticLibrary(project, projectFiles, configuration, packages, cr, monitor, outputName);
                    break;

                case CBinding.CompileTarget.SharedLibrary:
                    MakeSharedLibrary(project, projectFiles, configuration, packages, cr, monitor, outputName);
                    break;
                }
            }

            return(new BuildResult(cr, ""));
        }
Esempio n. 53
0
 protected override void OnClean(IProgressMonitor monitor, ConfigurationSelector configuration)
 {
 }
Esempio n. 54
0
 public static void ReplaceFirstInSelection(int offset, int length, IProgressMonitor monitor)
 {
     SetSearchOptions(monitor);
     FindFirstInSelection(offset, length, monitor);
 }
Esempio n. 55
0
        private void MakeSharedLibrary(Project project,
                                       ProjectFileCollection projectFiles,
                                       CProjectConfiguration configuration,
                                       ProjectPackageCollection packages,
                                       CompilerResults cr,
                                       IProgressMonitor monitor, string outputName)
        {
            if (!NeedsUpdate(projectFiles, configuration, outputName))
            {
                return;
            }

            string        objectFiles = string.Join(" ", ObjectFiles(projectFiles, configuration, true));
            string        pkgargs     = GeneratePkgLinkerArgs(packages);
            StringBuilder args        = new StringBuilder();

            if (configuration.ExtraLinkerArguments != null && configuration.ExtraLinkerArguments.Length > 0)
            {
                string extraLinkerArgs = ExpandBacktickedParameters(configuration.ExtraLinkerArguments.Replace('\n', ' '));
                args.Append(extraLinkerArgs + " ");
            }

            if (configuration.LibPaths != null)
            {
                foreach (string libpath in configuration.LibPaths)
                {
                    args.Append("-L\"" + StringParserService.Parse(libpath, GetStringTags(project)) + "\" ");
                }
            }

            if (configuration.Libs != null)
            {
                foreach (string lib in configuration.Libs)
                {
                    string directory = Path.GetDirectoryName(lib);
                    string library   = Path.GetFileName(lib);

                    // Is this a 'standard' (as in, uses an orthodox naming convention) library..?
                    string link_lib = String.Empty;
                    if (IsStandardLibrary(configuration, directory, library, ref link_lib))
                    {
                        args.Append("-l\"" + link_lib + "\" ");
                    }
                    // If not, reference the library by it's full pathname.
                    else
                    {
                        args.Append("\"" + lib + "\" ");
                    }
                }
            }

            string linker_args = string.Format("-shared -o \"{0}\" {1} {2} {3}",
                                               outputName, objectFiles, pkgargs, args.ToString());

            monitor.BeginTask(GettextCatalog.GetString("Generating shared object \"{0}\" from object files", Path.GetFileName(outputName)), 1);

            string errorOutput;
            int    exitCode = ExecuteCommand(linkerCommand, linker_args, Path.GetDirectoryName(outputName), monitor, out errorOutput);

            if (exitCode == 0)
            {
                monitor.Step(1);
            }
            monitor.EndTask();

            ParseCompilerOutput(errorOutput, cr);
            ParseLinkerOutput(errorOutput, cr);
            CheckReturnCode(exitCode, cr);
        }
Esempio n. 56
0
 static void SetSearchOptions(IProgressMonitor monitor)
 {
     find.SearchStrategy   = SearchReplaceUtilities.CreateSearchStrategy(SearchOptions.SearchStrategyType);
     find.DocumentIterator = SearchReplaceUtilities.CreateDocumentIterator(SearchOptions.DocumentIteratorType, monitor);
 }
Esempio n. 57
0
        private bool DoPrecompileHeader(ProjectFile file, string output, string args, IProgressMonitor monitor, CompilerResults cr)
        {
            string completeArgs = String.Format("\"{0}\" {1} -o {2}", file.Name, args, output);
            string errorOutput;
            int    exitCode = ExecuteCommand(compilerCommand, completeArgs, Path.GetDirectoryName(output), monitor, out errorOutput);

            ParseCompilerOutput(errorOutput, cr);
            return(exitCode == 0);
        }