Tips for IDE Extension development
- Last UpdatedJul 23, 2024
- 3 minute read
This section points out common pitfalls an IDE extension developer should avoid while developing an extension and recommends some optimizations.
-
The extension class (adorned with “aaPluginAttribute” custom attribute) must be public, otherwise the IDE won’t be able to instantiate it.
-
The command target class being registered for a command (the class, which implements “IaaCommandTarget” interface) should be extension public class, otherwise command routing will be indeterminist.
-
Ensure “IaaIDEView.SelectObject” method implementation checks for “NameSpace” property of the object when a galaxy object is requested.
-
If an extension does not register to “ServiceAdded” and “ServiceRemoved” events from the “IaaServiceProvider” interface then it must not cache queried service pointer, since service could un-register itself from the pool in the meantime.
-
Service pointer must be checked for non-null value after being queried from the service pool.
-
Minimize processing (especially any UI processing) done in the “IaaSnapin.Uninitialize” method implementation, since the IDE might be shutting down during the call.
-
Ensure “IaaSelectionSource.SelectedObjects” property getter implementation is as optimized as possible, since it is called upon every single selection change.
-
When publishing objects in the selection service, providing common base type closest to the selected objects would optimize performance.
-
When updating context sensitive commands when multiple objects are selected, check the common base type and not the actual objects for better performance.
-
General rules for command and command UI vector updates mentioned in “General Configuration and IDE DFS.doc” (FR89), related to enabling, disabling, showing and hiding UI vectors should be followed by all IDE extensions for uniformity.
-
In order to add a new command and its corresponding command UI vectors like a menu item or a toolbar button, developer should follow steps mentioned below.
-
Add a new command in the extension’s manifest file as described in the section “How to Add a New Command”.
-
Add a new menu item in the extension’s manifest file as described in the section “How to Extend IDE Menus”. Please refer to the sections “How to Extend IDE Toolbar” to add a new toolbar button and the section “How to Extend Context Menus” to add a new context menu item.
-
Add code to register/un-register command target. Typically extensions register their command targets in “IaaSnapin.Initialize”, whereas un-register them in “IaaSnapin.Uninitialize” method implementations.
-
Add code for the command target by implementing “IaaCommandTarget” interface, which has two methods, “OnUpdate” and “OnInvoke”. These methods are called by the IDE to give extension chance to update and handle command invocation respectively. Please see section “Handling Commands” for more detailed information on how to register and handle commands.
-
-
Adding a menu separator – Extension developer can add a separator to main menu or to the context menu by adding “Separator” tag in the manifest resource file. Following is an example of a menu separator.
<Resources>
<Separator ParentId="Object" ReferencedTo="Object/ViewObjViewer"
ReferencePosition="Before"/>
</Resources>
Its ParentId attribute indicates the menu the separator should be added to and for context menu it should be context menu id. ReferencedTo and ReferencePosition attributes dictate relative position of the separator with respect to some other menu item.
-
Adding a top-level menu – In order to add a top-level menu, extensions developer should add “Menu” tag in the manifest resource file, wherein the “ParentId” attribute value must be “menubarMain” as shown in the following example.
<Resources>
<Menu Id = "SpecialImport" ParentId="Galaxy">
<Text>Special I&mport</Text>
</Menu>
</Resources>