diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Rules/PropertyPages/PropertyPageRuleProvider.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Rules/PropertyPages/PropertyPageRuleProvider.cs new file mode 100644 index 00000000000..dc8e1d0994f --- /dev/null +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Rules/PropertyPages/PropertyPageRuleProvider.cs @@ -0,0 +1,110 @@ +ο»Ώ// 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; +using System.ComponentModel.Composition; +using System.Threading.Tasks; +using Microsoft.Build.Framework.XamlTypes; +using Microsoft.VisualStudio.ProjectSystem.Properties; + +namespace Microsoft.VisualStudio.ProjectSystem.Rules.PropertyPages +{ + /// + /// We want to provide certain rules when the "MyCapability" capability is present, but remove them if it goes away. + /// The is designed specifically for these situations. + /// + [Export(ExportContractNames.Scopes.UnconfiguredProject, typeof(IProjectDynamicLoadComponent))] + [AppliesTo("MyCapability")] + internal class PropertyPageRuleProvider : IProjectDynamicLoadComponent + { + /// + /// A CPS-provided service that supports adding and removing in-memory s. + /// + private readonly IAdditionalRuleDefinitionsService _additionalRuleDefinitionsService; + /// + /// Use a so we don't create the until we need it. + /// Technically this is unnecessary, since the constructor won't be called until the first + /// time the capabilities are satisified, and will be called shortly + /// after that. As such, making this lazy really just makes it very clear that it definitely + /// won't be created until it is needed, and will only be created once. + /// + private readonly Lazy _rule; + + [ImportingConstructor] + public PropertyPageRuleProvider( + IAdditionalRuleDefinitionsService additionalRuleDefinitionsService) + { + _additionalRuleDefinitionsService = additionalRuleDefinitionsService; + _rule = new Lazy(CreateRule); + } + + /// + /// Called when the specified capabilities are satisfied. + /// We can add our rules. + /// + public Task LoadAsync() + { + _additionalRuleDefinitionsService.AddRuleDefinition(_rule.Value, context: "Project"); + + return Task.CompletedTask; + } + + /// + /// Called when the specified capabilities are no longer satisfied. + /// We can remove our rules. + /// + public Task UnloadAsync() + { + _additionalRuleDefinitionsService.RemoveRuleDefinition(_rule.Value); + + return Task.CompletedTask; + } + + private Rule CreateRule() + { + Rule rule = new(); + + // Rule implements ISupportInitialize; we need to be sure to call BeginInit and EndInit. + rule.BeginInit(); + + // Basic information + + rule.Name = "MyInMemoryPropertyPage"; + rule.Description = "A Rule that is defined in memory and dynamically loaded and unloaded"; + rule.DisplayName = Resources.MyPropertyPage_DisplayName; + rule.PageTemplate = "generic"; + rule.Order = 10; + + // Metadata + + // (no metadata) + + // Categories + + rule.Categories.Add(new Category { Name = "General", DisplayName = "General" }); + rule.Categories.Add(new Category { Name = "OtherSettings", DisplayName = "Other Settings" }); + + // Data source + + rule.DataSource = new DataSource + { + Persistence = "ProjectFile", + SourceOfDefaultValue = DefaultValueSourceLocation.AfterContext, + HasConfigurationCondition = false, + }; + + // Properties + + rule.Properties.Add(new StringProperty + { + Name = "MyProperty", + DisplayName = "My Property", + Description = Resources.MyPropertyPage_PropertyDescription, + Category = "OtherSettings" + }); + + rule.EndInit(); + + return rule; + } + } +} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.Designer.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.Designer.cs index 592cbdbd185..ee12ca5a369 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.Designer.cs +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -159,6 +159,24 @@ internal static string MsBuildMissingValueToRename { } } + /// + /// Looks up a localized string similar to My In-Memory Page πŸ˜€. + /// + internal static string MyPropertyPage_DisplayName { + get { + return ResourceManager.GetString("MyPropertyPage_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰. + /// + internal static string MyPropertyPage_PropertyDescription { + get { + return ResourceManager.GetString("MyPropertyPage_PropertyDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} - {1}. /// diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.resx b/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.resx index 6889690e8a8..2b1b66b7412 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.resx +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/Resources.resx @@ -194,4 +194,10 @@ This project was loaded using the wrong project type, likely as a result of rena (None) Special value to show in the project property pages when a property has no value. + + My In-Memory Page πŸ˜€ + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.cs.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.cs.xlf index 1192b9ddb9b..edd07837629 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.cs.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.cs.xlf @@ -12,6 +12,16 @@ Importy + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} – {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.de.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.de.xlf index 5ccaf819a44..0f3725b41af 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.de.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.de.xlf @@ -12,6 +12,16 @@ Importe + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} – {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.es.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.es.xlf index c74a7c5a241..5a9e2f4f8a0 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.es.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.es.xlf @@ -12,6 +12,16 @@ Importaciones + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.fr.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.fr.xlf index 0348e940b3e..81531b86b2f 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.fr.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.fr.xlf @@ -12,6 +12,16 @@ Importations + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.it.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.it.xlf index ddb50cd2fad..8ecde8972d1 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.it.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.it.xlf @@ -12,6 +12,16 @@ Importazioni + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ja.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ja.xlf index 64d154295c0..d2fbd3a4727 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ja.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ja.xlf @@ -12,6 +12,16 @@ γ‚€γƒ³γƒγƒΌγƒˆ + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ko.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ko.xlf index da658818c4a..79a2fe5b5fd 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ko.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ko.xlf @@ -12,6 +12,16 @@ κ°€μ Έμ˜€κΈ° + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pl.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pl.xlf index fe9e52e9757..2a741124ede 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pl.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pl.xlf @@ -12,6 +12,16 @@ Importy + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} β€” {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pt-BR.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pt-BR.xlf index bcdb8936034..53f7356f642 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.pt-BR.xlf @@ -12,6 +12,16 @@ ImportaΓ§Γ΅es + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} – {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ru.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ru.xlf index efbb415cccc..58885d81e82 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ru.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.ru.xlf @@ -12,6 +12,16 @@ Π˜ΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΡƒΠ΅Ρ‚ + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0}Β β€” {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.tr.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.tr.xlf index 0e91ba39fdd..5bce3ade3e4 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.tr.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.tr.xlf @@ -12,6 +12,16 @@ Almalar + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hans.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hans.xlf index bd3099e9e20..74ac60b47e8 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hans.xlf @@ -12,6 +12,16 @@ ε―Όε…₯ + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1} diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hant.xlf b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hant.xlf index 6aeb91c86a2..b17ef4fa5cc 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/xlf/Resources.zh-Hant.xlf @@ -12,6 +12,16 @@ 匯ε…₯ + + My In-Memory Page πŸ˜€ + My In-Memory Page πŸ˜€ + + + + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + πŸŽ‰ Put anything you want here! It doesn't matter! πŸŽ‰ + + {0} - {1} {0} - {1}