Change VS option by using the Settings Store: finding the right CollectionPath?

179 views Asked by At

I need to set the value of a Visual Studio option found in Visual Studio -> Tools -> Options -> Text Editor -> JavaScript/TypeScript -> EsLint but I can't seem to find the CollectionPath for this option.

GetSubCollectionNames("Text Editor"); yield a number of results, while GetSubCollectionNames("Text Editor\\JavaScript"); yield 0 results.

TL;DR How would one go about finding the right CollectionPath for the option pictured in the image below?

enter image description here

This is what I'm using currently.

[ImportingConstructor]
internal VSOptions([Import] SVsServiceProvider serviceProvider)
{
    var settingsManager = new ShellSettingsManager(serviceProvider);

    _writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings)
        ?? throw new Exception(nameof(settingsManager));

    var textEditorSubCollections = _writableSettingsStore.GetSubCollectionNames("Text Editor");
    var javaScriptSubCollections = _writableSettingsStore.GetSubCollectionNames("Text Editor\\JavaScript");

    // TODO: set option value when we have the right CollectionPath
}
1

There are 1 answers

0
Weiwei On BEST ANSWER

The WritabelSettingsStore class used to extend Visual Studio common settings in Visual Studio. You could use GetPropertyNames("Text Editor\JavaScript") to list all writabel settings for JavaScript, where you will find not all Properties under JavaScript sub collections are listed.

The EsLint is not common Visual Studio Settings. It is third part tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs.

So we could not change it directly with WritableSettingsStore class. You need to know how the EsLint added in Visual Studio and then modify its configuration file for Visual Studio.