Skip to content

Commit 816370e

Browse files
authored
updates to the porting topics (#681)
1 parent 8008b78 commit 816370e

File tree

4 files changed

+271
-147
lines changed

4 files changed

+271
-147
lines changed

windows-apps-src/cpp-and-winrt-apis/clipboard-to-winrt-from-csharp.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.localizationpriority: medium
1111

1212
This topic presents a case study of porting one of the [Universal Windows Platform (UWP) app samples](https://github.com/microsoft/Windows-universal-samples) from [C#](/visualstudio/get-started/csharp) to [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). You can gain porting practice and experience by following along with the walkthrough and porting the sample for yourself as you go.
1313

14-
Also see [Move to C++/WinRT from C#](/windows/uwp/cpp-and-winrt-apis/move-to-winrt-from-csharp), which presents a number of sections that address specific technical details involved in porting from C# to C++/WinRT.
14+
For a comprehensive catalog of the technical details involved in porting to C++/WinRT from C#, see the companion topic [Move to C++/WinRT from C#](/windows/uwp/cpp-and-winrt-apis/move-to-winrt-from-csharp).
1515

1616
## Download and test the Clipboard sample
1717

@@ -134,7 +134,9 @@ And you'll recall that **MainPage.Scenarios** is a collection of **Scenario** ob
134134

135135
Now let's add to the `MainPage.idl` file the new types and the new member of **Mainpage** that we've decided to declare in IDL. At the same time, we'll remove from the IDL the placeholder members of **Mainpage** that the Visual Studio project template gave us.
136136

137-
So, in your C++/WinRT project, open `MainPage.idl`, and edit it so that it looks like the listing below. Note that one of the edits is to change the namespace name from **Clipboard** to **SDKTemplate**. If you like, you can just delete the current contents of your `MainPage.idl`, and paste in the listing below. Another tweak to note is that we're changing the name of **Scenario::ClassType** to **Scenario::ClassName**.
137+
So, in your C++/WinRT project, open `MainPage.idl`, and edit it so that it looks like the listing below. Note that one of the edits is to change the namespace name from **Clipboard** to **SDKTemplate**. If you like, you can just replace the entire contents of `MainPage.idl` with the following code. Another tweak to note is that we're changing the name of **Scenario::ClassType** to **Scenario::ClassName**.
138+
139+
138140

139141
```idl
140142
// MainPage.idl
@@ -1122,7 +1124,7 @@ There's value in consolidating your runtime classes into a single IDL file (see
11221124

11231125
While we're doing that, let's also remove the auto-generated dummy property (`Int32 MyProperty;`, and its implementation) from each of those five XAML page types.
11241126

1125-
First, add a new **Midl File (.idl)** item to the C++/WinRT project. Name it `Project.idl`. Delete the default contents of `Project.idl`, and in its place paste the listing below.
1127+
First, add a new **Midl File (.idl)** item to the C++/WinRT project. Name it `Project.idl`. Replace the entire contents of `Project.idl` with the following code.
11261128

11271129
```idl
11281130
// Project.idl

windows-apps-src/cpp-and-winrt-apis/faq.md

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ If you have a runtime class that frees resources in its destructor, and that run
7878
- If you can't guarantee that you have the last remaining reference to an object (because you passed it to other APIs, which could be keeping a reference), then calling **IClosable::Close** is a good idea.
7979
- When in doubt, it's safe to call **IClosable::Close** manually, rather than waiting for the wrapper to call it on destruction.
8080

81+
So, if you know that you have the last reference, then you can let the wrapper destructor do the work. If you need to close before the last reference vanishes, then you need to call **Close**. To be exception-safe, you should **Close** in a resource-acquisition-is-initialization (RAII) type (so that close happens on unwind). C++/WinRT doesn't have a **unique_close** wrapper, but you can make your own.
82+
8183
## Can I use LLVM/Clang to compile with C++/WinRT?
8284
We don't support the LLVM and Clang toolchain for C++/WinRT, but we do make use of it internally to validate C++/WinRT's standards conformance. For example, if you wanted to emulate what we do internally, then you could try an experiment such as the one described below.
8385

windows-apps-src/cpp-and-winrt-apis/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ C++/WinRT performs better and produces smaller binaries than any other language
5757
| [Move to C++/WinRT from C++/CX](move-to-winrt-from-cx.md) | This topic describes the technical details involved in porting the source code in a [C++/CX](/cpp/cppcx/visual-c-language-reference-c-cx) project to its equivalent in [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). |
5858
| [Interop between C++/WinRT and C++/CX](interop-winrt-cx.md) | This topic shows two helper functions that can be used to convert between [C++/CX](/cpp/cppcx/visual-c-language-reference-c-cx) and [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt) objects. |
5959
| [Move to C++/WinRT from WRL](move-to-winrt-from-wrl.md) | This topic shows how to port [Windows Runtime C++ Template Library (WRL)](/cpp/windows/windows-runtime-cpp-template-library-wrl) code to its equivalent in [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). |
60-
| [Porting the Clipboard sample to C++/WinRT from C#—a case study](clipboard-to-winrt-from-csharp.md) | This topic presents a case study of porting one of the [Universal Windows Platform (UWP) app samples](https://github.com/microsoft/Windows-universal-samples) from [C#](/visualstudio/get-started/csharp) to [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). |
61-
| [Move to C++/WinRT from C#](move-to-winrt-from-csharp.md) | This topic describes the technical details involved in porting the source code in a [C#](/visualstudio/get-started/csharp) project to its equivalent in [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). |
60+
| [Porting the Clipboard sample to C++/WinRT from C#—a case study](clipboard-to-winrt-from-csharp.md) | This topic presents a case study of porting one of the [Universal Windows Platform (UWP) app samples](https://github.com/microsoft/Windows-universal-samples) from [C#](/visualstudio/get-started/csharp) to [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). You can gain porting practice and experience by following along with the walkthrough and porting the sample for yourself as you go. |
61+
| [Move to C++/WinRT from C#](move-to-winrt-from-csharp.md) | This topic comprehensively catalogs the technical details involved in porting the source code in a [C#](/visualstudio/get-started/csharp) project to its equivalent in [C++/WinRT](/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt). |
6262
| [Interop between C++/WinRT and the ABI](interop-winrt-abi.md) | This topic shows how to convert between application binary interface (ABI) and C++/WinRT objects. |
6363
| [Strong and weak references in C++/WinRT](weak-references.md) | The Windows Runtime is a reference-counted system; and in such a system it's important for you to know about the significance of, and distinction between, strong and weak references. |
6464
| [Agile objects](agile-objects.md) | An agile object is one that can be accessed from any thread. Your C++/WinRT types are agile by default, but you can opt out. |

0 commit comments

Comments
 (0)