microsoft / microsoft/microsoft-ui-xaml
Proposal:Remove `using namespace Microsoft::UI::Xaml;` in C++/WinRT file templates
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Title
Remove `using namespace Microsoft::UI::Xaml;` in C++/WinRT file templates
### Summary
The default C++/WinRT file templates should not include using namespace Microsoft::UI::Xaml; as it causes namespace collisions and violates C++ best practices
### Rationale
The current default template includes:
```cpp
using namespace winrt;
using namespace Microsoft::UI::Xaml;
```
This causes namespace collisions with the Windows Implementation Library (WIL, which is by default bundled with winui3 project templates) and other libraries like WRL.
```cpp
#include
```
steps to reproduce:
- Create a new WinUI 3 C++/WinRT project
- Add a WIL header to a .cpp file: #include
- Observe compilation errors due to namespace collision
### Scope
| Capability | Priority |
| :---------- | :------- |
| Solves namespace collision issue with WIL | Must |
| Remove the using statement | Could |
| Change it to `using namespace winrt::Microsoft::UI::Xaml;` | Could
### Important Notes
_No response_
### Open Questions
_No response_
Contributor guide
Research direction
Search the C++/WinRT file-template sources for the exact `using namespace Microsoft::UI::Xaml;` statement and inspect how those templates are tested or generated. Reproduce the issue by adding `#include ` to a generated WinUI 3 C++ project, then verify that generated files no longer cause the namespace collision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100