You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.9 KiB

15 years ago
15 years ago
15 years ago
  1. ILSpy uses MEF (Managed Extensibility Framework) for plugins.
  2. Plugins must be placed in the same directory as ILSpy.exe, and must be called "*.Plugin.dll".
  3. To write a plugin, you need to add a reference to ILSpy.exe and to System.ComponentModel.Composition.
  4. Depending on what your plugin is doing, you might also need references to the other libraries shipping with ILSpy.
  5. Plugins work by exporting types for certain extension points.
  6. Here is a list of extension points:
  7. Adding another language:
  8. [Export(typeof(Language))]
  9. public class CustomLanguage : Language
  10. This adds an additional language to the combobox in the toolbar.
  11. The language has to implement its own decompiler (all the way from IL), but it can also re-use
  12. the ICSharpCode.Decompiler library to decompile to C#, and then translate the C# code to the target language.
  13. ---
  14. Adding an entry to the main menu:
  15. [ExportMainMenuCommand(Menu = "_File", MenuIcon = "Clear.png", Header = "_Clear List", MenuCategory = "Open", MenuOrder = 1.5)]
  16. public class UnloadAllAssembliesCommand : SimpleCommand
  17. Menu: menu into which the item is added
  18. MenuIcon: optional, icon to use for the menu item. Must be embedded as "Resource" (WPF-style resource) in the same assembly as the command type.
  19. Header: text on the menu item
  20. MenuCategory: optional, used for grouping related menu items together. A separator is added between different groups.
  21. MenuOrder: controls the order in which the items appear (items are sorted by this value)
  22. The command class must implement WPF's ICommand interface.
  23. ---
  24. Adding an entry to the tool bar:
  25. [ExportToolbarCommand(ToolTip = "Clears the current assembly list", ToolbarIcon = "Clear.png", ToolbarCategory = "Open", ToolbarOrder = 1.5)]
  26. public class UnloadAllAssembliesCommand : SimpleCommand
  27. ToolTip: the tool tip
  28. ToolbarIcon: The icon. Must be embedded as "Resource" (WPF-style resource) in the same assembly as the command type.
  29. ToolbarCategory: optional, used for grouping related toolbar items together. A separator is added between different groups.
  30. ToolbarOrder: controls the order in which the items appear (items are sorted by this value)
  31. The command class must implement WPF's ICommand interface.
  32. ---
  33. Adding an entry to the context menu:
  34. [ExportContextMenuEntry(Header = "_Save Assembly")]
  35. public class SaveAssembly : IContextMenuEntry
  36. Icon: optional, icon to use for the menu item. Must be embedded as "Resource" (WPF-style resource) in the same assembly as the command type.
  37. Header: text on the menu item
  38. Category: optional, used for grouping related menu items together. A separator is added between different groups.
  39. Order: controls the order in which the items appear (items are sorted by this value)
  40. Context menu entries must implement IContextMenuEntry, which defines 3 methods:
  41. bool IsVisible, bool IsEnabled, and void Execute.
  42. ---
  43. Adding an option page:
  44. [ExportOptionPage("TestPlugin")]
  45. partial class CustomOptionPage : UserControl, IOptionPage