File tree 1 file changed +9
-3
lines changed
src/Microsoft.TestPlatform.ObjectModel
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
17
17
[ DataContract ]
18
18
public abstract class TestObject
19
19
{
20
+ static TestObject ( )
21
+ {
22
+ // Do TypeConverter registrations in static constructor only to avoid multiple registrations
23
+ // If we register too much, deserialization of large number of testobjects will cause StackOverflow exception
24
+ TypeDescriptor . AddAttributes ( typeof ( Guid ) , new TypeConverterAttribute ( typeof ( CustomGuidConverter ) ) ) ;
25
+ TypeDescriptor . AddAttributes ( typeof ( KeyValuePair < string , string > [ ] ) , new TypeConverterAttribute ( typeof ( CustomKeyValueConverter ) ) ) ;
26
+ TypeDescriptor . AddAttributes ( typeof ( string [ ] ) , new TypeConverterAttribute ( typeof ( CustomStringArrayConverter ) ) ) ;
27
+ }
28
+
20
29
#region Fields
21
30
22
31
/// <summary>
@@ -64,9 +73,6 @@ private List<KeyValuePair<TestProperty, object>> StoreKeyValuePairs
64
73
protected TestObject ( )
65
74
{
66
75
this . store = new Dictionary < TestProperty , object > ( ) ;
67
- TypeDescriptor . AddAttributes ( typeof ( Guid ) , new TypeConverterAttribute ( typeof ( CustomGuidConverter ) ) ) ;
68
- TypeDescriptor . AddAttributes ( typeof ( KeyValuePair < string , string > [ ] ) , new TypeConverterAttribute ( typeof ( CustomKeyValueConverter ) ) ) ;
69
- TypeDescriptor . AddAttributes ( typeof ( string [ ] ) , new TypeConverterAttribute ( typeof ( CustomStringArrayConverter ) ) ) ;
70
76
}
71
77
72
78
[ OnSerializing ]
You can’t perform that action at this time.
0 commit comments