dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.96k stars 4.03k forks source link

Refactor-to-New-Namespace doesn't work for C# types that are associated with XAML #35337

Open pierceboggan opened 5 years ago

pierceboggan commented 5 years ago

Version Used: Microsoft Visual Studio Enterprise 2019 Int Preview Version 16.1.0 Preview 3.0 [28824.287.d16.1] VisualStudio.16.IntPreview/16.1.0-pre.3.0+28824.287.d16.1 Microsoft .NET Framework Version 4.8.03752

Installed Version: Enterprise

Visual C++ 2019 00435-60000-00000-AA045 Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package 9.0.20307.1 Application Insights Tools for Visual Studio

Azure App Service Tools v3.0.0 16.1.371.8123 Azure App Service Tools v3.0.0

C# Tools 3.1.0-beta3-19223-09+ce8ac3f71fa4c73b78cf8218d58b322bdbdfa1c9 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.1.77 (master@24013d5) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 16.1.1 (2473f22) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.1.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

Visual Basic Tools 3.1.0-beta3-19223-09+ce8ac3f71fa4c73b78cf8218d58b322bdbdfa1c9 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 16.1.0.537 (d16-1@2ce5a1af6) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.1.99.108 (remotes/origin/master@f2a5d8344) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.2.101 (cb5edbc) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.3.0.18 (HEAD/2da2d99e8) Xamarin.Android Reference Assemblies and MSBuild support. Mono: mono/mono/2018-08@3f5ec6d95c3 Java.Interop: xamarin/java.interop/d16-1@5ddc3e3 LibZipSharp: grendello/LibZipSharp/d16-1@44de300 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26

Xamarin.iOS and Xamarin.Mac SDK 12.10.0.150 (99c0cfa) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Steps to Reproduce:

  1. Create a new Mobile App (Xamarin.Forms) app from File > New Project.
  2. Open Views/AboutPage.xaml.cs.
  3. Use the new refactor-to-new-namespace functionality.

Expected Behavior: Namespace is updated in C# and associated XAML file.

Actual Behavior: Namespace is not updated in C# and associated XAML file.

Video: https://www.screencast.com/t/qVrPpfMRG

ryzngard commented 5 years ago

Expanding notes from investigation: It seems that all partial types with multiple definitions (which is likely all of them) currently don't work. The underlying check is ContainsPartialTypeWithMultipleDeclarationsAsync

ryzngard commented 5 years ago

@pierceboggan even once this is enabled for partial types, there are issues with IVSRefactorNotify I believe. All of the symbol notifications up until this point only include the namespace OR symbol name, but not both. With this new implementation, the FQN will go through. I'm not sure that's being handled by listeners on the other side. This will result in the XAML not being fixed up, and the codegen file will be wrong.