Examples from Chapter 14 (Attributes) of Programming C# 12.0 (O'Reilly).
- Example 1. Attributes in a unit test class
- Example 2. Attribute with constructor argument
- Example 3. Specifying optional attribute settings with properties
- Example 4. Assembly-level attributes
- Example 5. Module-level attribute
- Example 6. Attribute for compiler-generated property and event fields
- Example 7. Method and return value attributes
- Example 8. Referring to a method argument by name in an attribute before C# 11.0
- Example 9. Referring to a method argument by name in an attribute using
nameof
0 - Example 10. Lambda with attributes
- Example 11. A typical generated file with assembly-level attributes
- Example 12. Version attributes
- Example 13. Typical assembly description attributes
- Example 14. Applying caller info attributes to method parameters
- Example 15. INotifyPropertyChanged
- Example 16. A reusable INotifyPropertyChanged implementation
- Example 17. Raising a property changed event
- Example 18. The CallerArgumentExpressionAttribute in ArgumentNullException.ThrowIfNull
- Example 19. Calling a method that uses CallerArgumentExpressionAttribute
- Example 20. InternalsVisibleToAttribute
- Example 21. Regular expression source generation
- Example 22. Interop attributes
- Example 23. An attribute type
- Example 24. Applying an attribute
- Example 25. Providing an optional property value for an attribute
- Example 26. ICustomAttributeProvider
- Example 27. Showing plug-in information
- Example 28. Retrieving attributes with the metadata load context
- Example 29. A generic attribute type