IEnumerable <ProjectReference> CreateProjectReferences(MonoDevelop.Projects.DotNetProject p, CancellationToken token) { foreach (var referencedProject in p.GetReferencedAssemblyProjects(IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default)) { if (token.IsCancellationRequested) { yield break; } if (TypeSystemService.IsOutputTrackedProject(referencedProject)) { continue; } yield return(new ProjectReference(GetOrCreateProjectId(referencedProject))); } }
IEnumerable <ProjectReference> CreateProjectReferences(MonoDevelop.Projects.Project p, CancellationToken token) { foreach (var pr in p.GetReferencedItems(MonoDevelop.Projects.ConfigurationSelector.Default)) { if (token.IsCancellationRequested) { yield break; } var referencedProject = pr as MonoDevelop.Projects.DotNetProject; if (referencedProject == null) { continue; } if (TypeSystemService.IsOutputTrackedProject(referencedProject)) { continue; } yield return(new ProjectReference(GetOrCreateProjectId(referencedProject))); } }
static async Task <List <MetadataReference> > CreateMetadataReferences(MonoDevelop.Projects.Project p, ProjectId projectId, CancellationToken token) { List <MetadataReference> result = new List <MetadataReference> (); var netProject = p as MonoDevelop.Projects.DotNetProject; if (netProject == null) { return(result); } var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default; var hashSet = new HashSet <string> (FilePath.PathComparer); bool addFacadeAssemblies = false; try { foreach (string file in await netProject.GetReferencedAssemblies(configurationSelector, false).ConfigureAwait(false)) { if (token.IsCancellationRequested) { return(result); } string fileName; if (!Path.IsPathRooted(file)) { fileName = Path.Combine(Path.GetDirectoryName(netProject.FileName), file); } else { fileName = Path.GetFullPath(file); } if (hashSet.Contains(fileName)) { continue; } hashSet.Add(fileName); if (!File.Exists(fileName)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, fileName)); addFacadeAssemblies |= MonoDevelop.Core.Assemblies.SystemAssemblyService.ContainsReferenceToSystemRuntime(fileName); } } catch (Exception e) { LoggingService.LogError("Error while getting referenced assemblies", e); } // HACK: Facade assemblies should be added by the project system. Remove that when the project system can do that. if (addFacadeAssemblies) { if (netProject != null) { var runtime = netProject.TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; var facades = runtime.FindFacadeAssembliesForPCL(netProject.TargetFramework); foreach (var facade in facades) { if (!File.Exists(facade)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, facade)); } } } foreach (var pr in p.GetReferencedItems(configurationSelector)) { if (token.IsCancellationRequested) { return(result); } var referencedProject = pr as MonoDevelop.Projects.DotNetProject; if (referencedProject == null) { continue; } if (TypeSystemService.IsOutputTrackedProject(referencedProject)) { var fileName = referencedProject.GetOutputFileName(configurationSelector); if (!File.Exists(fileName)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, fileName)); } } return(result); }
static async Task <List <MetadataReference> > CreateMetadataReferences(MonoDevelop.Projects.DotNetProject netProject, ProjectId projectId, CancellationToken token) { List <MetadataReference> result = new List <MetadataReference> (); var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default; var hashSet = new HashSet <string> (FilePath.PathComparer); try { foreach (string file in await netProject.GetReferencedAssemblies(configurationSelector, false).ConfigureAwait(false)) { if (token.IsCancellationRequested) { return(result); } string fileName; if (!Path.IsPathRooted(file)) { fileName = Path.Combine(Path.GetDirectoryName(netProject.FileName), file); } else { fileName = Path.GetFullPath(file); } if (hashSet.Contains(fileName)) { continue; } hashSet.Add(fileName); if (!File.Exists(fileName)) { LoggingService.LogError("Error while getting referenced Assembly " + fileName + " for project " + netProject.Name + ": File doesn't exist"); continue; } var metadataReference = MetadataReferenceCache.LoadReference(projectId, fileName); if (metadataReference == null) { continue; } result.Add(metadataReference); } } catch (Exception e) { LoggingService.LogError("Error while getting referenced assemblies", e); } foreach (var pr in netProject.GetReferencedItems(configurationSelector)) { if (token.IsCancellationRequested) { return(result); } var referencedProject = pr as MonoDevelop.Projects.DotNetProject; if (referencedProject == null) { continue; } if (TypeSystemService.IsOutputTrackedProject(referencedProject)) { var fileName = referencedProject.GetOutputFileName(configurationSelector); if (!File.Exists(fileName)) { LoggingService.LogError("Error while getting project Reference (" + referencedProject.Name + ") " + fileName + " for project " + netProject.Name + ": File doesn't exist"); continue; } var metadataReference = MetadataReferenceCache.LoadReference(projectId, fileName); if (metadataReference != null) { result.Add(metadataReference); } } } return(result); }
bool AddMetadataProjectReferences(AddMetadataReferencesData data) { try { var referencedProjects = data.Project.GetReferencedItems(data.ConfigurationSelector); foreach (var pr in referencedProjects) { if (data.Token.IsCancellationRequested) { return(false); } if (!(pr is MonoDevelop.Projects.DotNetProject referencedProject) || !TypeSystemService.IsOutputTrackedProject(referencedProject)) { continue; } var fileName = referencedProject.GetOutputFileName(data.ConfigurationSelector); if (!data.Visited.Add(fileName)) { continue; } var metadataReference = manager.GetOrCreateMetadataReference(fileName, MetadataReferenceProperties.Assembly); if (metadataReference != null) { data.Result.Add(metadataReference); } } } catch (Exception e) { LoggingService.LogError("Error while getting referenced assemblies", e); // TODO: Check whether this should return false, I retained compat for now. return(true); } return(true); }