Remove dependency on Windows user32 library and enable test for all platforms.
Fixes #13048
<ExcludeList Include="$(XunitTestBinBase)/Interop/ExecInDefAppDom/ExecInDefAppDom/*">
<Issue>Issue building native components for the test.</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/JIT/Directed/pinvoke/tail/*">
- <Issue>13048</Issue>
- </ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/Regressions/coreclr/1514/interlockexchange/*">
<Issue>22975</Issue>
</ExcludeList>
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+project(pinvoke_user32menu)
+
+set(CMAKE_SHARED_LIBRARY_PREFIX "")
+
+add_library(user32menu SHARED user32menu.cpp)
+SET_TARGET_PROPERTIES(user32menu PROPERTIES COMPILE_FLAGS "-c")
+
+# add the install targets (this "installs" the native file on Windows systems)
+install(TARGETS user32menu DESTINATION bin)
+
+# This "installs" the native file on System V systems
+set_target_properties(user32menu PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/user32menu)
.class private auto ansi beforefieldinit Test
extends [mscorlib]System.Object
{
- .method private hidebysig static pinvokeimpl("user32" ansi winapi)
+ .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
native uint CreatePopupMenu() cil managed preservesig
{
}
- .method private hidebysig static pinvokeimpl("user32" ansi winapi)
+ .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
bool DestroyMenu(native uint hMenu) cil managed preservesig
{
}
- .method private hidebysig static pinvokeimpl("user32" ansi winapi)
+ .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
bool AppendMenu(native uint hMenu,
unsigned int32 uFlags,
unsigned int32 uID,
string item) cil managed preservesig
{
}
- .method private hidebysig static pinvokeimpl("user32" ansi winapi)
+ .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
int32 GetMenuString(native uint hMenu,
unsigned int32 uIDItem,
class [mscorlib]System.Text.StringBuilder data,
unsigned int32 uFlag) cil managed preservesig
{
}
-
+
.method private hidebysig static native uint __CreatePopupMenu() cil managed
{
tail. call native uint JitTest.Test::CreatePopupMenu()
int32,
unsigned int32)
}
-
- .method private hidebysig static int32
+
+ .method private hidebysig static int32
Main() cil managed
{
.entrypoint
IL_00b0: ret
} // end of method Test::Main
- .method public hidebysig specialname rtspecialname
+ .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.maxstack 8
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
-
- <!-- Test unsupported outside of windows -->
- <TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows>
- <DisableProjectBuild Condition="'$(TargetsUnix)' == 'true'">true</DisableProjectBuild>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ <ProjectReference Include="CMakeLists.txt" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// This file fakes a few Windows APIs to enable the tail.il test on all platforms.
+
+#include <cstring>
+#include <string>
+#include <vector>
+
+#if defined(_MSC_VER)
+#define EXPORT_API extern "C" __declspec(dllexport)
+#else
+#define EXPORT_API extern "C" __attribute__((visibility("default")))
+
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
+#endif
+
+#include <cstddef>
+
+typedef std::vector<std::string> MENU;
+typedef MENU * HMENU;
+
+EXPORT_API
+HMENU
+CreatePopupMenu()
+{
+ return new MENU();
+}
+
+EXPORT_API
+unsigned __int32
+DestroyMenu(
+ HMENU hMenu
+ )
+{
+ delete hMenu;
+
+ return 1;
+}
+
+EXPORT_API
+unsigned __int32
+AppendMenuA(
+ HMENU hMenu,
+ unsigned __int32 uFlags,
+ unsigned __int32 uID,
+ const char * item
+ )
+{
+ if (uFlags != 0)
+ {
+ throw "AppendMenu: only MF_STRING (0) supported for uFlags";
+ }
+
+ hMenu->push_back(std::string(item));
+
+ return 1;
+}
+
+EXPORT_API
+__int32
+GetMenuStringA(
+ HMENU hMenu,
+ unsigned __int32 uIDItem,
+ char * lpString,
+ __int32 cchMax,
+ unsigned __int32 flags
+ )
+{
+ if (flags != 0x400)
+ {
+ throw "GetMenuStringA: only MF_BYPOSITION (0x400) supported for flags";
+ }
+
+ if (cchMax < 0)
+ {
+ throw "GetMenuStringA: invalid argument (cchMax)";
+ }
+
+ if (uIDItem >= hMenu->size())
+ {
+ return 0;
+ }
+
+ const std::string & str = (*hMenu)[uIDItem];
+
+ __int32 cch = (__int32)str.size();
+
+ if ((cchMax == 0) || (lpString == nullptr))
+ {
+ return cch;
+ }
+
+ if (cch >= cchMax)
+ {
+ cch = cchMax - 1;
+ }
+
+ memcpy(lpString, str.c_str(), cch);
+ lpString[cch] = '\0';
+
+ return cch;
+}
+