├── demo1.png ├── demo2.png ├── demo3.png ├── Tests └── Standard │ ├── TestProject │ ├── A │ │ └── B │ │ │ └── C │ │ │ └── D │ │ │ └── Class1.cs │ ├── Exp10 │ │ ├── MyClass.cs │ │ ├── Typed.cs │ │ └── Nested.cs │ ├── Program.cs │ ├── Exp5 │ │ ├── Class1.cs │ │ ├── UserControl1.xaml │ │ ├── UserControl3.xaml │ │ ├── UserControl2.xaml │ │ ├── UserControl4.xaml │ │ ├── UserControl4.xaml.cs │ │ ├── UserControl2.xaml.cs │ │ ├── UserControl3.xaml.cs │ │ ├── UserControl5.xaml.cs │ │ ├── UserControl6.xaml.cs │ │ ├── UserControl1.xaml.cs │ │ ├── UserControl5.xaml │ │ └── UserControl6.xaml │ ├── Exp13 │ │ ├── Exp13 │ │ │ └── Exp13.cs │ │ └── Class1.cs │ ├── Exp12 │ │ ├── Class1 │ │ │ └── Class1.cs │ │ └── Class2.cs │ ├── Exp11 │ │ ├── Folder1 │ │ │ └── Nested.cs │ │ └── Folder2 │ │ │ ├── MyClass12.cs │ │ │ └── Typed12.cs │ ├── Exp2 │ │ ├── Class1.cs │ │ └── Class2.cs │ ├── Exp1 │ │ ├── Class4.cs │ │ ├── Class5.cs │ │ ├── Class123.cs │ │ └── Class67.cs │ ├── Exp3 │ │ ├── Class1.cs │ │ └── Class23456.cs │ ├── Exp4 │ │ ├── Class1.cs │ │ └── Class23.cs │ ├── Exp7 │ │ └── Class1.cs │ ├── Exp6 │ │ ├── Class1234.cs │ │ └── Class5.cs │ ├── Exp9 │ │ └── Class100.cs │ ├── TestProject.csproj │ └── Exp8 │ │ └── FakeAttribute.cs │ ├── TestMauiApp │ ├── Resources │ │ ├── Fonts │ │ │ ├── OpenSans-Regular.ttf │ │ │ └── OpenSans-Semibold.ttf │ │ ├── AppIcon │ │ │ ├── appicon.svg │ │ │ └── appiconfg.svg │ │ ├── Raw │ │ │ └── AboutAssets.txt │ │ ├── Splash │ │ │ └── splash.svg │ │ └── Styles │ │ │ └── Colors.xaml │ ├── Properties │ │ └── launchSettings.json │ ├── AppShell.xaml.cs │ ├── App.xaml.cs │ ├── Platforms │ │ ├── Android │ │ │ ├── Resources │ │ │ │ └── values │ │ │ │ │ └── colors.xml │ │ │ ├── AndroidManifest.xml │ │ │ ├── MainApplication.cs │ │ │ └── MainActivity.cs │ │ ├── iOS │ │ │ ├── AppDelegate.cs │ │ │ ├── Program.cs │ │ │ └── Info.plist │ │ ├── MacCatalyst │ │ │ ├── AppDelegate.cs │ │ │ ├── Program.cs │ │ │ └── Info.plist │ │ ├── Windows │ │ │ ├── App.xaml │ │ │ ├── app.manifest │ │ │ ├── App.xaml.cs │ │ │ └── Package.appxmanifest │ │ └── Tizen │ │ │ ├── Main.cs │ │ │ └── tizen-manifest.xml │ ├── AppShell.xaml │ ├── MauiProgram.cs │ ├── MainPage.xaml.cs │ ├── App.xaml │ ├── MainPage.xaml │ └── TestMauiApp.csproj │ ├── DatabaseProject │ ├── ClassFile1.cs │ ├── MyFolder │ │ └── ClassFile2.cs │ └── DatabaseProject.sqlproj │ ├── TestSharedProject │ ├── SharedClass1.cs │ ├── SharedFolder │ │ └── SharedClass2.cs │ ├── TestSharedProject.projitems │ └── TestSharedProject.shproj │ ├── adjust_namespaces_settings.xml │ └── TestSolution.sln ├── AdjustNamespace.2022 ├── Resources │ ├── order16.png │ ├── order512.png │ └── order90.png ├── Properties │ └── AssemblyInfo.cs ├── Monikers.imagemanifest ├── source.extension.cs ├── source.extension.vsixmanifest └── VSCommandTable.cs ├── AdjustNamespace.VsixShared ├── UI │ ├── StepFactory │ │ ├── IStepFactory.cs │ │ ├── PreparationStepFactory.cs │ │ ├── PerformingStepFactory.cs │ │ └── SelectedStepFactory.cs │ ├── Control │ │ ├── PerformingUserControl.xaml.cs │ │ ├── PreparationUserControl.xaml.cs │ │ ├── SelectedUserControl.xaml.cs │ │ ├── SpaceKeyUpEventTrigger.cs │ │ ├── PerformingUserControl.xaml │ │ └── PreparationUserControl.xaml │ ├── ViewModel │ │ ├── SelectedStepParameters.cs │ │ ├── Select │ │ │ ├── ISelectItemViewModel.cs │ │ │ ├── KnownRegex.cs │ │ │ ├── SelectFileViewModel.cs │ │ │ └── SelectFolderViewModel.cs │ │ └── PerformingParameters.cs │ ├── FileEx.cs │ └── TextLikeButtonResource.xaml ├── Adjusting │ ├── Fixer │ │ ├── IFixer.cs │ │ ├── FixerContainer.cs │ │ ├── FixerSet.cs │ │ └── Specific │ │ │ ├── QualifiedNameFixer.cs │ │ │ └── AddUsingFixer.cs │ ├── Adjuster │ │ ├── IAdjuster.cs │ │ ├── XamlAdjuster.cs │ │ └── AdjusterFactory.cs │ └── Cleanup.cs ├── Xaml │ ├── Positioned │ │ ├── IXamlPositioned.cs │ │ ├── IXamlPerformable.cs │ │ ├── XamlX.cs │ │ ├── XamlClass.cs │ │ ├── XamlXmlns.cs │ │ ├── XamlControl.cs │ │ └── XamlAttributeReference.cs │ ├── BodyProvider │ │ ├── IXamlBodyProvider.cs │ │ ├── ClosedXamlBodyProvider.cs │ │ └── OpenedXamlBodyProvider.cs │ ├── XamlEngine.cs │ └── XamlStructure.cs ├── Helper │ ├── ChainViewModel.cs │ ├── HashSetHelper.cs │ ├── EmbeddedResourceHelper.cs │ ├── ExtensionPath.cs │ ├── WpfHelper.cs │ ├── DocumentChangerHelper.cs │ ├── BaseViewModel.cs │ └── RoslynHelper.cs ├── ImageMonikers.cs ├── Settings │ ├── AdjustNamespaceSettings.cs │ ├── AdjustNamespaceSettings2.cs │ └── SettingsReader.cs ├── NamespaceReplaceRegex.cs ├── LICENSE.txt ├── AdjustNamespace.VsixShared.shproj ├── Options │ └── General.cs ├── Predicate.cs ├── Namespace │ ├── NamespaceTransition.cs │ └── NamespaceCenter.cs ├── Logging.cs ├── Window │ ├── AdjustNamespaceWindow.xaml │ ├── AdjustNamespaceWindow.xaml.cs │ └── EditSkippedPathsWindow.xaml ├── InfoBar │ ├── InfoBarService.cs │ └── ReleaseNotesInfoBarService.cs ├── AdjustNamespacePackage.cs ├── VsServices.cs └── Command │ ├── ShowReleaseNotesCommand.cs │ └── EditSkippedPathsCommand.cs ├── LICENSE ├── README.md ├── RELEASE_NOTES.md └── AdjustNamespace.sln /demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/demo1.png -------------------------------------------------------------------------------- /demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/demo2.png -------------------------------------------------------------------------------- /demo3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/demo3.png -------------------------------------------------------------------------------- /Tests/Standard/TestProject/A/B/C/D/Class1.cs: -------------------------------------------------------------------------------- 1 | namespace fixme; 2 | 3 | class Class1 4 | { 5 | } -------------------------------------------------------------------------------- /AdjustNamespace.2022/Resources/order16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/AdjustNamespace.2022/Resources/order16.png -------------------------------------------------------------------------------- /AdjustNamespace.2022/Resources/order512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/AdjustNamespace.2022/Resources/order512.png -------------------------------------------------------------------------------- /AdjustNamespace.2022/Resources/order90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/AdjustNamespace.2022/Resources/order90.png -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp10/MyClass.cs: -------------------------------------------------------------------------------- 1 | namespace SubjectWrong.Exp10 2 | { 3 | public class MyClass : Typed 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/Tests/Standard/TestMauiApp/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsoft/AdjustNamespace/HEAD/Tests/Standard/TestMauiApp/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp10/Typed.cs: -------------------------------------------------------------------------------- 1 | namespace SubjectWrong.Exp10 2 | { 3 | public abstract class Typed : Nested 4 | where RowT : Nested 5 | { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tests/Standard/DatabaseProject/ClassFile1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FakeDatabaseProject 6 | { 7 | class ClassFile1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/UI/StepFactory/IStepFactory.cs: -------------------------------------------------------------------------------- 1 | namespace AdjustNamespace.UI.StepFactory 2 | { 3 | public interface IStepFactory 4 | { 5 | System.Threading.Tasks.Task CreateAsync(object argument); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Tests/Standard/TestSharedProject/SharedClass1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FakeNamespace 6 | { 7 | internal class SharedClass1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Tests/Standard/DatabaseProject/MyFolder/ClassFile2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FakeDatabaseProject.FakeFolder 6 | { 7 | class ClassFile2 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace TestMauiApp 2 | { 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Tests/Standard/TestSharedProject/SharedFolder/SharedClass2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FakeNamespace.SharedFolder 6 | { 7 | internal class SharedClass2 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Subject 4 | { 5 | internal class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace TestMauiApp 2 | { 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | 9 | MainPage = new AppShell(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp5/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SubjectWrong.Exp5 8 | { 9 | internal class Class1 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp10/Nested.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SubjectWrong.Exp10 8 | { 9 | public class Nested 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp13/Exp13/Exp13.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TestProject.Exp13 8 | { 9 | internal class Exp13 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp12/Class1/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TestProject.Exp12 8 | { 9 | internal class Class1 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp11/Folder1/Nested.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SubjectWrong.Exp11.Folder1 8 | { 9 | public class Nested 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp2/Class1.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SubjectWrong.Exp2; 9 | 10 | internal class Class1 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace TestMauiApp 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp1/Class4.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SubjectWrong.Exp1SubjectWrong; 9 | 10 | internal class Exp1Class4 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp13/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TestProject.Exp13 8 | { 9 | internal class Class1 10 | { 11 | Exp13 Field; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Adjusting/Fixer/IFixer.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace AdjustNamespace.Adjusting.Fixer 4 | { 5 | public interface IFixer 6 | { 7 | public string FilePath 8 | { 9 | get; 10 | } 11 | 12 | Task FixAsync(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace TestMauiApp 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp3/Class1.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SubjectWrong.Exp3 9 | { 10 | internal class Class1 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Adjusting/Adjuster/IAdjuster.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | 6 | namespace AdjustNamespace.Adjusting.Adjuster 7 | { 8 | public interface IAdjuster 9 | { 10 | Task AdjustAsync(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp12/Class2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TestProject.Exp12 8 | { 9 | internal class Class2 10 | { 11 | public Class1 MyClass; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Xaml/Positioned/IXamlPositioned.cs: -------------------------------------------------------------------------------- 1 | namespace AdjustNamespace.Xaml.Positioned 2 | { 3 | public interface IXamlPositioned 4 | { 5 | int Index 6 | { 7 | get; 8 | } 9 | 10 | int Length 11 | { 12 | get; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Helper/ChainViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace AdjustNamespace.Helper 2 | { 3 | public abstract class ChainViewModel : BaseViewModel 4 | { 5 | protected ChainViewModel() 6 | : base() 7 | { 8 | } 9 | 10 | public abstract System.Threading.Tasks.Task StartAsync(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp4/Class1.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SubjectWrong.Exp4 9 | { 10 | internal enum MyEnum 11 | { 12 | MustBeCrossCluster 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp11/Folder2/MyClass12.cs: -------------------------------------------------------------------------------- 1 | namespace TestProject.Exp11.Folder2 2 | { 3 | using SubjectWrong.Exp11.Folder1; 4 | 5 | public class MyClass1 : Typed1 6 | { 7 | 8 | } 9 | } 10 | 11 | namespace TestProject.Exp11.Folder2 12 | { 13 | public class MyClass2 : Typed2 14 | { 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp7/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace System.Runtime.CompilerServices 8 | { 9 | sealed class CallerMemberNameAttribute : Attribute { } 10 | } 11 | 12 | namespace TestProject.Exp7 13 | { 14 | internal class Class1 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Xaml/BodyProvider/IXamlBodyProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AdjustNamespace.Xaml.BodyProvider 6 | { 7 | public interface IXamlBodyProvider 8 | { 9 | string XamlFilePath 10 | { 11 | get; 12 | } 13 | 14 | string ReadText(); 15 | 16 | 17 | void UpdateText(string text); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/UI/Control/PerformingUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace AdjustNamespace.UI.Control 4 | { 5 | /// 6 | /// Interaction logic for PerformingUserControl.xaml 7 | /// 8 | public partial class PerformingUserControl : UserControl 9 | { 10 | public PerformingUserControl() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/UI/Control/PreparationUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace AdjustNamespace.UI.Control 4 | { 5 | /// 6 | /// Interaction logic for PreparationUserControl.xaml 7 | /// 8 | public partial class PreparationUserControl : UserControl 9 | { 10 | public PreparationUserControl() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Helper/HashSetHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AdjustNamespace.Helper 6 | { 7 | internal static class HashSetHelper 8 | { 9 | public static void AddRange(this HashSet set, IEnumerable list) 10 | { 11 | foreach(var i in list) 12 | { 13 | set.Add(i); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/ImageMonikers.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Imaging.Interop; 2 | using System; 3 | 4 | namespace AdjustNamespace 5 | { 6 | public static class ImageMonikers 7 | { 8 | public static ImageMoniker Logo 9 | { 10 | get; 11 | } = new ImageMoniker 12 | { 13 | Guid = new Guid("872022f4-493a-4d7b-97f5-8b474662c341"), 14 | Id = 0 15 | }; 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui; 2 | using Microsoft.Maui.Hosting; 3 | using System; 4 | 5 | namespace TestMauiApp 6 | { 7 | internal class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Xaml/Positioned/IXamlPerformable.cs: -------------------------------------------------------------------------------- 1 | namespace AdjustNamespace.Xaml.Positioned 2 | { 3 | public interface IXamlPerformable : IXamlPositioned 4 | { 5 | bool Perform( 6 | XamlStructure structure, 7 | string sourceNamespace, 8 | string objectClassName, 9 | string targetNamespace, 10 | ref string xaml, 11 | out XamlXmlns? newXmlns 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace TestMauiApp 5 | { 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp2/Class2.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace TestProject.Exp2 9 | { 10 | internal class Class2 : SubjectWrong.Exp2.Class1 11 | { 12 | } 13 | } 14 | 15 | namespace TestProject.Exp2 16 | { 17 | using SubjectWrong.Exp2; 18 | 19 | internal class Class3 : Class1 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp11/Folder2/Typed12.cs: -------------------------------------------------------------------------------- 1 | namespace TestProject.Exp11.Folder2 2 | { 3 | public abstract class Typed1 : SubjectWrong.Exp11.Folder1.Nested 4 | where RowT : SubjectWrong.Exp11.Folder1.Nested 5 | { 6 | 7 | } 8 | } 9 | 10 | namespace TestProject.Exp11.Folder2 11 | { 12 | public abstract class Typed2 : SubjectWrong.Exp11.Folder1.Nested 13 | where RowT : SubjectWrong.Exp11.Folder1.Nested 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp6/Class1234.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SubjectWrong.Exp6 8 | { 9 | internal class Class1 10 | { 11 | internal class Class2 12 | { 13 | internal class Class3 14 | { 15 | internal class Class4 16 | { 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace TestMauiApp 6 | { 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace TestMauiApp 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp1/Class5.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Subject.Exp1Wrong; 8 | 9 | namespace SubjectWrong.Exp1SubjectWrong2; 10 | 11 | internal class Exp1Class5 12 | { 13 | public Exp1Class5( 14 | SubjectWrong.Exp1.Exp1Class1 p1, 15 | Exp1Class2 p2, 16 | Exp1Wrong.Exp1Class3 p3 17 | ) 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace TestMauiApp 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp9/Class100.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace System.Runtime.CompilerServices 8 | { 9 | [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 10 | internal class Fake2Attribute : Attribute 11 | { 12 | } 13 | 14 | } 15 | 16 | namespace TestProject.Exp7 17 | { 18 | 19 | internal class Class100 20 | { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Settings/AdjustNamespaceSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace AdjustNamespace.Settings 7 | { 8 | public class AdjustNamespaceSettings 9 | { 10 | public List SkippedFolderSuffixes 11 | { 12 | get; 13 | set; 14 | } = null!; 15 | 16 | 17 | public AdjustNamespaceSettings() 18 | { 19 | SkippedFolderSuffixes = new List(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp5/UserControl1.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Xaml/Positioned/XamlX.cs: -------------------------------------------------------------------------------- 1 | namespace AdjustNamespace.Xaml.Positioned 2 | { 3 | public class XamlX : IXamlPositioned 4 | { 5 | public int Index 6 | { 7 | get; 8 | } 9 | public int Length 10 | { 11 | get; 12 | } 13 | public string Alias 14 | { 15 | get; 16 | } 17 | 18 | public XamlX(int index, int length, string alias) 19 | { 20 | Index = index; 21 | Length = length; 22 | Alias = alias; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/TestProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0-windows 6 | true 7 | true 8 | Latest 9 | 10 | 11 | 12 | 13 | Code 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp5/UserControl3.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | namespace TestMauiApp 2 | { 3 | public static class MauiProgram 4 | { 5 | public static MauiApp CreateMauiApp() 6 | { 7 | var builder = MauiApp.CreateBuilder(); 8 | builder 9 | .UseMauiApp() 10 | .ConfigureFonts(fonts => 11 | { 12 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 13 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 14 | }); 15 | 16 | return builder.Build(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp4/Class23.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace TestProject.Exp4 9 | { 10 | internal class Class2 11 | { 12 | public SubjectWrong.Exp4.MyEnum Setting => SubjectWrong.Exp4.MyEnum.MustBeCrossCluster; 13 | } 14 | } 15 | 16 | namespace TestProject.Exp4 17 | { 18 | using SubjectWrong.Exp4; 19 | 20 | internal class Class3 21 | { 22 | public MyEnum Setting => MyEnum.MustBeCrossCluster; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace TestMauiApp 2 | { 3 | public partial class MainPage : ContentPage 4 | { 5 | int count = 0; 6 | 7 | public MainPage() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void OnCounterClicked(object sender, EventArgs e) 13 | { 14 | count++; 15 | 16 | if (count == 1) 17 | CounterBtn.Text = $"Clicked {count} time"; 18 | else 19 | CounterBtn.Text = $"Clicked {count} times"; 20 | 21 | SemanticScreenReader.Announce(CounterBtn.Text); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp8/FakeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace System.Runtime.CompilerServices 8 | { 9 | [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 10 | internal class FakeAttribute : Attribute 11 | { 12 | } 13 | 14 | } 15 | 16 | namespace TestProject.Exp8 17 | { 18 | 19 | [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 20 | internal class FakeAttribute : Attribute 21 | { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp1/Class123.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable IDE0001, IDE0005 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | //uncomment this line to see a small defect in AdjustNamespace algorithm: using SubjectWrong; 8 | using SubjectWrong.Exp1; 9 | 10 | namespace SubjectWrong.Exp1 11 | { 12 | internal class Exp1Class1 13 | { 14 | } 15 | } 16 | 17 | namespace Subject.Exp1Wrong 18 | { 19 | internal class Exp1Class2 20 | { 21 | } 22 | } 23 | 24 | namespace SubjectWrong.Exp1Wrong 25 | { 26 | internal class Exp1Class3 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp5/UserControl2.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/UI/ViewModel/SelectedStepParameters.cs: -------------------------------------------------------------------------------- 1 | using AdjustNamespace.UI.ViewModel; 2 | using AdjustNamespace; 3 | using System.Collections.Generic; 4 | 5 | namespace AdjustNamespace.UI.ViewModel 6 | { 7 | public readonly struct SelectedStepParameters 8 | { 9 | public readonly HashSet FilePaths; 10 | 11 | public SelectedStepParameters( 12 | HashSet filePaths 13 | ) 14 | { 15 | if (filePaths is null) 16 | { 17 | throw new ArgumentNullException(nameof(filePaths)); 18 | } 19 | 20 | FilePaths = filePaths; 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/UI/Control/SelectedUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace AdjustNamespace.UI.Control 4 | { 5 | /// 6 | /// Interaction logic for SelectedUserControl.xaml 7 | /// 8 | public partial class SelectedUserControl : UserControl 9 | { 10 | public SelectedUserControl() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void ListView_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) 16 | { 17 | if (e.Key == System.Windows.Input.Key.Space) 18 | { 19 | e.Handled = true; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Tests/Standard/TestMauiApp/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /Tests/Standard/TestProject/Exp5/UserControl4.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Command/ShowReleaseNotesCommand.cs: -------------------------------------------------------------------------------- 1 | using AdjustNamespace.Helper; 2 | using AdjustNamespace.Window; 3 | using Microsoft.VisualStudio.Shell; 4 | using System; 5 | using System.ComponentModel.Design; 6 | 7 | namespace AdjustNamespace.Command 8 | { 9 | /// 10 | /// Command handler 11 | /// 12 | internal sealed class ShowReleaseNotesCommand 13 | { 14 | public static string ProjectKind = "{52AEFF70-BBD8-11d2-8598-006097C68E81}"; 15 | 16 | 17 | /// 18 | /// Command ID. 19 | /// 20 | public const int CommandId = PackageIds.ShowReleaseNotesCommandId; 21 | 22 | /// 23 | /// Command menu group (command set GUID). 24 | /// 25 | public static readonly Guid CommandSet = new Guid("3f7538ed-5c20-4d49-89fc-c401bb76df25"); 26 | 27 | /// 28 | /// VS Package that provides this command, not null. 29 | /// 30 | private readonly AsyncPackage package; 31 | 32 | /// 33 | /// Initializes a new instance of the class. 34 | /// Adds our command handlers for menu (commands must exist in the command table file) 35 | /// 36 | /// Owner package, not null. 37 | /// Command service to add command to, not null. 38 | private ShowReleaseNotesCommand(AsyncPackage package, OleMenuCommandService commandService) 39 | { 40 | this.package = package ?? throw new ArgumentNullException(nameof(package)); 41 | commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); 42 | 43 | var menuCommandID = new CommandID(CommandSet, CommandId); 44 | var menuItem = new MenuCommand(Execute, menuCommandID); 45 | commandService.AddCommand(menuItem); 46 | } 47 | 48 | /// 49 | /// Gets the instance of the command. 50 | /// 51 | public static ShowReleaseNotesCommand? Instance 52 | { 53 | get; 54 | private set; 55 | } 56 | 57 | /// 58 | /// Gets the service provider from the owner package. 59 | /// 60 | Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider 61 | { 62 | get 63 | { 64 | return package; 65 | } 66 | } 67 | 68 | /// 69 | /// Initializes the singleton instance of the command. 70 | /// 71 | /// Owner package, not null. 72 | public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package) 73 | { 74 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); 75 | 76 | var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; 77 | Instance = new ShowReleaseNotesCommand(package, commandService!); 78 | } 79 | 80 | /// 81 | /// This function is the callback used to execute the command when the menu item is clicked. 82 | /// See the constructor to see how the menu item is associated with this function using 83 | /// OleMenuCommandService service and MenuCommand class. 84 | /// 85 | /// Event sender. 86 | /// Event args. 87 | private async void Execute(object sender, EventArgs e) 88 | { 89 | try 90 | { 91 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 92 | 93 | var rnPath = "RELEASE_NOTES.md".GetFullPathToFile(); 94 | 95 | _ = await VS.Documents.OpenAsync( 96 | rnPath 97 | ); 98 | } 99 | catch (Exception excp) 100 | { 101 | VS.MessageBox.ShowError("Error:", excp.Message); 102 | } 103 | } 104 | 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Command/EditSkippedPathsCommand.cs: -------------------------------------------------------------------------------- 1 | using AdjustNamespace.Window; 2 | using Microsoft.VisualStudio.Shell; 3 | using System; 4 | using System.ComponentModel.Design; 5 | 6 | namespace AdjustNamespace.Command 7 | { 8 | /// 9 | /// Command handler 10 | /// 11 | internal sealed class EditSkippedPathsCommand 12 | { 13 | public static string ProjectKind = "{52AEFF70-BBD8-11d2-8598-006097C68E81}"; 14 | 15 | 16 | /// 17 | /// Command ID. 18 | /// 19 | public const int CommandId = PackageIds.EditSkippedPathsCommandId; 20 | 21 | /// 22 | /// Command menu group (command set GUID). 23 | /// 24 | public static readonly Guid CommandSet = new Guid("3f7538ed-5c20-4d49-89fc-c401bb76df25"); 25 | 26 | /// 27 | /// VS Package that provides this command, not null. 28 | /// 29 | private readonly AsyncPackage package; 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// Adds our command handlers for menu (commands must exist in the command table file) 34 | /// 35 | /// Owner package, not null. 36 | /// Command service to add command to, not null. 37 | private EditSkippedPathsCommand(AsyncPackage package, OleMenuCommandService commandService) 38 | { 39 | this.package = package ?? throw new ArgumentNullException(nameof(package)); 40 | commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); 41 | 42 | var menuCommandID = new CommandID(CommandSet, CommandId); 43 | var menuItem = new MenuCommand(Execute, menuCommandID); 44 | commandService.AddCommand(menuItem); 45 | } 46 | 47 | /// 48 | /// Gets the instance of the command. 49 | /// 50 | public static EditSkippedPathsCommand? Instance 51 | { 52 | get; 53 | private set; 54 | } 55 | 56 | /// 57 | /// Gets the service provider from the owner package. 58 | /// 59 | Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider 60 | { 61 | get 62 | { 63 | return package; 64 | } 65 | } 66 | 67 | /// 68 | /// Initializes the singleton instance of the command. 69 | /// 70 | /// Owner package, not null. 71 | public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package) 72 | { 73 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); 74 | 75 | var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; 76 | Instance = new EditSkippedPathsCommand(package, commandService!); 77 | } 78 | 79 | /// 80 | /// This function is the callback used to execute the command when the menu item is clicked. 81 | /// See the constructor to see how the menu item is associated with this function using 82 | /// OleMenuCommandService service and MenuCommand class. 83 | /// 84 | /// Event sender. 85 | /// Event args. 86 | private async void Execute(object sender, EventArgs e) 87 | { 88 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 89 | 90 | try 91 | { 92 | var vss = await VsServices.CreateAsync(ServiceProvider); 93 | 94 | var w = new EditSkippedPathsWindow( 95 | vss 96 | ); 97 | w.ShowDialog(); 98 | } 99 | catch (Exception excp) 100 | { 101 | Logging.LogVS(excp); 102 | } 103 | } 104 | 105 | 106 | //private void ShowError(string errorMessage) 107 | //{ 108 | // VsShellUtilities.ShowMessageBox( 109 | // package, 110 | // errorMessage, 111 | // $"Error has been found", 112 | // OLEMSGICON.OLEMSGICON_WARNING, 113 | // OLEMSGBUTTON.OLEMSGBUTTON_OK, 114 | // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST 115 | // ); 116 | //} 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Adjusting/Fixer/Specific/AddUsingFixer.cs: -------------------------------------------------------------------------------- 1 | using AdjustNamespace.Helper; 2 | using Microsoft.CodeAnalysis; 3 | using Microsoft.CodeAnalysis.CSharp; 4 | using Microsoft.CodeAnalysis.CSharp.Syntax; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace AdjustNamespace.Adjusting.Fixer 12 | { 13 | /// 14 | /// Fixer for adding a using statements like using System.Threading.Tasks 15 | /// 16 | public class AddUsingFixer : IFixer 17 | { 18 | private readonly Workspace _workspace; 19 | private readonly HashSet _symbolTargetNamespaces = new (); 20 | 21 | public string FilePath 22 | { 23 | get; 24 | } 25 | 26 | public AddUsingFixer( 27 | Workspace workspace, 28 | string filePath 29 | ) 30 | { 31 | if (workspace is null) 32 | { 33 | throw new ArgumentNullException(nameof(workspace)); 34 | } 35 | 36 | if (filePath is null) 37 | { 38 | throw new ArgumentNullException(nameof(filePath)); 39 | } 40 | 41 | _workspace = workspace; 42 | FilePath = filePath; 43 | } 44 | 45 | 46 | public void AddSubject(string symbolTargetNamespace) 47 | { 48 | if (symbolTargetNamespace is null) 49 | { 50 | throw new ArgumentNullException(nameof(symbolTargetNamespace)); 51 | } 52 | 53 | _symbolTargetNamespaces.Add(symbolTargetNamespace); 54 | } 55 | 56 | 57 | public async Task FixAsync() 58 | { 59 | bool r; 60 | do 61 | { 62 | var (document, syntaxRoot) = await _workspace.GetDocumentAndSyntaxRootAsync(FilePath); 63 | if (document == null || syntaxRoot == null) 64 | { 65 | //skip this document 66 | return; 67 | } 68 | 69 | foreach (var symbolTargetNamespace in _symbolTargetNamespaces) 70 | { 71 | var usingSyntaxes = syntaxRoot 72 | .DescendantNodes() 73 | .OfType() 74 | .ToList(); 75 | 76 | if (usingSyntaxes.Count > 0) 77 | { 78 | if (usingSyntaxes.Any(s => s.Name.ToString() == symbolTargetNamespace)) 79 | { 80 | //that using already exists 81 | continue; 82 | } 83 | } 84 | 85 | Debug.WriteLine($"Fix references in {FilePath}: Add '{symbolTargetNamespace}' "); 86 | 87 | if (usingSyntaxes.Count > 0) 88 | { 89 | var lastUsing = usingSyntaxes.Last(); 90 | 91 | syntaxRoot = syntaxRoot.InsertNodesAfter( 92 | lastUsing, 93 | new[] 94 | { 95 | SyntaxFactory.UsingDirective( 96 | SyntaxFactory.ParseName( 97 | " " + symbolTargetNamespace 98 | ) 99 | ).WithTrailingTrivia(SyntaxFactory.CarriageReturnLineFeed) 100 | .WithLeadingTrivia(lastUsing.GetLeadingTrivia()) 101 | }); 102 | } 103 | else 104 | { 105 | var cus = (CompilationUnitSyntax)syntaxRoot; 106 | var modifiedcus = cus.AddUsings( 107 | SyntaxFactory.UsingDirective( 108 | SyntaxFactory.ParseName( 109 | " " + symbolTargetNamespace 110 | ) 111 | ).WithTrailingTrivia(SyntaxFactory.CarriageReturnLineFeed, SyntaxFactory.CarriageReturnLineFeed) 112 | .WithLeadingTrivia(cus.GetLeadingTrivia()) 113 | ); 114 | 115 | syntaxRoot = modifiedcus; 116 | } 117 | } 118 | 119 | var changedDocument = document.WithSyntaxRoot(syntaxRoot); 120 | r = _workspace.TryApplyChanges(changedDocument.Project.Solution); 121 | } 122 | while (!r); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /AdjustNamespace.VsixShared/Adjusting/Adjuster/AdjusterFactory.cs: -------------------------------------------------------------------------------- 1 | using AdjustNamespace.Helper; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace AdjustNamespace.Adjusting.Adjuster 6 | { 7 | public class AdjusterFactory 8 | { 9 | private readonly VsServices _vss; 10 | private readonly NamespaceReplaceRegex _replaceRegex; 11 | private readonly bool _openFilesToEnableUndo; 12 | private readonly NamespaceCenter _namespaceCenter; 13 | private readonly List _xamlFilePaths; 14 | 15 | public static async Task CreateAsync( 16 | VsServices vss, 17 | NamespaceReplaceRegex replaceRegex, 18 | bool openFilesToEnableUndo, 19 | NamespaceCenter namespaceCenter 20 | ) 21 | { 22 | if (replaceRegex is null) 23 | { 24 | throw new ArgumentNullException(nameof(replaceRegex)); 25 | } 26 | 27 | if (namespaceCenter is null) 28 | { 29 | throw new ArgumentNullException(nameof(namespaceCenter)); 30 | } 31 | 32 | //get all xaml files in current solution 33 | var filePaths = await SolutionHelper.GetAllFilesFromAsync(); 34 | var xamlFilePaths = filePaths.FindAll(fp => fp.EndsWith(".xaml")); 35 | 36 | return new AdjusterFactory( 37 | vss, 38 | replaceRegex, 39 | openFilesToEnableUndo, 40 | namespaceCenter, 41 | xamlFilePaths 42 | ); 43 | 44 | } 45 | 46 | private AdjusterFactory( 47 | VsServices vss, 48 | NamespaceReplaceRegex replaceRegex, 49 | bool openFilesToEnableUndo, 50 | NamespaceCenter namespaceCenter, 51 | List xamlFilePaths 52 | ) 53 | { 54 | if (replaceRegex is null) 55 | { 56 | throw new ArgumentNullException(nameof(replaceRegex)); 57 | } 58 | 59 | if (namespaceCenter is null) 60 | { 61 | throw new ArgumentNullException(nameof(namespaceCenter)); 62 | } 63 | 64 | if (xamlFilePaths is null) 65 | { 66 | throw new ArgumentNullException(nameof(xamlFilePaths)); 67 | } 68 | 69 | _vss = vss; 70 | _replaceRegex = replaceRegex; 71 | _openFilesToEnableUndo = openFilesToEnableUndo; 72 | _namespaceCenter = namespaceCenter; 73 | _xamlFilePaths = xamlFilePaths; 74 | } 75 | 76 | public async Task CreateAsync( 77 | string subjectFilePath 78 | ) 79 | { 80 | if (subjectFilePath is null) 81 | { 82 | throw new ArgumentNullException(nameof(subjectFilePath)); 83 | } 84 | 85 | var pii = await SolutionHelper.TryGetProjectItemAsync(subjectFilePath); 86 | if (!pii.HasValue) 87 | { 88 | return null; 89 | } 90 | 91 | var targetNamespace = await NamespaceHelper.TryDetermineTargetNamespaceAsync( 92 | pii.Value.Project, 93 | _vss, 94 | _replaceRegex, 95 | subjectFilePath 96 | ); 97 | if (string.IsNullOrEmpty(targetNamespace)) 98 | { 99 | return null; 100 | } 101 | 102 | if (subjectFilePath.EndsWith(".xaml")) 103 | { 104 | //it's a xaml 105 | 106 | var xamlAdjuster = new XamlAdjuster( 107 | _vss, 108 | _openFilesToEnableUndo, 109 | subjectFilePath, 110 | targetNamespace! 111 | ); 112 | return xamlAdjuster; 113 | } 114 | else 115 | { 116 | //we can do nothing with not a C# documents 117 | var subjectDocument = _vss.Workspace.GetDocument(subjectFilePath); 118 | if (!subjectDocument.IsDocumentInScope()) 119 | { 120 | return null; 121 | } 122 | 123 | var csAdjuster = new CsAdjuster( 124 | _vss, 125 | _openFilesToEnableUndo, 126 | _namespaceCenter, 127 | subjectFilePath, 128 | targetNamespace!, 129 | _xamlFilePaths 130 | ); 131 | 132 | return csAdjuster; 133 | } 134 | } 135 | } 136 | } 137 | --------------------------------------------------------------------------------