Dart-code: cannot view contents of Map<DateTime, List> while debugging

Created on 4 Dec 2019  路  11Comments  路  Source: Dart-Code/Dart-Code

I have a structure defined as Map , each element of List is also a map. During debugging I cannot view the data in the List maps. Expanding each list element shows only its meta data values (_checkSum, _data, _deletedKeys, _hashMask, _index etc...) not the map key/values. This makes debugging very difficult.

Screen Shot 2019-12-04 at 7 48 33 PM

this worked fine in previous versions

in debugger is bug

Most helpful comment

Ok, I finally managed to track this down! It was a silly mistake on my part..

Against the values we track an "evaluateName" (this is a string that evaluates to the value shown, which can be used for "Add Watch", etc.). This only works when the key is a simple type (eg. we can add a watch expression for myMap[1] but not for myMap[someComplexType]).

When fixing up for TypeScript strict mode, I'd incorrectly assumed that value was always present/required to display the map when it's not (it's only required for things like "Add Watch") and caused it to follow a different code path.

All 11 comments

Thanks, I can reproduce this - seems to only happen when the map has DateTime keys:

Screenshot 2019-12-04 at 4 33 45 pm

I'll see what I can find!

@devoncarew @pq Is there a way to get a log of the VM service traffic from Android Studio? This same code seems to work fine there, but in VS Code we get an object with kind="PlainInstance" and not kind="Map" so I want to figure out what we're doing differently.

Screenshot 2019-12-04 at 5 01 15 pm

@DanTup: do you have the Android Studio plugin running from source? I think you'd have to add print statements to the VmServiceManager (IIRC or similar). I'm not in front of the source now but happy to help instrument if you want to spelunk.

do you have the Android Studio plugin running from source?

I don't. Is it simple to set up? (I've never built any java in my life :-))

Or if it's simpler - if I paste the Dart code in here, could you easily run it and capture the VM service traffic?

Failing that - can you point me at the code that is fetching the values for this tree? I'll see if I can see any obvious differences with what you're doing there and I'm doing here. Thanks!

Go ahead and paste code here. Setup takes a bit...

@pq Here's the code from above:

import 'dart:convert';

main() {
  final mapOfListOfMaps1 = {
    1: [
      {1: 1, 2: 2},
    ],
  };
  final mapOfListOfMaps2 = {
    DateTime.now(): [
      {1: 1, 2: 2},
    ],
  };

  print('Hello!');
}

If you breakpojnt on the print and expand through mapOfListOfMaps2 to reveal values inside the leaf map (1:1, 2:2) capturing the VM service traffic, that should help my figure out what I'm doing differently.

Thanks!

@pq ping! I don't support you're able to capture a log for above (or give some hints on how I could do it)?

@pq ping! :)

(if it's not already possible, maybe there's value in having a way to write logs easily for end users? I'm often wishing I could get logs from Android Studio, and the logs from VS Code come in handy debugging user issues all the time!)

Ack! Sorry. Will look today.

EDIT: whoops; looks like this is in the Dart Plugin Debugger -- let me get that setup...

Ok, I finally managed to track this down! It was a silly mistake on my part..

Against the values we track an "evaluateName" (this is a string that evaluates to the value shown, which can be used for "Add Watch", etc.). This only works when the key is a simple type (eg. we can add a watch expression for myMap[1] but not for myMap[someComplexType]).

When fixing up for TypeScript strict mode, I'd incorrectly assumed that value was always present/required to display the map when it's not (it's only required for things like "Add Watch") and caused it to follow a different code path.

Good deal @DanTup!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shamrin picture shamrin  路  5Comments

FeimiSzy picture FeimiSzy  路  4Comments

lukepighetti picture lukepighetti  路  4Comments

partounian picture partounian  路  4Comments

ifredom picture ifredom  路  3Comments