Pablo Galiano : Wednesday, June 06, 2007 - Posts

Subscriptions

<March 2010>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News

Subscribe to Pablo Galiano by Email

Post Categories

Wednesday, June 06, 2007 - Posts

Dealing with DTE properties collections

There are a bunch of DTE classes that expose a Properties collection property such as:

  • EnvDTE.Project.Properties
  • EnvDTE.ProjectItem.Properties
  • EnvDTE.Configuration.Properties

    The properties collection are not typed because they depend on the project type, language and so on. Unfortunately there is no documentation in the MSDN for the list of collection property names.

    So you basically end up doing something like this:

        public void GetPropertyValues(EnvDTE.Properties properties)

        {

            foreach(EnvDTE.Property property in properties)

            {

                try

                {

                    Debug.WriteLine(

                        string.Format("Property Name: {0} - Property Value: {1}",

                            property.Name, property.Value.ToString));

                }

                catch

                {

                }

            }

        }

    And once you find the one that you want, you do:

    ProjectItem.Properties.Item("PropertyName").Value ...

    But with the help of Reflector you can reflect the following interfaces to get a list of property names:

    For project item properties:

  • VSLangProj.FileProperties
  • VSLangProj.FolderProperties
  • VSLangProj80.FileProperties2
  • VSLangProj80.FolderProperties2

    For project properties:

  • VSLangProj.ProjectProperties
  • VSLangProj2.ProjectProperties2
  • VSLangProj80.ProjectProperties3
  • VSLangProj.ProjectConfigurationProperties
  • VSLangProj2.ProjectConfigurationProperties2
  • VSLangProj80.ProjectConfigurationProperties3

    Pablo

  • posted Wednesday, June 06, 2007 9:10 AM by pga with 3 Comments