C# documentation says that you can assign custom attributes to parameters. The exact sentence is: “A target element can be an assembly, class, constructor, delegate, enum, event, field, interface, method, portable executable file module, parameter, property, return value, struct, or another attribute.” Given that, what would be the correct syntax to do something like this:
private void SomeMethod
([CustomAttribute(Blah = "blah1")] string actualParam,
[CustomAttribute(Blah = "blah2")] DateTime anotherParam
)
{
// method's body
}
Or am I missing something entirely?
That’s exactly like what you said. For parameters, you’ll do something like:
For return value, you’d do:
Similarly, there are
[module: MyAttribute],[assembly: MyAttribute]for modules and assemblies.