microsoft / microsoft/react-native-windows

Remove Global Leakage of winrt namespaces

Open
#4,841 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Code Cleanup enhancement Workstream: Component Parity
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the shared headers containing the shown winrt using-directives and inspect how their namespace names are exposed to customers. Remove the global leakage and make namespace reduction explicit, then verify that affected code still resolves the intended types without silently selecting incorrect ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.