Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array entries in Records don't serialize correctly in log #3857

Open
nohwnd opened this issue Sep 23, 2024 · 0 comments
Open

Array entries in Records don't serialize correctly in log #3857

nohwnd opened this issue Sep 23, 2024 · 0 comments
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Needs: Triage 🔍 Type: Bug

Comments

@nohwnd
Copy link
Member

nohwnd commented Sep 23, 2024

Describe the bug

public sealed record TestMethodIdentifierProperty(string AssemblyFullName, string Namespace, string TypeName, string MethodName, string[] ParameterTypeFullNames, string ReturnTypeFullName) : IProperty

is serialized to log via call to .ToString(). This causes members that don't serialize well to just print the type name, e.g. : string[] ParameterTypeFullNames will seralize as System.String[] making the values invisible in log.

Similar issue is happening with StepTimingInfo[] on TimingProperty, or TrxMessage[]

Serialization can be customized by implementing PrintMembers manually.

Youssef did some previous work here to automate this via source gen. Maybe it would be worth revisiting, to fix this issue without us writing the serializers manually https://github.com/Youssef1313/PrintMembersGenerator

(docs on writing it manually: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record#printmembers-formatting-in-derived-records)

As shown by these xunit and mstest diag logs:

2024-09-23T11:21:53.1866167+00:00 Microsoft.Testing.Platform.Messages.AsynchronousMessageBus TRACE The producer 'xUnit.net v3 Microsoft.Testing.Platform execution message sink' (ID: fa7e6681-c892-4741-9980-724bd818f1f1) pushed data:
TestNodeUpdateMessage { DisplayName = TestNode update, Description = This data is used to report a TestNode state change., Properties = [], ParentTestNodeUid = <null>, TestNode = TestNode { Uid = TestNodeUid { Value = 38af0ae4063189b42e257efc1614f0e5d680cf8ac0ea248dce21b8d42d65b745 }, DisplayName = ProjectB.V3.DerivedTestsInDifferentProject.InheritedTest, Properties = [ TestMethodIdentifierProperty { AssemblyFullName = ProjectB.V3, Namespace = ProjectB.V3, TypeName = ProjectB.V3.DerivedTestsInDifferentProject, MethodName = InheritedTest, ParameterTypeFullNames = System.String[], ReturnTypeFullName = System.Void }, InProgressTestNodeStateProperty { Explanation =  } ] } }

TestNodeUpdateMessage { DisplayName = TestNode update, Description = This data is used to report a TestNode state change., Properties = [], ParentTestNodeUid = <null>, TestNode = TestNode { Uid = TestNodeUid { Value = TestProject1.Test1.TestMethod1 }, DisplayName = TestMethod1, Properties = [ TimingProperty { GlobalTiming = TimingInfo { StartTime = 23/09/2024 13:14:59 +02:00, EndTime = 23/09/2024 13:14:59 +02:00, Duration = 00:00:00.0021410 }, StepTimings = Microsoft.Testing.Platform.Extensions.Messages.StepTimingInfo[] }, TrxMessagesProperty { Messages = Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxMessage[] }, TrxFullyQualifiedTypeNameProperty { FullyQualifiedTypeName = TestProject1.Test1 }, TrxExceptionProperty { Message = , StackTrace =  }, VSTestProperty [Id: ParentExecId] [Description: ] [ValueType: System.Guid] [Value: 00000000-0000-0000-0000-000000000000], VSTestProperty [Id: InnerResultsCount] [Description: ] [ValueType: System.Int32] [Value: 0], VSTestProperty [Id: ExecutionId] [Description: ] [ValueType: System.Guid] [Value: 00000000-0000-0000-0000-000000000000], VSTestProperty [Id: TestResult.StartTime] [Description: ] [ValueType: System.DateTimeOffset] [Value: 01/01/0001 00:00:00 +00:00], VSTestProperty [Id: TestResult.Outcome] [Description: ] [ValueType: Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a] [Value: None], VSTestProperty [Id: TestResult.ErrorStackTrace] [Description: ] [ValueType: System.String] [Value: null], VSTestProperty [Id: TestResult.ErrorMessage] [Description: ] [ValueType: System.String] [Value: null], VSTestProperty [Id: TestResult.EndTime] [Description: ] [ValueType: System.DateTimeOffset] [Value: 01/01/0001 00:00:00 +00:00], VSTestProperty [Id: TestResult.Duration] [Description: ] [ValueType: System.TimeSpan] [Value: 00:00:00], VSTestProperty [Id: TestResult.DisplayName] [Description: ] [ValueType: System.String] [Value: null], VSTestProperty [Id: TestResult.ComputerName] [Description: ] [ValueType: System.String] [Value: null], VSTestProperty [Id: MSTest.TestIdGenerationStrategy] [Description: ] [ValueType: System.Int32] [Value: 2], SerializableKeyValuePairStringProperty { Key = vstest.original-executor-uri, Value = executor://mstestadapter/v2 }, VSTestProperty [Id: vstest.original-executor-uri] [Description: ] [ValueType: System.Uri] [Value: executor://mstestadapter/v2], VSTestProperty [Id: TestObject.Traits] [Description: ] [ValueType: System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]] [Value: System.Collections.Generic.KeyValuePair`2[System.String,System.String][]], VSTestProperty [Id: TestCase.ManagedType] [Description: ] [ValueType: System.String] [Value: TestProject1.Test1], VSTestProperty [Id: TestCase.ManagedMethod] [Description: ] [ValueType: System.String] [Value: TestMethod1], VSTestProperty [Id: MSTestDiscoverer.TestClassName] [Description: ] [ValueType: System.String] [Value: TestProject1.Test1], SerializableNamedArrayStringProperty { Name = vstest.TestCase.Hierarchy, Values = System.String[] }, VSTestProperty [Id: TestCase.Hierarchy] [Description: ] [ValueType: System.String[]] [Value: System.String[]], VSTestProperty [Id: TestCase.Source] [Description: ] [ValueType: System.String] [Value: S:\c\XUnitInheritedTests\TestProject1\bin\Debug\net8.0\TestProject1.dll], VSTestProperty [Id: TestCase.LineNumber] [Description: ] [ValueType: System.Int32] [Value: -1], SerializableKeyValuePairStringProperty { Key = vstest.TestCase.Id, Value = 2f4ebbee-b0f8-692f-7912-4eb80fe25b8d }, VSTestProperty [Id: TestCase.Id] [Description: ] [ValueType: System.Guid] [Value: 2f4ebbee-b0f8-692f-7912-4eb80fe25b8d], SerializableKeyValuePairStringProperty { Key = vstest.TestCase.FullyQualifiedName, Value = TestProject1.Test1.TestMethod1 }, VSTestProperty [Id: TestCase.FullyQualifiedName] [Description: ] [ValueType: System.String] [Value: TestProject1.Test1.TestMethod1], VSTestProperty [Id: TestCase.ExecutorUri] [Description: ] [ValueType: System.Uri] [Value: executor://testingplatform-bridge/v1], VSTestProperty [Id: TestCase.DisplayName] [Description: ] [ValueType: System.String] [Value: TestMethod1], VSTestProperty [Id: TestCase.CodeFilePath] [Description: ] [ValueType: System.String] [Value: null], PassedTestNodeStateProperty { Explanation =  } ] } }
@nohwnd nohwnd added Type: Bug Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Needs: Triage 🔍 Type: Bug
Projects
None yet
Development

No branches or pull requests

1 participant