Exemplo n.º 1
0
 private CachedDecompiledMember DecompileMember(MethodDefinition method)
 {
     V_0 = null;
     if (method != null)
     {
         if (method.get_Body() != null)
         {
             if (this.get_IsCachingEnabled() && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
             {
                 return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
             }
             V_2 = this.DecompileMethod(method.get_Body(), out V_1);
             V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_2, V_1));
             if (this.get_IsCachingEnabled())
             {
                 this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, V_0);
             }
         }
         else
         {
             V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
         }
     }
     return(V_0);
 }
Exemplo n.º 2
0
        private static void AddAssignmentDataToDecompiledType(CachedDecompiledMember decompiledMember, DecompiledType decompiledType)
        {
            if (!decompiledType.get_TypeContext().get_FieldInitializationFailed())
            {
                V_0 = decompiledMember.get_FieldAssignmentData().GetEnumerator();
                try
                {
                    while (V_0.MoveNext())
                    {
                        V_1 = V_0.get_Current();
                        if (decompiledType.get_TypeContext().get_AssignmentData().ContainsKey(V_1.get_Key()))
                        {
                            if (decompiledType.get_TypeContext().get_AssignmentData().get_Item(V_1.get_Key()).get_AssignmentExpression().Equals(V_1.get_Value().get_AssignmentExpression()))
                            {
                                continue;
                            }
                            decompiledType.get_TypeContext().set_FieldInitializationFailed(true);
                            decompiledType.get_TypeContext().set_AssignmentData(new Dictionary <string, InitializationAssignment>());
                            goto Label0;
                        }
                        else
                        {
                            decompiledType.get_TypeContext().get_AssignmentData().Add(V_1.get_Key(), V_1.get_Value());
                        }
                    }
                }
                finally
                {
                    ((IDisposable)V_0).Dispose();
                }
            }
Label0:
            return;
        }
Exemplo n.º 3
0
 public void Decompile(out CachedDecompiledMember getMethod, out CachedDecompiledMember setMethod, out bool isAutoImplemented)
 {
     getMethod         = null;
     setMethod         = null;
     isAutoImplemented = false;
     if (this.propertyDef.get_GetMethod() == null || this.propertyDef.get_GetMethod().get_Parameters().get_Count() != 0 || !this.propertyDef.get_GetMethod().get_HasBody() || this.propertyDef.get_OtherMethods().get_Count() != 0)
     {
         getMethod         = this.DecompileMember(this.propertyDef.get_GetMethod());
         setMethod         = this.DecompileMember(this.propertyDef.get_SetMethod());
         isAutoImplemented = false;
         return;
     }
     if (this.propertyDef.get_SetMethod() == null)
     {
         if (this.language.get_SupportsGetterOnlyAutoProperties())
         {
             isAutoImplemented = this.DecompileAndCheckForAutoImplementedPropertyMethod(this.propertyDef.get_GetMethod(), out getMethod, true, new Func <BlockStatement, bool>(this.CheckGetter));
             return;
         }
         getMethod         = this.DecompileMember(this.propertyDef.get_GetMethod());
         setMethod         = this.DecompileMember(this.propertyDef.get_SetMethod());
         isAutoImplemented = false;
         return;
     }
     if (this.propertyDef.get_SetMethod().get_Parameters().get_Count() != 1 || !this.propertyDef.get_SetMethod().get_HasBody())
     {
         getMethod         = this.DecompileMember(this.propertyDef.get_GetMethod());
         setMethod         = this.DecompileMember(this.propertyDef.get_SetMethod());
         isAutoImplemented = false;
         return;
     }
     isAutoImplemented = this.DecompileAndCheckForAutoImplementedPropertyMethod(this.propertyDef.get_GetMethod(), out getMethod, true, new Func <BlockStatement, bool>(this.CheckGetter)) & this.DecompileAndCheckForAutoImplementedPropertyMethod(this.propertyDef.get_SetMethod(), out setMethod, true, new Func <BlockStatement, bool>(this.CheckSetter));
     return;
 }
