Share via


Edit & Continue and Make Object ID Improvements in CTP 6

It's the beginning of a new year! According to Back to the Future Part II, everyone will be riding hoverboards in a couple months (and, let's be honest, Doc would love the HoloLens). In the meantime, let's explore the enhancements we've made to the Visual Studio debugging experience. In CTP 6, we improved the edits supported by Edit & Continue and now support Make Object ID in the new 2015 C# and VB expression evaluators.

Before you read more about our improvements in CTP 6, make sure you have read Anthony's post on debugging improvements in Visual Studio 2015 Preview.

Edit & Continue is reaching its potential.

Hoverboards

Edit & Continue lets you modify and add to your source code while debugging without ever having to restart your session. I'm happy to say we listened to you all and have fleshed out the Edit & Continue experience. Say goodbye to the days of pre-2005 language support and small edits! See the list below to see what source code edits are possible while debugging*:

  • Adding methods, fields, constructors, properties, events, indexers, field and property initializers, and nested and top-level types (including delegates, enums, interfaces, abstract and generic types)
  • Modifying bodies of constructors (including constructor initializers), expression-bodied members, and field and property initializers
  • Adding and modifying methods that use the following post-2005 types and features:
  • Reordering type members and type parameter constraints
  • Refactoring code (extract method and inline temporary variable) using Ctrl + .
  • Example of inlining a variable while debugging

*The following types of edits are not supported:

  • Deletion of members, types, or entire method bodies
  • Modifying method signatures and renaming
  • Modifying generics, interfaces, and abstract types
  • Adding or modifying enum members to an existing enum
  • Modifying await expressions wrapped inside other expressions (e.g., G(await F());)

Object IDs are a hidden gem and we've modified the syntax.

Object IDs

Did you know you can tag an object in the debugger and refer to it later using Make Object ID (even when the object is out of scope)? Did you know you could compare references of objects and verify that they refer to the same object with an Object ID tag? While Object IDs have been around for several years, few know and take advantage of this feature.

An Object ID is a unique identifier for an object. Because garbage collection unpredictably shifts object memory addresses, we can’t use pointers to track objects. Instead, our debugger gives you a unique identifier and keeps track of the object's current location for you (using an aliasing mechanism in the CLR). You can use the Object ID when debugging to compare references of objects and be absolutely certain they refer to the same object. You can also use an Object ID to monitor an object when it is out of scope in the debugger.

Below, I am stopped at a breakpoint on line 13. I have created a Watch for Circle a and made an Object ID for it ($1). Now if I step into the initialization of Circle b, putting Circle a out of scope, I can still inspect the value of Circle a via its Object ID:

Object IDs track objects even when they are out of scope

Another change to note is that we've changed the Object ID syntax for C# and Visual Basic. It is now a dollar-sign ($) followed by a numeric for both languages (e.g., $1). The previous syntax for Object IDs was [number]# for C# (e.g., 1#) and ObjID[number] for Visual Basic (e.g., ObjID1). We chose to alter the Object ID syntax for the following reasons:

  • The new syntax will allow us to provide a better IntelliSense experience by showing defined Object IDs in the completion list after typing the “$” prefix character (planned for RTM)
  • The new syntax is now consistent with other pseudo-variables, (e.g. $exception, $ReturnValue)

Try out all these new features in Visual Studio 2015 CTP 6. Let us know what you think using Visual Studio’s Send a Smile feature! And don’t forget to log issues on our GitHub.

Over 'n' out
Kasey Uhlenhuth, Program Manager, Managed Languages Team

