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

Add a way for the extensions hook to know what assembly it hooks to #5116

Open
nohwnd opened this issue Feb 24, 2025 · 2 comments
Open

Add a way for the extensions hook to know what assembly it hooks to #5116

nohwnd opened this issue Feb 24, 2025 · 2 comments
Labels
Area: MTP Belongs to the Microsoft.Testing.Platform core library Needs: Design Needs research and proposal for how the feature will be implemented.

Comments

@nohwnd
Copy link
Member

nohwnd commented Feb 24, 2025

Summary

Automatic extension registration via hook is limited does not tell the extension into which dll it registers.

This forces mstest to call GetEntryAssembly which is null in native aot.

public static void AddExtensions(ITestApplicationBuilder testApplicationBuilder, string[] arguments) => 
    testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);

Look for a way to provide the hooking binary to the hook, so it can use it in a fashion similar to Assembly.GetEntryAssembly(), but without it being null in native aot.

This is also an api that is used by all extensions so it is possibly hard to change.

Background and Motivation

Proposed Feature

Alternative Designs

Similar issue and the aot reasoning is mentioned in #4312 but providing arbitrary assemblies externall is not a goal of this change. Instead the api should just answer the question:

I am installing as extension into a dll, what is that dll?

@nohwnd nohwnd added Area: MTP Belongs to the Microsoft.Testing.Platform core library Needs: Design Needs research and proposal for how the feature will be implemented. labels Feb 24, 2025
@nohwnd nohwnd added this to the MSTest 3.10 / MTP 1.8 milestone Feb 24, 2025
@Evangelink
Copy link
Member

I would instead push strongly to have explicit Program.cs and registration. The auto-generated is to me only a "temporary" solution to ease transition from VSTest. This is a common .NET pattern and by making things explicit and available to the devs it's simplifying many scenario (even the simple is main even reached before a crash)

@nohwnd
Copy link
Member Author

nohwnd commented Feb 25, 2025

I do agree with you (As I said in the original issue). But even the automatic temporary solution could work more correctly, instead of us "guessing" what the dll that we are registering into is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: MTP Belongs to the Microsoft.Testing.Platform core library Needs: Design Needs research and proposal for how the feature will be implemented.
Projects
None yet
Development

No branches or pull requests

2 participants