Exemplo n.º 1
0
		async Task<ProjectInfo> LoadProject (MonoDevelop.Projects.Project p, CancellationToken token)
		{
			if (!projectIdMap.ContainsKey (p)) {
				p.FileAddedToProject += OnFileAdded;
				p.FileRemovedFromProject += OnFileRemoved;
				p.FileRenamedInProject += OnFileRenamed;
				p.Modified += OnProjectModified;
			}

			var projectId = GetOrCreateProjectId (p);
			var projectData = GetOrCreateProjectData (projectId);
			var references = await CreateMetadataReferences (p, projectId, token).ConfigureAwait (false);
			if (token.IsCancellationRequested)
				return null;
			var config = IdeApp.Workspace != null ? p.GetConfiguration (IdeApp.Workspace.ActiveConfiguration) as MonoDevelop.Projects.DotNetProjectConfiguration : null;
			MonoDevelop.Projects.DotNetCompilerParameters cp = null;
			if (config != null)
				cp = config.CompilationParameters;
			FilePath fileName = IdeApp.Workspace != null ? p.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration) : (FilePath)"";
			if (fileName.IsNullOrEmpty)
				fileName = new FilePath (p.Name + ".dll");

			var sourceFiles = await p.GetSourceFilesAsync (config != null ? config.Selector : null).ConfigureAwait (false);

			var info = ProjectInfo.Create (
				projectId,
				VersionStamp.Create (),
				p.Name,
				fileName.FileNameWithoutExtension,
				LanguageNames.CSharp,
				p.FileName,
				fileName,
				cp != null ? cp.CreateCompilationOptions () : null,
				cp != null ? cp.CreateParseOptions (config) : null,
				CreateDocuments (projectData, p, token, sourceFiles),
				CreateProjectReferences (p, token),
				references
			);
			projectData.Info = info;
			return info;
		}