testfx
testfx copied to clipboard
Data contract serialization for System.Type
Today, System.Type isn't serializable via data contract serialization. Thus, any parameterized tests making use of System.Type will be forced to be folded. It will throw this exception:
System.Runtime.Serialization.InvalidDataContractException: 'Type 'System.RuntimeType' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.'
We catch the exception in TryUnfoldITestDataSources and then we don't "unfold" during discovery.
This is originally reported in https://developercommunity.visualstudio.com/t/C-TestExplorer-does-not-show-children-f/10936786
A better solution here is to avoid serialization altogether and solely rely on TestCaseIndex.