Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Robinson <arobins@microsoft.com>2020-08-05 23:02:57 +0300
committerGitHub <noreply@github.com>2020-08-05 23:02:57 +0300
commitc58deadab46be312d8a458db7aac411bd8378e10 (patch)
treeed206d69d6c6173ebbe193b1a7783cfe0ad6a210 /src/libraries
parent9968397fdd4260b897f533853340dd46106fdde6 (diff)
Special case boolean/char types in managed/native signatures. (dotnet/runtimelab#47)
Commit migrated from https://github.com/dotnet/runtimelab/commit/39ce2af428817677201f0f2fdd79c2a3bfddcefe
Diffstat (limited to 'src/libraries')
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs5
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj1
2 files changed, 5 insertions, 1 deletions
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs
index 34e7f77dd9d..c9cf380c3db 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs
@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
-using System.Text;
namespace Microsoft.Interop
{
@@ -153,6 +152,8 @@ namespace Microsoft.Interop
var typeAsString = type.SpecialType switch
{
SpecialType.System_Void => "void",
+ SpecialType.System_Boolean => "bool",
+ SpecialType.System_Char => "char",
SpecialType.System_SByte => "sbyte",
SpecialType.System_Byte => "byte",
SpecialType.System_Int16 => "short",
@@ -199,6 +200,8 @@ namespace Microsoft.Interop
return type.SpecialType switch
{
SpecialType.System_Void => "void",
+ SpecialType.System_Boolean => "byte", // [TODO] Determine marshalling default C++ bool or Windows' BOOL
+ SpecialType.System_Char => "ushort", // CLR character width (UTF-16)
SpecialType.System_SByte => "sbyte",
SpecialType.System_Byte => "byte",
SpecialType.System_Int16 => "short",
diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
index ad8edc59403..536eec52ae8 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
+++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>8.0</LangVersion>
+ <RootNamespace>System.Runtime.InteropServices</RootNamespace>
</PropertyGroup>
</Project>