Exemplo n.º 4
0
        private CachedDecompiledMember DecompileMember(MethodDefinition method)
        {
            CachedDecompiledMember cachedDecompiledMember = null;

            if (method != null)
            {
                if (method.Body == null)
                {
                    cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
                }
                else if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
                {
                    return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
                }
                else
                {
                    MethodSpecificContext methodContext;
                    BlockStatement        block = this.DecompileMethod(method.Body, out methodContext);
                    cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), block, methodContext));
                    if (this.IsCachingEnabled)
                    {
                        this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, cachedDecompiledMember);
                    }
                }
            }

            return(cachedDecompiledMember);
        }
Exemplo n.º 5
0
        private CachedDecompiledMember DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext)
        {
            CachedDecompiledMember decompiledMember;
            Statement statement;

            try
            {
                DecompilationContext innerContext = null;
                statement        = method.Body.Decompile(language, out innerContext, typeContext);
                decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), statement, innerContext.MethodContext), innerContext.TypeContext);
            }
            catch (Exception ex)
            {
                this.ExceptionsWhileDecompiling.Add(method);

                BlockStatement blockStatement = new BlockStatement();
                statement = new ExceptionStatement(ex, method);
                blockStatement.AddStatement(statement);

                decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), blockStatement, new MethodSpecificContext(method.Body)));

                OnExceptionThrown(ex);
            }
            return(decompiledMember);
        }
 protected void AddDecompiledMemberToDecompiledType(CachedDecompiledMember decompiledMember, DecompiledType decompiledType)
 {
     if (!decompiledType.DecompiledMembers.ContainsKey(decompiledMember.Member.MemberFullName))
     {
         decompiledType.DecompiledMembers.Add(decompiledMember.Member.MemberFullName, decompiledMember.Member);
     }
 }
Exemplo n.º 7
0
 protected void AddGeneratedFilterMethodsToDecompiledType(DecompiledType decompiledType, TypeSpecificContext context, ILanguage language)
 {
     foreach (GeneratedMethod generatedMethod in context.GeneratedFilterMethods)
     {
         CachedDecompiledMember member = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(generatedMethod.Method), generatedMethod.Body, generatedMethod.Context));
         AddDecompiledMemberToDecompiledType(member, decompiledType);
     }
 }
Exemplo n.º 8
0
 protected void AddDecompiledMemberToDecompiledType(CachedDecompiledMember decompiledMember, DecompiledType decompiledType)
 {
     if (!decompiledType.get_DecompiledMembers().ContainsKey(decompiledMember.get_Member().get_MemberFullName()))
     {
         decompiledType.get_DecompiledMembers().Add(decompiledMember.get_Member().get_MemberFullName(), decompiledMember.get_Member());
     }
     return;
 }
Exemplo n.º 9
0
 protected CachedDecompiledMember AddDecompiledMemberToCache(IMemberDefinition member, DecompiledMember decompiledMember, TypeSpecificContext typeContext, ILanguage language)
 {
     V_0 = new CachedDecompiledMember(decompiledMember, typeContext);
     if (!this.cacheService.IsDecompiledMemberInCache(member, language, this.renameInvalidMembers))
     {
         this.cacheService.AddDecompiledMemberToCache(member, language, this.renameInvalidMembers, V_0);
     }
     return(V_0);
 }
        private void MergeConstructorsTypeContexts(List <CachedDecompiledMember> allConstructors, DecompiledType decompiledType)
        {
            if (allConstructors == null || allConstructors.Count == 0)
            {
                return;
            }

            for (int j = 0; j < allConstructors.Count; j++)
            {
                // context can be null, if the constructor has no body
                if (allConstructors[j].Member.Context != null && allConstructors[j].Member.Context.IsBaseConstructorInvokingConstructor)
                {
                    decompiledType.TypeContext.BaseCtorInvocators.Add(allConstructors[j].Member.Context.Method);
                }
            }

            int i = 0;
            Dictionary <string, FieldInitializationAssignment> combinedDictionary = new Dictionary <string, FieldInitializationAssignment>();

            for (; i < allConstructors.Count; i++)
            {
                if (allConstructors[i].Member.Context != null && allConstructors[i].Member.Context.IsBaseConstructorInvokingConstructor)
                {
                    /// at least one constructor will call the base's ctor
                    combinedDictionary = new Dictionary <string, FieldInitializationAssignment>(allConstructors[i].FieldAssignmentData);
                    break;
                }
            }

            for (; i < allConstructors.Count; i++)
            {
                CachedDecompiledMember constructor = allConstructors[i];
                if (constructor.Member.Context == null || !constructor.Member.Context.IsBaseConstructorInvokingConstructor)
                {
                    continue;
                }
                if (constructor.FieldAssignmentData.Count != combinedDictionary.Count)
                {
                    // merge should fail
                    decompiledType.TypeContext.FieldInitializationFailed = true;
                    decompiledType.TypeContext.FieldAssignmentData       = new Dictionary <string, FieldInitializationAssignment>();
                    return;
                }
                foreach (KeyValuePair <string, FieldInitializationAssignment> pair in constructor.FieldAssignmentData)
                {
                    if (combinedDictionary.ContainsKey(pair.Key) && combinedDictionary[pair.Key].AssignmentExpression.Equals(pair.Value.AssignmentExpression))
                    {
                        continue;
                    }
                    // merge should fail otherwise
                    decompiledType.TypeContext.FieldInitializationFailed = true;
                    decompiledType.TypeContext.FieldAssignmentData       = new Dictionary <string, FieldInitializationAssignment>();
                    return;
                }
            }
            decompiledType.TypeContext.FieldAssignmentData = combinedDictionary;
        }
Exemplo n.º 11
0
        private bool DecompileAndCheckForAutoImplementedPropertyMethod(MethodDefinition method, out CachedDecompiledMember decompiledMember,
                                                                       bool needDecompiledMember, Func <BlockStatement, bool> checker)
        {
            decompiledMember = null;

            DecompilationContext context;
            BlockStatement       statements = this.DecompileMethodPartially(method.Body, out context, needDecompiledMember);

            if (statements == null && context == null)
            {
                if (needDecompiledMember)
                {
                    decompiledMember = DecompileMember(method);
                }

                return(false);
            }
            else if (statements.Statements.Count == 1 && statements.Statements[0].CodeNodeType == CodeNodeType.ExceptionStatement)
            {
                if (needDecompiledMember)
                {
                    decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), statements, new MethodSpecificContext(method.Body)));
                }

                return(false);
            }

            if (checker(statements))
            {
                if (needDecompiledMember)
                {
                    if (this.propertyDef.ShouldStaySplit())
                    {
                        decompiledMember = FinishDecompilationOfMember(method, statements, context);
                    }
                    else
                    {
                        decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), statements, context.MethodContext));
                    }
                }

                return(true);
            }
            else
            {
                if (needDecompiledMember)
                {
                    decompiledMember = FinishDecompilationOfMember(method, statements, context);
                }

                return(false);
            }
        }
        protected void DecompileMember(MethodDefinition method, ILanguage language, DecompiledType decompiledType)
        {
            if (method.IsConstructor && !method.IsStatic && method.HasBody)
            {
                DecompileConstructorChain(method, language, decompiledType);
                return;
            }
            CachedDecompiledMember decompiledMember = GetDecompiledMember(method, language, decompiledType);

            AddDecompiledMemberToDecompiledType(decompiledMember, decompiledType);
            //UpdateTypeContext(decompiledType.TypeContext, decompiledMember);
        }
Exemplo n.º 13
0
 private CachedDecompiledMember FinishDecompilationOfMember(MethodDefinition method, BlockStatement block, DecompilationContext context)
 {
     if (this.get_IsCachingEnabled() && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
     {
         return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
     }
     V_1 = this.FinishDecompilationOfMethod(block, context, out V_0);
     V_2 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, V_0));
     if (this.get_IsCachingEnabled())
     {
         this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, V_2);
     }
     return(V_2);
 }
