-
I have an extension with a lot of options. I've created a single Options class like so: public class Options : BaseOptionModel<Options> {
// Lots of options...
} Because there are a lot of options that fall into different categories, I've defined multiple Tools Options pages where each page is for a different category of options. [ProvideOptionPage(typeof(AzureDevOpsServerOptionsPage), ...)]
[ProvideOptionPage(typeof(BitbucketServerOptionsPage), ...)]
[ProvideOptionPage(typeof(GeneralOptionsPage), ...)]
[ProvideOptionPage(typeof(GitHubEnterpriseOptionsPage), ...)]
[ProvideOptionPage(typeof(GitHubOptionsPage), ...)]
[ProvideOptionPage(typeof(GitilesOptionsPage), ...)]
[ProvideOptionPage(typeof(GitLabEnterpriseOptionsPage), ...)] This works great, and all of the pages are grouped under a single node. Now I'm trying to work out how I should use [ProvideProfile(typeof(AzureDevOpsServerOptionsPage), ...)]
[ProvideProfile(typeof(BitbucketServerOptionsPage), ...)]
[ProvideProfile(typeof(GeneralOptionsPage), ...)]
[ProvideProfile(typeof(GitHubEnterpriseOptionsPage), ...)]
[ProvideProfile(typeof(GitHubOptionsPage), ...)]
[ProvideProfile(typeof(GitilesOptionsPage), ...)]
[ProvideProfile(typeof(GitLabEnterpriseOptionsPage), ...)] Then I end up with this mess in the Export Settings Wizard: What I really want is to have all of the categories grouped together, just like they are in the Tools Options dialog. I've tried all sorts of combinations of So there's a few questions that I have:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Really good questions. Perhaps @jekelly knows the answer? |
Beta Was this translation helpful? Give feedback.
-
What!! I was today years old when I learned about |
Beta Was this translation helpful? Give feedback.
-
Thanks to @JoshuaBStevens, I was able to get this working how I wanted. ❤️ As he pointed out, there's a By setting the I'm still a bit confused about what Visual Studio actually does when loading and saving those properties, because it seems to be able to export settings without actually creating an instance of the Another thing that I couldn't get working was the loading and saving of objects and collections. In the end I just gave up and defined a string property that serialized the collection to/from JSON and had that string property saved to the registry and to the exported XML file. 🤷♂️ If anyone is interested, you can see my implementation here: https://github.com/reduckted/GitWebLinks/tree/3cb46cb99f2657d1e8e70c32de571df7a29e656b/visual-studio/source/GitWebLinks/Options I think there's a few changes that we can make in the toolkit to make things a little bit easier. The one major thing that caught me out is needing the |
Beta Was this translation helpful? Give feedback.
Thanks to @JoshuaBStevens, I was able to get this working how I wanted. ❤️
As he pointed out, there's a
SupportsProfiles
property on theProvideOptionPage
attribute that will give me the behavior that I wanted.By setting the
SupportsProfiles
property to true, I was able to completely do away with theBaseOptionModel
base class and just define the properties on eachDialogPage
. Visual Studio will load and save those properties automatically.I'm still a bit confused about what Visual Studio actually does when loading and saving those properties, because it seems to be able to export settings without actually creating an instance of the
DialogPage
(no breakpoints were hit anywhere in the c…