implementing Assert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zeng

    implementing Assert

    Hi,

    I'm wondering if there is a way to capture the line that call a method
    within the invoked method. I need to implement an assert statement
    checking. For example:

    public class Tools
    {
    static public void Assert( bool bMustBeTrue )
    {
    if( !bMustBeTrue )
    ErrorLog.Output ( "This statement is not true:" + ????? ); //
    how do I capture "State_X == CurrentState" ? );
    }
    }


    invoking code:
    Assert( State_X == CurrentState )


    Thanks!!


  • Robert Jordan

    #2
    Re: implementing Assert

    Hi,
    [color=blue]
    >
    > I'm wondering if there is a way to capture the line that call a method
    > within the invoked method. I need to implement an assert statement
    > checking. For example:[/color]

    Did you considered System.Diagnost ics.Debug.Asser t?

    bye
    Rob

    [color=blue]
    >
    > public class Tools
    > {
    > static public void Assert( bool bMustBeTrue )
    > {
    > if( !bMustBeTrue )
    > ErrorLog.Output ( "This statement is not true:" + ????? ); //
    > how do I capture "State_X == CurrentState" ? );
    > }
    > }
    >
    >
    > invoking code:
    > Assert( State_X == CurrentState )
    >
    >
    > Thanks!!
    >
    >[/color]

    Comment

    Working...