react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Remove Global Leakage of winrt namespaces

Open NickGerleman opened this issue 5 years ago • 1 comments

We have code today in shared headers that looks like this:

namespace winrt {
using namespace Windows::UI::Core;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
} // namespace winrt

This type of global leakage can lead to confusion of where namespaces are coming from, can leak to customers, and has bitten us in Office before, where incorrect types are silently included. E.g. the wrong IInspectable.

Cppcoreguidelines, which we try to follow explicitly calls this out as something not to do http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-using-directive

We should remove this, ensure it's not leaking to customers, and make namespace reduction explicit.

NickGerleman avatar May 08 '20 22:05 NickGerleman

Will need to do an audit of where we're doing this. Coming up with that index seems like the next step. Solution used in tests: header file that has aliases that is included from cpp. Problem: interaction with PCHs.

chrisglein avatar May 11 '20 18:05 chrisglein