From ccb051f1d1eb21c054b02fcc29ca08c702d6701c Mon Sep 17 00:00:00 2001 From: Chris Donnelly Date: Fri, 15 May 2020 15:11:26 -0500 Subject: [PATCH] Adding Update, Exclude, and Remove everywhere they currently are not. This fixes dotnet#68, at least the ArgumentNullException part -- targets files without an Sdk attribute don't seem to work. --- .../Completion/PackageCompletionSource.cs | 8 +++++++- .../GoToDefinition/GoToDefinitionController.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ProjectFileTools/Completion/PackageCompletionSource.cs b/src/ProjectFileTools/Completion/PackageCompletionSource.cs index 06a32c1..08c608a 100644 --- a/src/ProjectFileTools/Completion/PackageCompletionSource.cs +++ b/src/ProjectFileTools/Completion/PackageCompletionSource.cs @@ -22,6 +22,9 @@ internal class PackageCompletionSource : ICompletionSource private static readonly IReadOnlyDictionary AttributeToCompletionTypeMap = new Dictionary(StringComparer.Ordinal) { {"Include", "Name" }, + {"Update", "Name" }, + {"Exclude", "Name" }, + {"Remove", "Name" }, {"Version", "Version" } }; @@ -85,7 +88,10 @@ public static bool TryGetPackageInfoFromXml(XmlInfo info, out string packageName && info.AttributeName != null && AttributeToCompletionTypeMap.ContainsKey(info.AttributeName) && info.TryGetElement(out XElement element)) { - XAttribute name = element.Attribute(XName.Get("Include")); + XAttribute name = element.Attribute(XName.Get("Include")) + ?? element.Attribute(XName.Get("Update")) + ?? element.Attribute(XName.Get("Exclude")) + ?? element.Attribute(XName.Get("Remove")); XAttribute version = element.Attribute(XName.Get("Version")); packageName = name?.Value; packageVersion = version?.Value; diff --git a/src/ProjectFileTools/GoToDefinition/GoToDefinitionController.cs b/src/ProjectFileTools/GoToDefinition/GoToDefinitionController.cs index 22551da..ce642f0 100644 --- a/src/ProjectFileTools/GoToDefinition/GoToDefinitionController.cs +++ b/src/ProjectFileTools/GoToDefinition/GoToDefinitionController.cs @@ -145,7 +145,7 @@ internal static GotoDefinitionController CreateAndRegister(IWpfTextView textview { ThreadHelper.ThrowIfNotOnUIThread(); - if (info.AttributeName == "Include") + if (info.AttributeName == "Include" || info.AttributeName == "Update" || info.AttributeName == "Exclude" || info.AttributeName == "Remove") { string relativePath = info.AttributeValue; IWorkspace workspace = workspaceManager.GetWorkspace(textDoc.FilePath);