Skip to content

Arguments of an Invocation are not deserialized. #50

@eNeRGy164

Description

@eNeRGy164

The following JSON:

[
  {
    "FullName": "Pitstop.Application.CustomerManagementAPI.Controllers.CustomersController",
    "BaseTypes": [
      "Microsoft.AspNetCore.Mvc.Controller"
    ],
    "Methods": [
      {
        "Parameters": [
          {
            "Type": "Pitstop.CustomerManagementAPI.Commands.RegisterCustomer",
            "Name": "command",
            "Attributes": [
              {
                "Type": "Microsoft.AspNetCore.Mvc.FromBodyAttribute",
                "Name": "FromBody"
              }
            ]
          }
        ],
        "Name": "RegisterAsync",
        "Modifiers": 258,
        "Attributes": [
          {
            "Type": "Microsoft.AspNetCore.Mvc.HttpPostAttribute",
            "Name": "HttpPost"
          }
        ],
        "ReturnType": "System.Threading.Tasks.Task\u003CMicrosoft.AspNetCore.Mvc.IActionResult\u003E",
        "Statements": [
          {
            "$type": "DendroDocs.If, DendroDocs.Shared",
            "Sections": [
              {
                "Condition": "ModelState.IsValid",
                "Statements": [
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Pitstop.CustomerManagementAPI.Mappers.Mappers",
                    "Name": "MapToCustomer"
                  },
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Microsoft.EntityFrameworkCore.DbSet\u003CPitstop.CustomerManagementAPI.Model.Customer\u003E",
                    "Name": "Add",
                    "Arguments": [
                      {
                        "Type": "Pitstop.CustomerManagementAPI.Model.Customer",
                        "Text": "customer"
                      }
                    ]
                  },
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Microsoft.EntityFrameworkCore.DbContext",
                    "Name": "SaveChangesAsync"
                  },
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Pitstop.CustomerManagementAPI.Mappers.Mappers",
                    "Name": "MapToCustomerRegistered"
                  },
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Pitstop.Infrastructure.Messaging.IMessagePublisher",
                    "Name": "PublishMessageAsync",
                    "Arguments": [
                      {
                        "Type": "string",
                        "Text": "e.MessageType"
                      },
                      {
                        "Type": "Pitstop.CustomerManagementAPI.Events.CustomerRegistered",
                        "Text": "e"
                      },
                      {
                        "Type": "string",
                        "Text": ""
                      }
                    ]
                  },
                  {
                    "$type": "DendroDocs.ReturnDescription, DendroDocs.Shared",
                    "Expression": "CreatedAtRoute(\u0022GetByCustomerId\u0022, new { customerId = customer.CustomerId }, customer)"
                  },
                  {
                    "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
                    "ContainingType": "Microsoft.AspNetCore.Mvc.ControllerBase",
                    "Name": "CreatedAtRoute",
                    "Arguments": [
                      {
                        "Type": "string",
                        "Text": "GetByCustomerId"
                      },
                      {
                        "Type": "\u003Canonymous type: string customerId\u003E",
                        "Text": "new { customerId = customer.CustomerId }"
                      },
                      {
                        "Type": "Pitstop.CustomerManagementAPI.Model.Customer",
                        "Text": "customer"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "$type": "DendroDocs.ReturnDescription, DendroDocs.Shared",
            "Expression": "BadRequest()"
          },
          {
            "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
            "ContainingType": "Microsoft.AspNetCore.Mvc.ControllerBase",
            "Name": "BadRequest"
          },
          {
            "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
            "ContainingType": "Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary",
            "Name": "AddModelError",
            "Arguments": [
              {
                "Type": "string",
                "Text": ""
              },
              {
                "Type": "string",
                "Text": "Unable to save changes. Try again, and if the problem persists see your system administrator."
              }
            ]
          },
          {
            "$type": "DendroDocs.ReturnDescription, DendroDocs.Shared",
            "Expression": "StatusCode(StatusCodes.Status500InternalServerError)"
          },
          {
            "$type": "DendroDocs.InvocationDescription, DendroDocs.Shared",
            "ContainingType": "Microsoft.AspNetCore.Mvc.ControllerBase",
            "Name": "StatusCode",
            "Arguments": [
              {
                "Type": "int",
                "Text": "StatusCodes.Status500InternalServerError"
              }
            ]
          }
        ]
      }
    ]
  },

Does not deserialize the Arguments on the "PublishMessageAsync" InvocationDescription using the System.Text.Json deserializer.

  • Validate this issue.
  • Check it for both Newtonsoft.Json and System.Text.Json implementations.
  • Create tests (also for future regression detection)
  • Solve the issue
    • If required, modify JsonConstructor methods
      • These constructors are only used on deserialization, they serve no other purpose for consumers, so they don't break the public API
      • Do not use init on the setter if the constructor suffices.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions