microsoft / microsoft/microsoft-ui-xaml
Generated partial App class in XamlTypeInfo.g.cs has fixed "public" access modifier
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
When a WinUI 3 app has the [CA1515: Consider making public types internal](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1515) code rule enabled, the `App` class can not be made `internal` due to its partial class generated in XamlTypeInfo.g.cs is made `public`.
### Steps to reproduce the bug
1. Create a blank WinUI 3 app with VisualStudio's WinUI 3 app template.
2. Go to App.xaml.cs, change the `App` class's access modifier from public to internal.
3. Build the project.
4. Build fails with the following error:
```
Error (active) CS0262 Partial declarations of 'App' have conflicting accessibility modifiers
```
### Expected behavior
App should be able to successfully build when change App to internal.
### Screenshots
_No response_
### NuGet package version
WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
Upon search there are 3 generated partial classes for App. While the following two do not have access modifier:
`partial class App : global::Microsoft.UI.Xaml.Application`
.\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\Views\App.g.cs
.\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\Views\App.g.i.cs
the generated partial class in
.\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs
has `public partial class App : global::Microsoft.UI.Xaml.Markup.IXamlMetadataProvider`.
Contributor guide
Research direction
Reproduce the issue with a blank WinUI 3 app by changing App.xaml.cs from public to internal, then inspect the generated App declarations in App.g.cs, App.g.i.cs, and XamlTypeInfo.g.cs. Trace how XamlTypeInfo.g.cs assigns accessibility and verify the project builds successfully with App declared internal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100