FromClrType() private method

Creates CodeType from the CLR type.
private FromClrType ( Microsoft clrType ) : CodeType
clrType Microsoft The CLR type.
return CodeType
Esempio n. 1
0
        /// <summary>
        /// Converts the CLR values to variable collection.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="names">The names.</param>
        private VariableCollection ConvertClrToVariableCollection(IList <Microsoft.Diagnostics.Runtime.ClrValue> values, string[] names)
        {
            if (values.Count != names.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(names));
            }

            List <Variable> variables = new List <Variable>(values.Count);

            for (int i = 0; i < names.Length; i++)
            {
                if (values[i] != null)
                {
                    try
                    {
                        var value = values[i];

                        variables.Add(Variable.CreateNoCast(Module.FromClrType(value.Type), value.Address, names[i]));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(new VariableCollection(variables.ToArray()));
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the CLR values to variable collection.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="names">The names.</param>
        private VariableCollection ConvertClrToVariableCollection(IList <Microsoft.Diagnostics.Runtime.ClrValue> values, string[] names)
        {
            if (values.Count != names.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(names));
            }

            List <Variable> variables = new List <Variable>(values.Count);

            for (int i = 0; i < names.Length; i++)
            {
                if (values[i] != null)
                {
                    try
                    {
                        var      value    = values[i];
                        ulong    address  = value.Address;
                        CodeType codeType = Module.FromClrType(value.Type);
                        Variable variable;

                        if (codeType.IsPointer)
                        {
                            variable = Variable.CreatePointerNoCast(codeType, address, names[i]);
                        }
                        else
                        {
                            // TODO: This address unboxing should be part of ClrMD.
                            if (value.ElementType == Microsoft.Diagnostics.Runtime.ClrElementType.Class)
                            {
                                address += Process.GetPointerSize();
                            }
                            variable = Variable.CreateNoCast(codeType, address, names[i]);
                        }

                        variables.Add(Variable.UpcastClrVariable(variable));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(new VariableCollection(variables.ToArray()));
        }