Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ItSkary opened this issue Aug 30, 2021 · 0 comments
Open

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

ItSkary opened this issue Aug 30, 2021 · 0 comments

Comments

@ItSkary
Copy link

ItSkary commented Aug 30, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant