My experimental VSXtra project reached the third (alpha) release. This version has the following new features:
VsIde class representing the DTE2 object (root of the VSX object model). This class contains only a few methods and properties, including the DteInstance to access the DTE2 object from the package code without using the GetService method or even storing the instance.
VsIde contains "shortcuts" to execute Visual Studio commands:
if ((bool)view.ShowDialog())
{
VsIde.File.SaveAll();
DeleteRecentFileList(view.Model.SelectedListEntries);
VsIde.RestartVS();
}
VsRegistry class to access the registry settings of the VS instance the package runs within:
Console.WriteLine("*** Local registry root key: {0}",
VsRegistry.LocalRegistryRoot);
Console.WriteLine("*** List of recent projects:");
foreach (var item in VsRegistry.RecentProjectsList.OrderBy(k => k.Key))
{
Console.WriteLine(" {0}", item.Value);
}
RunningDocumentTable and RunningDocumentInfo classes to access the RDT, catch and handle RDT events:
public override void OnToolWindowCreated()
{
UIControl.SelectionTracker = SelectionTracker;
RunningDocumentTable.OnAfterAttributeChange += OnAfterAttributeChange;
// ...
}
//...
void OnAfterAttributeChange(object sender, RdtDocumentChangedEventArgs e)
{
if (Options.OptAfterAttributeChange) LogEvent(e);
}
SolutionEvents class to subscribe to all the Visual Studio events related to solution and project hierarchy.
SelectionTracker class to support property window handling
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (_IgnoreSelectedObjectsChanges) return;
var selectedObjects = new List<SelectionProperties>();
// --- Collect objects for selectedObjects
SelectionTracker.SelectObjects(selectedObjects, WindowsProperties);
}
EventHooker<> class to handle Advise and Unadvise methods and translate COM-like VS events to .NET event semantics
PackageBase now supports command handler methods and command actions
// ...
public sealed class ShowMessagePackage : PackageBase
{
[CommandExecMethod]
[CommandId(GuidList.guidShowMessageCmdSetString, CmdIDs.cmdidDisplayMyMessage)]
[ShowMessageAction("Hello, World from ShowMessagePackage")]
private static void DisplayMessage()
{
}
}
Subtle bug fixes and features
Right now the project does not have a complete documentation of features but you can download many well-commented examples with the source code. These definitely will help you to understand VSXtra details.
The VSXtra Runtime binary can be downloaded from here.
Posted
Aug 07 2008, 04:04 PM
by
inovak