fix(engine): emit ECMA-335 metadata-format type names in TestMethodIdentifierProperty#6433
Conversation
…entifierProperty Microsoft.Testing.Platform specifies that TestMethodIdentifierProperty values are ECMA-335 compliant (managed name format, vstest RFC 0017). TUnit was passing reflection Type.FullName for ParameterTypeFullNames and ReturnTypeFullName, which yields assembly-qualified generic arguments (List`1[[System.String, System.Private.CoreLib, ...]]) and null for open generic method parameters. New MetadataTypeNameFormatter emits the spec format: - constructed generics: List`1<System.String> - generic method/type parameters: !!0 / !0 - arrays, byref, pointer suffixes; nested types via '+' TypeName intentionally keeps TUnit's class-argument decoration (MyTests(arg1, arg2)) so parameterized classes stay distinguishable in Test Explorer.
Code reviewReviewed the diff, cross-checked the new Notes from the review:
Checked for bugs and CLAUDE.md compliance (dual-mode metadata collection, snapshot testing, AOT compatibility, performance). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 772139f923
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (var i = 0; i < parameters.Length; i++) | ||
| { | ||
| array[i] = parameters[i].Type.FullName!; | ||
| array[i] = MetadataTypeNameFormatter.GetMetadataFullName(parameters[i].Type); |
There was a problem hiding this comment.
Use TypeInfo for source-gen generic parameters
In source-generated metadata, parameters that depend on generic arguments are stored with Type == typeof(object) and the real signature in TypeInfo (for example the generated snapshots create IEnumerable<TSource> as typeof(object) plus ConstructedGeneric). Because this new formatting path only reads parameters[i].Type, source-gen generic tests still publish System.Object instead of metadata names like !!0 or System.Collections.Generic.IEnumerable1<!!0>`, while reflection mode now publishes the correct placeholders; that leaves MTP method identity/source navigation wrong for those generic tests and violates the dual-mode requirement.
Useful? React with 👍 / 👎.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 1 minor |
| BestPractice | 3 medium |
🟢 Metrics 19 complexity
Metric Results Complexity 19
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Problem
Microsoft.Testing.Platform specifies that
TestMethodIdentifierPropertyvalues are ECMA-335 compliant (managed name format, vstest RFC 0017). TUnit was passing raw reflectionType.FullNameforParameterTypeFullNamesandReturnTypeFullName, which produces:System.Collections.Generic.List1[[System.String, System.Private.CoreLib, Version=...]]`null(viaFullName!) for open generic method parameters (T)Fix
New
MetadataTypeNameFormatter(cached perType) emits the spec format, matching what MSTest'sManagedNameParserproduces:System.Collections.Generic.List1<System.String>`!!0; generic type parameters:!0[],[,], jagged), byref&, pointer*+Deliberately unchanged
TypeNamekeeps TUnit's class-argument decoration (MyTests(arg1, arg2)) for parameterized test classes — this keeps class-data-source instances distinguishable in Test Explorer. Nested-type+joining, namespace split, and generic backtick arity were already spec-conformant.No internal consumers read
ParameterTypeFullNames/ReturnTypeFullName(reporters only readTypeName/MethodName/Namespace), so no downstream output changes.Tests
15 new tests in
MetadataTypeNameFormatterTestscovering simple types, constructed/open generics, nested generics, arrays, nullable, nested types,!!n/!nplaceholders, byref.