diff --git a/src/native/corehost/hostfxr.h b/src/native/corehost/hostfxr.h index 0c316a59b1159..f25eb60953654 100644 --- a/src/native/corehost/hostfxr.h +++ b/src/native/corehost/hostfxr.h @@ -1,12 +1,17 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __HOSTFXR_H__ -#define __HOSTFXR_H__ +#ifndef HAVE_HOSTFXR_H +#define HAVE_HOSTFXR_H #include #include +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + #if defined(_WIN32) #define HOSTFXR_CALLTYPE __cdecl #ifdef _WCHAR_T_DEFINED @@ -296,10 +301,6 @@ struct hostfxr_dotnet_environment_sdk_info const char_t* path; }; -typedef void(HOSTFXR_CALLTYPE* hostfxr_get_dotnet_environment_info_result_fn)( - const struct hostfxr_dotnet_environment_info* info, - void* result_context); - struct hostfxr_dotnet_environment_framework_info { size_t size; @@ -322,6 +323,10 @@ struct hostfxr_dotnet_environment_info const struct hostfxr_dotnet_environment_framework_info* frameworks; }; +typedef void(HOSTFXR_CALLTYPE* hostfxr_get_dotnet_environment_info_result_fn)( + const struct hostfxr_dotnet_environment_info* info, + void* result_context); + // // Returns available SDKs and frameworks. // @@ -384,7 +389,7 @@ struct hostfxr_resolve_frameworks_result }; typedef void (HOSTFXR_CALLTYPE* hostfxr_resolve_frameworks_result_fn)( - const hostfxr_resolve_frameworks_result* result, + const struct hostfxr_resolve_frameworks_result* result, void* result_context); // @@ -411,8 +416,12 @@ typedef void (HOSTFXR_CALLTYPE* hostfxr_resolve_frameworks_result_fn)( // typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_resolve_frameworks_for_runtime_config_fn)( const char_t* runtime_config_path, - /*opt*/ const hostfxr_initialize_parameters* parameters, + /*opt*/ const struct hostfxr_initialize_parameters* parameters, /*opt*/ hostfxr_resolve_frameworks_result_fn callback, /*opt*/ void* result_context); -#endif //__HOSTFXR_H__ +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // HAVE_HOSTFXR_H diff --git a/src/native/corehost/test/mockhostfxr/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/CMakeLists.txt index 6820b27d84715..95e57456f57f7 100644 --- a/src/native/corehost/test/mockhostfxr/CMakeLists.txt +++ b/src/native/corehost/test/mockhostfxr/CMakeLists.txt @@ -1,8 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -add_library(mockhostfxr_2_2 SHARED mockhostfxr.cpp) -add_library(mockhostfxr_5_0 SHARED mockhostfxr.cpp) +set(MOCKHOSTFXR_SRC mockhostfxr.cpp test_c_api.c) + +add_library(mockhostfxr_2_2 SHARED ${MOCKHOSTFXR_SRC}) +add_library(mockhostfxr_5_0 SHARED ${MOCKHOSTFXR_SRC}) target_link_libraries(mockhostfxr_2_2 PRIVATE libhostcommon) target_link_libraries(mockhostfxr_5_0 PRIVATE libhostcommon) @@ -11,4 +13,4 @@ target_compile_definitions(mockhostfxr_2_2 PRIVATE MOCKHOSTFXR_2_2 EXPORT_SHARED target_compile_definitions(mockhostfxr_5_0 PRIVATE MOCKHOSTFXR_5_0 EXPORT_SHARED_API) install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) -install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) \ No newline at end of file +install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/mockhostfxr.cpp b/src/native/corehost/test/mockhostfxr/mockhostfxr.cpp index 46509a0f14d81..75de5a1c3f7e5 100644 --- a/src/native/corehost/test/mockhostfxr/mockhostfxr.cpp +++ b/src/native/corehost/test/mockhostfxr/mockhostfxr.cpp @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + #include "error_codes.h" #include "hostfxr.h" #include "host_startup_info.h" diff --git a/src/native/corehost/test/mockhostfxr/test_c_api.c b/src/native/corehost/test/mockhostfxr/test_c_api.c new file mode 100644 index 0000000000000..3cb130101c09b --- /dev/null +++ b/src/native/corehost/test/mockhostfxr/test_c_api.c @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// hostfxr.h is a public API. When included in .c files, it may fail to compile +// if C++-specific syntax is used within the extern "C" block. Since all usage of +// this API in runtime repo are within C++ code, such breakages are not encountered +// during normal development or testing. +#include "hostfxr.h"