Exemplo n.º 14
0
        private BlockStatement DecompileMethodPartially(MethodBody body, out DecompilationContext context, bool needDecompiledMember = false)
        {
            context = null;

            if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(body.Method, this.language, this.renameInvalidMembers))
            {
                CachedDecompiledMember cachedDecompiledMember = this.cacheService.GetDecompiledMemberFromCache(body.Method, this.language, this.renameInvalidMembers);
                return(cachedDecompiledMember.Member.Statement as BlockStatement);
            }

            //Performance improvement
            ControlFlowGraph cfg = new ControlFlowGraphBuilder(body.Method).CreateGraph();

            if (cfg.Blocks.Length > 2)
            {
                return(null);
            }

            BlockStatement block;

            try
            {
                DecompilationPipeline pipeline;
                DecompilationContext  decompilationContext =
                    new DecompilationContext(new MethodSpecificContext(body), this.typeContext ?? new TypeSpecificContext(body.Method.DeclaringType));
                if (!needDecompiledMember)
                {
                    decompilationContext.MethodContext.EnableEventAnalysis = false;
                }

                pipeline = new DecompilationPipeline(BaseLanguage.IntermediateRepresenationPipeline.Steps, decompilationContext);

                context = pipeline.Run(body);

                block = pipeline.Body;
            }
            catch (Exception ex)
            {
                this.ExceptionsWhileDecompiling.Add(body.Method);

                block = new BlockStatement();
                block.AddStatement(new ExceptionStatement(ex, body.Method));

                OnExceptionThrown(ex);
            }

            return(block);
        }
        protected CachedDecompiledMember GetDecompiledMember(MethodDefinition method, ILanguage language, DecompiledType decompiledType)
        {
            if (method.Body == null)
            {
                return(new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null)));
            }

            if (this.cacheService.IsDecompiledMemberInCache(method, language, this.renameInvalidMembers))
            {
                return(this.cacheService.GetDecompiledMemberFromCache(method, language, this.renameInvalidMembers));
            }

            CachedDecompiledMember decompiledMember = DecompileMethod(language, method, decompiledType.TypeContext);

            this.cacheService.AddDecompiledMemberToCache(method, language, this.renameInvalidMembers, decompiledMember);
            return(decompiledMember);
        }
Exemplo n.º 16
0
        private CachedDecompiledMember FinishDecompilationOfMember(MethodDefinition method, BlockStatement block, DecompilationContext context)
        {
            if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
            {
                return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
            }

            MethodSpecificContext  methodContext;
            BlockStatement         fullyDecompiledBlock   = this.FinishDecompilationOfMethod(block, context, out methodContext);
            CachedDecompiledMember cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), fullyDecompiledBlock, methodContext));

            if (this.IsCachingEnabled)
            {
                this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, cachedDecompiledMember);
            }

            return(cachedDecompiledMember);
        }
Exemplo n.º 17
0
 private CachedDecompiledMember DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext)
 {
     try
     {
         V_2 = null;
         V_1 = method.get_Body().Decompile(language, out V_2, typeContext);
         V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, V_2.get_MethodContext()), V_2.get_TypeContext());
     }
     catch (Exception exception_0)
     {
         V_3 = exception_0;
         this.get_ExceptionsWhileDecompiling().Add(method);
         V_4 = new BlockStatement();
         V_4.AddStatement(new ExceptionStatement(V_3, method));
         V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_4, new MethodSpecificContext(method.get_Body())));
         this.OnExceptionThrown(V_3);
     }
     return(V_0);
 }
