1
System.Reflection.Emit을 통해 몇 가지 유형을 정의하고 있습니다.System.Reflection.Emit - 형식 정의를 반환 할 특성을 추가하는 방법?
[return: MyAttr]
MyType MethodName([MyOtherAttr] MyOtherType);
내가 그것을 생성과 같은 코드를 사용 :
TypeBuilder t = assembly.DefineType(...);
MethodAttributes methodAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot;
MethodBuilder method = t.DefineMethod("MethodName", methodAttr, typeof(MyType), new Type[] { typeof(MyOtherType) });
method.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
// return type
ParameterBuilder pbr = method.DefineParameter(0, ParameterAttributes.Retval, null);
CustomAttributeBuilder cabr = GetMyAttrBuilder();
pbr.SetCustomAttribute(cabr);
// parameter
ParameterBuilder pbp = method.DefineParameter(1, ParameterAttributes.None, null);
CustomAttributeBuilder cabp = GetMyOtherAttrBuilder();
pbp.SetCustomAttribute(cabp);
t.CreateType();
을하지만 생성 된 메소드 서명은 다음과 같습니다
MyType MethodName([MyOtherAttr] MyOtherType);
일부 사용자는이 같은 특성으로 나는 방법 서명을 할 것인지 상상
반환 특성이 누락되었습니다. (올바른 동작을 얻는 방법은 무엇입니까?
미리 감사드립니다.