public static string GetPropertyName(MemberMethodDefinition methodDef)
        {
            // property
            string name = methodDef.GetRenameName();

            if (name.StartsWith("get"))
            {
                return(name.Substring(3));
            }

            if (name.StartsWith("set"))
            {
                return(name.Substring(3));
            }

            if (!methodDef.MetaDef.CodeStyleDef.AllowIsInPropertyName && name.StartsWith("is"))
            {
                return(name.Substring(2));
            }

            // For properties named like "hasEnabledAnimationState".
            return(methodDef.MetaDef.CodeStyleDef.ConvertPropertyName(methodDef.CLRName, methodDef));
        }
        /// <summary>
        /// Checks whether this method is a set accessor for a CLR property.
        /// </summary>
        /// <seealso cref="IsPropertyGetAccessor"/>
        public static bool CheckForSetAccessor(MemberMethodDefinition methodDef)
        {
            //
            // IMPORTANT: Don't use any of the "IsProperty..." properties of MemberMethodDefinition
            //   in this method as those properties use this method to determine their values.
            //
            if (methodDef.IsOverriding)
            {
                // Check this before checking possible attributes
                return(methodDef.BaseMethod.IsPropertySetAccessor);
            }

            if (methodDef.IsConstructor || methodDef.MemberTypeName != "void" || methodDef.Parameters.Count != 1)
            {
                // Check this before checking possible attributes
                return(false);
            }

            if (methodDef.HasAttribute <PropertyAttribute>())
            {
                return(true);
            }

            if (methodDef.HasAttribute <MethodAttribute>())
            {
                return(false);
            }

            if (methodDef.HasAttribute <CustomIncDeclarationAttribute>() ||
                methodDef.HasAttribute <CustomCppDeclarationAttribute>())
            {
                return(false);
            }

            string name = methodDef.GetRenameName();

            if (!name.StartsWith("set") || !Char.IsUpper(name[3]))
            {
                return(false);
            }

            // Check to see if there is a "get" function
            string propName = name.Substring(3);
            MemberMethodDefinition method;

            // TODO by manski: Allow the case that the getter and the setter come from different classes.
            //   Special care must be taken in this case as for example "Property.ContainingClass" can't
            //   be used anymore, since there are two classes involved. This could be solved by returning
            //   the "lowest" subclass (i.e. the class in which both accessors are defined then).
            //   Then the second argument should be changed to "true" here.
            method = methodDef.ContainingClass.GetMethodByNativeName("get" + propName, false, false);
            if (method == null)
            {
                method = methodDef.ContainingClass.GetMethodByNativeName("is" + propName, false, false);
                if (method == null)
                {
                    method = methodDef.ContainingClass.GetMethodByNativeName("has" + propName, false, false);
                }
            }

            // NOTE: Most checks done in "CheckForGetAccessor()" are represented in "method.IsPropertyGetAccessor".
            return(method != null && method.IsPropertyGetAccessor && method.MemberTypeName == methodDef.Parameters[0].TypeName &&
                   (!methodDef.ContainingClass.AllowVirtuals ||
                    (method.IsVirtual == methodDef.IsVirtual && method.IsOverriding == methodDef.IsOverriding)));
        }
        /// <summary>
        /// Checks whether this method is a get accessor for a CLR property.
        /// </summary>
        /// <seealso cref="IsPropertyGetAccessor"/>
        public static bool CheckForGetAccessor(MemberMethodDefinition methodDef)
        {
            //
            // IMPORTANT: Don't use any of the "IsProperty..." properties of MemberMethodDefinition
            //   in this method as those properties use this method to determine their values.
            //
            if (methodDef.IsOverriding)
            {
                // Check this before checking possible attributes
                return(methodDef.BaseMethod.IsPropertyGetAccessor);
            }

            if (methodDef.IsConstructor || methodDef.MemberTypeName == "void" || methodDef.Parameters.Count != 0)
            {
                // Check this before checking possible attributes
                return(false);
            }

            if (methodDef.HasAttribute <PropertyAttribute>())
            {
                return(true);
            }

            if (methodDef.HasAttribute <MethodAttribute>())
            {
                return(false);
            }

            if (methodDef.HasAttribute <CustomIncDeclarationAttribute>() ||
                methodDef.HasAttribute <CustomCppDeclarationAttribute>())
            {
                return(false);
            }

            string name = methodDef.GetRenameName();

            if (methodDef.MemberTypeName == "bool" &&
                ((name.StartsWith("is") && Char.IsUpper(name[2]) && methodDef.MetaDef.CodeStyleDef.AllowIsInPropertyName) ||
                 (name.StartsWith("has") && Char.IsUpper(name[3]))) &&
                methodDef.Parameters.Count == 0)
            {
                return(true);
            }

            if (!methodDef.MemberType.IsValueType &&
                (methodDef.MemberType.IsSharedPtr || methodDef.MemberType is DefTemplateOneType || methodDef.MemberType is DefTemplateTwoTypes))
            {
                return(false);
            }

            if (methodDef.MemberType.HasAttribute <ReturnOnlyByMethodAttribute>())
            {
                // Invalid type for a property
                return(false);
            }

            string propName;

            if (name.StartsWith("get") && Char.IsUpper(name[3]))
            {
                propName = name.Substring(3);
            }
            else if (name.StartsWith("is") && Char.IsUpper(name[2]))
            {
                propName = name.Substring(2);
            }
            else
            {
                // Not a valid getter prefix.
                return(false);
            }

            // Check if the property's name collides with the name of a nested type. In this
            // case we can't convert the method into a property.
            AbstractTypeDefinition type = methodDef.ContainingClass.GetNestedType(propName, false);

            if (type != null)
            {
                return(false);
            }

            // Check if the property's name collides with the name of a method. In this
            // case we can't convert the method into a property.
            MemberMethodDefinition method = methodDef.ContainingClass.GetMethodByCLRName(propName, true, false);

            // If there is no method == valid property name
            return(method == null);
        }