CustomAttribute Class
Represents a custom attribute that can be applied to code declarations.
public class CustomAttribute : CodeObject, ICommentableExample
var attr = new CustomAttribute(typeof(ObsoleteAttribute));
attr.Arguments.Add(new CustomAttributeArgument(new LiteralExpression("Use NewMethod instead")));
Assert.Equal("""[global::System.ObsoleteAttribute("Use NewMethod instead")]""", attr.ToCsharpString());- Inheritance
CodeObjectCustomAttribute- Implements
Constructors
| Name | Description |
|---|---|
| CustomAttribute() | |
| CustomAttribute(TypeReference?) | Initializes a new instance of the CustomAttribute class with the specified attribute type. |
CustomAttribute overloads
CustomAttribute()
CustomAttribute.cspublic CustomAttribute()No documentation is available.
CustomAttribute(TypeReference?)
CustomAttribute.csInitializes a new instance of the CustomAttribute class with the specified attribute type.
public CustomAttribute(TypeReference? typeReference)Parameters
typeReferenceTypeReference?- The type of the attribute.
Properties
| Name | Description |
|---|---|
| Arguments | |
| CommentsAfter | |
| CommentsBefore | |
| Target | |
| Type |
Arguments
CustomAttribute.cspublic CodeObjectCollection<CustomAttributeArgument> Arguments { get; }Property value
No documentation is available.