-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace collision when used with WinUI 3 #219
Comments
That's one option. There are actually What version of CsWin32 are you using that has this bug? It doesn't repro on 0.1.422-beta, I think. |
See #124 for the original report and fix for the namespace collision. |
You are correct. This has been fixed since I last used CsWin32 and WinUI 3 together. Thank you for your assistance. |
Still seeing this issue. Repro steps: Seems to happen when there's an XAML file in the project. Doesn't happen if there's no xaml in the project. Repro sample: Using VS16.10.p1 /cc @AArnott |
@dotMorten, can you navigate to the generated file and line that produces the error and copy the code snippet into the issue? |
@AArnott Here: Doesn't show any squiggles, so think it is still the xaml precompile step causing it I figured changing the default namespace would fix the problem, but that doesn't help, so it isn't a namespace collision. |
oh, it's complaining about your code, @dotMorten ? I don't know there's anything we can do about that. Try adding |
@AArnott Well it's complaining about calling "your" code :-) It's not a namespace collision issue (see last line in my above comment). |
Ok, so this looks like a project reunion flavor of #7, but the WPF workaround is apparently not effective in Reunion. I filed https://github.com/dotnet/roslyn/issues/52306 to get this fixed. |
This isn't a namespace collision with WinUI which is what this bug was tracking, so I'm going to re-close this issue. We'll open another issue in this repo to track the dotnet/roslyn one. |
Bumps [xunit](https://github.com/xunit/xunit) from 2.5.0 to 2.5.1. - [Commits](xunit/xunit@2.5.0...2.5.1) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
When you link WinUI 3 into your app, it defines a namespace called
Microsoft.System
. CsWin32 outputs go intoMicrosoft.Windows.Sdk
. Notice the common prefix. The generated code (ab)uses a strange quirk of the C# language by placing its using statements inside the namespace body, which changes the algorithm used to look up types. This results inusing System.Runtime.InteropServices
resolving to the namespaceMicrosoft.System.Runtime.InteropServices
because of the common prefix. Of course, this namespace doesn’t exist, which breaks the build. Hence, CsWin32 and WinUI 3 cannot coexist in the same project.The fix here is dead simple: Move the using statements to the top of the file, outside the namespace, which is where they should have been in the first place. When you do this, the using statements will be resolved exactly as they are specified. Thanks!
The text was updated successfully, but these errors were encountered: