Quantcast
Channel: Managed Extensibility Framework
Viewing all articles
Browse latest Browse all 265

Created Unassigned: MEF2 error with custom metadata attributes [14625]

$
0
0
The nuget version of MEF (MEF2?) can't handle null values on custom metadata attributes when AllowMultiple is true. It will try to construct an array (which is ok) but TypeInspector.AddMetadata calls existingValue.GetType() -- if the metadata value is null this throws an exception.

An example is implementing a VS-style order attribute where you are supposed to set either the Before or After property but usually not both.

[MetadataAttribute]
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public sealed class OrderAttribute : Attribute
{
public string Before { get; set; }
public string After { get; set; }
}


Viewing all articles
Browse latest Browse all 265

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>