Click here to Skip to main content
15,895,709 members
Articles / Desktop Programming / Windows Forms

Project Metadata Generation using T4

Rate me:
Please Sign up or sign in to vote.
4.97/5 (45 votes)
7 Nov 2009BSD16 min read 168.7K   1.5K   152  
Generate project metadata with T4 and unburden yourself from string literals in XAML binding expressions and INotifyPropertyChanged event arguments.


// ReSharper disable PossibleNullReferenceException
/*
This code was automatically generated by Daniel Vaughan's metadata generator.
Changes to this file may be lost if regeneration occurs.
http://danielvaughan.orpius.com
*/
using System.Windows;
using System;
using System.Linq;
using System.Linq.Expressions;


namespace CSharpDesktopClrDemo.XamlMetadata.Metadata
{
    /// <summary>Metadata for XAML Window1.xaml</summary>
    public static class Window1XamlMetadata
    {
            /// <summary>Represents x:Key="Person"/></summary>
            public static string PersonKey { get { return "Person"; } }


    }

}

    /// <summary>Metadata for class <see cref="SimpleClass"/></summary>
    public static class SimpleClassMetadata
    {
                /// <summary>Refers to property <see cref="SimpleClass.Property0"/></summary>
        public const string Property0 = "Property0";

        /// <summary>Refers to property <see cref="SimpleClass.Property1"/></summary>
        public const string Property1 = "Property1";

        /// <summary>Refers to property <see cref="SimpleClass.Property2"/></summary>
        public const string Property2 = "Property2";


        /// <summary>Refers to property <see cref="SimpleClass.Property0"/></summary>
        public static PropertyPath Property0Path { get { return new PropertyPath("Property0"); } }

        /// <summary>Refers to property <see cref="SimpleClass.Property1"/></summary>
        public static PropertyPath Property1Path { get { return new PropertyPath("Property1"); } }

        /// <summary>Refers to property <see cref="SimpleClass.Property2"/></summary>
        public static PropertyPath Property2Path { get { return new PropertyPath("Property2"); } }

    }


