-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark package content items as "user read-only"
Fixes: #2141 This marks package content items as user read-only, which causes them to be opened read-only in the editor.
- Loading branch information
Showing
8 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...o.ProjectSystem.Managed/ProjectSystem/Tree/PackageContentProjectTreePropertiesProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
||
using System.ComponentModel.Composition; | ||
|
||
namespace Microsoft.VisualStudio.ProjectSystem.Tree | ||
{ | ||
/// <summary> | ||
/// Marks content items that come from packages as "user read-only". | ||
/// </summary> | ||
[Export(typeof(IProjectTreePropertiesProvider))] | ||
[AppliesTo(ProjectCapability.PackageReferences)] | ||
internal class PackageContentProjectTreePropertiesProvider : IProjectTreePropertiesProvider | ||
{ | ||
public void CalculatePropertyValues(IProjectTreeCustomizablePropertyContext propertyContext, IProjectTreeCustomizablePropertyValues propertyValues) | ||
{ | ||
// Package content items always come in as linked items, so to reduce | ||
// the number of items we look at, we limit ourselves to them | ||
if (propertyValues.Flags.Contains(ProjectTreeFlags.LinkedItem) && | ||
propertyContext.Metadata != null && | ||
propertyContext.Metadata.TryGetValue(None.NuGetPackageIdProperty, out string packageId) && packageId.Length > 0) | ||
{ | ||
// TODO: Replace this with strongly typed value when we next update | ||
propertyValues.Flags |= ProjectTreeFlags.Create("UserReadOnly"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters