|
It would be very helpful to have access to the current SharedType of a data source. Here is an illustrative example: public class MyDataSource : IAsyncInitializer
{
public int MyData { get; private set; } = -1;
public Task InitializeAsync()
{
// get the current sharedtype for SharedDataSource.
var myKey = TestContext.Current.DataSource.SharedType;
MyData = await DataGetter.GetKeyedAsync(myKey);
return Task.CompletedTask;
}
}In the above snippet, I want to know the lifetime scope of MyDataSource at initialization time. I imagine maybe a field For instance, I would expect the following |
Answered by
thomhurst
Jul 23, 2026
Replies: 1 comment
|
@TheRumle upgrade to the latest and you can do: if (TestContext.Current?.Metadata.MethodDataSource is ClassDataSourceAttribute<MyFixture> attr)
{
var shared = attr.Shared; // SharedType.Keyed
var key = attr.Key; // "MyKey"
} |
0 replies
Answer selected by
TheRumle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@TheRumle upgrade to the latest and you can do: