Verify icon indicating copy to clipboard operation
Verify copied to clipboard

TypeNameHandling.Auto not respected in arrays (bug introduced by version 17.4.2)

Open stocksr opened this issue 2 years ago • 2 comments

I have an array property of a base type that is populated with several different Concrete Types

public class Query
{
    public Filter[] Filters { get; set; } ;
}
public abstract class Filter { }
public class DateRangeFilter : Filter
{
    public DateOnly StartDate { get; set; }
    public DateOnly EndDate { get; set; }
}
public class IsCompleteFilter : Filter
{
  // no properties needed 
}
public class IsSpamFilter : Filter
{
  // no properties needed 
}


in order to confirm that the correct types are being inserted, I added VerifierSettings.AddExtraSettings(js => { js.TypeNameHandling = TypeNameHandling.Auto; }); in the ModuleInitializer

prior to version 17.4.2 this produced the desired output

 Filters : [
      {
        $type: DateRangeFilter,
        StartDate: Date_1,
        EndDate: Date_2
      },
      {
         $type: IsCompleteFilter ,
     },
      {
         $type: IsSpamFilter ,
     }
    ],

after the upgrade to 7.4.2 (or the latest version 17.9.0) with no other changes I am getting this output.

 Filters : [
      {
        StartDate: Date_1,
        EndDate: Date_2
      },
      {
     },
      {
     }
    ],

as you can see we can no longer verify that the correct filter types have been added to the list.

Please note my example has been drastically simplified for this bug - TypeNameHandling.All is not a valid solution in this case, as this problem is actually deep inside a more complex object.

stocksr avatar Aug 12 '22 10:08 stocksr

can u submit a minimal repro (as a test in a pull request) for something that worked previously showed type information.

SimonCropp avatar Aug 12 '22 10:08 SimonCropp

First off - my apologies I got the version number where this was introduced wrong, the correct version where this is introduced is 17.4.2 not 17.4.0 as I originally stated I will edit my bug to correct that, I guess my initial testing was not as careful as I thought.

Second - I have created a test case in a small repo - apologies I could not get this project to build on my machine (something about not having .net7) - https://github.com/stocksr/Verify.Sample contains my minimal reproduction of the issue.

I hope this helps - let me know if you need any more help from me.

stocksr avatar Aug 12 '22 13:08 stocksr