envdte

Is there an elegant way to make a EnvDTE.CodeProperty ReadOnly?

I need to switch my CodeProperty between read only and read / write. I can achive this with Edit points and ReplaceText so: if(readOnly) { CodeFunction setter = codeProperty.Setter; TextPoint start = setter.StartPoint; TextPoint end = setter.EndPoint; start.CreateEditPoint().ReplaceText(end, string.Empty, 0); } else { CodeFunction ...

Are there differences between EnvDTE or CodeDom when generating Code

I have the requirement to generate and read some CS classes with a DSL, I have adopted one method for reading the CS files using EnvDTE and my colleague has used CodeDom to produce the CS files. Is it just sugar or is there a big difference between... codeClass.AddFunction("DoSomething", vsCMFunction.vsCMFunctionFunction, "bool"); an...

Capture window close event

I want to capture events that close editor window (tab) in Visual Studio 2008 IDE. When I use dte2.Application.Events.get_CommandEvents(null, 0).BeforeExecute I successfully captured such events: File.Close File.CloseAllButThis File.Exit Window.CloseDocumentWindow and others. If code in window is not acceptable, I stop the event (C...

EnvDTE.CodeClass.Base.Fullname does not give proper name for VB types

Public Class c1(Of T) End Class Public Class c2 Inherits c1(Of Integer) End Class For the following peice of code, if we try to get the CodeClass.Base.Fullname, it gives the fullname as "c1(Of T)". Ideally it should give the fullname of the instance i.e. "c1(Of Integer)". The CodeModel API behaves differently for VB and C# codes. ...

How can you add code to a Designer.cs file using the DTE classes?

I'm writing an IWizard Item Template, which will be adding code to a Form.Designer.cs file that already exists in the project, but I can't find a way to force new code to write to that file, rather than Form.cs. How do you specify which partial class to write code to in the CodeModel and other DTE classes? Project project = dte.Solutio...

How to create CodeFunction2 with IEnumerable<> Type?

Hi All, I really need to create something like the following, I am building 2 classes, the first is a class with the name of tableNameAsSingular (i.e AddressEntity) , in my second worker class I need to having something like the following public IEnumerable<AddressEntity> GetAddressEntity() { // the good stuff... } When creating the ...

How to get [#]region structure from (Document, ProjectItem, FileCodeModel in EnvDTE)

Hi to all, I'm developing the integrated Package which show structure of code (C#, VB) in TreeView of my control window. I found a SourceCodeOutliner project in (http://www.codeplex.com/SourceCodeOutliner) and translate it to C#. I'd learn how to get a project structure for file, but at now I want to add into my treeView [#]regions s...

VB.NET EnvDTE Up-To-Date check before building project

Hi all, how do I check if a project is up-to-date? I'm basically trying to programmatically build each project in a list but only if they have changed. So does anyone know of a way (using EnvDTE maybe) to check if a project changed and therefore needs to compile? Thanks in advance for all the help. ...

error while trying to create DTE2 Interface object with ruby

I am trying to use ruby win32ole lib and DTE2 Interface to control visual studio 8 \ tried this require 'win32ole' ide = WIN32OLE.new('EnvDTE80.DTE2') and received this error unknown OLE server: EnvDTE80.DTE2 what am I doing wrong, can this work at all ? ...

Can you access 'Service Reference' Programmatically?

Info: C#, Visual Studio 2010 I am trying to access the existing service references and am not sure how, I can achieve the following to get all 'references' DTE2 test = Package.GetGlobalService(typeof(SDTE)) as DTE2; StringBuilder sb = new StringBuilder(); VSProject2 project = test.ActiveDocument.ProjectItem.ContainingProject.Object as ...

EnvDTE partial class keyword

I'm introspecting on the code in a project using EnvDTE, and I want to be able to determine if they're a partial class, but it doesn't seem to exist in the namespace. Does anyone know how to do this? ...

Get ProjectItems for Partial Class through CodeModel

I have seen looking for a way to get the list of ProjectItems (files) for a known class, which generated from several partial classes. I use CodeModel to search for a class and accessing the ProjectItem to do stuff, which works fine for normal classes. But when it comes to partial classes, the ProjectItem property give one file but dont ...

Remove a keyboard shortcut binding in Visual Studio using Macros

Hi. I have a lot of custom keyboard shortcuts set up. To avoid having to set them up every time I install a new visual studio (happens quite a lot currectly, with VS2010 being in beta/RC) I have created a macro, that sets up all my custom commands, like this: DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Glo...

Can you do a RunCustomTool with EnvDTE as a pre-build event?

I am using T4MVC, and I can't use a pre-build event to run TextTransform.exe as it relies on EnvDTE, and must be run with Visual Studio as host. If I have run custom tool once, it works nicely because it marks itself dirty when its executed (AlwaysKeepTemplateDirty = true), but when you open the solution, it doesn't run on build, so I w...

OnBuildBegin does not fire in Visual Studio Macro until I run it from Macro Explorer

I have the following Visual Studio Macro: Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports MyMacros.EnvironmentEvents Imports System.Diagnostics Public Module Module1 Private WithEvents buildEvents As EnvDTE.BuildEvents = EnvironmentEvents.BuildEvents Public Sub BuildEvents_OnBuildBegin() Handles buildE...

Programmatically add a WCF Service Project Item

Info: C#, Visual Studio 2010 RC How can I add a WCF Web Service Project Item to my Project via code? I can add a Code Class file no problem with: string csItemTemplatePath = soln.GetProjectItemTemplate("CodeFile", "CSharp"); try { projectItems.AddFromTemplate(csItemTemplatePath, fileName); } catch (Exception ex) { // This is ...

C# equivalent of the C++ custom project Wizard

Hi., I have an existing wizard template created for VC++ from year back, ported to VS2008. It uses the custom wizard jscript/html templating system and DTE object. I've used this successfully for years, but now I want to create an entry for a standard C# project, I see there's no way to customise the C# project settings - the methods a...

Finding a ProjectItem by type name via DTE

Given a type name, is it possible to use DTE to find the ProjectItem that the type is located in? Something similar to how the Navigate To... dialog works in Visual Studio 2010. The closest I could find is Solution.FindProjectItem, but that takes in a file name. Thanks! ...

EnvDTE: ArgumentException when accessing the ActiveConfiguration

I'm writing an addin for Visual Studio 2008. At some point in my code, I'm attempting to access the current active configuration for a project: var configName = _Project.ConfigurationManager.ActiveConfiguration.ConfigurationName; Sometimes, in some very obscure cases, the getter for ActiveConfiguration throws an ArgumentException. Not...

Accessing .vsprops (Property Sheets) via VS Automation and Extension

I am trying to access user macros that are defined in a .vsprops (Property Sheet) that is used by a Visual Studio 2008 project. I cannot find any documentation on accessing any information in a .vsprops file using VS automation and extension functionality (i.e., EnvDTE et al). Does anyone know if this is possible? ...