AaronRobinsonMSFT / DNMD

Reimplementation of ECMA-335 metadata APIs
MIT License
16 stars 3 forks source link

Convert our unit tests and perf harness to use native entry-points #50

Closed jkoritzinsky closed 6 months ago

jkoritzinsky commented 7 months ago

Currently, our unit tests and perf harness are both C#-based (xUnit, BenchmarkDotNet) but do almost all of their work in native code.

This PR changes our tests to instead use GoogleTest and Google Benchmark and be fully-native test apps.

The only remaining managed code is the Regression.TargetAssembly app that is used for the FindAPIs test and the code to locate CoreCLR (done so using a DNNE-based API).

I've moved the .NET Framework install lookup and the "generate an image with indirection tables" functionality into the native code.

I'm still exploring how to move the CoreCLR locating APIs to C++. I'd like to use nethost and the hostfxr APIs to avoid starting up CoreCLR just to get its location, but it is difficult to use nethost without moving to vcpkg (right now I'm using FetchContent to pull in dependencies manually).

CoreCLR lookup is done with the nethost APIs from the current .NET installation (to avoid using vcpkg).

Test exploration/execution inner-loop still works very well in this world. The "Testing" pane on VSCode populates with all of the tests when the CMake extension is installed and configured, and the Test Explorer in VS populates when you open the DNMD project in the CMake targets view.

This PR updates the C++ standard version used in the tests to C++17 to get the standard filesystem APIs. I can move away from using these APIs, but then we'll need to provide a separate PAL for them (which I wanted to avoid for the first implementation to focus on getting things to work).

jkoritzinsky commented 7 months ago

I still have some work to get macOS passing, but think enough work is done for a first look.

jkoritzinsky commented 7 months ago

I can't reproduce the mac failures locally... I'll try to figure out what's going on.

jkoritzinsky commented 7 months ago

Okay looks like the problem is that hostfxr doesn't find runtimes/frameworks/sdks in its installation if that is not a global installation and the path is not specified. macOS is the only platform where the install path isn't the default path.

I'll try to figure out a good solution here.