1
Vote

AAST.AddUserPredicate throws exception if first exported type does not match

description

In AAST.cs, line 282 throws an exception if the first exported type does not match instead of continuing to iterate over the remaining exported types. The line 'hdlr.ListError(mSpan, 96, clsName); return;' should be moved outside of the loop:
foreach (Type type in types)
{
    if (type.FullName.Equals(clsName, StringComparison.OrdinalIgnoreCase) ||
        type.Name.Equals(clsName, StringComparison.OrdinalIgnoreCase))
    {
        QUT.Gplex.ICharTestFactory factory =
            (ICharTestFactory)System.Activator.CreateInstance(type);

        if (factory != null)
        {
            CharTest test = factory.GetDelegate(mthIdnt);
            if (test == null)
                hdlr.ListError(mSpan, 97, mthIdnt);
            else
                AddUserPredicate(name, test);
            return;
        }
    }
    hdlr.ListError(mSpan, 96, clsName); return;
}
becomes:
foreach (Type type in types)
{
    if (type.FullName.Equals(clsName, StringComparison.OrdinalIgnoreCase) ||
        type.Name.Equals(clsName, StringComparison.OrdinalIgnoreCase))
    {
        QUT.Gplex.ICharTestFactory factory =
            (ICharTestFactory)System.Activator.CreateInstance(type);

        if (factory != null)
        {
            CharTest test = factory.GetDelegate(mthIdnt);
            if (test == null)
                hdlr.ListError(mSpan, 97, mthIdnt);
            else
                AddUserPredicate(name, test);
            return;
        }
    }
}
hdlr.ListError(mSpan, 96, clsName); return;
In the absence of guidelines for contributing, I'll leave it to you to make the change.
Great tool, thanks for putting it out there!

comments

k_john_gough wrote Jun 9, 2013 at 3:20 AM

Thanks JosephGray. You will have worked out that my testing did not test the case of a helper assembly with multiple exported classes defined. Sorry about that, and thanks for the fix. I will upload the fix to the repository, so that it gets in the next refresh of the binary releases.
John.