Skip to content

Provide a way for debugger variables to include fields that are expensive/have side-effects and can be lazily evaluated #134450

@DanTup

Description

@DanTup

Many languages have "properties" on classes that require executing code when executed. Users often want to see these in the debug views (Watch, Variables, Evaluation) but executing them can be expensive and/or produce side-effects.

In Dart, we evaluate these by default but have a setting to turn it off - however it's a little hard to discover this if you don't know where to look.

It would be nice if there was some way to return some "placeholder" variables from a variablesRequest that could require some user-action to evaluate. For example, given the code:

class Person {
  String name = "Danny";
  String get email {
    return "foo@example.bar";
  }
}

final a = Person();

When evaluating a, I would like to be able to return a response that includes the value for name but a lazy placeholder for email that the user can trigger to get the value. It should look natural in the UI (eg. not wrapping the value for email in some dummy object):

a
  name:     Danny
  email:    (click to evaluate)

The "click to evaluate" could perhaps just trigger evaluation of the evaluateName on the variable?

This would also potentially allow common some well-known methods like toString() to be included in the list without having to execute them (but providing an easy/convenient way for the user to see them).

@isidorn @weinand @jacob314

Metadata

Metadata

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code Insiderson-testplan

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions