mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.03k stars 139 forks source link

Property with private setter are seen as writable even if not #93

Open ItSkary opened 3 years ago

ItSkary commented 3 years ago

The code to determine if a property is readeble or writable just wrap the PropertyInfo CanRead and CanWirte.

    `/// <summary>
    /// Property Can Read
    /// </summary>
    public bool CanRead
    {
        get
        {
            switch (member.MemberType)
            {
                case MemberTypes.Property: return ((PropertyInfo)member).CanRead;
                default: throw new NotSupportedException(member.MemberType.ToString());
            }
        }
    }`

   `/// <summary>
/// Property Can Write
/// </summary>
public bool CanWrite
    {
        get
        {
            switch (member.MemberType)
            {
                case MemberTypes.Property: return ((PropertyInfo)member).CanWrite;
                default: throw new NotSupportedException(member.MemberType.ToString());
            }
        }
    }`

IMHO in case of propeties FasMember should also check the value of PropertyInfo.GetMethod().IsPublic and PropertyInfo.SetMethod().IsPublic

I know that may be accessibile (getter or setter) even if not public (depending on where the fastmember code is executed) but at least add those two propeties to the Member instance should help to determine if the property is accessibile