modopt和.NET反射 [英] modopt and .NET reflection

查看:153
本文介绍了modopt和.NET反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CLI / C ++接口,我想通过.NET反射来检查。这是源代码中的函数签名:

I have a CLI/C++ interface that I want to examine via .NET Reflection. Here's the function signature in the source code:

class ClassA;
template<typename _Type> class ClassTempA;

public interface class Test : BaseFunc {
public:
    ClassTempA<int>& SomeFunc2(ClassA inst) = 0;
};

下面是在.NET Reflector中检查函数的样子:

Here's what the function looks like when examined in .NET Reflector:

unsafe ClassTempA<int>* modopt(IsImplicitlyDereferenced) SomeFunc2(ClassA inst);

有没有办法通过.NET反射获得modopt属性,元数据
非托管API?

Is there a way to get at the modopt attributes via .NET reflection, or do I have to use the Metadata Unmanaged API?

推荐答案

您可以获得 modopt modreq 信息从 System.Reflection com / en-us / library / system.reflection.parameterinfo.getoptionalcustommodifiers.aspx> ParameterInfo :: GetOptionalCustomModifiers() ParameterInfo :: GetRequiredCustomModifiers() 。要说明您的类型,请参阅以下内容。

You can get the modopt and modreq info from System.Reflection by calling ParameterInfo::GetOptionalCustomModifiers() and ParameterInfo::GetRequiredCustomModifiers(), respectively. To illustrate with your types, see the following.

class ClassA;
template<typename _Type> class ClassTempA;

public interface class Test : BaseFunc {
public:
    ClassTempA<int>& SomeFunc2(ClassA inst) = 0;
};

array<Type^>^ GetModifiers()
{
    MethodInfo^ SomeFunc2 = Test::typeid->GetMethod("SomeFunc2");
    return method->ReturnParameter->GetOptionalCustomModifiers();
}

这篇关于modopt和.NET反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