Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

(Case 1006282) VSTU: Using enum flags displays "Node not supported"

Discussion in 'Editor & General Support' started by Peter77, Feb 25, 2018.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,588
    @jbevain @sailro Using enum flags in the Visual Studio Watch window displays "Node not supported" rather than the actual value. Storing these enum flags in a variable and adding this variable to the Watch window, does display the enum flags value.

    Please see the attached screenshot.
    screenshot.png

    I use Unity 2018.1.0b8, VS 2017 Community and VSTU 3.3.0.2.

    Reproduce
    1. Open attached project
    2. Open Scenes/SampleScene.unity
    3. Execute "Assets > Open" C# Project
    4. Add breakpoint to NewBehaviourScript.cs at line 19 (Debug.Log)
    5. Attach Visual Studio to Unity
    6. Switch to Unity and press Play
    7. Visual Studio should now hot the breakpoint and halt
    8. Execute in VS "Debug > Window > Watch > Watch 1" to open the Watch window
    9. Add "flags" to Watch window (without quotes)
    10. Add "MyFlags.A | MyFlags.B" to Watch window (without quotes)
    Observe the Watch window displays the value of "flags", but does not display the value of "MyFlags.A | MyFlags.B".


    Expected
    Using enums in the Watch window should properly display the value.
     

    Attached Files:

  2. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    Hello,

    Thanks for reporting this, we'll look into it.
     
    Peter77 likes this.
  3. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    110
    Hi @Peter77,

    Good catch. After investigating, VSTU code is good, we even have unit tests that work in a comparable context.

    The bug is in the debugging layer between Unity and VSTU (Mono.Debugger.Soft).

    I filled an issue here:
    https://github.com/mono/mono/issues/7289

    With a custom fix to check:
    upload_2018-2-26_15-17-55.png
     
    Last edited: Feb 26, 2018
    Peter77 likes this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,588
    Great, thanks for the quick response!
     
  5. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    I can't say exactly when this will surface, but this will get fixed in a next version of VSTU where we'll take the fixed version of the Mono debugger client library.
     
    Peter77 likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,588
    Thanks, that's excellent new! Also thanks for keeping me in the loop.
     
  7. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    169
    @jbevain This appears to still be around in 2019.2.11f1, or at least i'm seeing it with the == operator
     
    sand_lantern likes this.
  8. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    @Reahreic could you give an example of the enum + the expression that returns the node not supported? That would help us diagnose this. Thanks!
     
  9. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    169
    When pasting:
    entityRef.entity.type == Entity.Type.None
    into the VS 2019 watch it shows "Node not supported: `entityRef.entity.type== Entity.Type.None`

    I use the below in a custom editor to alter the view based on an items configuration. (Stripped code to minimums for declutter)

    Code (CSharp):
    1.  
    2. public class EvalEditor : Editor {
    3.     private CrossSceneEntityReference entityRef;
    4.    
    5.     public override void OnInspectorGUI() {
    6.         serializedObject.Update();
    7.        
    8.         //Unity, it would be nice if cross scene reference support was native...
    9.         entityRef = EntityManager.ResolveReference(guid);
    10.  
    11.         if(entityRef == null) {
    12.             //Unable to locate reference
    13.             //TODO: Show friendly message.
    14.             return;
    15.         }
    16.  
    17.         if (entityRef.entity.type == Entity.Type.None) {
    18.             //TODO: Show Simple Config Instruction
    19.             return;
    20.         }
    21.        
    22.         //... more editor functionality
    23.        
    24.         serializedObject.ApplyModifiedProperties();
    25.     }
    26. }
    27.  
    28. public class Entity{
    29.     public enum Type{
    30.         None,
    31.         TypeA,
    32.         TypeB
    33.     }
    34.     public Type entityType {get; private set;} = Type.None;
    35.    
    36.     //... more class logic
    37. }
    38.  
    39. public class CrossSceneEntityReference{
    40.     public byte[] guid {get; private set;} = Guid.Empty.ToByteArray();
    41.     public Entity entity {get; private set;} = null;
    42.    
    43.     //... more class logic
    44. }
    45.  
     
  10. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    110
    Ok I repro. Thank you I'm going to have a look to fix this.

    As a workaround until we fix, you can use:

    Code (csharp):
    1. (int) entityRef.entity.type == (int) Entity.Type.None
     
    sand_lantern likes this.
  11. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    175
    Just ran into the same issue. In my case it's happening for pretty much all enums in my project and casting to ints does work around the issue.

    Also seems to be having troubles with extension functions that I have defined on my enums. For example, I have something like this:

    Code (CSharp):
    1.  
    2. public enum AttackType {
    3.     None = 0, Primary = 1, Secondary = 2
    4. }
    5.  
    6. public static AttackTypeExt {
    7.     public static bool IsNone (this AttackType self) {
    8.         return self == AttackType.None;
    9.     }
    10. }
    11.  
    12. public class Actor : Monobehaviour{
    13.     public AttackType Type;
    14. }
    15.  
    And VS gives the following:
    upload_2020-4-24_12-15-34.png

    This maybe should be in a separate thread, but it just seemed like a small little thing to mention along these lines.
     
  12. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    110
    The enum issue is fixed in our master.

    Yes extension methods are another issue that we have on our radar.
     
    sand_lantern likes this.
unityunity