I was one of the developers that ported the System.ComponentModel.DataAnnotations assembly to Silverlight.  Every once in awhile, someone asks me if the Silverlight version of the assembly is a subset of what is in .NET.  The answer is Yes, but there are some caveats, and I’m honestly tired of regurgitating the detailed answer.  With this blog post in place, I can now simply point people to a URL for the answer.  This is what we call DRY.

I’m sure that it goes without saying that the implementation details of the two assemblies differ.  In the .NET version, we have TypeDescriptor at our disposal, and it’s used to gather metadata about types and members.  In Silverlight, TypeDescriptor doesn’t exist, so raw Reflection is used in its place.  Moreover, .NET offers the MetadataTypeAttribute to allow metadata to be loaded from another type--Silverlight doesn’t support that either, so again the implementations differ rather significantly.  There are other reasons for implementation differences too, but it suffices to say that underneath the public API, the differences are manifold.

Public API Differences:

Type / Member

.NET

Silverlight

Notes

AssociatedMetadataTypeTypeDescriptionProvider

Yes

No

 

AssociationAttribute

Yes

Yes

 

AssociationAttribute.TypeId

Yes

No

Due to Attribute difference

ConcurrencyCheckAttribute

Yes

Yes

 

CustomValidationAttribute

Yes

Yes

 

CustomValidationAttribute.TypeId

Yes

No

Due to Attribute difference

DataType

Yes

Yes

 

DataTypeAttribute

Yes

Yes

 

DataTypeAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

DisplayAttribute

Yes

Yes

 

DisplayColumnAttribute

Yes

Yes

 

DisplayColumnAttribute.HtmlEncode

Yes

No

 

EditableAttribute

Yes

Yes

 

EnumDataTypeAttribute

Yes

Yes

 

EnumDataTypeAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

FilterUIHintAttribute

Yes

Yes

 

FilterUIHintAttribute.TypeId

Yes

No

Due to Attribute difference

IValidatableObject

Yes

No

 

KeyAttribute

Yes

Yes

 

MetadataTypeAttribute

Yes

No

 

RangeAttribute

Yes

Yes

 

RangeAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

RegularExpressionAttribute

Yes

Yes

 

RegularExpressionAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

RequiredAttribute

Yes

Yes

 

RequiredAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

ScaffoldColumnAttribute

Yes

No

 

ScaffoldTableAttribute

Yes

No

 

StringLengthAttribute

Yes

Yes

 

StringLengthAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

TimestampAttribute

Yes

Yes

 

UIHintAttribute

Yes

Yes

 

UIHintAttribute.TypeId

Yes

No

Due to Attribute difference

ValidationAttribute

Yes

Yes

 

ValidationAttribute.IsValid(Object)

Yes

No

Internal in Silverlight

ValidationAttribute.Validate(Object, String)

Yes

No

 

ValidationContext

Yes

Yes

 

ValidationContext.ServiceContainer

Yes

No

 

ValidationException

Yes

Yes

 

ValidationException.ctor(SerializationInfo, StreamingContext)

Yes

No

 

ValidationResult

Yes

Yes

Sealed in Silverlight, not in .NET

ValidationResult.ToString

Yes

No

Overridden in Silverlight, not in .NET

Validator

Yes

Yes