2

Assume two related projects.

  • Functionality.dll is a C++ library that contains an Extern "C" API with multiple functions
  • Interop.dll is a C# library that has static public p/invoke declarations to call into the C++ library.

I would like to have unit tests that fail whenever the mapping is outdated (because the C function changed), without having to test the functionality (that is, without having to provide valid input data for all the C functions).

How can I do this? Is there a way to test if a P/Invoke call / mapping is correct without having to actually perform the call?

Wilbert
  • 7,251
  • 6
  • 51
  • 91
  • You can parse the header file and see if it has changed. – David Heffernan Jan 27 '15 at 14:31
  • @IanChuTe The situation is different. The question you linked concerns p/invoke into a windows dll (or similar), where the API on the native side is stable. In my case, our developers develop both the C++ and the C# dll, so we need a way to test the case where a developer changed the C++ api but did not change the p/invoke. – Wilbert Mar 03 '15 at 14:39

0 Answers0