I am using the Description attribute in my enums to provide a user friendly name to an enum field. e.g.
public enum InstallationType
{
[Description(\"For
Whether something is available to a portable class library depends a bit on exactly which frameworks you selected for the library - you get the strict intersection only. However, it could well be that this attribute simply doesn't exist in one of your targeted frameworks. In which case, one option is add your own - then you know it is available. For example:
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class EnumDescriptionAttribute :Attribute
{
private readonly string description;
public string Description { get { return description; } }
public EnumDescriptionAttribute(string description)
{
this.description = description;
}
}
enum Foo
{
[EnumDescription("abc")]
A,
[EnumDescription("def")]
B
}
Note that I intentionally haven't included the additional serialization construtors here, because those too depend on features that are not available on all frameworks. Changing your code from using [Description] / DescriptionAttribute to [EnumDescription] / EnumDescriptionAttribute should be fairly trivial.