Visual Studio 调试器扩展获取用户设置

Visual Studio Debugger Extension get user settings

我正在编写一个基于 Concord Samples Hello World 项目的 visual studio 扩展。目标是让用户通过设置搜索字符串列表来过滤堆栈帧。如果任何搜索字符串在堆栈帧中,则将其省略。

我的过滤器适用于硬编码列表。这需要在非基于包的 dll 项目中,以便调试器能够拾取它。我有一个 vsix 项目,该项目使用 OptionPageGrid 引用该 dll 以接受字符串列表。但我终其一生都找不到连接它们的方法。

在调试器方面,我的代码看起来像这样:

    DkmStackWalkFrame[] IDkmCallStackFilter.FilterNextFrame(DkmStackContext stackContext, DkmStackWalkFrame input)
    {
        if (input == null) // null input frame indicates the end of the call stack. This sample does nothing on end-of-stack.
            return null;
        if (input.InstructionAddress == null) // error case
            return new[] { input };

        DkmWorkList workList = DkmWorkList.Create(null);
        DkmLanguage language = input.Process.EngineSettings.GetLanguage(new DkmCompilerId());
        DkmInspectionContext inspection = DkmInspectionContext.Create(stackContext.InspectionSession, input.RuntimeInstance, input.Thread, 1000,
            DkmEvaluationFlags.None, DkmFuncEvalFlags.None, 10, language, null);

        string frameName = "";
        inspection.GetFrameName(workList, input, DkmVariableInfoFlags.None, result => GotFrameName(result, out frameName));

        workList.Execute();

        CallstackCollapserDataItem dataItem = CallstackCollapserDataItem.GetInstance(stackContext);

        bool omitFrame = false;
        foreach (string filterString in dataItem.FilterStrings)
        {
            if (frameName.Contains(filterString))
            {
                omitFrame = true;
            }
        }

CallstackCollapserDataItem 是我理论上需要从用户设置中检索字符串的地方。但是我无权访问任何 services/packages 以便例如请求 WritableSettingsStore,例如 You've Been Haacked's Example. Nor can I get my OptionPageGrid, like in the MSDN Options Example.

我尝试的另一件事是基于 。我覆盖了 OptionPageGrid 的 LoadSettingsFromStorage 函数,并试图在 dll 项目中的 public class 上设置静态变量。但是,如果该代码完全存在于 LoadSettingsFromStorage 函数中,则即使不进入该函数,设置也无法加载。这对我来说就像巫术。注释掉设置变量的行,断点正常命中,设置加载正常。还原了,功能都进不去了

我很茫然。我真的只是想将一个字符串传递到我的 Concord 扩展中,我真的不在乎如何传递。

好吧,显然我需要做的就是post这里的问题让我弄清楚最后的小部分。在我的 CallstackCollapserDataItem : DkmDataItem class 中,我添加了以下代码:

    private CallstackCollapserDataItem()
    {
        string registryRoot = DkmGlobalSettings.RegistryRoot;
        string propertyPath = "vsix\CallstackCollapserOptionPageGrid";
        string fullKey = "HKEY_CURRENT_USER\" + registryRoot + "\ApplicationPrivateSettings\" + propertyPath;
        string savedStringSetting = (string)Registry.GetValue(fullKey, "SearchStrings", "");

        string semicolonSeparatedStrings = "";
        // The setting resembles "1*System String*Foo;Bar"
        if (savedStringSetting != null && savedStringSetting.Length > 0 && savedStringSetting.Split('*').Length == 3)
        {
            semicolonSeparatedStrings = savedStringSetting.Split('*')[2];
        }
    }

vsix 是程序集,其中 CallstackCollapserOptionPageGrid 是一个 DialogPage,而 SearchStrings 是它的 public 属性,它保存在选项菜单之外。