This project is read-only.
1

Resolved

Incorrect static variable & constant parsing

description

If you execute this test you will get Object not set to an instance of an object exception, because of incorrect private static string field parsing. Seems Node type is not detected correctly for it.

private static string aa = "aaa";
    [Test]
    public void PATest()
    {
        PAssert.IsTrue(()=>IsValidFunc(aa));
    }

    protected bool IsValidFunc(string aa)
    {
        return IsValidFunc2(aa);
    }

    protected bool IsValidFunc2(string aa)
    {
        return false;
    }

comments

flamedmg wrote Dec 12, 2010 at 9:06 AM

Here is a quickfix for this issue:

diff --git a/PowerAssert/Infrastructure/ExpressionParser.cs b/PowerAssert/Infrastructure/ExpressionParser.cs
--- a/PowerAssert/Infrastructure/ExpressionParser.cs
+++ b/PowerAssert/Infrastructure/ExpressionParser.cs
@@ -195,7 +195,7 @@
     static Node Member(MemberExpression e)

     {
  • if (IsDisplayClass(e.Expression))
  • if (IsDisplayClass(e.Expression) || e.Expression == null)
         {
    
             return new ConstantNode
    
             {
    
@@ -269,7 +269,7 @@
             {

                 return FormatTargetInvocationException(exception);

             }
  • if (Object.Equals(left, right))
  • if (Object.Equals(left, right))
             {
    
                 return ", but would have been True if you'd called .Equals()";
    
             }
    

robfe wrote Dec 13, 2010 at 8:11 AM

Fixed in changeset 227091d0fd43