Exemple #1
0
        /// <summary>
        /// Add an instruction's operand to <paramref name="sb"/>
        /// </summary>
        /// <param name="sb">Place result here</param>
        /// <param name="instr">The instruction</param>
        /// <param name="extra">A string that will be added before the operand, if there's
        /// an operand.</param>
        public static void AddOperandString(StringBuilder sb, Instruction instr, string extra)
        {
            var op = instr.Operand;

            switch (instr.OpCode.OperandType)
            {
            case OperandType.InlineBrTarget:
            case OperandType.ShortInlineBrTarget:
                sb.Append(extra);
                AddInstructionTarget(sb, op as Instruction);
                break;

            case OperandType.InlineField:
            case OperandType.InlineMethod:
            case OperandType.InlineTok:
            case OperandType.InlineType:
                sb.Append(extra);
                if (op is IFullName)
                {
                    sb.Append((op as IFullName).FullName);
                }
                else if (op != null)
                {
                    sb.Append(op.ToString());
                }
                else
                {
                    sb.Append("null");
                }
                break;

            case OperandType.InlineI:
            case OperandType.InlineI8:
            case OperandType.InlineR:
            case OperandType.ShortInlineI:
            case OperandType.ShortInlineR:
                sb.Append(string.Format("{0}{1}", extra, op));
                break;

            case OperandType.InlineSig:
                sb.Append(extra);
                sb.Append(FullNameCreator.MethodFullName(null, (UTF8String)null, op as MethodSig));
                break;

            case OperandType.InlineString:
                sb.Append(extra);
                EscapeString(sb, op as string, true);
                break;

            case OperandType.InlineSwitch:
                var targets = op as IList <Instruction>;
                if (targets == null)
                {
                    sb.Append("null");
                }
                else
                {
                    sb.Append('(');
                    for (int i = 0; i < targets.Count; i++)
                    {
                        if (i != 0)
                        {
                            sb.Append(',');
                        }
                        AddInstructionTarget(sb, targets.Get(i, null));
                    }
                    sb.Append(')');
                }
                break;

            case OperandType.InlineVar:
            case OperandType.ShortInlineVar:
                sb.Append(extra);
                if (op == null)
                {
                    sb.Append("null");
                }
                else
                {
                    sb.Append(op.ToString());
                }
                break;

            case OperandType.InlineNone:
            case OperandType.InlinePhi:
            default:
                break;
            }
        }
Exemple #2
0
 public override string ToString()
 {
     return(FullNameCreator.MethodFullName("", Name, MethodSig));
 }
Exemple #3
0
 public override string ToString() => FullNameCreator.MethodFullName("", Name, MethodSig);
Exemple #4
0
 public override string ToString()
 {
     return(FullNameCreator.MethodFullName(InterfaceType == null ? "" : FullNameCreator.FullName(InterfaceType, false), Name, MethodSig));
 }