Exemplo n.º 18
0
 private static void AddAssignmentDataToDecompiledType(CachedDecompiledMember decompiledMember, DecompiledType decompiledType)
 {
     if (!decompiledType.TypeContext.FieldInitializationFailed)
     {
         foreach (KeyValuePair <string, InitializationAssignment> pair in decompiledMember.FieldAssignmentData)
         {
             if (!decompiledType.TypeContext.AssignmentData.ContainsKey(pair.Key))
             {
                 decompiledType.TypeContext.AssignmentData.Add(pair.Key, pair.Value);
             }
             else if (!decompiledType.TypeContext.AssignmentData[pair.Key].AssignmentExpression.Equals(pair.Value.AssignmentExpression))
             {
                 decompiledType.TypeContext.FieldInitializationFailed = true;
                 decompiledType.TypeContext.AssignmentData            = new Dictionary <string, InitializationAssignment>();
                 return;
             }
         }
     }
 }
        private void RemoveBaseCtorInvocationStatements(CachedDecompiledMember decompiledMember, DecompiledType decompiledType)
        {
            MethodSpecificContext methodContext = decompiledMember.Member.Context;

            //value types chained constructors?
            if (methodContext == null || !methodContext.Method.IsConstructor || methodContext.Method.IsStatic || methodContext.CtorInvokeExpression == null)
            {
                return;
            }
            BlockStatement methodBody = decompiledMember.Member.Statement as BlockStatement;

            if (methodBody == null)             // it might have been an exception
            {
                return;
            }
            else if (methodBody.Statements.Count == 1 && methodBody.Statements[0] is UnsafeBlockStatement)
            {
                methodBody = methodBody.Statements[0] as UnsafeBlockStatement;
            }

            TypeSpecificContext typeContext = decompiledType.TypeContext;

            if (typeContext.FieldInitializationFailed && typeContext.BaseCtorInvocators.Contains(methodContext.Method))
            {
                methodContext.CtorInvokeExpression = null;
            }
            else
            {
                /// all statements before the constructor invocation should be removed
                for (int i = 0; i < methodBody.Statements.Count; i++)
                {
                    if (methodBody.Statements[i].CodeNodeType == Ast.CodeNodeType.ExpressionStatement &&
                        ((methodBody.Statements[i] as ExpressionStatement).Expression.CodeNodeType == Ast.CodeNodeType.ThisCtorExpression ||
                         (methodBody.Statements[i] as ExpressionStatement).Expression.CodeNodeType == Ast.CodeNodeType.BaseCtorExpression))
                    {
                        RemoveFirstStatements(methodBody.Statements, i + 1);
                        return;
                    }
                }
                throw new Exception("Constructor invocation not found.");
            }
        }
Exemplo n.º 20
0
 private bool DecompileAndCheckForAutoImplementedPropertyMethod(MethodDefinition method, out CachedDecompiledMember decompiledMember, bool needDecompiledMember, Func <BlockStatement, bool> checker)
 {
     decompiledMember = null;
     V_1 = this.DecompileMethodPartially(method.get_Body(), out V_0, needDecompiledMember);
     if (V_1 == null && V_0 == null)
     {
         if (needDecompiledMember)
         {
             decompiledMember = this.DecompileMember(method);
         }
         return(false);
     }
     if (V_1.get_Statements().get_Count() == 1 && V_1.get_Statements().get_Item(0).get_CodeNodeType() == 67)
     {
         if (needDecompiledMember)
         {
             decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, new MethodSpecificContext(method.get_Body())));
         }
         return(false);
     }
     if (!checker.Invoke(V_1))
     {
         if (needDecompiledMember)
         {
             decompiledMember = this.FinishDecompilationOfMember(method, V_1, V_0);
         }
         return(false);
     }
     if (needDecompiledMember)
     {
         if (!this.propertyDef.ShouldStaySplit())
         {
             decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, V_0.get_MethodContext()));
         }
         else
         {
             decompiledMember = this.FinishDecompilationOfMember(method, V_1, V_0);
         }
     }
     return(true);
 }
Exemplo n.º 21
0
 protected void AddGeneratedFilterMethodsToDecompiledType(DecompiledType decompiledType, TypeSpecificContext context, ILanguage language)
 {
     V_0 = context.get_GeneratedFilterMethods().GetEnumerator();
     try
     {
         while (V_0.MoveNext())
         {
             V_1 = V_0.get_Current();
             V_2 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(V_1.get_Method()), V_1.get_Body(), V_1.get_Context()));
             this.AddDecompiledMemberToDecompiledType(V_2, decompiledType);
         }
     }
     finally
     {
         if (V_0 != null)
         {
             V_0.Dispose();
         }
     }
     return;
 }
