From 7bfef485db361675b200387bf7fa564365ff56e9 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Wed, 20 Oct 2021 12:59:29 -0700 Subject: [PATCH 1/8] Update component_writers.h Clarified how to correctly manage generated files in the comment. --- cppwinrt/component_writers.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index b8894f8f4..af5aca93f 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -988,9 +988,22 @@ namespace winrt::@::implementation static void write_generated_static_assert(writer& w) { auto format = R"( -// Note: Remove this static_assert after copying these generated source files to your project. -// This assertion exists to avoid compiling these generated source files directly. -static_assert(false, "Do not compile generated C++/WinRT source files directly"); +// WARNING: This file is automatically generated from IDL. Do not directly +// add this file to your project, as any changes you make will be lost. +// +// If this is a new file: +// 1. Copy this file from the 'Generated Files' directory into the +// directory where you store your other source files (e.g. the project root). +// 2. Add the copied file to your project via Project -> Add Existing Item. +// 3. Delete this comment and the 'static_assert' (below) from the copied file +// (do not modify the original file in the 'Generated Files' directory). +// +// If this is an update to an existing file: +// 1. Copy the relevant changes from this file and merge them into the copy +// you made previously. +// +// This assertion helps prevent accidental modification of generated files. +static_assert(false, "This file is generated by a tool and will be overwritten. Open this error and view the comment for assistance."); )"; w.write(format); @@ -1206,4 +1219,4 @@ namespace winrt::@::implementation slot); } } -} \ No newline at end of file +} From 79871fe19e7e830c9f7b2d84be452278030e3ba3 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:24:42 -0700 Subject: [PATCH 2/8] Update cppwinrt/component_writers.h Accept Raymond's suggestion Co-authored-by: Raymond Chen --- cppwinrt/component_writers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index af5aca93f..a2c28a7a9 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -998,7 +998,7 @@ namespace winrt::@::implementation // 3. Delete this comment and the 'static_assert' (below) from the copied file // (do not modify the original file in the 'Generated Files' directory). // -// If this is an update to an existing file: +// To update an existing file in your project: // 1. Copy the relevant changes from this file and merge them into the copy // you made previously. // From 5f68d43d3c5bde726de79feda1f9052822e6dfaa Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:28:30 -0700 Subject: [PATCH 3/8] Update cppwinrt/component_writers.h Accept Raymond's suggestion Co-authored-by: Raymond Chen --- cppwinrt/component_writers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index a2c28a7a9..4098e935d 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -988,7 +988,7 @@ namespace winrt::@::implementation static void write_generated_static_assert(writer& w) { auto format = R"( -// WARNING: This file is automatically generated from IDL. Do not directly +// WARNING: This file is automatically generated by a tool. Do not directly // add this file to your project, as any changes you make will be lost. // // If this is a new file: From dd41de37831995f7c5b13ef365bd4c5ab59933ce Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:29:28 -0700 Subject: [PATCH 4/8] Update cppwinrt/component_writers.h Accept Raymond's suggestion Co-authored-by: Raymond Chen --- cppwinrt/component_writers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index 4098e935d..c36263e12 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -991,7 +991,7 @@ namespace winrt::@::implementation // WARNING: This file is automatically generated by a tool. Do not directly // add this file to your project, as any changes you make will be lost. // -// If this is a new file: +// To add a copy of this file to your project: // 1. Copy this file from the 'Generated Files' directory into the // directory where you store your other source files (e.g. the project root). // 2. Add the copied file to your project via Project -> Add Existing Item. From 7424cc108cc0ae882d92fbf5e316be969fca6b96 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:29:36 -0700 Subject: [PATCH 5/8] Update cppwinrt/component_writers.h Accept Raymond's suggestion Co-authored-by: Raymond Chen --- cppwinrt/component_writers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index c36263e12..83425d171 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -994,7 +994,8 @@ namespace winrt::@::implementation // To add a copy of this file to your project: // 1. Copy this file from the 'Generated Files' directory into the // directory where you store your other source files (e.g. the project root). -// 2. Add the copied file to your project via Project -> Add Existing Item. +// 2. Add the copied file to your project. In Visual Studio, you +// can use Project -> Add Existing Item. // 3. Delete this comment and the 'static_assert' (below) from the copied file // (do not modify the original file in the 'Generated Files' directory). // From 8a64a24cf4ccc576f2ae30d044dc1f9ca7eff104 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:30:07 -0700 Subject: [PATCH 6/8] Update cppwinrt/component_writers.h Accept Raymond's suggestion Co-authored-by: Raymond Chen --- cppwinrt/component_writers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index 83425d171..e00b10105 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -996,8 +996,8 @@ namespace winrt::@::implementation // directory where you store your other source files (e.g. the project root). // 2. Add the copied file to your project. In Visual Studio, you // can use Project -> Add Existing Item. -// 3. Delete this comment and the 'static_assert' (below) from the copied file -// (do not modify the original file in the 'Generated Files' directory). +// 3. Delete this comment and the 'static_assert' (below) from the copied file. +// (Do not modify this file.) // // To update an existing file in your project: // 1. Copy the relevant changes from this file and merge them into the copy From 029c2978cfd3dd887fd7473c9e9a333e3b64f795 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 09:43:22 -0700 Subject: [PATCH 7/8] Update component_writers.h More cleanup based on Raymond's feedback. --- cppwinrt/component_writers.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index e00b10105..3286d35d9 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -992,12 +992,12 @@ namespace winrt::@::implementation // add this file to your project, as any changes you make will be lost. // // To add a copy of this file to your project: -// 1. Copy this file from the 'Generated Files' directory into the -// directory where you store your other source files (e.g. the project root). -// 2. Add the copied file to your project. In Visual Studio, you -// can use Project -> Add Existing Item. +// 1. Copy this file from its original location to the location where you store +// your other source files (e.g. the project root). +// 2. Add the copied file to your project. In Visual Studio, you can use +// Project -> Add Existing Item. // 3. Delete this comment and the 'static_assert' (below) from the copied file. -// (Do not modify this file.) +// Do not modify the original file. // // To update an existing file in your project: // 1. Copy the relevant changes from this file and merge them into the copy From a893cfde1ba266e60a4b823017085d9157a20fd2 Mon Sep 17 00:00:00 2001 From: "Peter Torr (MSFT)" Date: Thu, 21 Oct 2021 15:07:56 -0700 Subject: [PATCH 8/8] Update component_writers.h --- cppwinrt/component_writers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index 3286d35d9..45970c538 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -990,6 +990,7 @@ namespace winrt::@::implementation auto format = R"( // WARNING: This file is automatically generated by a tool. Do not directly // add this file to your project, as any changes you make will be lost. +// This file is a stub you can use as a starting point for your implementation. // // To add a copy of this file to your project: // 1. Copy this file from its original location to the location where you store