Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When are ParameterInfo.IsLcid or ParameterInfo.IsRetval true?

Tags:

c#

reflection

I find this question in Stack Overflow when googleing, but it has been deleted. So I list this question again.

As I can't find the LcidAttribute or RetvalAttribute in BCL, I guess C# hasn't provided the support for locale identifier parameter and return value parameter.

Is that it?

Thanks all.

like image 202
Kirin Yao Avatar asked Jul 31 '12 06:07

Kirin Yao


1 Answers

They are associated with the ParameterAttributes enumeration. Which is used in metadata for the parameter of a method, only a compiler can emit the [modopt].

I do not know of a compiler that actually does this. I have a decent guess at the background though, these attributes are also used in IDL. Which is an interface description language that is used in COM and RPC. Having this option ensures that .NET metadata can also describe the kind of declarations that are written in IDL and can appear in type libraries.

The [lcid] attribute is described here. It doesn't actually describe usage and I've never used it myself. No real idea why you'd use it.

The [retval] attribute is described here. Very important in COM automation method declarations, it marks the parameter that returns the method value. And used by a tool like Tlbimp.exe, it rewrites the method to make that parameter the return value type.

like image 200
Hans Passant Avatar answered Nov 08 '22 22:11

Hans Passant