Ejemplo n.º 1
0
        public TypeDefinition?ResolveToTypeDefinition(TypeReference typeReference)
        {
            if (typeReference is ArrayType)
            {
                return(BCL.FindPredefinedType("System", "Array", _context));
            }

            return(_context.TryResolve(typeReference));
        }
Ejemplo n.º 2
0
            void CleanRemovedVariables(List <VariableDefinition> variables)
            {
                foreach (var instr in body.Instructions)
                {
                    VariableDefinition variable = GetVariableReference(instr);
                    if (variable == null)
                    {
                        continue;
                    }

                    if (!variables.Remove(variable))
                    {
                        continue;
                    }

                    if (variables.Count == 0)
                    {
                        return;
                    }
                }

                variables.Sort((a, b) => b.Index.CompareTo(a.Index));
                var body_variables = body.Variables;

                foreach (var variable in variables)
                {
                    var index = body_variables.IndexOf(variable);

                    //
                    // Remove variable only if it's the last one. Instead of
                    // re-indexing all variables change it to System.Object,
                    // which is enough to drop the dependency
                    //
                    if (index == body_variables.Count - 1)
                    {
                        body_variables.RemoveAt(index);
                    }
                    else
                    {
                        var objectType = BCL.FindPredefinedType("System", "Object", context);
                        body_variables[index].VariableType = objectType ?? throw new NotSupportedException("Missing predefined 'System.Object' type");
                    }
                }
            }