diff --git a/nuget/readme.txt b/nuget/readme.txt index 72f7420c1..f02528ba8 100644 --- a/nuget/readme.txt +++ b/nuget/readme.txt @@ -18,5 +18,5 @@ In addition, C++/WinRT generates templates and skeleton implementations for each ======================================================================== For more information, visit: -https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget +https://github.com/Microsoft/cppwinrt/tree/master/nuget ======================================================================== diff --git a/test/nuget/TestApp/PropertySheet.props b/test/nuget/TestApp/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/test/nuget/TestApp/PropertySheet.props +++ b/test/nuget/TestApp/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/test/nuget/TestRuntimeComponent1/PropertySheet.props b/test/nuget/TestRuntimeComponent1/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/test/nuget/TestRuntimeComponent1/PropertySheet.props +++ b/test/nuget/TestRuntimeComponent1/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/test/nuget/TestRuntimeComponent2/PropertySheet.props b/test/nuget/TestRuntimeComponent2/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/test/nuget/TestRuntimeComponent2/PropertySheet.props +++ b/test/nuget/TestRuntimeComponent2/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/test/nuget/TestRuntimeComponent3/PropertySheet.props b/test/nuget/TestRuntimeComponent3/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/test/nuget/TestRuntimeComponent3/PropertySheet.props +++ b/test/nuget/TestRuntimeComponent3/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/test/nuget/TestRuntimeComponentEmpty/PropertySheet.props b/test/nuget/TestRuntimeComponentEmpty/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/test/nuget/TestRuntimeComponentEmpty/PropertySheet.props +++ b/test/nuget/TestRuntimeComponentEmpty/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Desktop/ConsoleApplication/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Desktop/ConsoleApplication/PropertySheet.props index c6b0691dd..b0c622690 100644 --- a/vsix/ProjectTemplates/VC/Windows Desktop/ConsoleApplication/PropertySheet.props +++ b/vsix/ProjectTemplates/VC/Windows Desktop/ConsoleApplication/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Desktop/WindowsApplication/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Desktop/WindowsApplication/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/vsix/ProjectTemplates/VC/Windows Desktop/WindowsApplication/PropertySheet.props +++ b/vsix/ProjectTemplates/VC/Windows Desktop/WindowsApplication/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/BlankApp.vcxproj b/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/BlankApp.vcxproj index 6acd6cd60..cb666a57a 100644 --- a/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/BlankApp.vcxproj +++ b/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/BlankApp.vcxproj @@ -80,6 +80,9 @@ WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions) + + false + diff --git a/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/PropertySheet.props +++ b/vsix/ProjectTemplates/VC/Windows Universal/BlankApp/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Universal/CoreApp/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Universal/CoreApp/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/vsix/ProjectTemplates/VC/Windows Universal/CoreApp/PropertySheet.props +++ b/vsix/ProjectTemplates/VC/Windows Universal/CoreApp/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.cpp b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.cpp new file mode 100644 index 000000000..cc0146bad --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.cpp @@ -0,0 +1,16 @@ +#include "pch.h" +#include "Class.h" +#include "Class.g.cpp" + +namespace winrt::$safeprojectname$::implementation +{ + int32_t Class::MyProperty() + { + throw hresult_not_implemented(); + } + + void Class::MyProperty(int32_t /* value */) + { + throw hresult_not_implemented(); + } +} diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.h b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.h new file mode 100644 index 000000000..f2ea96a0c --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Class.g.h" + +namespace winrt::$safeprojectname$::implementation +{ + struct Class : ClassT + { + Class() = default; + + int32_t MyProperty(); + void MyProperty(int32_t value); + }; +} + +namespace winrt::$safeprojectname$::factory_implementation +{ + struct Class : ClassT + { + }; +} diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.idl b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.idl new file mode 100644 index 000000000..86166e978 --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/Class.idl @@ -0,0 +1,9 @@ +namespace $safeprojectname$ +{ + [default_interface] + runtimeclass Class + { + Class(); + Int32 MyProperty; + } +} diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/PropertySheet.props new file mode 100644 index 000000000..e34141b01 --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/PropertySheet.props @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj new file mode 100644 index 000000000..e619fe0b3 --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj @@ -0,0 +1,136 @@ + + + + true + true + -lib $(MSBuildProjectName) + true + {$guid1$} + $projectname$ + $safeprojectname$ + en-US + 14.0 + true + Windows Store + 10.0 + $targetplatformversion$ + 10.0.17134.0 + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + StaticLibrary + v140 + v141 + v142 + Unicode + false + + + true + true + + + false + true + false + + + + + + + + + + + + + + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + + /DWINRT_NO_MAKE_DETECTION %(AdditionalOptions) + + WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions) + $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) + + + Console + false + $safeprojectname$.def + + + + + _DEBUG;%(PreprocessorDefinitions) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + true + true + + + + + + Class.idl + + + + + Create + + + Class.idl + + + + + + + + + + false + + + + + + \ No newline at end of file diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj.filters b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj.filters new file mode 100644 index 000000000..b6b6f9d64 --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/StaticLibrary.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + accd3aa8-1ba0-4223-9bbe-0c431709210b + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms + + + {926ab91d-31b4-48c3-b9a4-e681349f27f0} + + + + + + + Generated Files + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/cppwinrt_StaticLibrary.vstemplate b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/cppwinrt_StaticLibrary.vstemplate new file mode 100644 index 000000000..7eda1ca29 --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/cppwinrt_StaticLibrary.vstemplate @@ -0,0 +1,41 @@ + + + Static Library (C++/WinRT) + A project for a C++/WinRT Static Library that can be used by a Universal Windows Platform app + VC + 3000 + microsoft.Windows.CppWinRT.StaticLibrary + true + StaticLibrary + true + Enabled + true + cppwinrt.ico + cppwinrt.png + + + + StaticLibrary.vcxproj.filters + pch.cpp + pch.h + Class.idl + Class.cpp + Class.h + PropertySheet.props + readme.txt + + + + Microsoft.VisualStudio.Universal.TemplateWizards, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard + + + NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + NuGet.VisualStudio.TemplateWizard + + + + + + + \ No newline at end of file diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.cpp b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.cpp new file mode 100644 index 000000000..bcb5590be --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.h b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.h new file mode 100644 index 000000000..21199686d --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/pch.h @@ -0,0 +1,4 @@ +#pragma once +#include +#include +#include diff --git a/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/readme.txt b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/readme.txt new file mode 100644 index 000000000..64228f81d --- /dev/null +++ b/vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/readme.txt @@ -0,0 +1,44 @@ +======================================================================== + C++/WinRT $projectname$ Project Overview +======================================================================== + +This project demonstrates how to get started authoring Windows Runtime +classes directly with standard C++, using the C++/WinRT SDK component +to generate implementation headers from interface (IDL) files. The +generated static library should be consumed by a single Runtime Component +or App project and the types will automatically be added to that binary. + +To be able to instantiate types from the static library you need to +update the activation factory in the consuming binary to call the +activation factory exposed by this static library using code similar to: + +void* __stdcall $projectname$_get_activation_factory( + std::wstring_view const& name); + +void* __stdcall winrt_get_activation_factory( + std::wstring_view const& name) +{ + void* factory = $projectname$_get_activation_factory(name); + if (factory) + { + return factory; + } + + /* call other activation factories */ + + return nullptr; +} + +Steps: +1. Create an interface (IDL) file to define your Windows Runtime class, + its default interface, and any other interfaces it implements. +2. Build the project once to generate module.g.cpp, module.h.cpp, and + implementation templates under the "Generated Files" folder, as + well as skeleton class definitions under "Generated Files\sources". +3. Use the skeleton class definitions for reference to implement your + Windows Runtime classes. + +======================================================================== +Learn more about C++/WinRT here: +http://aka.ms/cppwinrt/ +======================================================================== diff --git a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/PropertySheet.props b/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/PropertySheet.props index 5942ba395..e34141b01 100644 --- a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/PropertySheet.props +++ b/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/PropertySheet.props @@ -9,7 +9,7 @@ * select the C++/WinRT property page For more advanced scenarios, and complete documentation, please see: - https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget + https://github.com/Microsoft/cppwinrt/tree/master/nuget --> diff --git a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/WindowsRuntimeComponent.vcxproj b/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/WindowsRuntimeComponent.vcxproj index 162719dc3..b917f4eda 100644 --- a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/WindowsRuntimeComponent.vcxproj +++ b/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/WindowsRuntimeComponent.vcxproj @@ -87,7 +87,7 @@ Console - true + false $safeprojectname$.def diff --git a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/module.g.cpp b/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/module.g.cpp deleted file mode 100644 index d903ace11..000000000 --- a/vsix/ProjectTemplates/VC/Windows Universal/WindowsRuntimeComponent/module.g.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// WARNING: Please don't edit this file. It was generated by C++/WinRT v1.0.171228.1 - -#include "pch.h" -#include "module.g.h" - -#ifndef WINRT_SUPPRESS_MODULE_EXPORTS - -#include "Class.h" - -HRESULT __stdcall WINRT_CanUnloadNow() -{ -#ifdef _WRL_MODULE_H_ - if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate()) - { - return S_FALSE; - } -#endif - - if (winrt::get_module_lock()) - { - return S_FALSE; - } - - winrt::clear_factory_cache(); - return S_OK; -} - -HRESULT __stdcall WINRT_GetActivationFactory(HSTRING classId, void** factory) -{ - try - { - *factory = nullptr; - wchar_t const* const name = WindowsGetStringRawBuffer(classId, nullptr); - - if (0 == wcscmp(name, L"WindowsRuntimeComponent.Class")) - { - *factory = winrt::detach_abi(winrt::make()); - return S_OK; - } - -#ifdef _WRL_MODULE_H_ - return ::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().GetActivationFactory(classId, reinterpret_cast<::IActivationFactory**>(factory)); -#else - return winrt::hresult_class_not_available().to_abi(); -#endif - } - catch (...) - { - return winrt::to_hresult(); - } -} - -#endif