diff --git a/change/react-native-windows-2020-03-07-06-25-07-fix-etw.json b/change/react-native-windows-2020-03-07-06-25-07-fix-etw.json new file mode 100644 index 00000000000..64de1786ac4 --- /dev/null +++ b/change/react-native-windows-2020-03-07-06-25-07-fix-etw.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "comment": "Fix Support For SysTraceSection", + "packageName": "react-native-windows", + "email": "ngerlem@microsoft.com", + "commit": "6745910fa922e880c314c9581419a6a2cc3f2e2a", + "dependentChangeType": "patch", + "date": "2020-03-07T14:25:07.210Z" +} \ No newline at end of file diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index d07ebeb0c4b..7c4e4eb932b 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -41,7 +41,7 @@ ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) diff --git a/vnext/ReactWindowsCore/tracing/fbsystrace.h b/vnext/ReactWindowsCore/tracing/fbsystrace.h index 256ea90d209..edaaaa123ff 100644 --- a/vnext/ReactWindowsCore/tracing/fbsystrace.h +++ b/vnext/ReactWindowsCore/tracing/fbsystrace.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include @@ -6,6 +9,7 @@ #include #include #include +#include #include #define TRACE_TAG_REACT_CXX_BRIDGE 1 << 10 @@ -51,44 +55,33 @@ class FbSystraceSection { .count()); } - void init(std::string &&v) { - args_[index_++] = std::move(v); - begin_section(); + template + FbSystraceSection(uint64_t tag, std::string &&profileName, RestArg &&... rest) + : tag_(tag), profile_name_(std::move(profileName)) { + id_ = s_id_counter++; + init(std::forward(rest)...); } - void init(const std::string &v) { - args_[index_++] = v; // copy - begin_section(); + ~FbSystraceSection() { + end_section(); } + private: void init() { begin_section(); } - template - void init(std::string &&v, ConvertsToStringPiece &&... rest) { - args_[index_++] = std::move(v); - init(std::forward(rest)...); - } - - template - void init(const std::string &v, ConvertsToStringPiece &&... rest) { - args_[index_++] = v; // copy - init(std::forward(rest)...); - } - - template - FbSystraceSection(uint64_t tag, std::string &&v, ConvertsToStringPiece &&... rest) - : tag_(tag), profile_name_(std::move(v)) { - id_ = s_id_counter++; - init(std::forward(rest)...); - } + template + void init(Arg &&arg, RestArg &&... rest) { + if constexpr (std::is_convertible_v) { + args_[index_++] = std::forward(arg); + } else { + args_[index_++] = std::to_string(std::forward(arg)); + } - ~FbSystraceSection() { - end_section(); + init(std::forward(rest)...); } - private: std::array args_; uint64_t tag_{0};