public static ICSharpFunctionDeclaration GetContractMethodForAbstractFunction(this ICSharpFunctionDeclaration functionDeclaration)
        {
            Contract.Requires(functionDeclaration != null);

            Contract.Requires(functionDeclaration.IsAbstract);

            var currentClass = (IClassLikeDeclaration)functionDeclaration.GetContainingTypeDeclaration();

            Contract.Assert(currentClass != null);

            var contractClassDeclaration = currentClass.GetContractClassDeclaration();

            if (contractClassDeclaration == null || contractClassDeclaration.Body == null)
            {
                return(null);
            }

            // Get all "function declarations": methods and property accessors
            var functionDeclarations =
                contractClassDeclaration.Body.Methods.OfType <ICSharpFunctionDeclaration>()
                .Concat(
                    contractClassDeclaration.Body.Properties
                    .SelectMany(pd => pd.AccessorDeclarations)
                    );

            // Function declaration contains IFunction as DeclaredElement, but we need IOverridableMember
            // instead to get all super members
            Func <ICSharpFunctionDeclaration, bool> isOverridesCurrentFunction =
                md => md.DeclaredElement.With(x => x as IOverridableMember)
                .Return(x => x.GetAllSuperMembers(), Enumerable.Empty <OverridableMemberInstance>())
                .SelectMany(GetMembers)
                .Any(overridable => overridable.Equals(functionDeclaration.DeclaredElement));

            return(functionDeclarations.FirstOrDefault(isOverridesCurrentFunction));

            //Func<IMethodDeclaration, bool> isOverridesCurrentFunction =
            //    md => md.DeclaredElement.GetAllSuperMembers()
            //        .SelectMany(GetMembers)
            //        .Any(overridable => overridable.Equals(functionDeclaration.DeclaredElement));

            //Func<IPropertyDeclaration, bool> isOverridesCurrentProperty =
            //    pd => pd.DeclaredElement.GetAllSuperMembers()
            //        .SelectMany(GetMembers)
            //        .Any(overridable => overridable.Equals(functionDeclaration.DeclaredElement));

            ////IPropertyDeclaration pd = null;
            ////var rrr = pd.DeclaredElement.Getter as ICSharpFunctionDeclaration;
            //IMethodDeclaration met = null;
            //IPropertyDeclaration pppd = null;
            //IClassMemberDeclaration ccm = met;
            //IAccessorDeclaration ad = null;
            //var function = contractClassDeclaration
            //    .With(x => x.Body)
            //    .Return(x => x.Methods.FirstOrDefault(isOverridesCurrentFunction));
            //if (function != null)
            //    return function;

            //var selectedProperty = contractClassDeclaration.With(x => x.Body)
            //    .Return(x => x.Properties.FirstOrDefault(isOverridesCurrentProperty));
            //return selectedProperty.AccessorDeclarations.FirstOrDefault();
            ////var rrr = selectedProperty.DeclaredElement.Getter as ICSharpFunctionDeclaration;
            //return null;
            ////return selectedProperty.DeclaredElement;
        }