G
Glen
I'm working on a custom assembly and I'm trying to figure out the best
approach to handling known constraints within the assembly, once
compiled, to alert the developer at compile time of a potential issue.
For example, in the assembly I would like to add a constraint that
states a particular property member of the class can not be equal to one
other property. In standard coding I can throw an exception during
run-time, but I would rather have the constraint work during compile to
throw an error or warning to the developer.
Other constraints might include:
- Property value type must be of typeA, typeB, or typeC.
- Property value can be of any type except Null.
- Property value must be one of structX member constants.
I've read a few articles that may suggest using System.Attributes to
accomplish this in the meta data, but the examples provided were
simplified for discussion purposes.
Can anyone point me to a good article or give an example of how I can
implement this type of behavior?
- Glen
approach to handling known constraints within the assembly, once
compiled, to alert the developer at compile time of a potential issue.
For example, in the assembly I would like to add a constraint that
states a particular property member of the class can not be equal to one
other property. In standard coding I can throw an exception during
run-time, but I would rather have the constraint work during compile to
throw an error or warning to the developer.
Other constraints might include:
- Property value type must be of typeA, typeB, or typeC.
- Property value can be of any type except Null.
- Property value must be one of structX member constants.
I've read a few articles that may suggest using System.Attributes to
accomplish this in the meta data, but the examples provided were
simplified for discussion purposes.
Can anyone point me to a good article or give an example of how I can
implement this type of behavior?
- Glen