Programming Languages Hacks

Importanti regole per linguaggi di programmazione rilevanti come Java, C, C++, C#…

  • Subscribe

  • Lettori

    I miei lettori abituali

  • Twitter

Archive for January, 2014

Quick Debug a Value (Chaining)

Posted by Ricibald on 24th January 2014

This code fails on method Pay:

Customer customer = repository.GetCustomer(id);

You have to debug the result value of the method GetOpenOrders. To accomplish this you have to add one row to split the statement:

Customer customer = repository.GetCustomer(id);
IEnumerable<Order> openOrders = customer.GetOpenOrders();   // BREAKPOINT HERE

Having one more row we can now add a breakpoint on row 2. This approach requires to rewrite the statement.
Just adding this extension method we can now debug every value:

public static T Break<T>(this T t) {
    return t;

Just use in this way:

Customer customer = repository.GetCustomer(id);

No new rows, just chaining :-)!!

Posted in .net | No Comments »