madskristensen / WebEssentials2013

Visual Studio extension
http://vswebessentials.com
Other
944 stars 251 forks source link

Using Visual Studio for C#, Paste special, Paste JSON as classes, Lists and attributes with dots. #2031

Open scampsd opened 3 years ago

scampsd commented 3 years ago

I've just installed Web Essentials for making a class diagram for a JSON structure. I've copied the JSON structure, and used the Visual Studio Paste Special "Paste JSON as classes" feature.

This worked almost fine, but there were two issues: My JSON contained attributes with dots. Those were deleted, but no [JsonProperty] was created for it. My JSON contained collections. Web Essentials used dynamical arrays for those, while List objects are to be preferred (in case one needs to increase).

JSON excerpt:

    "header.rest_of_attribute": 10000,
    "tags": [
    ...
    ]

Web Essentials generated this:

        public int headerrest_of_attribute { get; set; }
        public Tag[] tags { get; set; }

What Web Essentials should generate:

        [JsonProperty("header.rest_of_attribute")]
        public int headerrest_of_attribute { get; set; }
        public List<Tag> tags { get; set; }

Best regards