You're using the GetElementType() which returns the original element type
for a TypeSpec. That's poorly named but that's the way it is.

Use the .ElementType property to access the next  composed type.

Jb

On Fri, Jan 6, 2017 at 9:04 PM, <[email protected]> wrote:

> On Friday, January 6, 2017 at 10:12:05 PM UTC+3, Jb Evain wrote:
>>
>> On Thu, Jan 5, 2017 at 8:58 PM, LRN wrote:
>>
>>> AFAIU, cecil insists that ByReferenceType and ArrayType are mutually
>>> exclusive.
>>> Because of that, some methods have by-reference arguments that are
>>> arrays, but cecil denies that (IsArray is false). Here's the list of
>>> methods:
>>> Method System.Void Windows.Foundation.IPropertyValue::GetUInt8Array(
>>> System.Byte[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetInt16Array(
>>> System.Int16[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetUInt16Array(
>>> System.UInt16[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetInt32Array(
>>> System.Int32[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetUInt32Array(
>>> System.UInt32[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetInt64Array(
>>> System.Int64[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetUInt64Array(
>>> System.UInt64[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetSingleArray(
>>> System.Single[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetDoubleArray(
>>> System.Double[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetChar16Array(
>>> System.Char[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetBooleanArray(
>>> System.Boolean[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetStringArray(
>>> System.String[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::
>>> GetInspectableArray(System.Object[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetGuidArray(
>>> System.Guid[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetDateTimeArray(
>>> Windows.Foundation.DateTime[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetTimeSpanArray(
>>> Windows.Foundation.TimeSpan[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetPointArray(
>>> Windows.Foundation.Point[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetSizeArray(
>>> Windows.Foundation.Size[]&)
>>> Method System.Void Windows.Foundation.IPropertyValue::GetRectArray(
>>> Windows.Foundation.Rect[]&)
>>> Method System.Void Windows.Media.MediaProperties.
>>> IAudioEncodingPropertiesWithFormatUserData::GetFormatUserData(System.
>>> Byte[]&)
>>> Method System.Void Windows.Media.MediaProperties.
>>> IVideoEncodingProperties2::GetFormatUserData(System.Byte[]&)
>>> Method System.Void Windows.Media.Core.IMediaStrea
>>> mSampleProtectionProperties::GetKeyIdentifier(System.Byte[]&)
>>> Method System.Void Windows.Media.Core.IMediaStrea
>>> mSampleProtectionProperties::GetInitializationVector(System.Byte[]&)
>>> Method System.Void Windows.Media.Core.IMediaStrea
>>> mSampleProtectionProperties::GetSubSampleMapping(System.Byte[]&)
>>> Method System.Void Windows.Networking.Vpn.IVpnInterfaceId::
>>> GetAddressInfo(System.Byte[]&)
>>> Method System.Void Windows.Security.Cryptography.
>>> ICryptographicBufferStatics::CopyToByteArray(Windows.Storage.Streams.
>>> IBuffer,System.Byte[]&)
>>> Method System.Void Windows.UI.Xaml.Automation.Provider.
>>> ITextRangeProvider::GetBoundingRectangles(System.Double[]&)
>>>
>>>
>> Typespecs are composed.
>>
>> In that case you'll have a ByReferenceType instance whose ElementType
>> will be an ArrayType, whose ElementType will be System.Byte.
>>
>
> That doesn't seem to match my observations.
> Here's roughly what i'm doing:
>       foreach (TypeDefinition type in module.Types)
>       {
>         if (!type.IsInterface)
>           continue;
>
>         foreach (MethodDefinition method in type.Methods)
>         {
>           foreach (ParameterDefinition param in method.Parameters)
>           {
>             string param_type = param.ParameterType.FullName;
>             int amp = param_type.LastIndexOf ('&');
>             int lbrace = param_type.LastIndexOf ('[');
>             int rbrace = param_type.LastIndexOf (']');
>             if (param.ParameterType.IsByReference && !param.ParameterType.
> IsArray && amp > 0 && rbrace > lbrace && lbrace > 0)
>             {
>               TypeReference eltype = param.ParameterType.GetElementType
> ();
>               Console.WriteLine ("Parameter {0} of method {1} is by
> reference", param.Name, method.FullName);
>               Console.WriteLine ("Its element type is {0} and it {1}",
> eltype, eltype.IsArray ? "is an array" : "is not an array");
>               if (eltype.GetElementType () != eltype)
>                 Console.WriteLine ("Subelement type is {0}", eltype.
> GetElementType ());
>             }
>           }
>         }
>       }
> and the output is like this:
> Parameter value of method System.Void Windows.Foundation.IPropertyValue::
> GetUInt8Array(System.Byte[]&) is by reference
> Its element type is System.Byte and it is not an array
>
> What am i doing wrong?
>
> --
> --
> --
> 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.

Reply via email to