namespace DanielVaughan.MetaGen.Demo.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.App"/></summary>
    public static class AppMetadata
    {
        
    }

    /// <summary>Metadata for interface <see cref="DanielVaughan.MetaGen.Demo.IPerson"/></summary>
    public static class IPersonMetadata
    {
                /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Name"/></summary>
        public const string Name = "Name";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Address"/></summary>
        public const string Address = "Address";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Age"/></summary>
        public const string Age = "Age";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Name"/></summary>
        public static PropertyPath NamePath { get { return new PropertyPath("Name"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Address"/></summary>
        public static PropertyPath AddressPath { get { return new PropertyPath("Address"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Age"/></summary>
        public static PropertyPath AgePath { get { return new PropertyPath("Age"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Person"/></summary>
    public static class PersonMetadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.name"/></summary>
        public const string name = "name";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Name"/></summary>
        public const string Name = "Name";

        /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.address"/></summary>
        public const string address = "address";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Address"/></summary>
        public const string Address = "Address";

        /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.age"/></summary>
        public const string age = "age";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Age"/></summary>
        public const string Age = "Age";

        /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Person.ObfuscationTest"/></summary>
        public const string ObfuscationTest = "ObfuscationTest";

        /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Person.OnPropertyChanged"/></summary>
        public const string OnPropertyChanged = "OnPropertyChanged";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Name"/></summary>
        public static PropertyPath NamePath { get { return new PropertyPath("Name"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Address"/></summary>
        public static PropertyPath AddressPath { get { return new PropertyPath("Address"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Age"/></summary>
        public static PropertyPath AgePath { get { return new PropertyPath("Age"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Address"/></summary>
    public static class AddressMetadata
    {
                /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Address.StreetLine"/></summary>
        public const string StreetLine = "StreetLine";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Address.StreetLine"/></summary>
        public static PropertyPath StreetLinePath { get { return new PropertyPath("StreetLine"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension"/></summary>
    public static class JoinPathExtensionMetadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.members"/></summary>
        public const string members = "members";

        /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.ProvideValue"/></summary>
        public const string ProvideValue = "ProvideValue";

        /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.SetMember"/></summary>
        public const string SetMember = "SetMember";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member0"/></summary>
        public const string Member0 = "Member0";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member1"/></summary>
        public const string Member1 = "Member1";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member2"/></summary>
        public const string Member2 = "Member2";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member3"/></summary>
        public const string Member3 = "Member3";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member4"/></summary>
        public const string Member4 = "Member4";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member5"/></summary>
        public const string Member5 = "Member5";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member6"/></summary>
        public const string Member6 = "Member6";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member7"/></summary>
        public const string Member7 = "Member7";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member8"/></summary>
        public const string Member8 = "Member8";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member9"/></summary>
        public const string Member9 = "Member9";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member10"/></summary>
        public const string Member10 = "Member10";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member0"/></summary>
        public static PropertyPath Member0Path { get { return new PropertyPath("Member0"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member1"/></summary>
        public static PropertyPath Member1Path { get { return new PropertyPath("Member1"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member2"/></summary>
        public static PropertyPath Member2Path { get { return new PropertyPath("Member2"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member3"/></summary>
        public static PropertyPath Member3Path { get { return new PropertyPath("Member3"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member4"/></summary>
        public static PropertyPath Member4Path { get { return new PropertyPath("Member4"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member5"/></summary>
        public static PropertyPath Member5Path { get { return new PropertyPath("Member5"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member6"/></summary>
        public static PropertyPath Member6Path { get { return new PropertyPath("Member6"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member7"/></summary>
        public static PropertyPath Member7Path { get { return new PropertyPath("Member7"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member8"/></summary>
        public static PropertyPath Member8Path { get { return new PropertyPath("Member8"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member9"/></summary>
        public static PropertyPath Member9Path { get { return new PropertyPath("Member9"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.JoinPathExtension.Member10"/></summary>
        public static PropertyPath Member10Path { get { return new PropertyPath("Member10"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Window1"/></summary>
    public static class Window1Metadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Window1.stateToggled"/></summary>
        public const string stateToggled = "stateToggled";

        /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Window1.Button_ChangeClick"/></summary>
        public const string Button_ChangeClick = "Button_ChangeClick";


    }

}

namespace DanielVaughan.MetaGen.Demo.Folder1.Metadata
{
    /// <summary>Metadata for interface <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface"/></summary>
    public static class Folder1InterfaceMetadata
    {
                /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface.Foo"/></summary>
        public const string Foo = "Foo";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface.Foo"/></summary>
        public static PropertyPath FooPath { get { return new PropertyPath("Foo"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass"/></summary>
    public static class Folder1StaticClassMetadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringConstant"/></summary>
        public const string StringConstant = "StringConstant";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringStaticProperty"/></summary>
        public const string StringStaticProperty = "StringStaticProperty";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringStaticProperty"/></summary>
        public static PropertyPath StringStaticPropertyPath { get { return new PropertyPath("StringStaticProperty"); } }

    }

}

namespace DanielVaughan.MetaGen.Demo.Folder1.Folder2.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class"/></summary>
    public static class Folder2ClassMetadata
    {
                /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Foo"/></summary>
        public const string Foo = "Foo";

        /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass"/></summary>
        public static class Folder2InnerClassMetadata
        {
                        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass.Foo2"/></summary>
            public const string Foo2 = "Foo2";


            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass.Foo2"/></summary>
            public static PropertyPath Foo2Path { get { return new PropertyPath("Foo2"); } }

        }


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Foo"/></summary>
        public static PropertyPath FooPath { get { return new PropertyPath("Foo"); } }

    }

}

namespace CSharpDesktopClrDemo.XamlMetadata.Folder1.Metadata
{
    /// <summary>Metadata for XAML MainDictionary.xaml</summary>
    public static class MainDictionaryXamlMetadata
    {
            /// <summary>Represents x:Key="ButtonBackground"/></summary>
            public static string ButtonBackgroundKey { get { return "ButtonBackground"; } }

            /// <summary>Represents x:Key="MyBrush"/></summary>
            public static string MyBrushKey { get { return "MyBrush"; } }

            /// <summary>Represents x:Key="ButtonStyle"/></summary>
            public static string ButtonStyleKey { get { return "ButtonStyle"; } }


    }

}

namespace DanielVaughan.MetaGen.Demo.Properties.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources"/></summary>
    public static class ResourcesMetadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.resourceMan"/></summary>
        public const string resourceMan = "resourceMan";

        /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.resourceCulture"/></summary>
        public const string resourceCulture = "resourceCulture";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.ResourceManager"/></summary>
        public const string ResourceManager = "ResourceManager";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.Culture"/></summary>
        public const string Culture = "Culture";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.ResourceManager"/></summary>
        public static PropertyPath ResourceManagerPath { get { return new PropertyPath("ResourceManager"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.Culture"/></summary>
        public static PropertyPath CulturePath { get { return new PropertyPath("Culture"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings"/></summary>
    public static class SettingsMetadata
    {
                /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.defaultInstance"/></summary>
        public const string defaultInstance = "defaultInstance";

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.Default"/></summary>
        public const string Default = "Default";


        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.Default"/></summary>
        public static PropertyPath DefaultPath { get { return new PropertyPath("Default"); } }

    }

}

// ReSharper restore PossibleNullReferenceException

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
Engineer
Switzerland Switzerland
Daniel is a former senior engineer in Technology and Research at the Office of the CTO at Microsoft, working on next generation systems.

Previously Daniel was a nine-time Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company.

Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.

Daniel is the developer behind several acclaimed mobile apps including Surfy Browser for Android and Windows Phone. Daniel is the creator of a number of popular open-source projects, most notably Codon.

Would you like Daniel to bring value to your organisation? Please contact

Blog | Twitter


Xamarin Experts
Windows 10 Experts

Comments and Discussions