I am looking for a list of reasonable use cases for attributes in a parameter.
I can think of some good cases for attributes in a method, but I don't seem to see a good use for the parameter attribute. Please enlighten me.
What about the attributes of the return type of the method?
, , PInvoke. PInvoke , Pinnovoke- , , :
[DllImport("yay.dll")] public static extern int Bling([MarshalAs(UnmanagedType.LPStr)] string woo);
"woo".
, Vici MVC, .NET MVC, "" . Vici MVC:
public void ActionMethod([Parameter("user")] int userId) { }
"" userId.
, .
, , , .
Boo -. :
def Foo([required]p): pass
Foo :
def Foo(p): raise ArgumentNullException("p") if p is null
, , . , MEF , , :
public class Foo { [ImportingConstructor] public Foo([Import("main")] Bar bar) { ... } }