1

I'm writing a visual studio extension based on the Concord Samples Hello World project. The goal is to let the user filter out stack frames by setting a list of search strings. If any of the search strings are in a stack frame, it is omitted.

I've got the filter working for a hardcoded list. That needs to be in a non-package-based dll project in order for the debugger to pick it up. And I have a vsix project that references that dll with an OptionPageGrid to accept the list of strings. But I can't for the life of me find a way to connect them.

On the debugger side, my code looks something like this:

    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;
            }
        }

The CallstackCollapserDataItem is where I theoretically need to retrieve the strings from user settings. But I don't have access to any services/packages in order to e.g. ask for WritableSettingsStore, like in You've Been Haacked's Example. Nor can I get my OptionPageGrid, like in the MSDN Options Example.

The other thing I tried was based on this StackOverflow question. I overrode the LoadSettingsFromStorage function of my OptionPageGrid and attempted to set a static variable on a public class in the dll project. But if that code existed in the LoadSettingsFromStorage function at all, the settings failed to load without even entering the function. Which felt like voodoo to me. Comment out the line that sets the variable, the breakpoint hits normally, the settings load normally. Restore it, and the function isn't even entered.

I'm at a loss. I really just want to pass a string into my Concord extension, and I really don't care how.

Bill Clark
  • 21
  • 4
  • Worth noting that while my setting from the OptionGridPage persists across runs of the 14.0Exp session, I can't find it in the registry anywhere. The dialog page has the following SettingsRegistryPath: "DialogPage\\vsix.CallstackCollapserOptionPageGrid" and the DkmGlobalSettings.RegistryRoot is: "Software\\Microsoft\\VisualStudio\\14.0Exp" But try as I might, I can't find anything matching in my registry. – Bill Clark Nov 27 '17 at 02:17
  • There it is: Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0Exp\ApplicationPrivateSettings\vsix\CallstackCollapserOptionPageGrid – Bill Clark Nov 27 '17 at 02:26

1 Answers1

1

Ok, apparently all I needed to do was post the question here for me to figure out the last little pieces. In my CallstackCollapserDataItem : DkmDataItem class, I added the following code:

    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 is the assembly in which CallstackCollapserOptionPageGrid is a DialogPage, and SearchStrings is its public property that's saved out of the options menu.

Bill Clark
  • 21
  • 4
  • Since this issue is resolved now, you could mark it as the answer, so it could help other community members who get the same issue as yours. Thanks for your sharing:) – Jack Zhai Nov 28 '17 at 06:09
  • Thanks for the reminder. It doesn't let you accept your own answer for 2 days, but now that time has passed. – Bill Clark Nov 29 '17 at 06:45