From 64deb692cd9f690e3ce5560530fe93d7f0e3cd67 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 15 Jul 2020 16:47:24 +1000 Subject: Add WixBuildTools.TestSupport.Native. --- WixBuildTools.sln | 12 +++ src/Cpp.Build.props | 104 +++++++++++++++++++++ .../AssemblyInfo.cpp | 17 ++++ .../NativeAssert.h | 85 +++++++++++++++++ .../WixBuildTools.TestSupport.Native.vcxproj | 60 ++++++++++++ ...ixBuildTools.TestSupport.Native.vcxproj.filters | 33 +++++++ .../build/WixBuildTools.TestSupport.Native.props | 29 ++++++ .../build/WixBuildTools.TestSupport.Native.targets | 15 +++ .../packages.config | 12 +++ src/WixBuildTools.TestSupport.Native/precomp.cpp | 3 + src/WixBuildTools.TestSupport.Native/precomp.h | 11 +++ 11 files changed, 381 insertions(+) create mode 100644 src/Cpp.Build.props create mode 100644 src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp create mode 100644 src/WixBuildTools.TestSupport.Native/NativeAssert.h create mode 100644 src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj create mode 100644 src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters create mode 100644 src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props create mode 100644 src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets create mode 100644 src/WixBuildTools.TestSupport.Native/packages.config create mode 100644 src/WixBuildTools.TestSupport.Native/precomp.cpp create mode 100644 src/WixBuildTools.TestSupport.Native/precomp.h diff --git a/WixBuildTools.sln b/WixBuildTools.sln index 37cb79ff..689832fb 100644 --- a/WixBuildTools.sln +++ b/WixBuildTools.sln @@ -8,6 +8,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.MsgGen", "src EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.TestSupport", "src\WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj", "{6C57EF2C-979A-4106-A9E5-FE342810619A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WixBuildTools.TestSupport.Native", "src\WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj", "{95BABD97-FBDB-453A-AF8A-FA031A07B599}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F6660B22-092F-4BC5-A303-E6F696C31E1B}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -59,6 +61,16 @@ Global {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x64.Build.0 = Release|Any CPU {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x86.ActiveCfg = Release|Any CPU {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x86.Build.0 = Release|Any CPU + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Debug|Any CPU.Build.0 = Debug|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Debug|x64.ActiveCfg = Debug|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Debug|x86.ActiveCfg = Debug|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Debug|x86.Build.0 = Debug|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|Any CPU.ActiveCfg = Release|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|Any CPU.Build.0 = Release|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x64.ActiveCfg = Release|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x86.ActiveCfg = Release|Win32 + {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props new file mode 100644 index 00000000..44a042c7 --- /dev/null +++ b/src/Cpp.Build.props @@ -0,0 +1,104 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp b/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp new file mode 100644 index 00000000..23a48993 --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitleAttribute("WixBuildTools.TestSupport.Native")]; +[assembly: AssemblyDescriptionAttribute("")]; +[assembly: AssemblyCultureAttribute("")]; +[assembly: ComVisible(false)]; diff --git a/src/WixBuildTools.TestSupport.Native/NativeAssert.h b/src/WixBuildTools.TestSupport.Native/NativeAssert.h new file mode 100644 index 00000000..34af4f34 --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/NativeAssert.h @@ -0,0 +1,85 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +namespace WixBuildTools { +namespace TestSupport { + + using namespace System; + using namespace System::Collections::Generic; + using namespace System::Linq; + using namespace Xunit; + + public ref class NativeAssert : WixAssert + { + public: + static void NotNull(LPCWSTR wz) + { + if (!wz) + { + Assert::NotNull(nullptr); + } + } + + // For some reason, naming these NotStringEqual methods "NotEqual" breaks Intellisense in files that call any overload of the NotEqual method. + static void NotStringEqual(LPCWSTR expected, LPCWSTR actual) + { + NativeAssert::NotStringEqual(expected, actual, FALSE); + } + + static void NotStringEqual(LPCWSTR expected, LPCWSTR actual, BOOL ignoreCase) + { + IEqualityComparer^ comparer = ignoreCase ? StringComparer::InvariantCultureIgnoreCase : StringComparer::InvariantCulture; + Assert::NotEqual(NativeAssert::LPWSTRToString(expected), NativeAssert::LPWSTRToString(actual), comparer); + } + + // For some reason, naming these StringEqual methods "Equal" breaks Intellisense in files that call any overload of the Equal method. + static void StringEqual(LPCWSTR expected, LPCWSTR actual) + { + NativeAssert::StringEqual(expected, actual, FALSE); + } + + static void StringEqual(LPCWSTR expected, LPCWSTR actual, BOOL ignoreCase) + { + IEqualityComparer^ comparer = ignoreCase ? StringComparer::InvariantCultureIgnoreCase : StringComparer::InvariantCulture; + Assert::Equal(NativeAssert::LPWSTRToString(expected), NativeAssert::LPWSTRToString(actual), comparer); + } + + static void Succeeded(HRESULT hr, LPCSTR zFormat, LPCSTR zArg, ... array^ zArgs) + { + array^ formatArgs = gcnew array(zArgs->Length + 1); + formatArgs[0] = NativeAssert::LPSTRToString(zArg); + for (int i = 0; i < zArgs->Length; ++i) + { + formatArgs[i + 1] = NativeAssert::LPSTRToString(zArgs[i]); + } + WixAssert::Succeeded(hr, gcnew String(zFormat), formatArgs); + } + + static void Succeeded(HRESULT hr, LPCSTR zFormat, ... array^ wzArgs) + { + array^ formatArgs = gcnew array(wzArgs->Length); + for (int i = 0; i < wzArgs->Length; ++i) + { + formatArgs[i] = NativeAssert::LPWSTRToString(wzArgs[i]); + } + WixAssert::Succeeded(hr, gcnew String(zFormat), formatArgs); + } + + static void ValidReturnCode(HRESULT hr, ... array^ validReturnCodes) + { + Assert::Contains(hr, (IEnumerable^)validReturnCodes); + } + + private: + static String^ LPSTRToString(LPCSTR z) + { + return z ? gcnew String(z) : nullptr; + } + static String^ LPWSTRToString(LPCWSTR wz) + { + return wz ? gcnew String(wz) : nullptr; + } + }; +} +} diff --git a/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj new file mode 100644 index 00000000..9f58a0bd --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj @@ -0,0 +1,60 @@ + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {95BABD97-FBDB-453A-AF8A-FA031A07B599} + WixBuildTools::TestSupport + ManagedCProj + DynamicLibrary + Unicode + true + + + + + + + + + + + + + Create + + 4564;4691 + + + + + + + + + + + + + + + + {6C57EF2C-979A-4106-A9E5-FE342810619A} + + + + + \ No newline at end of file diff --git a/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters new file mode 100644 index 00000000..34c1380f --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props new file mode 100644 index 00000000..4a7a0035 --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props @@ -0,0 +1,29 @@ + + + + + + + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), version.json)) + + + + + v142 + v4.7.2 + + + + $(RepoRootDir)\packages\xunit.abstractions.2.0.3\lib\netstandard2.0\xunit.abstractions.dll + + + $(RepoRootDir)\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll + + + $(RepoRootDir)\packages\xunit.extensibility.core.2.4.1\lib\netstandard1.1\xunit.core.dll + + + $(RepoRootDir)\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll + + + \ No newline at end of file diff --git a/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets new file mode 100644 index 00000000..09746229 --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets @@ -0,0 +1,15 @@ + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/src/WixBuildTools.TestSupport.Native/packages.config b/src/WixBuildTools.TestSupport.Native/packages.config new file mode 100644 index 00000000..b62d37e6 --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/packages.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/WixBuildTools.TestSupport.Native/precomp.cpp b/src/WixBuildTools.TestSupport.Native/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/precomp.cpp @@ -0,0 +1,3 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" diff --git a/src/WixBuildTools.TestSupport.Native/precomp.h b/src/WixBuildTools.TestSupport.Native/precomp.h new file mode 100644 index 00000000..f54b55be --- /dev/null +++ b/src/WixBuildTools.TestSupport.Native/precomp.h @@ -0,0 +1,11 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include +#include + +#include "NativeAssert.h" + +#pragma managed +#include -- cgit v1.2.3-55-g6feb