Exemplo n.º 22
0
        public void Decompile(out CachedDecompiledMember getMethod, out CachedDecompiledMember setMethod, out bool isAutoImplemented)
        {
            getMethod         = null;
            setMethod         = null;
            isAutoImplemented = false;

            if (propertyDef.GetMethod == null || propertyDef.GetMethod.Parameters.Count != 0 || !propertyDef.GetMethod.HasBody ||
                propertyDef.OtherMethods.Count != 0)
            {
                getMethod         = DecompileMember(propertyDef.GetMethod);
                setMethod         = DecompileMember(propertyDef.SetMethod);
                isAutoImplemented = false;
            }
            else if (propertyDef.SetMethod != null)
            {
                if (propertyDef.SetMethod.Parameters.Count != 1 || !propertyDef.SetMethod.HasBody)
                {
                    getMethod         = DecompileMember(propertyDef.GetMethod);
                    setMethod         = DecompileMember(propertyDef.SetMethod);
                    isAutoImplemented = false;
                }
                else
                {
                    // Auto-implemented property with getter and setter
                    isAutoImplemented = DecompileAndCheckForAutoImplementedPropertyMethod(propertyDef.GetMethod, out getMethod, true, CheckGetter) &
                                        DecompileAndCheckForAutoImplementedPropertyMethod(propertyDef.SetMethod, out setMethod, true, CheckSetter);
                }
            }
            else if (!this.language.SupportsGetterOnlyAutoProperties)
            {
                getMethod         = DecompileMember(propertyDef.GetMethod);
                setMethod         = DecompileMember(propertyDef.SetMethod);
                isAutoImplemented = false;
            }
            else
            {
                // Getter only auto-implemented property
                isAutoImplemented = DecompileAndCheckForAutoImplementedPropertyMethod(propertyDef.GetMethod, out getMethod, true, CheckGetter);
            }
        }
