How Does the MetadataView Work?

Mar 16, 2009 at 6:14 PM

I got a surprise when I used this attribute 

   [MetadataAttribute()]
   public class T4DirectiveProcessorCompositionAttribute : ExportCompositionBaseAttribute, IT4DirectiveProcessorComposition
   {
      private string _providerName;

      public T4DirectiveProcessorCompositionAttribute(string providerName)
         : base(typeof(T4DirectiveProcessorCompositionAttribute))
      {
         _providerName = providerName;
      }

      public T4DirectiveProcessorCompositionAttribute(Type provider)
         : base(typeof(T4DirectiveProcessorCompositionAttribute))
      {
         _providerName = provider.GetType().FullName;
      }
      public string ProviderName
      {
         get
         {
            return _providerName;
         }
      }
   }

My intention was to provide a secondary way to determine an attribute value which is a string (a text file which is a T4 template may determine which provider to use):

   [Export(typeof(IT4DirectiveProcessor))]
   [T4DirectiveProcessorComposition(typeof(PropertyProvider))]
   public class PropertyProvider : DirectiveProcessor, IT4DirectiveProcessor
   {

But, what I see is:

? exports[0].Metadata
Count = 3
    [0]: {[ProviderName, System.RuntimeType]}
    [1]: {[Id, AppVenture.Common.T4DirectiveProcessorCompositionAttribute]}
    [2]: {[Priority, 0]}

I thought you were pulling these values from public properties in the attribute because the only place hte ID and Priority reside in this case is those properties and their backing fields (the defaults are included here).

So, the question is: Why RuntimeType and not the string I expect?