Skip to content

Commit cb08199

Browse files
committed
Add methods to remove attribute from Project
1 parent edac116 commit cb08199

File tree

1 file changed

+25
-0
lines changed
  • src/toolkit/Community.VisualStudio.Toolkit.Shared/Solution

1 file changed

+25
-0
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/Solution/Project.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ public bool IsCapabilityMatch(string capability)
8484
return hier.IsCapabilityMatch(capability);
8585
}
8686

87+
/// <summary>
88+
/// Tries to remove an attribute in the project file for the item.
89+
/// </summary>
90+
public Task<bool> RemoveAttributeAsync(string name)
91+
{
92+
return RemoveAttributeAsync(name, ProjectStorageType.ProjectFile);
93+
}
94+
95+
/// <summary>
96+
/// Tries to remove an attribute in the project file for the item from the specified storage type.
97+
/// </summary>
98+
public async Task<bool> RemoveAttributeAsync(string name, ProjectStorageType storageType)
99+
{
100+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
101+
GetItemInfo(out IVsHierarchy hierarchy, out _, out _);
102+
103+
if (hierarchy is IVsBuildPropertyStorage storage)
104+
{
105+
storage.RemoveProperty(name, "", ToPersistStorageType(storageType));
106+
return true;
107+
}
108+
109+
return false;
110+
}
111+
87112
/// <summary>
88113
/// Save the project if it's dirty.
89114
/// </summary>

0 commit comments

Comments
 (0)