Exemplo n.º 23
0
 protected void DecompileConstructorChain(MethodDefinition method, ILanguage language, DecompiledType decompiledType)
 {
     if (this.cacheService.IsDecompiledMemberInCache(method, language, this.renameInvalidMembers))
     {
         V_3 = this.cacheService.GetDecompiledMemberFromCache(method, language, this.renameInvalidMembers);
         this.AddDecompiledMemberToDecompiledType(V_3, decompiledType);
         BaseWriterContextService.AddAssignmentDataToDecompiledType(V_3, decompiledType);
         return;
     }
     if (method.get_Body() == null)
     {
         V_4 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
         this.cacheService.AddDecompiledMemberToCache(method, language, this.renameInvalidMembers, V_4);
         return;
     }
     V_0 = this.DecompileMethod(language, method, decompiledType.get_TypeContext().ShallowPartialClone());
     V_1 = new List <CachedDecompiledMember>();
     V_2 = method.get_DeclaringType();
     if (!method.get_IsStatic())
     {
         V_5 = V_2.get_Methods().GetEnumerator();
         try
         {
             while (V_5.MoveNext())
             {
                 V_6 = V_5.get_Current();
                 if (!V_6.get_IsConstructor() || String.op_Equality(V_6.get_FullName(), V_0.get_Member().get_MemberFullName()) || V_6.get_IsStatic())
                 {
                     continue;
                 }
                 if (V_6.get_Body() != null)
                 {
                     V_1.Add(this.DecompileMethod(language, V_6, decompiledType.get_TypeContext().ShallowPartialClone()));
                 }
                 else
                 {
                     V_7 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(V_6), null, null));
                     V_1.Add(V_7);
                 }
             }
         }
         finally
         {
             V_5.Dispose();
         }
         V_1.Add(V_0);
         this.MergeConstructorsTypeContexts(V_1, decompiledType);
         V_8 = V_1.GetEnumerator();
         try
         {
             while (V_8.MoveNext())
             {
                 V_9             = new BaseWriterContextService.u003cu003ec__DisplayClass15_0();
                 V_9.constructor = V_8.get_Current();
                 if (language as IntermediateLanguage == null)
                 {
                     this.RemoveBaseCtorInvocationStatements(V_9.constructor, decompiledType);
                 }
                 if (V_9.constructor.get_Member().get_Context() != null)
                 {
                     if (!this.cacheService.IsDecompiledMemberInCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers))
                     {
                         this.cacheService.AddDecompiledMemberToCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers, V_9.constructor);
                     }
                 }
                 else
                 {
                     V_10 = decompiledType.get_Type().get_Methods().First <MethodDefinition>(new Func <MethodDefinition, bool>(V_9.u003cDecompileConstructorChainu003eb__0));
                     if (!this.cacheService.IsDecompiledMemberInCache(V_10, language, this.renameInvalidMembers))
                     {
                         this.cacheService.AddDecompiledMemberToCache(V_10, language, this.renameInvalidMembers, V_9.constructor);
                     }
                 }
                 this.AddDecompiledMemberToDecompiledType(V_9.constructor, decompiledType);
             }
         }
         finally
         {
             ((IDisposable)V_8).Dispose();
         }
     }
     return;
 }
        protected void DecompileConstructorChain(MethodDefinition method, ILanguage language, DecompiledType decompiledType)
        {
            if (this.cacheService.IsDecompiledMemberInCache(method, language, this.renameInvalidMembers))
            {
                ///all constructors have already been decompiled.

                CachedDecompiledMember decompiledMember = this.cacheService.GetDecompiledMemberFromCache(method, language, this.renameInvalidMembers);
                AddDecompiledMemberToDecompiledType(decompiledMember, decompiledType);

                return;
            }
            if (method.Body == null)
            {
                CachedDecompiledMember methodCache = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
                this.cacheService.AddDecompiledMemberToCache(method, language, this.renameInvalidMembers, methodCache);
                return;
            }
            CachedDecompiledMember        originalConstructor = DecompileMethod(language, method, decompiledType.TypeContext.ShallowPartialClone());
            List <CachedDecompiledMember> allConstructors     = new List <CachedDecompiledMember>();
            TypeDefinition declaringType = method.DeclaringType;

            if (!method.IsStatic)
            {
                foreach (MethodDefinition constructor in declaringType.Methods)
                {
                    if (!constructor.IsConstructor || constructor.FullName == originalConstructor.Member.MemberFullName || constructor.IsStatic)
                    {
                        continue;
                    }
                    if (constructor.Body == null)
                    {
                        CachedDecompiledMember methodCache = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(constructor), null, null));
                        allConstructors.Add(methodCache);
                    }
                    else
                    {
                        allConstructors.Add(DecompileMethod(language, constructor, decompiledType.TypeContext.ShallowPartialClone()));
                    }
                }
                allConstructors.Add(originalConstructor);

                MergeConstructorsTypeContexts(allConstructors, decompiledType);

                foreach (CachedDecompiledMember constructor in allConstructors)
                {
                    if (!(language is IntermediateLanguage))
                    {
                        // there are no such statements in IL
                        RemoveBaseCtorInvocationStatements(constructor, decompiledType);
                    }
                    if (constructor.Member.Context == null)
                    {
                        var methodDefinition = decompiledType.Type.Methods.First(x => x.FullName == constructor.Member.MemberFullName);

                        if (!this.cacheService.IsDecompiledMemberInCache(methodDefinition, language, this.renameInvalidMembers))
                        {
                            this.cacheService.AddDecompiledMemberToCache(methodDefinition, language, this.renameInvalidMembers, constructor);
                        }
                    }
                    else
                    {
                        if (!this.cacheService.IsDecompiledMemberInCache(constructor.Member.Context.Method, language, this.renameInvalidMembers))
                        {
                            this.cacheService.AddDecompiledMemberToCache(constructor.Member.Context.Method, language, this.renameInvalidMembers, constructor);
                        }
                    }
                    AddDecompiledMemberToDecompiledType(constructor, decompiledType);
                    //UpdateTypeContext(decompiledType.TypeContext, constructor);
                }
            }
        }