Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Exclude attributes from precondition visibility verification #280

Merged
merged 2 commits into from
Oct 28, 2015

Conversation

SergeyTeplyakov
Copy link
Contributor

Fix for #273


return IsAttribute(declaringType.BaseType);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current code checks declaringType.BaseType twice on recurrence.
Loop version should be simpler:

private static bool IsAttribute(TypeNode declaringType)
{
    TypeNode currentType = declaringType;
    while (currentType != null)
    {
        if (currentType == systemAttributeType.Value)
        {
            return true;
        }

        currentType = declaringType.BaseType;
    }

    return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the loop version instead of

currentType = declaringType.BaseType

this should be

currentType = currentType.BaseType

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, thanks. Otherwise it might be less efficient than recursive version...

SergeyTeplyakov added a commit that referenced this pull request Oct 28, 2015
Exclude attributes from precondition visibility verification
@SergeyTeplyakov SergeyTeplyakov merged commit c5626e3 into microsoft:master Oct 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants