slimCODE

commUNITY
Welcome to slimCODE Sign in | Join | Help
in Search

Plugin Lifecycle

Last post 02-07-2007, 11:39 by slimcode. 4 replies.
Sort Posts: Previous Next
  •  02-06-2007, 21:18 187

    Plugin Lifecycle

    Firstly, wow. You write nice code.

    Secondly, I've only looked at the SDK for an our or two, but I still don't have a great sense for a plugin's lifecycle. Like which methods get called when. What would help alot is a very bare bones "plugin harness". Maybe a simple WinForms app that loads the plugin and a textbox for slimLaunch testing. I just want to see what gets called when without having to attach to the slimKeys process.
     

  •  02-06-2007, 22:44 188 in reply to 187

    Re: Plugin Lifecycle

    Hmmm, creating a separate application that calls the same methods on the plug-in as slimKEYS would be dangerous. It may not reproduce the exact behavior as slimKEYS, and I would have two code bases to maintain. What I can do is modify one of the plug-in samples in the SDK to create a plug-in that outputs information about what is being called when.

    What you can do to trace your plug-in is simply to debug slimKEYS itself. You can make your project run slimKEYS on debug, or simply attach to the slimKEYS process ("Debug" menu, "Attach to process" sub-menu). From there, you can put a breakpoint on your provider's constructor, then in the methods you are curious about. The provider's constructor that takes a HotKeyManager parameter is the starting point. You can add a post-build step that copies your plug-in output filename in the slimKEYS "plugins" subfolder, or you can test "first-time use" by making sure your plug-in is NOT in the "plugins" subfolder, start debugging slimKEYS, then manually copy your DLL (and PDB?) file to the "plugins" subfolder. slimKEYS should prompt you if you would like to run this new plug-in. If you press "Yes", the provider's constructor will get called and the party begins.

    I'll try to build something to clarify how plug-ins work, either in code or some blog post. Hang on!

  •  02-07-2007, 7:37 190 in reply to 188

    Re: Plugin Lifecycle

    I understand your reluctance to maintain two "code bases", but it really doesn't have to be much more than a test fixture and a utility method that takes a HotKeyHandlerProvider and accesses the provider's members in the order in which the app does. If you have unit tests, I imagine you would have such a test fixture to ensure each plugin you've written gets initialized properly. In fact, if you have unit tests, I probably only need the most generic one or two tests.

    In anycase, I've sprinkled calls to the following throughout all members in the HelloSlimLaunch assembly and am probably good to go:

          private static string WhereAmI( MethodBase method )
          {
              string info    = String.Format( "Called {0}.{1}", method.DeclaringType.Name, method.Name );
              string[] lines = Environment.StackTrace.Split( Environment.NewLine.ToCharArray() );

              if( lines.Length >= 8 )
                  return String.Concat( info, Environment.NewLine, "By ", lines[ 8 ].Remove( 0, 6 ) );

              return info;
          }
     

  •  02-07-2007, 7:53 191 in reply to 190

    Re: Plugin Lifecycle

    Excellent. The following will help alot:

    Called HelloSlimLaunchHotKeyHandlerProvider..ctor
    By System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
    Called HelloSlimLaunchHotKeyHandlerProvider.Initialize
    By SlimCode.SlimKeys.GlobalHotKeyManager.LoadPlugIn(String filename, String folder, Boolean setupProviders)
    Called HelloSlimLaunchHotKeyHandlerProvider.get_Verb
    By SlimCode.SlimKeys.GlobalHotKeyManager.LoadPlugIn(String filename, String folder, Boolean setupProviders)
    Called HelloSlimLaunchHotKeyHandlerProvider.Setup
    By SlimCode.SlimKeys.GlobalHotKeyManager.LoadPlugIn(String filename, String folder, Boolean setupProviders)
    Called HelloSlimLaunchItemSource..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchHotKeyHandlerProvider.Setup() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchHotKeyHandlerProvider.cs:line 169
    Called HelloSlimLaunchItemSource.StartUpdate
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchHotKeyHandlerProvider.Setup() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchHotKeyHandlerProvider.cs:line 173
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 167
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 168
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 169
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 170
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 171
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 172
    Called HelloSlimLaunchItem..ctor
    By SlimCode.SlimKeys.Samples.HelloSlimLaunch.HelloSlimLaunchItemSource.StartUpdate() in C:\Program Files\slimCODE\slimKEYS SDK\Samples\HelloSlimLaunch\HelloSlimLaunch\HelloSlimLaunchItemSource.cs:line 173
    Called HelloSlimLaunchHotKeyHandlerProvider.get_Verb
    By SlimCode.SlimKeys.HotKeysForm.RefreshHotKeyList()
    Called HelloSlimLaunchHotKeyHandlerProvider.get_Verb
    By SlimCode.SlimKeys.HotKeysForm.RefreshHotKeyList()
    Called HelloSlimLaunchHotKeyHandlerProvider.get_Description
    By SlimCode.SlimKeys.HotKeysForm.RefreshHotKeyList()
    Called HelloSlimLaunchItemSource.get_Name
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchHotKeyHandler.get_Description()
    Called HelloSlimLaunchHotKeyHandlerProvider.get_CanAddNewHotKeys
    By SlimCode.SlimKeys.HotKeysForm.RefreshHotKeyList()
    Called HelloSlimLaunchItemSource.PauseUpdate
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchHotKeyHandler.PauseUpdate()
    Called HelloSlimLaunchItemSource.get_Items
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchHotKeyHandler.UpdateCommand(String command)
    Called HelloSlimLaunchItem.get_SupportedKeys
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_SelectedIndexChanged(Object sender, EventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItemSource.get_Items
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchHotKeyHandler.UpdateCommand(String command)
    Called HelloSlimLaunchItem.get_SupportedKeys
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_SelectedIndexChanged(Object sender, EventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.Launch
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.SlimLaunchForm_KeyDown(Object sender, KeyEventArgs e)
    Called HelloSlimLaunchItem.DrawIcon
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItem.get_Description
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchForm.MatchingItemListBox_DrawItem(Object sender, DrawItemEventArgs e)
    Called HelloSlimLaunchItemSource.ResumeUpdate
    By SlimCode.SlimKeys.SlimLaunch.SlimLaunchHotKeyHandler.ResumeUpdate()
     

  •  02-07-2007, 11:39 193 in reply to 191

    Re: Plugin Lifecycle

    Thanks!

    It seems we had the same idea. I created the following plug-in sample, which is both a slimKEYS plug-in for displaying debug traces, and a slimLAUNCH extension for browsing Fibonacci values at specific ranks (how useful! Tongue Tied).

    I'm still not sure a separate plug-in test app is a good idea. I'm thinking more about a debug build of slimKEYS. I'll think about this a little more...

View as RSS news feed in XML