There are 2 completely different things here. The first thing is how the winmd file will represent a COM type. In that case, the C# definition will NOT include the HRESULT as the runtime has the ability to turn the COM call into a nice C# method that will throw if the HRESULT is not S_OK. The metadata definition for this method in the winmd is:
.method public hidebysig static object CreateUInt32([in] uint32 'value') runtime managed So there's nothing about a HRESULT here. The second thing is the ability in Cecil to read and write the name of the Param row that is backing the return "parameter" information. Which was indeed missing as it's not used outside of winmd. I've just added a way to access it: https://github.com/jbevain/cecil/commit/6e592a98ee8398992c010d24029c5d9ff9812f00 That should give you the name you need. Jb On Fri, Jan 6, 2017 at 8:45 PM, <[email protected]> wrote: > On Friday, January 6, 2017 at 10:10:17 PM UTC+3, Jb Evain wrote: >> >> On Thu, Jan 5, 2017 at 4:37 PM, LRN wrote: >> >>> On Thursday, January 5, 2017 at 8:01:17 PM UTC+3, Jb Evain wrote: >>>> >>>> On Thu, Jan 5, 2017 at 5:47 AM, LRN wrote: >>>> >>>>> MethodReturnType has internal Parameter object that it uses to store >>>>> information about the thing that method returns. >>>>> I need to access that object, because it has Parameter.Name property - >>>>> the name of return value. Normally return value is nameless, but in COM >>>>> all >>>>> interface methods actually return HRESULT, and the "real" result is passed >>>>> via [output] parameter - which does have a name, and i need to know that >>>>> name. >>>>> >>>> >>>> For a COM interface method, for a MethodDefinition, you'll have the >>>> HRESULT (maybe an int?) as the ReturnType. >>>> >>> I think it's established that we agree on this one. >>> >>> >>>> The [Out] parameter will be in the .Parameters collection of the >>>> MethodDefinition. >>>> >>> >>> That does not match my observations. For example, >>> Windows.Foundation.IPropertyValueStatics interface has CreateUInt8() >>> method with one parameter ([in]System.Byte value). I'm using "foreach >>> (ParameterDefinition param in method.Parameters)" to look through all >>> parameters of a method. >>> >>> >> The signature of this method is: >> >> public static object CreateUInt32(uint value) >> >> So it doesn't return an HResult, it returns an object, and takes one >> parameter. In that case there's simply no out parameter. >> > > In IDL the signature of this method is: > HRESULT CreateUInt8([in] BYTE value, [out] [retval] > IInspectable** propertyValue); > in C++ its signature is: > virtual HRESULT STDMETHODCALLTYPE CreateUInt8( > /* [in] */ BYTE value, > /* [out][retval] */ __RPC__deref_out_opt > IInspectable **propertyValue) = 0; > > and in C it is: > HRESULT ( STDMETHODCALLTYPE *CreateUInt8 )( > __RPC__in __x_ABI_CWindows_CFoundation_CIPropertyValueStatics > * This, > /* [in] */ BYTE value, > /* [out][retval] */ __RPC__deref_out_opt IInspectable ** > propertyValue); > (all of the above is according to Windows SDK). > > All COM methods return HRESULT, because it's COM. The actual (useful) > return value is passed via pointer. Because COM methods return HRESULT. > > To turn a ECMA-335 method (what cecil reads from metadata) into COM method > (what i need), you make it return HRESULT and add an extra argument for the > real return value (two arguments, if return value is an array). That "real > return value" is an argument. It has a name. I need to know that name. And > i can know it, because ECMA-335 encodes method return value as just another > method parameter, and allows it to have a name. Which i need to know. > Because in COM return value is an argument. Because COM method itself > returns HRESULT. Because COM. > > -- > -- > -- > mono-cecil > --- > You received this message because you are subscribed to the Google Groups > "mono-cecil" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
