Skip to content

Highlighter gets confused with nested anonymous objects #38

@DustinCampbell

Description

@DustinCampbell

From @G-Rath on February 11, 2017 23:56

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
VS Code version: 1.9.1
C# Extension version: 1.7.0

If I have a dynamic object that has inside it another dynamic object, the syntax highlighter gets confused, and ignores the next function header, resulting in the function header being white instead of color-highlighted.

The code itselfs seems valid, since it doesn't throw any errors, and it works as expected. This wasn't an issue in the previous version of the plugin (occurred after updating).

public static string GenJsonCommandStringForUpdateStatus(string newStatus)
        {
            return JsonConvert.SerializeObject(new
            {
                command = "update-status",
                commandData = new
                {
                    status = newStatus
                }
            });
        }

        public static string GenJsonCommandStringForUpdatingAudioInfo()
        {
            IList<AudioProcessInfo> audioProcessInfoList = GetListOfAudioApplicationsInfo();

            return JsonConvert.SerializeObject(new
            {
                command = "update-audio-list",
                commandData = new
                {
                    audioProcessList = audioProcessInfoList
                }
            });
        }

If I assign the inner dynamic object to a variable, I can use it fine without the highlighter giving up. The highlighter only ignores the next function method. If I assign the dynamic object to a variable (for example), and return it, the return line is fine, but the next function header remains white.

public static string GenJsonCommandStringForUpdateStatus(string newStatus)
{ 
  dynamic commandData = new
  {
    status = newStatus
  };

  return JsonConvert.SerializeObject(new
  {
    command = "update-status",
    commandData = commandData
  });
}

Copied from original issue: dotnet/vscode-csharp#1228

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions