I have a Visual Studio extension that gets the value and then sets a value to the Text Editor -> General -> Track Changes setting in the Options dialog.
A code that was working fine with Visual Studio 2012-2017:
DTE vsEnvironment = (DTE)GetService(typeof(DTE));
Property trackChangesProperty = vsEnvironment.Properties["TextEditor", "General"].Item("TrackChanges");
is throwing a COMException
with the following message: "Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))" at EnvDTE._DTE.get_Properties(String Category, String Page)
in Visual Studio 2019.
Apparently the setting is moved, so I, trying to get the new location, exported the settings to file in Visual Studio 2017 and 2019, and compared the results:
Visual Studio 2017:
<ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor"> <ToolsOptionsSubCategory name="General" RegisteredName="General" PackageName="Text Management Package"> <PropertyValue name="TrackChanges">true</PropertyValue> </ToolsOptionsSubCategory>
Visual Studio 2019:
<Category name="Text Editor_General" Category="{c178af61-531a-46f0-bd57-102d9e42c711}" Package="{e269b994-ef71-4ce0-8bcd-581c217372e8}" RegisteredName="Text Editor_General" PackageName="Microsoft.VisualStudio.Editor.Implementation.EditorPackage"> <PropertyValue name="TrackChanges">true</PropertyValue>
I am still not sure how to use the information, as the indexer of the DTE.Properties
accepts two parameters: Category
and Page
. I already tried the following:
vsEnvironment.Properties["TextEditor", null].Item("TrackChanges");
vsEnvironment.Properties["TextEditor", string.Empty].Item("TrackChanges");
vsEnvironment.Properties["Text Editor_General", null].Item("TrackChanges");
vsEnvironment.Properties["Text Editor_General", string.Empty].Item("TrackChanges");
but without success.