Language

DynamicDataSourceResolver Class

Definition

Infrastructure. Registry that the MSTest source generator uses to publish compile-time accessors for DynamicDataAttribute data sources and display-name methods, so that at runtime MSTest reads dynamic data without reflecting over the declaring type.

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.CompilerServices.Nullable(0)]
public static class DynamicDataSourceResolver
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static class DynamicDataSourceResolver
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[<System.Runtime.CompilerServices.Nullable(0)>]
type DynamicDataSourceResolver = class
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
type DynamicDataSourceResolver = class
Public Class DynamicDataSourceResolver
Inheritance
DynamicDataSourceResolver
Attributes

Remarks

This type is not intended to be used directly from application code. It is public only because the MSTest source generator emits a [ModuleInitializer] in the test assembly that calls it across the assembly boundary, and module initializers cannot use internal APIs from another assembly. The signature and behaviour are implementation details that may evolve with the generator; do not hand-roll calls to RegisterDataProvider(Type, String, DynamicDataSourceType, Func<Object[],Object>) / RegisterDisplayNameProvider(Type, String, Func<MethodInfo,Object[],String>).

When a source is not registered here (reflection mode, or a source the generator could not resolve), DynamicDataAttribute falls back to reflecting over the declaring type. That fallback is annotated with DynamicallyAccessedMembersAttribute, so it preserves the required members and remains trim / Native AOT safe on its own. The source-generated registrations are an optimization that lets [DynamicData] read its data without reflecting at all.

Methods

Name Description
RegisterDataProvider(Type, String, DynamicDataSourceType, Func<Object[],Object>)

Infrastructure. Registers a compile-time accessor that returns the raw data object for the DynamicDataAttribute source named sourceName on declaringType. The delegate receives the attribute's data-source arguments (empty for property/field sources) and returns the property/field value or the method's return value.

RegisterDisplayNameProvider(Type, String, Func<MethodInfo,Object[],String>)

Infrastructure. Registers a compile-time accessor for the custom display-name method named methodName on declaringType (see DynamicDataDisplayName).

Applies to