Is there a standard framework (maybe part of Enterprise Library… or .NET itself) that allows you to do common parameter validation in method attributes?
Is there a standard framework (maybe part of Enterprise Library… or .NET itself) that
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Microsoft Code Contracts, which are part of .NET Framework since 4.0 CTP and are available for earlier .NET Framework versions as a stand-alone package, allow to specify coding assumptions. This includes specifying pre-conditions which can verify parameters.
An example use for parameter checking would be (copied from Code Contracts documentation):
The benefit of using Code Contracts is that it is a library which will be part of future .NET Framework releases, so sooner or later you will have one dependency less in your application.
EDIT: Just noticed that your specifically asking for a library that uses Attributes for argument checking… that Code Contracts does not. The reason why Code Contracts does not use attributes is listed in their FAQ: