@@ -34,18 +34,6 @@ internal static class ObjectModelConverters
3434 valueType : typeof ( string ) ,
3535 owner : typeof ( TestCase ) ) ;
3636
37- private static readonly TestProperty TestCategoryProperty = TestProperty . Register (
38- id : "MSTestDiscoverer.TestCategory" ,
39- label : "TestCategory" ,
40- valueType : typeof ( string [ ] ) ,
41- owner : typeof ( TestCase ) ) ;
42-
43- private static readonly TestProperty TraitsProperty = TestProperty . Register (
44- id : "TestObject.Traits" ,
45- label : "Traits" ,
46- valueType : typeof ( KeyValuePair < string , string > [ ] ) ,
47- owner : typeof ( TestObject ) ) ;
48-
4937 /// <summary>
5038 /// Converts a VSTest <see cref="TestCase"/> to a Microsoft Testing Platform <see cref="TestNode"/>.
5139 /// </summary>
@@ -82,27 +70,33 @@ public static TestNode ToTestNode(this TestCase testCase, bool isTrxEnabled, INa
8270
8371 private static void CopyCategoryAndTraits ( TestObject testCaseOrResult , TestNode testNode , bool isTrxEnabled )
8472 {
85- // TPv2 is doing some special handling for MSTest... we should probably do the same.
86- // See https://github.com/microsoft/vstest/blob/main/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs#L66-L70
87- if ( testCaseOrResult . GetPropertyValue < string [ ] > ( TestCategoryProperty , defaultValue : null ) is string [ ] mstestCategories )
73+ foreach ( KeyValuePair < TestProperty , object ? > property in testCaseOrResult . GetProperties ( ) )
8874 {
89- if ( isTrxEnabled )
75+ #pragma warning disable CS0618 // Type or member is obsolete
76+ if ( ( property . Key . Attributes & TestPropertyAttributes . Trait ) == 0 )
77+ #pragma warning restore CS0618 // Type or member is obsolete
9078 {
91- testNode . Properties . Add ( new TrxCategoriesProperty ( mstestCategories ) ) ;
79+ continue ;
9280 }
9381
94- foreach ( string category in mstestCategories )
82+ if ( property . Value is string [ ] categories )
9583 {
96- testNode . Properties . Add ( new TestMetadataProperty ( category , string . Empty ) ) ;
97- }
98- }
84+ if ( isTrxEnabled )
85+ {
86+ testNode . Properties . Add ( new TrxCategoriesProperty ( categories ) ) ;
87+ }
9988
100- if ( testCaseOrResult . GetPropertyValue < KeyValuePair < string , string > [ ] > ( TraitsProperty , defaultValue : null ) is KeyValuePair < string , string > [ ] traits &&
101- traits . Length > 0 )
102- {
103- foreach ( KeyValuePair < string , string > trait in traits )
89+ foreach ( string category in categories )
90+ {
91+ testNode . Properties . Add ( new TestMetadataProperty ( category , string . Empty ) ) ;
92+ }
93+ }
94+ else if ( property . Value is KeyValuePair < string , string > [ ] traits )
10495 {
105- testNode . Properties . Add ( new TestMetadataProperty ( trait . Key , trait . Value ) ) ;
96+ foreach ( KeyValuePair < string , string > trait in traits )
97+ {
98+ testNode . Properties . Add ( new TestMetadataProperty ( trait . Key , trait . Value ) ) ;
99+ }
106100 }
107101 }
108102 }
0 commit comments