I am trying to go through the mess of COM interop definitions we have scattered across various projects and collect them into a single, known-good location from which the wh
No, it's not strictly necessary to apply any of these attributes in your own code. They're all optional, and automatically applied to your code depending on the type of the parameter.
Essentially, they have the following C# keyword equivalents:
[In]
by default.ref
keyword gets you [In, Out]
.out
keyword gets you [Out]
.All documented in a nice table here.
You only need to use them when you want to alter those implied semantics or change the default behavior of the marshaler. For example, you can mark a parameter declared ref
with the [In]
attribute only to suppress the "out" part of marshaling.
That said, I find myself using them because they're a very easy way of making code self-documenting.