Comments

  • Anonymous
    February 23, 2015
    Looks like some good improvements.  What about edit and continue for xaml?   I spend ages restarting just to make a minor change  and check that looks okay

  • Anonymous
    February 23, 2015
    There appears to be a broken link. The 3rd one under "Edit & Continue is reaching its potential" (Dynamic objects)

  • Anonymous
    February 23, 2015
    Absolutely incredible announcement! These edit and continue features will save many hours a year wasting to wait for the app to restart! Great work! One question: I read that modifying generic classes is not supported. Is this a temporary limitation? Are you working on this too or is it too hard or technically impossible?

  • Anonymous
    February 23, 2015
    Does it work now for 64bit asp.net apps?

  • Anonymous
    February 23, 2015
    Fantastic! It's little things like these that cumulatively make Visual Studio the best IDE in the known universe. Tooling is a huge percentage of the value proposition of the Microsoft ecosystem.

  • Anonymous
    February 23, 2015
    @Stefan, the XAML team is working on it. You can read about their progress under XAML UI Debugging here: blogs.msdn.com/.../visual-studio-2015-ctp-6-and-team-foundation-server-2015-ctp-released.aspx @Rory, I updated the link, not sure what went wrong there! @Dave, we are considering supporting modification of generics post-RTM. Stay tuned (request it on uservoice!)

  • Anonymous
    February 23, 2015
    The improvements to Make Object ID are nice, but what would be really great is the ability to use names rather than numeric ids. Our limited human brain can only keep track of a small number of ids; using names would make it much easier to work with multiple object ids. I assume the implementation would be fairly easy; you can still have a numeric id internally, and maintain a name <-> id mapping.

  • Anonymous
    February 23, 2015
    @StefanOlson try XamlWatcher ( github.com/.../XamlWatcher ) for live xaml refresh

  • Anonymous
    February 23, 2015
    @Thomas, that is definitely a nice feature that we've talked about but unfortunately we can't spend time on it for RTM.

  • Anonymous
    February 23, 2015
    Hi, just a question. Are these new Edit&Continue features available only in standard .NET Framework, or in other platforms as well? Silverlight 5, Windows/Phone 8.1, ASP.NET 5? Both when targeting x86, x64, ARM? Thanks

  • Anonymous
    February 23, 2015
    @Kasey Uhlenhuth I installied CTP6 and new ENC is really cool! However the following operations are still not allowed:

  • Modify a method which contains a linq expression
  • Add/change linq expressions
  • Add additional await keyword in existing async method Especially the linq part is very annoying.  Will this be in CTP7?
  • Anonymous
    February 23, 2015
    Will changes to lambdas still break E&C? I don't see that mentioned in the post but know it has been a major pain point for many devs.

  • Anonymous
    February 24, 2015
    @Dave, @Rob H:  LINQ and lambda expressions are not supported in EnC in CTP 6. We hope to get these in by RTM!  Fingers crossed!

  • Anonymous
    February 24, 2015
    @Thomas L,  I created an issue for your request on our github: github.com/.../823

  • Anonymous
    February 25, 2015
    @Robert, @martinsuchan: in CTP 6, Edit & Continue is supported for all non-ASP.NET 5 scenarios running on the 4.6 desktop version of the CLR for both x86 and x64.  This means that it will work for Windows 8.1 apps, but it will not work for Silverlight 5, Phone 8.1, or ASP.NET 5.  We are currently working on enabling it for ASP.NET 5 and Windows Phone 10 emulator scenarios (x86 only), but at this point cannot promise exactly when that work will be ready. I hope this helps!

  • Anonymous
    February 25, 2015
    Would the program being debugged be able to know when and what was changed during edit and continue in order to reapply any IL analysis and post processing?

  • Anonymous
    May 01, 2015
    Did this break it for VB.NET or something?  I can edit and continue the same VB.NET project if I open it in VS 2013 but can't in VS 2015.

  • Anonymous
    May 05, 2015
    @Chris, There should be more edits supported in Visual Basic in 2015 than in 2013. I think there might have been some corner cases or there may be a bug. Edit and Continue definitely has more capabilities in Visual Studio 2015 RC than it did in CTP6 (like edits in and around lambda and query expressions). If you're using the RC version and still seeing this problem, please file an issue @ github.com/.../new detailing the before and after code that's not working for you and a team member will follow up. Regards, -ADG

  • Anonymous
    June 15, 2015
    This feature looks very good to me !