LINQ is awesome. It allows us to write powerful, succinct, and expressive code that’s a pleasure to read and maintain. The only problem is that using LINQ means sacrificing the debuggability of your code for its readability. If you F10 over a line of code that’s using LINQ – you’ve just performed a whole bunch of complicated logic, but you get absolutely no insight into what actually happened. When debugging LINQ, using breakpoints and manual stepping can be a futile waste of time.
OzCode’s groundbreaking LINQ debugging visualizations allows you to see exactly how the different items passed through the LINQ pipeline, and see the return value of each and every lambda expression, all while leveraging powerful OzCode tools such as Reveal and Search.
LINQ Debugging is only supported in VS2015 and up. .NET Core is not yet supported, but support is coming soon.
During debugging, when the execution point (the yellow line) reaches a LINQ query, an indicator appears next to each LINQ operator, denoting how many items it produced.
These indicators show you at-a-glance how many items were consumed by each operator, and how many were produced, helping you decide which operator to focus on.
Clicking on one of the numeric indicators puts OzCode into LINQ Debugging Mode, and opens the LINQ DataTip window which shows the items the given operator produced. You can press the “before/after” buttons in the DataTip to quickly switch between the items that were produced and the ones consumed by that operator.
Clicking on one of the items will update the Head-Up Display to reflect what each lambda returned as that particular item passed through the LINQ pipeline. Another option is to use the mouse wheel while hovering over the numeric annotation to quickly scroll through the items, seeing their values change instantly in the debugged code.
LINQ Analysis Window
The detailed analysis tool window can be opened from the DataTip window, or by clicking on the lambda icon to the left of the debugged query:
You can use Search and Reveal to find objects of interest, navigate between the LINQ pipeline using the operator breadcrumbs, and take advantage of the animation to visualize the flow of the LINQ query:
Understanding Exceptions in LINQ queries
One of the hardest bugs to tackle is when an exception is thrown from deep within a complicated LINQ query – this is almost impossible to debug. OzCode will warn you about such an exception before it is even thrown by highlighting the LINQ Numeric Indicator in red, letting you drill down using the LINQ DataTip or LINQ Analysis Window to find out exactly which item caused that exception!
Fluent and Query Syntax Support
When using LINQ to query, filter and transform collections, a developer has a choice between two flavors – the lambda-based fluent API, or the SQL-like query expressions.
The choice of which syntax to use depends on personal preference, as well as the nature of the problem. The fluent syntax is more terse, and tends to be preferable when the query is simple. However, some more complicated queries are much more easily expressed with the query syntax, which allows you to leverage the ‘let’ keyword and multiple
from clauses to work with complicated data.
OzCode fully supports both flavors of LINQ. When you use the query syntax, OzCode will visually highlight which items came from which
from clause, what values were calculated by the
let expression for each item, and more!
Export allows you to save a textual representation of an object instance to a file or to the clipboard, to be used after the debugging session has ended.
With Export, a developer can “grab” objects and save them as either JSON, XML or even as a C# code that can be used to create Unit Tests with the values of the last debug run.
Once the exported instance is saved (or copied to the clipboard), it can be used to reproduce the instance state, analyzed or compared using external diff tools.
For the JSON output, OzCode uses the industry-standard Newtonsoft Json.NET serializer, which makes it super easy to deserialize and work with the result.
Debugging complex expressions is never easy. How do you see what was returned by a method call? What did each boolean condition evaluate to in a long convoluted if statement? Without simplifying the code or adding variables to store individual results, answering these questions is difficult. With OzCode’s powerful “Simplify” visualization, you can instantly figure out exactly what is happening in your code! When stepping over an expression, a red/green color coding will tell you exactly which expressions returned false/true, respectively. The red or green indicate the result of the entire expression.
Simply click the Simplify button and the expression will be visualized instantly, giving you the option to drill down and see individual expression results.
The nicest thing about Simplify is that you can see a historical view of your code’s execution. Each time you Step Over (F10) a line of code, a new Simplify button will appear, allowing you to look into the past! No longer will you have to restart debugging if you’ve Stepped Over too far!
Simplify Time Travel Keyboard Shortcuts
If you’re a keyboard person, we’ve made some useful shortcuts for you to time travel without lifting your palms: Hit + to visualize the current line and then use + to visualize the current line or + to navigate between the different lines of code.You can also hold down the key while debugging and then tap a digit ( – ) to directly pick the statement to visualize.
The Magic Glance, which can be toggled by clicking the Toolbar icon (or by pressing the + + shortcut), gives you amazing insight into your code by showing you a summary of each line of code you stepped through.
Predict the Future
OzCode v2.0 performs predictive analysis of code execution (or as we like to call it: Fortune telling!). In the following switch statement, OzCode is predicting the future: you can see the arrow pointing to where we’re going to go when we hit F10, and irrelevant code paths are made semi-transparent.
Predict brings a new meaning to the term “Live Coding” by giving you instant feedback on changes you make as you’re debugging, allowing you to fix silly little coding mistakes extremely quickly.
If you’re using VS2015, Predict will even able to predict more complicated expressions, such as LINQ queries:
Conditional Breakpoints can make debugging so much more productive, but without OzCode, using them feels like a chore. OzCode makes adding a Conditional Breakpoint super easy! In just a single click, OzCode will set up a Conditional Breakpoint based on a specific property value, and pre-fill the predicate for you.
Want to add more predicates to the breakpoint? Take a shortcut! Simply hover over the relevant variable, and click the “Add Condition” button.
When Set... Break
The toughest bugs to figure out are those that involve mutating state. What do you do if at some point during the program’s execution, the state of some objects becomes invalid, but you have no idea exactly when and where it got that way? While inspecting values in the debugger, when you spot a problematic property value, use the Magic Wand and choose “When Set -> Break”. The next time the property value is changed, OzCode will break into the debugger and allow you to inspect the state of the program and figure exactly how that problematic value got there in the first place! These Setter Breakpoints work on both regular properties and auto-properties, and you can even add a Setter Breakpoint on properties you don’t have the source code to!
Without OzCode, investigating an exception is a dreary task – navigating through a trail of inner exceptions, scrolling through lengthy callstacks, and squinting through the exception’s associated data to try to make sense of the error. With OzCode, all the relevant information about the exception is presented in a handy tool-window. You can navigate through each inner-exception with a super- convenient breadcrumb control, and even launch a Google or stackoverflow search right from within Visual Studio!
OzCode’s Predict will alert you of an exception that’s about to happen. But that’s not all – if, for instance, OzCode detects an imminent NullReferenceException, you’ll see a red highlight showing exactly what expression is going to cause the exception!
OzCode’s predictive exception analysis makes it super-easy to fix an exception before it even happens, with the powerful of Edit & Continue!
When you’re debugging a tough problem, especially in debugging legacy code or a heavily multi-threaded scenario, stepping through the code to figure out what the system is doing feels like trying to juggle 12 balls in your head at once. With OzCode, when things get hairy, you can easily add dynamic logging on-the-fly at key points during the program’s execution, and then view the output using the fully featured integrated log-viewer that OzCode bakes into Visual Studio. No longer do you need to stop debugging, add logging code and then rebuild each time you want to add a simple trace!
Simply use the “Create Tracepoint” command on the value you want to trace. A Tracepoint is just like a Breakpoint, except that instead of breaking the program’s execution, it writes a trace message.
Then, add whatever bits of information you think might be related to the bug with the “Add To Tracepoint” button:
Finally, watch the trace messages come into the Tracepoints Viewer:
In many projects you can’t start a debugging session by just hitting F5. Instead, you have to use the “Attach to Process” option, find the correct process in the long list of processes, and finally connect to it. Later on, when you restart your debugging session, you have to do it all over again. And again. And again.
With QuickAttach, OzCode makes the routine of attaching to a process super-fast. The QuickAttach window shows you the list of processes you attached to most recently. By clicking the Pin button, you can attach a shortcut key to that process:
And that’s it. From now on, whenever we want to attach to ‘w3wp.exe’, we’ll just hit + + , and that’s it
If the process you want to attach to is not in the “Recently Attached” list, you can always search for it, and even see a preview of what its UI looks like:
OzCode makes attaching to an IIS Application Pool super easy, by showing you exactly what web site you’re attaching to:
When debugging objects and collections, you are often looking for a specific property or field, or a value held within a property or field. Unfortunately, this usually involves either a lot of clicking and scrolling, or writing custom debug-specific code. Finding items even in simple structures is not easy, not to mention doing so in a complex object graph. With our “Search” feature, this is no longer the case. Quickly and effortlessly search member names and values, no matter the size of the collection or complexity of the object graph!
When stepping through a foreach loop during a debug session, you are likely to encounter some common issues such as determining where you are in the loop and navigating to a specific item in the collection. While Visual Studio does offer ways to answer these questions, they are far from easy. With OzCode’s innovative “Foresee” feature, dealing with foreach loops is simple and intuitive. Foresee is a debug visualizer that helps you keep track of where you are in the loop at all times and allows navigation to specific items in the collection. It gives you visual representation of the collection including items already iterated over, the current item and upcoming items. Interested in a particular item in the collection? Just right click on the item and choose ‘Run to item’ and the loop will execute and then break on the desired item. No need to setup and deal with conditional break points!
Due to a limitation with Visual Studio, the Foresee feature is currently only supported in Visual Studio 2013
When you want to compare files, you use a diff application to spot the differences. Unfortunately, when you need to compare two (or more) objects, you have to trust your eyes and memory. With our Compare feature, you can now spend less time squinting, and let OzCode Compare objects and collections with a simple click! The results are displayed in a side-by-side view that helps you investigate the differences and the similarities between the two objects.
Once an object is selected for comparison, OzCode will highlight all other local variables and fields that are comparable to the selected instance (meaning they are the same type or derive from the same type).
Compare items in a collection
What if you need to spot the difference between two or more items in the same collection? OzCode’s Compare makes comparing multiple items simple and fast. Comparing several items in the same collection is easy and the results are shown side by side.
Using external diff tool
When comparing two long strings – such as two XML or Json documents, Compare will automatically launch your favorite Diff tool, making it super easy to spot the difference between the two.
You can configure Compare to use either Visual Studio’s native diff tool, or an external diff tool, under OzCode->Options.
Currently supported options include Beyond Compare (v3 or v4), KDiff, WinMerge, Araxis Merge, and Tortoise.
The hardest bugs to solve are the ones that involve mysterious side effects. Consider a long and complicated method which takes an object and performs various mutations on it. Would you be able to tell what has actually changed?
For a class with many members, which might also contain a few members themselves, finding the differences is difficult. With Compare you can now save an object’s state and later compare the object, during debugging, to its original saved state. After the function executes, you can choose the Compare to Snapshot option to see the differences.
When you save a snapshot of a given object, it will now persist across debugging sessions! You can save a snapshot of an object, stop your debugging session or even close Visual Studio, and then come back the next day and compare a live object to the snapshot you had saved!
Objects can have many properties, but when debugging, not all of them are useful to you. You’re usually interested only in a selected few. For a Customer class, it might be the ID and Username properties, for a Point in 3D space, it might be the X, Y, and Z fields. With our “Reveal” feature, you can finally focus on the data that actually matters. Star the properties you are interested in and they will appear right next to the object. If you have, for example, a collection of Customer objects and you are mostly concerned with their first and last names, simply star the FirstName and Surname properties and immediately all the objects in the collection show these properties next to them. Your choices will be persisted across debugging session and across different Visual Studio solution files.
When debugging, sometimes the information you need is not contained in the fields and properties of an object; rather, it’s a calculation or an expression that is based on your object. You might find yourself wishing you had a different set of properties just for this specific debugging session.
For example, when you’re looking at a Player object in your game, you might like to see the distance from the nearest enemy without having to add such a property to its interface.
With our Custom Expression feature, you can create multiple custom expressions on any object type, which will be displayed just like any other member of that type. You can even star the ones that interest you the most.
For example, if a Customer class has a salary history among its properties, but what you really need to see in order to fix a bug is the customer’s due taxes for a certain year, simply use the “Add Custom Expression” option on the Customer variable, and write the expression that you’d like to see. The expression will be displayed as a property of the Customer class, containing the value of the expression.
Filtering a collection in code is relatively easy and there are plenty of ways to do it. But how do you filter while debugging? For example, you have a collection of Customer objects and you’d like to filter the ones that are older than 35 years. Visual Studio’s immediate window and watch windows don’t support lambdas. With our Filter Collections feature, you can apply a filter expression to any collection. To solve the customer problem, choose the collection of customers and set its filter to: DateTime.Today.Year – [obj].Birthday.Year > 35, press Enter and see the results right away. Once a collection is filtered, all the other features work on the filtered results as well.
OzCode’s Quick Actions offer you the most relevant actions, depending on your current context. Want to add a breakpoint to every method in the class? Trace every entry to a particular method? Quickly run forward to a particular line of code? Hit Alt+Shift+D to open up the Quick Actions menu or click the Magic Wand, and do some magic!
Show All Instances
OzCode makes it trivial to find specific objects in memory that you want to explore. Just open “Show All Instances of Type” and you’ll be able to see every object of that type that’s currently in memory. Why is that object still in memory? Are there any objects that contain this value? OzCode’s exciting new exploration tool effortlessly and instantly answers these questions and more.