Skip to content

[MTP v2][Breaking] Avoid the use of C# records in public API #5517

@Youssef1313

Description

@Youssef1313

I don't think it was a good idea to use records in MTP's public APIs.

Take for example:

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

Downsides:

  1. Constructor signature uses PascalCase for parameter names.

  2. Compiler synthesized methods are centralized about the primary constructor.

    • PrintMembers uses parameters of the primary constructor
    • Clone constructor copies parameters of the primary constructor
    • Deconstruct method deconstructs parameters of the primary constructor (with names again being PascalCase)
    • Equality implementation as well.

    Consider a case where we want to add a new constructor, while keeping the old one for backward compatibility, it becomes more challenging to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MTPBelongs to the Microsoft.Testing.Platform core libraryBreaking ‼️

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions