Update existing COM test assets (native/managed) to share CLSIDs with… (#19756)
authorAaron Robinson <arobins@microsoft.com>
Thu, 30 Aug 2018 22:01:12 +0000 (15:01 -0700)
committerGitHub <noreply@github.com>
Thu, 30 Aug 2018 22:01:12 +0000 (15:01 -0700)
* Update existing COM test assets (native/managed) to share CLSIDs with other projects.

* Update Interop.settings.targets

None of these test changes apply to Ubuntu ARM

13 files changed:
tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj
tests/src/Interop/COM/NETServer/NETServer.csproj
tests/src/Interop/COM/NativeServer/ArrayTesting.h
tests/src/Interop/COM/NativeServer/ErrorMarshalTesting.h
tests/src/Interop/COM/NativeServer/NumericTesting.h
tests/src/Interop/COM/NativeServer/Servers.h
tests/src/Interop/COM/NativeServer/StringTesting.h
tests/src/Interop/COM/NativeServer/stdafx.h
tests/src/Interop/COM/ServerContracts/PrimitivesNativeServer.cs
tests/src/Interop/COM/ServerContracts/ServerGuids.cs [new file with mode: 0644]
tests/src/Interop/Interop.settings.targets
tests/src/Interop/common/types.h
tests/src/Interop/common/xplatform.h

index 094bea9..56d18ef 100644 (file)
@@ -28,6 +28,7 @@
     <Compile Include="StringTests.cs" />
     <Compile Include="../../ServerContracts/Primitives.cs" />
     <Compile Include="../../ServerContracts/PrimitivesNativeServer.cs" />
+    <Compile Include="../../ServerContracts/ServerGuids.cs" />
     <Compile Include="../../../common/Assertion.cs" />
   </ItemGroup>
   <ItemGroup>
index cf62cc0..214bb25 100644 (file)
@@ -24,6 +24,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ImportedTypes.cs" />
+    <Compile Include="../ServerContracts/ServerGuids.cs" />
   </ItemGroup>
   <ItemGroup>
     <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
index cbf54cf..6939762 100644 (file)
@@ -7,7 +7,7 @@
 #include <cstdint>
 #include "Servers.h"
 
-class DECLSPEC_UUID("B99ABE6A-DFF6-440F-BFB6-55179B8FE18E") ArrayTesting : public UnknownImpl, public IArrayTesting
+class ArrayTesting : public UnknownImpl, public IArrayTesting
 {
 private:
     template<typename L, typename D>
index 36d758a..6dd7649 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "Servers.h"
 
-class DECLSPEC_UUID("71CF5C45-106C-4B32-B418-43A463C6041F") ErrorMarshalTesting : public UnknownImpl, public IErrorMarshalTesting
+class ErrorMarshalTesting : public UnknownImpl, public IErrorMarshalTesting
 {
 public: // IErrorMarshalTesting
     DEF_RAWFUNC(Throw_HResult)(
index 9a80230..555a38d 100644 (file)
@@ -5,9 +5,10 @@
 #pragma once
 
 #include <type_traits>
+#include <limits>
 #include "Servers.h"
 
-class DECLSPEC_UUID("53169A33-E85D-4E3C-B668-24E438D0929B") NumericTesting : public UnknownImpl, public INumericTesting
+class NumericTesting : public UnknownImpl, public INumericTesting
 {
 public:
     DEF_RAWFUNC(Add_Byte)(
index 5a22e80..bcfdbe2 100644 (file)
@@ -4,15 +4,35 @@
 
 #pragma once
 
-#include "ComHelpers.h"
+#include <xplatform.h>
 
 //#import "Server.Contract.tlb" no_namespace
 #include <Server.Contracts.tlh>
 
-#define DEF_RAWFUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE raw_ ## n
-#define DEF_FUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ## n
+// Forward declare servers so COM clients can reference the CLSIDs
+class DECLSPEC_UUID("53169A33-E85D-4E3C-B668-24E438D0929B") NumericTesting;
+class DECLSPEC_UUID("B99ABE6A-DFF6-440F-BFB6-55179B8FE18E") ArrayTesting;
+class DECLSPEC_UUID("C73C83E8-51A2-47F8-9B5C-4284458E47A6") StringTesting;
+class DECLSPEC_UUID("71CF5C45-106C-4B32-B418-43A463C6041F") ErrorMarshalTesting;
 
-#include "NumericTesting.h"
-#include "ArrayTesting.h"
-#include "StringTesting.h"
-#include "ErrorMarshalTesting.h"
+#define CLSID_NumericTesting __uuidof(NumericTesting)
+#define CLSID_ArrayTesting __uuidof(ArrayTesting)
+#define CLSID_StringTesting __uuidof(StringTesting)
+#define CLSID_ErrorMarshalTesting __uuidof(ErrorMarshalTesting)
+
+#define IID_INumericTesting __uuidof(INumericTesting)
+#define IID_IArrayTesting __uuidof(IArrayTesting)
+#define IID_IStringTesting __uuidof(IStringTesting)
+#define IID_IErrorMarshalTesting __uuidof(IErrorMarshalTesting)
+
+#ifndef COM_CLIENT
+    #include "ComHelpers.h"
+
+    #define DEF_RAWFUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE raw_ ## n
+    #define DEF_FUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ## n
+
+    #include "NumericTesting.h"
+    #include "ArrayTesting.h"
+    #include "StringTesting.h"
+    #include "ErrorMarshalTesting.h"
+#endif
index 7589bf2..1f3a35c 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "Servers.h"
 
-class DECLSPEC_UUID("C73C83E8-51A2-47F8-9B5C-4284458E47A6") StringTesting : public UnknownImpl, public IStringTesting
+class StringTesting : public UnknownImpl, public IStringTesting
 {
 private:
     template <typename STRING>
index 058ec2e..c7eb109 100644 (file)
@@ -6,8 +6,7 @@
 
 #define NOMINMAX
 #define WIN32_LEAN_AND_MEAN
-// Windows Header Files
-#include <windows.h>
+#include <xplatform.h>
 
 #include <atomic>
 #include <memory>
index 4e02880..86a256d 100644 (file)
@@ -23,7 +23,7 @@ namespace Server.Contract.Servers
     /// Managed activation for CoClass
     /// </summary>
     [ComImport]
-    [Guid("53169A33-E85D-4E3C-B668-24E438D0929B")]
+    [Guid(Server.Contract.Guids.NumericTesting)]
     internal class NumericTestingClass
     {
     }
@@ -42,7 +42,7 @@ namespace Server.Contract.Servers
     /// Managed activation for CoClass
     /// </summary>
     [ComImport]
-    [Guid("B99ABE6A-DFF6-440F-BFB6-55179B8FE18E")]
+    [Guid(Server.Contract.Guids.ArrayTesting)]
     internal class ArrayTestingClass
     {
     }
@@ -61,7 +61,7 @@ namespace Server.Contract.Servers
     /// Managed activation for CoClass
     /// </summary>
     [ComImport]
-    [Guid("C73C83E8-51A2-47F8-9B5C-4284458E47A6")]
+    [Guid(Server.Contract.Guids.StringTesting)]
     internal class StringTestingClass
     {
     }
@@ -80,7 +80,7 @@ namespace Server.Contract.Servers
     /// Managed activation for CoClass
     /// </summary>
     [ComImport]
-    [Guid("71CF5C45-106C-4B32-B418-43A463C6041F")]
+    [Guid(Server.Contract.Guids.ErrorMarshalTesting)]
     internal class ErrorMarshalTestingClass
     {
     }
diff --git a/tests/src/Interop/COM/ServerContracts/ServerGuids.cs b/tests/src/Interop/COM/ServerContracts/ServerGuids.cs
new file mode 100644 (file)
index 0000000..8b89f26
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+namespace Server.Contract
+{
+    /// <summary>
+    /// Guids for all COM Servers
+    /// </summary>
+    internal sealed class Guids
+    {
+        public const string NumericTesting = "53169A33-E85D-4E3C-B668-24E438D0929B";
+        public const string ArrayTesting = "B99ABE6A-DFF6-440F-BFB6-55179B8FE18E";
+        public const string StringTesting = "C73C83E8-51A2-47F8-9B5C-4284458E47A6";
+        public const string ErrorMarshalTesting = "71CF5C45-106C-4B32-B418-43A463C6041F";
+    }
+}
\ No newline at end of file
index ca22f88..50e37af 100644 (file)
@@ -1,4 +1,4 @@
-<Project>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <!-- Properties for all Interop managed test assets -->
   <PropertyGroup>
   </PropertyGroup>
index f183a07..37c1454 100755 (executable)
@@ -14,16 +14,8 @@ typedef int BOOL;
 typedef WCHAR *LPWSTR, *PWSTR;
 typedef const WCHAR *LPCWSTR, *PCWSTR;
 
-#ifdef UNICODE
-typedef WCHAR TCHAR;
-#else // ANSI
-typedef char TCHAR;
-#endif // UNICODE
-
 typedef char* LPSTR;
 typedef const char* LPCSTR;
-typedef TCHAR* LPTSTR;
-typedef const TCHAR* LPCTSTR;
 typedef void* FARPROC;
 typedef void* HMODULE;
 typedef void* ULONG_PTR;
index e262cd7..e0b939e 100644 (file)
 #define _CRT_SECURE_NO_WARNINGS 1
 #endif
 
+// Ensure that both UNICODE and _UNICODE are set.
+#ifndef _UNICODE
+#define _UNICODE
+#endif
+#ifndef UNICODE
+#define UNICODE
+#endif
+
 // common headers
 #include <stdio.h>
 #include <memory.h>
@@ -29,6 +37,7 @@
 //  include 
 #ifdef _WIN32
     #include <windows.h>
+    #include <combaseapi.h>
 
     #ifndef snprintf
     #define snprintf _snprintf
 #endif
 #endif //!_WIN32
 
-// Ensure that both UNICODE and _UNICODE are set.
-#ifndef _UNICODE
-    #define _UNICODE
-#endif
-#ifndef UNICODE
-    #define UNICODE
-#endif
-
-void *CoreClrAlloc(size_t cb)
+inline void *CoreClrAlloc(size_t cb)
 {
 #ifdef _WIN32
     return ::CoTaskMemAlloc(cb);
@@ -85,7 +86,7 @@ void *CoreClrAlloc(size_t cb)
 #endif
 }
 
-void CoreClrFree(void *p)
+inline void CoreClrFree(void *p)
 {
 #ifdef _WIN32
     return ::CoTaskMemFree(p);