As an optimization, compiler should place [InAttribute] if user didn't on in parameters in marshaling methods. This saves an extra copy by the run-time on method return. because right now, it is treated as an ordinary ref, and the value is copied in and out.
cc @tannergooding @jcouv
Related to https://github.com/dotnet/coreclr/issues/11830 and https://github.com/dotnet/csharplang/issues/38#issuecomment-303570195
FYI. @yizhang82
:memo: It's ok to fix this after 7.2, as it is an optimization. Users can manually add the [In] as a workaround (when the compiler will add it, it will be superfluous, but won't break).
@OmarTawfik Can you take this one?
Most helpful comment
@OmarTawfik Can you take this one?