protected override bool TryCreateCollectionSource( IVsHierarchyItem hierarchyItem, string flagsString, string?target, IRelationProvider relationProvider, [NotNullWhen(returnValue: true)] out AggregateRelationCollectionSource?containsCollectionSource) { if (ErrorHandler.Succeeded(hierarchyItem.HierarchyIdentity.Hierarchy.GetProperty( hierarchyItem.HierarchyIdentity.ItemID, (int)__VSHPROPID.VSHPROPID_ExtObject, out object projectItemObject))) { var projectItem = projectItemObject as ProjectItem; EnvDTE.Properties?props = projectItem?.Properties; if (props?.Item("TargetingPackPath")?.Value is string path && props?.Item("OriginalItemSpec")?.Value is string name) { string?profile = props?.Item("Profile").Value as string; var framework = new FrameworkReferenceIdentity(path, profile, name); var item = new FrameworkReferenceItem(framework); if (AggregateContainsRelationCollection.TryCreate(item, _relationProvider, out AggregateContainsRelationCollection? collection)) { containsCollectionSource = new AggregateRelationCollectionSource(hierarchyItem, collection); return(true); } } } containsCollectionSource = null; return(false); }
public FrameworkReferenceAssemblyItem(string assemblyName, string?path, string?assemblyVersion, string?fileVersion, FrameworkReferenceIdentity framework) : base(assemblyName) { Requires.NotNull(framework, nameof(framework)); AssemblyName = assemblyName; Path = path; AssemblyVersion = assemblyVersion; FileVersion = fileVersion; Framework = framework; }
static ImmutableArray <FrameworkReferenceAssemblyItem> LoadItems(FrameworkReferenceIdentity framework) { string frameworkListPath = Path.Combine(framework.Path, "data", "FrameworkList.xml"); var pool = new Dictionary <string, string>(StringComparer.Ordinal); XDocument doc; try { doc = XDocument.Load(frameworkListPath); } catch { return(ImmutableArray <FrameworkReferenceAssemblyItem> .Empty); } ImmutableArray <FrameworkReferenceAssemblyItem> .Builder results = ImmutableArray.CreateBuilder <FrameworkReferenceAssemblyItem>(); foreach (XElement file in doc.Root.Elements("File")) { if (!Strings.IsNullOrEmpty(framework.Profile)) { // We must filter to a specific profile string?fileProfile = file.Attribute("Profile")?.Value; if (fileProfile == null) { // The file doesn't specify a profile, so skip it continue; } if (!new LazyStringSplit(fileProfile, ';').Contains(framework.Profile, StringComparer.OrdinalIgnoreCase)) { // File file specifies a profile, but not one we are looking for, so skip it continue; } } if (file.Attribute("ReferencedByDefault")?.Value.Equals("false", StringComparison.OrdinalIgnoreCase) == true) { // Don't include if ReferencedByDefault=false continue; } string?assemblyName = Pool(file.Attribute("AssemblyName")?.Value); string?path = Pool(file.Attribute("Path")?.Value); string?assemblyVersion = Pool(file.Attribute("AssemblyVersion")?.Value); string?fileVersion = Pool(file.Attribute("FileVersion")?.Value); if (assemblyName != null) { results.Add(new FrameworkReferenceAssemblyItem(assemblyName, path, assemblyVersion, fileVersion, framework)); } } return(results.ToImmutable()); string?Pool(string?s) { if (s != null) { if (pool.TryGetValue(s, out string existing)) { return(existing); } pool.Add(s, s); } return(s); } }
public FrameworkReferenceItem(FrameworkReferenceIdentity framework) : base(framework.Name) { Framework = framework; }
public ImmutableArray <FrameworkReferenceAssemblyItem> GetContents(FrameworkReferenceIdentity framework) { return(ImmutableInterlocked.GetOrAdd(ref _cache, framework, LoadItems));