Example #1
0
        private static CallingConventionSignature ReadSignature(
            ModuleDefinition module,
            IBinaryStreamReader reader,
            RecursionProtection protection)
        {
            byte flag = reader.ReadByte();

            reader.FileOffset--;

            switch ((CallingConventionAttributes)flag & SignatureTypeMask)
            {
            case CallingConventionAttributes.Default:
            case CallingConventionAttributes.C:
            case CallingConventionAttributes.ExplicitThis:
            case CallingConventionAttributes.FastCall:
            case CallingConventionAttributes.StdCall:
            case CallingConventionAttributes.ThisCall:
            case CallingConventionAttributes.VarArg:
                return(MethodSignature.FromReader(module, reader, protection));

            case CallingConventionAttributes.Property:
                return(PropertySignature.FromReader(module, reader, protection));

            case CallingConventionAttributes.Local:
                return(LocalVariablesSignature.FromReader(module, reader, protection));

            case CallingConventionAttributes.GenericInstance:
                return(GenericInstanceMethodSignature.FromReader(module, reader, protection));

            case CallingConventionAttributes.Field:
                return(FieldSignature.FromReader(module, reader, protection));
            }

            throw new NotSupportedException();
        }
Example #2
0
        /// <inheritdoc />
        public bool Equals(CallingConventionSignature x, CallingConventionSignature y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            return(x switch
            {
                LocalVariablesSignature localVarSig => Equals(localVarSig, y as LocalVariablesSignature),
                FieldSignature fieldSig => Equals(fieldSig, y as FieldSignature),
                MethodSignature methodSig => Equals(methodSig, y as MethodSignature),
                PropertySignature propertySig => Equals(propertySig, y as PropertySignature),
                _ => false
            });