├── readme_files
├── fullrename.png
├── FullRenamer2017-11-13.vsix
└── FullRenamer2019-12-19.vsix
├── src
├── RenameProjectVsExtension
│ ├── Core.UnitTests
│ │ ├── FakeProjectRenamer.cs
│ │ ├── packages.config
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Core.UnitTests.csproj
│ │ └── ProjectRenamerTests.cs
│ ├── Core
│ │ ├── packages.config
│ │ ├── NamespaceRenamer.cs
│ │ ├── StringExtensions.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── SharedTypeProjectRenamer.cs
│ │ ├── Core.csproj
│ │ └── ProjectRenamer.cs
│ ├── VSIX
│ │ ├── Resources
│ │ │ ├── RenameCommand.png
│ │ │ └── RenameCommandPackage.ico
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── source.extension.vsixmanifest
│ │ ├── Helpers
│ │ │ ├── MessageBoxHelper.cs
│ │ │ ├── ProjectRenamerFactory.cs
│ │ │ └── DteSolutionHelper.cs
│ │ ├── packages.config
│ │ ├── FullRenameDialog.xaml
│ │ ├── FullRenameDialog.xaml.cs
│ │ ├── RenameCommandPackage.cs
│ │ ├── RenameCommandPackage.vsct
│ │ ├── RenameCommand.cs
│ │ ├── VSPackage.resx
│ │ └── VSIX.csproj
│ ├── ConsoleApp
│ │ ├── App.config
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── ConsoleApp.csproj
│ └── RenameProjectVsExtension.sln
└── RenameProjectVs2015Extension
│ ├── Core
│ ├── packages.config
│ ├── StringExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SharedTypeProjectRenamer.cs
│ ├── Core.csproj
│ └── ProjectRenamer.cs
│ ├── RenameProjectVs2015Extension
│ ├── Resources
│ │ ├── RenameCommand.png
│ │ └── RenameCommandPackage.ico
│ ├── source.extension.vsixmanifest
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Helpers
│ │ ├── MessageBoxHelper.cs
│ │ └── DteSolutionHelper.cs
│ ├── packages.config
│ ├── RenameCommandPackage.cs
│ ├── RenameCommandPackage.vsct
│ ├── RenameCommand.cs
│ ├── VSPackage.resx
│ └── RenameProjectVs2015Extension.csproj
│ └── RenameProjectVs2015Extension.sln
├── README.md
├── LICENSE
├── .gitattributes
└── .gitignore
/readme_files/fullrename.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/readme_files/fullrename.png
--------------------------------------------------------------------------------
/readme_files/FullRenamer2017-11-13.vsix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/readme_files/FullRenamer2017-11-13.vsix
--------------------------------------------------------------------------------
/readme_files/FullRenamer2019-12-19.vsix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/readme_files/FullRenamer2019-12-19.vsix
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core.UnitTests/FakeProjectRenamer.cs:
--------------------------------------------------------------------------------
1 | namespace Core.UnitTests
2 | {
3 | public class FakeProjectRenamer : ProjectRenamer
4 | {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core.UnitTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Resources/RenameCommand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/src/RenameProjectVsExtension/VSIX/Resources/RenameCommand.png
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Resources/RenameCommandPackage.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/src/RenameProjectVsExtension/VSIX/Resources/RenameCommandPackage.ico
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/ConsoleApp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Resources/RenameCommand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Resources/RenameCommand.png
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Resources/RenameCommandPackage.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuanysh-nabiyev/RenameProjectVsExtension/HEAD/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Resources/RenameCommandPackage.ico
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/NamespaceRenamer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Core
4 | {
5 | public class NamespaceRenamer
6 | {
7 | public bool IsNecessaryToRename { get; set; }
8 | public IEnumerable ProjectFiles { get; set; }
9 | public IEnumerable SolutionFiles { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Core
9 | {
10 | internal static class StringExtensions
11 | {
12 | public static string WrapWithTag(this string str, string tag)
13 | {
14 | return $"<{tag}>{str}{tag}>";
15 | }
16 |
17 | public static string ReplaceWithTag(this string sourceStr, string oldValue, string newValue, string tag)
18 | {
19 | return sourceStr.Replace(oldValue.WrapWithTag(tag), newValue.WrapWithTag(tag));
20 | }
21 |
22 | public static string GetDirectoryName(this string str)
23 | {
24 | return Path.GetDirectoryName(str);
25 | }
26 |
27 | public static string GetFileName(this string str)
28 | {
29 | return Path.GetFileName(str);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Core
9 | {
10 | internal static class StringExtensions
11 | {
12 | public static string WrapWithTag(this string str, string tag)
13 | {
14 | return $"<{tag}>{str}{tag}>";
15 | }
16 |
17 | public static string ReplaceWithTag(this string sourceStr, string oldValue, string newValue, string tag)
18 | {
19 | return sourceStr.Replace(oldValue.WrapWithTag(tag), newValue.WrapWithTag(tag));
20 | }
21 |
22 | public static string GetDirectoryName(this string str)
23 | {
24 | return Path.GetDirectoryName(str);
25 | }
26 |
27 | public static string GetFileName(this string str)
28 | {
29 | return Path.GetFileName(str);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Rename project name in:
2 | - project location folder
3 | - solution file
4 | - reference in other projects
5 | - assembly name, information
6 | - default namespace
7 |
8 | Only tested for c# projects.
9 |
10 | It doesn't matter if project is located in solution folder (even for subfolder of solution folder)
11 |
12 | In case of error at any stage of renaming project, all changes will be rolled back.
13 |
14 | Download the latest version from [FullRenamer2019-12-19.vsix](https://github.com/kuanysh-nabiyev/RenameProjectVsExtension/blob/master/readme_files/FullRenamer2019-12-19.vsix)
15 |
16 | 
17 |
18 | #### If you got "Access to the path XXX is denied", try the following:
19 | https://github.com/kuanysh-nabiyev/RenameProjectVsExtension/issues/17#issuecomment-421806448
20 | https://github.com/kuanysh-nabiyev/RenameProjectVsExtension/issues/17#issuecomment-421811318
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 kuanysh-nabiyev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("VSIX")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("VSIX")]
13 | [assembly: AssemblyCopyright("")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Version information for an assembly consists of the following four values:
23 | //
24 | // Major Version
25 | // Minor Version
26 | // Build Number
27 | // Revision
28 | //
29 | // You can specify all the values or you can default the Build and Revision Numbers
30 | // by using the '*' as shown below:
31 | // [assembly: AssemblyVersion("1.0.*")]
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | RenameProjectVs2015Extension
6 | Rename project name in:
7 | project location folder,
8 | solution,
9 | reference in other projects,
10 | assembly name, information
11 | default namespace
12 | rename, fullrename
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RenameProjectVs2015Extension")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RenameProjectVs2015Extension")]
13 | [assembly: AssemblyCopyright("")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Version information for an assembly consists of the following four values:
23 | //
24 | // Major Version
25 | // Minor Version
26 | // Build Number
27 | // Revision
28 | //
29 | // You can specify all the values or you can default the Build and Revision Numbers
30 | // by using the '*' as shown below:
31 | // [assembly: AssemblyVersion("1.0.*")]
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Helpers/MessageBoxHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.VisualStudio.Shell;
7 | using Microsoft.VisualStudio.Shell.Interop;
8 |
9 | namespace VSIX.Helpers
10 | {
11 | internal class MessageBoxHelper
12 | {
13 | private readonly IServiceProvider _serviceProvider;
14 |
15 | public MessageBoxHelper(IServiceProvider serviceProvider)
16 | {
17 | _serviceProvider = serviceProvider;
18 | }
19 |
20 | public void ShowSuccessMessage()
21 | {
22 | VsShellUtilities.ShowMessageBox(
23 | _serviceProvider,
24 | "Full rename was completed",
25 | "Success",
26 | OLEMSGICON.OLEMSGICON_INFO,
27 | OLEMSGBUTTON.OLEMSGBUTTON_OK,
28 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
29 | }
30 |
31 | public void ShowErrorMessage(Exception ex, string title = "Error")
32 | {
33 | VsShellUtilities.ShowMessageBox(
34 | _serviceProvider,
35 | $"{ex.Message}\n{ex.StackTrace}",
36 | title,
37 | OLEMSGICON.OLEMSGICON_CRITICAL,
38 | OLEMSGBUTTON.OLEMSGBUTTON_OK,
39 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/ConsoleApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Core;
7 |
8 | namespace ConsoleApp
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | var projectRenamer = new ProjectRenamer()
15 | {
16 | SolutionFullName = @"C:\Users\KUANYSH-PC\Documents\visual studio 2017\Projects\TestSolutionForRenaming\TestSolutionForRenaming.sln",
17 | ProjectFullName = @"C:\Users\KUANYSH-PC\Documents\visual studio 2017\Projects\TestSolutionForRenaming\TestProjectA\TestProjectA.csproj",
18 | ProjectName = "TestProjectA",
19 | ProjectUniqueName = @"TestProjectA\TestProjectA.csproj",
20 | ProjectNameNew = "TestProjectA_NewName",
21 | SolutionProjects = new List
22 | {
23 | @"C:\Users\KUANYSH-PC\Documents\visual studio 2017\Projects\TestSolutionForRenaming\TestProjectA\TestProjectA.csproj",
24 | @"C:\Users\KUANYSH-PC\Documents\visual studio 2017\Projects\TestSolutionForRenaming\TestProjectB\TestProjectB.csproj",
25 | @"C:\Users\KUANYSH-PC\Documents\visual studio 2017\Projects\TestSolutionForRenaming\TestProjectC\TestProjectC.csproj",
26 | }
27 | };
28 |
29 | projectRenamer.FullRename();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6b7e3634-3f22-4870-9e75-f1e0a4342659")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("243c70e3-a440-41f1-a814-a169bcd2bf19")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/ConsoleApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ConsoleApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ConsoleApp")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e463ddff-d375-405b-b06f-e64dfed0f68f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Core.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Core.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("09ebf39a-5d4e-4dd0-827f-6fe9ab5e26aa")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenameProjectVs2015Extension", "RenameProjectVs2015Extension\RenameProjectVs2015Extension.csproj", "{0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{243C70E3-A440-41F1-A814-A169BCD2BF19}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {243C70E3-A440-41F1-A814-A169BCD2BF19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {243C70E3-A440-41F1-A814-A169BCD2BF19}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {243C70E3-A440-41F1-A814-A169BCD2BF19}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {243C70E3-A440-41F1-A814-A169BCD2BF19}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Full Rename Project
6 | Rename project name in:
7 | project location folder,
8 | solution,
9 | reference in other projects,
10 | assembly name, information
11 | default namespace,
12 | class namespace in each project file
13 | fix bug: the property fullpath is not exist for some project items
14 | rename, fullrename
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Helpers/MessageBoxHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.VisualStudio.Shell;
7 | using Microsoft.VisualStudio.Shell.Interop;
8 |
9 | namespace VSIX.Helpers
10 | {
11 | internal class MessageBoxHelper
12 | {
13 | private readonly IServiceProvider _serviceProvider;
14 |
15 | public MessageBoxHelper(IServiceProvider serviceProvider)
16 | {
17 | _serviceProvider = serviceProvider;
18 | }
19 |
20 | public void ShowSuccessMessage()
21 | {
22 | VsShellUtilities.ShowMessageBox(
23 | _serviceProvider,
24 | "Full rename was completed",
25 | "Success",
26 | OLEMSGICON.OLEMSGICON_INFO,
27 | OLEMSGBUTTON.OLEMSGBUTTON_OK,
28 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
29 | }
30 |
31 | public void ShowErrorMessage(Exception ex, string title = "Error")
32 | {
33 | VsShellUtilities.ShowMessageBox(
34 | _serviceProvider,
35 | $"{ex.Message}\n{ex.StackTrace}",
36 | title,
37 | OLEMSGICON.OLEMSGICON_CRITICAL,
38 | OLEMSGBUTTON.OLEMSGBUTTON_OK,
39 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
40 | }
41 |
42 | public void ShowInfoMessage(string message, string title = "")
43 | {
44 | VsShellUtilities.ShowMessageBox(
45 | _serviceProvider,
46 | message,
47 | title,
48 | OLEMSGICON.OLEMSGICON_INFO,
49 | OLEMSGBUTTON.OLEMSGBUTTON_OK,
50 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/Helpers/DteSolutionHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.VisualStudio.Shell;
3 | using EnvDTE;
4 | using EnvDTE80;
5 |
6 | namespace RenameProjectVs2015Extension.Helpers
7 | {
8 | internal class DteSolutionHelper
9 | {
10 | public DTE2 GetDte()
11 | {
12 | return Package.GetGlobalService(typeof(DTE)) as DTE2;
13 | }
14 |
15 | public Project GetSelectedProject()
16 | {
17 | var dte = GetDte();
18 | if (dte.SelectedItems.Count == 0)
19 | return null;
20 |
21 | return dte.SelectedItems.Item(1).Project;
22 | }
23 |
24 | public string GetSolutionFullName()
25 | {
26 | var dte = GetDte();
27 | return dte.Solution.FullName;
28 | }
29 |
30 | public IEnumerable GetSolutionProjects()
31 | {
32 | var dte = GetDte();
33 |
34 | var projects = new List();
35 | for (int i = 1; i <= dte.Solution.Projects.Count; i++)
36 | {
37 | var project = dte.Solution.Projects.Item(i);
38 | FindProjects(projects, project);
39 | }
40 |
41 | return projects;
42 | }
43 |
44 | public void FindProjects(IList projects, Project project)
45 | {
46 | if (string.IsNullOrEmpty(project.FullName))
47 | {
48 | for (int j = 1; j <= project.ProjectItems.Count; j++)
49 | {
50 | var projectItem = project.ProjectItems.Item(j);
51 | if (projectItem.SubProject != null)
52 | FindProjects(projects, projectItem.SubProject);
53 | }
54 | }
55 | else
56 | {
57 | projects.Add(project);
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/SharedTypeProjectRenamer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Core
9 | {
10 | public class SharedTypeProjectRenamer : ProjectRenamer
11 | {
12 | public string ProjectItemsFileName => $"{this.ProjectName}.projitems";
13 | public string ProjectItemsFileNameNew => $"{this.ProjectNameNew}.projitems";
14 |
15 | public override void RenameAssemblyNameAndDefaultNamespace()
16 | {
17 | }
18 |
19 | public override void RenameAssemblyInformation()
20 | {
21 | }
22 |
23 | public override void CustomRenameForProjectType()
24 | {
25 | string projFileText = File.ReadAllText(ProjectFullNameNew);
26 | projFileText = projFileText.Replace(this.ProjectName, this.ProjectNameNew);
27 | FileManager.WriteAllText(ProjectFullNameNew, projFileText);
28 |
29 | var projectDirectory = ProjectFullNameNew.GetDirectoryName();
30 | var projItemsFilePath = Path.Combine(projectDirectory, ProjectItemsFileName);
31 | if (File.Exists(projItemsFilePath))
32 | {
33 | string assemblyInfoFileText = File.ReadAllText(projItemsFilePath);
34 | assemblyInfoFileText = assemblyInfoFileText
35 | .ReplaceWithTag(ProjectName, ProjectNameNew, "Import_RootNamespace");
36 | FileManager.WriteAllText(projItemsFilePath, assemblyInfoFileText);
37 | }
38 |
39 | var fullNameWithRenamedFolder =
40 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectItemsFileName);
41 | var fullNameWithRenamedFolderNew =
42 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectItemsFileNameNew);
43 | FileManager.Move(fullNameWithRenamedFolder, fullNameWithRenamedFolderNew);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/SharedTypeProjectRenamer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Core
9 | {
10 | public class SharedTypeProjectRenamer : ProjectRenamer
11 | {
12 | public string ProjectItemsFileName => $"{this.ProjectName}.projitems";
13 | public string ProjectItemsFileNameNew => $"{this.ProjectNameNew}.projitems";
14 |
15 | public override void RenameAssemblyNameAndDefaultNamespace()
16 | {
17 | }
18 |
19 | public override void RenameAssemblyInformation()
20 | {
21 | }
22 |
23 | public override void CustomRenameForEachProjectType()
24 | {
25 | string projFileText = File.ReadAllText(ProjectFullNameNew);
26 | projFileText = projFileText.Replace(this.ProjectName, this.ProjectNameNew);
27 | FileManager.WriteAllText(ProjectFullNameNew, projFileText);
28 |
29 | var projectDirectory = ProjectFullNameNew.GetDirectoryName();
30 | var projItemsFilePath = Path.Combine(projectDirectory, ProjectItemsFileName);
31 | if (File.Exists(projItemsFilePath))
32 | {
33 | string assemblyInfoFileText = File.ReadAllText(projItemsFilePath);
34 | assemblyInfoFileText = assemblyInfoFileText
35 | .ReplaceWithTag(ProjectName, ProjectNameNew, "Import_RootNamespace");
36 | FileManager.WriteAllText(projItemsFilePath, assemblyInfoFileText);
37 | }
38 |
39 | var fullNameWithRenamedFolder =
40 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectItemsFileName);
41 | var fullNameWithRenamedFolderNew =
42 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectItemsFileNameNew);
43 | FileManager.Move(fullNameWithRenamedFolder, fullNameWithRenamedFolderNew);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/FullRenameDialog.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
15 |
17 |
18 |
19 |
23 |
24 |
25 |
28 |
32 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/FullRenameDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using Microsoft.VisualStudio.PlatformUI;
16 | using VSIX.Helpers;
17 |
18 | namespace VSIX
19 | {
20 | ///
21 | /// Interaction logic for FullRenameDialog.xaml
22 | ///
23 | public partial class FullRenameDialog : DialogWindow
24 | {
25 | public FullRenameDialog(RenameOptions renameOptions)
26 | {
27 | InitializeComponent();
28 | DataContext = renameOptions;
29 | }
30 |
31 | private void OK_OnClick(object sender, RoutedEventArgs e)
32 | {
33 | DialogResult = true;
34 | }
35 |
36 | private void Cancel_OnClick(object sender, RoutedEventArgs e)
37 | {
38 | DialogResult = false;
39 | }
40 |
41 | private void Readme_OnClick(object sender, RoutedEventArgs e)
42 | {
43 | MessageBox.Show(@"
44 | 1. Only for C# projects.
45 | 2. 'namespace oldProjectName' will be changed to 'namespace newProjectName' in the renamed(selected) project.
46 | 3. 'using oldProjectName' will be changed to 'using newProjectName' in the referenced projects
47 | 4. 'oldProjectName.ClassName' will be changed to 'newProjectName.ClassName'",
48 | string.Empty,
49 | MessageBoxButton.OK,
50 | MessageBoxImage.Information);
51 | }
52 | }
53 |
54 | public class RenameOptions
55 | {
56 | public string ProjectName { get; set; }
57 | public bool IsNecessaryToRenameClassNamespace { get; set; }
58 |
59 | public string ProjectFullName { get; set; }
60 | public bool CanRenameNamespace => ProjectFullName.EndsWith(".csproj");
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Helpers/ProjectRenamerFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Core;
8 | using EnvDTE;
9 |
10 | namespace VSIX.Helpers
11 | {
12 | public class ProjectRenamerFactory
13 | {
14 | public static ProjectRenamer Create(Project selectedProject, RenameOptions renameOptions)
15 | {
16 | var dteSolutionHelper = new DteSolutionHelper();
17 | ProjectRenamer projectRenamer;
18 | if (IsSharedProject(selectedProject))
19 | {
20 | projectRenamer = new SharedTypeProjectRenamer
21 | {
22 | ProjectUniqueName = Path.ChangeExtension(selectedProject.UniqueName, null),
23 | };
24 | }
25 | else
26 | {
27 | projectRenamer = new ProjectRenamer
28 | {
29 | ProjectUniqueName = selectedProject.UniqueName
30 | };
31 | }
32 |
33 | projectRenamer.SolutionFullName = dteSolutionHelper.GetSolutionFullName();
34 | projectRenamer.ProjectFullName = selectedProject.FullName;
35 | projectRenamer.ProjectName = selectedProject.Name;
36 | projectRenamer.ProjectNameNew = renameOptions.ProjectName;
37 | projectRenamer.SolutionProjects = dteSolutionHelper.GetSolutionProjects().Select(it => it.FullName);
38 | if (renameOptions.IsNecessaryToRenameClassNamespace)
39 | {
40 | projectRenamer.NamespaceRenamer = new NamespaceRenamer
41 | {
42 | IsNecessaryToRename = renameOptions.IsNecessaryToRenameClassNamespace,
43 | ProjectFiles = dteSolutionHelper.GetProjectFiles(selectedProject),
44 | SolutionFiles = dteSolutionHelper.GetSolutionFilesExceptSelectedProject(selectedProject)
45 | };
46 | }
47 |
48 | return projectRenamer;
49 | }
50 |
51 | private static bool IsSharedProject(Project selectedProject)
52 | {
53 | if (Path.GetExtension(selectedProject.FileName) == ".shproj")
54 | return true;
55 | return false;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/RenameProjectVsExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26430.12
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSIX", "VSIX\VSIX.csproj", "{3799872D-D112-4110-AF97-AD7FA0161453}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{E463DDFF-D375-405B-B06F-E64DFED0F68F}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{6B7E3634-3F22-4870-9E75-F1E0A4342659}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.UnitTests", "Core.UnitTests\Core.UnitTests.csproj", "{09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {3799872D-D112-4110-AF97-AD7FA0161453}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {3799872D-D112-4110-AF97-AD7FA0161453}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {3799872D-D112-4110-AF97-AD7FA0161453}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {3799872D-D112-4110-AF97-AD7FA0161453}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {E463DDFF-D375-405B-B06F-E64DFED0F68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {E463DDFF-D375-405B-B06F-E64DFED0F68F}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {E463DDFF-D375-405B-B06F-E64DFED0F68F}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {E463DDFF-D375-405B-B06F-E64DFED0F68F}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/ConsoleApp/ConsoleApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E463DDFF-D375-405B-B06F-E64DFED0F68F}
8 | Exe
9 | ConsoleApp
10 | ConsoleApp
11 | v4.5.2
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | {6b7e3634-3f22-4870-9e75-f1e0a4342659}
54 | Core
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core.UnitTests/Core.UnitTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {09EBF39A-5D4E-4DD0-827F-6FE9AB5E26AA}
8 | Library
9 | Properties
10 | Core.UnitTests
11 | Core.UnitTests
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}
56 | Core
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6B7E3634-3F22-4870-9E75-F1E0A4342659}
8 | Library
9 | Properties
10 | Core
11 | Core
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 | false
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | ..\packages\TxFileManager.1.3\lib\net20\ChinhDo.Transactions.dll
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {243C70E3-A440-41F1-A814-A169BCD2BF19}
8 | Library
9 | Properties
10 | Core
11 | Core
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\TxFileManager.1.3\lib\net20\ChinhDo.Transactions.dll
35 | True
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/RenameCommandPackage.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Company. All rights reserved.
4 | //
5 | //------------------------------------------------------------------------------
6 |
7 | using System;
8 | using System.ComponentModel.Design;
9 | using System.Diagnostics;
10 | using System.Diagnostics.CodeAnalysis;
11 | using System.Globalization;
12 | using System.Runtime.InteropServices;
13 | using Microsoft.VisualStudio;
14 | using Microsoft.VisualStudio.OLE.Interop;
15 | using Microsoft.VisualStudio.Shell;
16 | using Microsoft.VisualStudio.Shell.Interop;
17 | using Microsoft.Win32;
18 |
19 | namespace VSIX
20 | {
21 | ///
22 | /// This is the class that implements the package exposed by this assembly.
23 | ///
24 | ///
25 | ///
26 | /// The minimum requirement for a class to be considered a valid package for Visual Studio
27 | /// is to implement the IVsPackage interface and register itself with the shell.
28 | /// This package uses the helper classes defined inside the Managed Package Framework (MPF)
29 | /// to do it: it derives from the Package class that provides the implementation of the
30 | /// IVsPackage interface and uses the registration attributes defined in the framework to
31 | /// register itself and its components with the shell. These attributes tell the pkgdef creation
32 | /// utility what data to put into .pkgdef file.
33 | ///
34 | ///
35 | /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file.
36 | ///
37 | ///
38 | [PackageRegistration(UseManagedResourcesOnly = true)]
39 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
40 | [ProvideMenuResource("Menus.ctmenu", 1)]
41 | [Guid(RenameCommandPackage.PackageGuidString)]
42 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
43 | public sealed class RenameCommandPackage : Package
44 | {
45 | ///
46 | /// RenameCommandPackage GUID string.
47 | ///
48 | public const string PackageGuidString = "1f0f5b79-0722-4c2b-9057-2391b78cb196";
49 |
50 | ///
51 | /// Initializes a new instance of the class.
52 | ///
53 | public RenameCommandPackage()
54 | {
55 | // Inside this method you can place any initialization code that does not require
56 | // any Visual Studio service because at this point the package object is created but
57 | // not sited yet inside Visual Studio environment. The place to do all the other
58 | // initialization is the Initialize method.
59 | }
60 |
61 | #region Package Members
62 |
63 | ///
64 | /// Initialization of the package; this method is called right after the package is sited, so this is the place
65 | /// where you can put all the initialization code that rely on services provided by VisualStudio.
66 | ///
67 | protected override void Initialize()
68 | {
69 | RenameCommand.Initialize(this);
70 | base.Initialize();
71 | }
72 |
73 | #endregion
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/RenameCommandPackage.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Company. All rights reserved.
4 | //
5 | //------------------------------------------------------------------------------
6 |
7 | using System;
8 | using System.ComponentModel.Design;
9 | using System.Diagnostics;
10 | using System.Diagnostics.CodeAnalysis;
11 | using System.Globalization;
12 | using System.Runtime.InteropServices;
13 | using Microsoft.VisualStudio;
14 | using Microsoft.VisualStudio.OLE.Interop;
15 | using Microsoft.VisualStudio.Shell;
16 | using Microsoft.VisualStudio.Shell.Interop;
17 | using Microsoft.Win32;
18 | using RenameProjectVs2015Extension;
19 |
20 | namespace RenameProjectVs2015Extension
21 | {
22 | ///
23 | /// This is the class that implements the package exposed by this assembly.
24 | ///
25 | ///
26 | ///
27 | /// The minimum requirement for a class to be considered a valid package for Visual Studio
28 | /// is to implement the IVsPackage interface and register itself with the shell.
29 | /// This package uses the helper classes defined inside the Managed Package Framework (MPF)
30 | /// to do it: it derives from the Package class that provides the implementation of the
31 | /// IVsPackage interface and uses the registration attributes defined in the framework to
32 | /// register itself and its components with the shell. These attributes tell the pkgdef creation
33 | /// utility what data to put into .pkgdef file.
34 | ///
35 | ///
36 | /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file.
37 | ///
38 | ///
39 | [PackageRegistration(UseManagedResourcesOnly = true)]
40 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
41 | [ProvideMenuResource("Menus.ctmenu", 1)]
42 | [Guid(RenameCommandPackage.PackageGuidString)]
43 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
44 | public sealed class RenameCommandPackage : Package
45 | {
46 | ///
47 | /// RenameCommandPackage GUID string.
48 | ///
49 | public const string PackageGuidString = "1f0f5b79-0722-4c2b-9057-2391b78cb196";
50 |
51 | ///
52 | /// Initializes a new instance of the class.
53 | ///
54 | public RenameCommandPackage()
55 | {
56 | // Inside this method you can place any initialization code that does not require
57 | // any Visual Studio service because at this point the package object is created but
58 | // not sited yet inside Visual Studio environment. The place to do all the other
59 | // initialization is the Initialize method.
60 | }
61 |
62 | #region Package Members
63 |
64 | ///
65 | /// Initialization of the package; this method is called right after the package is sited, so this is the place
66 | /// where you can put all the initialization code that rely on services provided by VisualStudio.
67 | ///
68 | protected override void Initialize()
69 | {
70 | RenameCommand.Initialize(this);
71 | base.Initialize();
72 | }
73 |
74 | #endregion
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core.UnitTests/ProjectRenamerTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Core.UnitTests
4 | {
5 | [TestFixture]
6 | public class ProjectRenamerTests
7 | {
8 | [Test]
9 | public void GetFolderOfUniqueName_OwnProject_ReturnFolder()
10 | {
11 | var projectRenamer = new FakeProjectRenamer();
12 | var folderName = projectRenamer.GetFolderOfUniqueName(@"TestProjectA\TestProjectA.csproj");
13 | Assert.AreEqual("TestProjectA", folderName);
14 | }
15 |
16 | [Test]
17 | public void GetFolderOfUniqueName_AddedExistingProject_ReturnFolder()
18 | {
19 | var projectRenamer = new FakeProjectRenamer();
20 | var folderName = projectRenamer.GetFolderOfUniqueName(@"..\TestProjectA\TestProjectA.csproj");
21 | Assert.AreEqual("TestProjectA", folderName);
22 | }
23 |
24 | [Test]
25 | public void GetFolderOfUniqueName_AddedExistingProjectFromDesktop_ReturnFolder()
26 | {
27 | var projectRenamer = new FakeProjectRenamer();
28 | var folderName = projectRenamer.GetFolderOfUniqueName(@"..\..\Desktop\Folder1\Folder2\TestProjectA\TestProjectA.csproj");
29 | Assert.AreEqual("TestProjectA", folderName);
30 | }
31 |
32 | [TestCase(@"TestProjectA\TestProjectA.csproj")]
33 | [TestCase(@"..\TestProjectA\TestProjectA.csproj")]
34 | [TestCase(@"Desktop\Folder1\Folder2\TestProjectA\TestProjectA.csproj")]
35 | public void ProjectUniqueName_DifferentNames_ReturnFolderAndFileName(string projectUniqueName)
36 | {
37 | var projectRenamer = new FakeProjectRenamer()
38 | {
39 | ProjectUniqueName = projectUniqueName
40 | };
41 |
42 | Assert.AreEqual(@"TestProjectA\TestProjectA.csproj", projectRenamer.ProjectUniqueName);
43 | }
44 |
45 | [TestCase(@"TestProjectA\TestProjectA.csproj")]
46 | [TestCase(@"..\TestProjectA\TestProjectA.csproj")]
47 | [TestCase(@"..\..\..\..\Desktop\Folder1\Folder2\TestProjectA\TestProjectA.csproj")]
48 | [TestCase(@"Desktop\Folder1\TestProjectA\TestProjectA\TestProjectA.csproj")]
49 | [TestCase(@"..\TestProjectA\TestProjectA\TestProjectA.csproj")]
50 | public void ProjectUniqueNameNew_DifferentNames_ReturnNewUniqueName(string projectUniqueName)
51 | {
52 | var projectRenamer = new FakeProjectRenamer()
53 | {
54 | ProjectName = "TestProjectA",
55 | ProjectNameNew = "TestProjectA_NewName",
56 | ProjectUniqueName = projectUniqueName
57 | };
58 |
59 | Assert.AreEqual(@"TestProjectA_NewName\TestProjectA_NewName.csproj", projectRenamer.ProjectUniqueNameNew);
60 | }
61 |
62 | [TestCase(@"D:\Projects\SolutionFolderName\TestProjectA\TestProjectA.csproj", ExpectedResult = @"D:\Projects\SolutionFolderName\TestProjectA_NewName\TestProjectA_NewName.csproj", Description = "Standard situation")]
63 | [TestCase(@"D:\Projects\TestProjectA\TestProjectA\TestProjectA.csproj", ExpectedResult = @"D:\Projects\TestProjectA\TestProjectA_NewName\TestProjectA_NewName.csproj", Description = "Project folder is same with solution folder")]
64 | public string ProjectFullNameNew_DifferentNames_ReturnNewFullName(string projectFullName)
65 | {
66 | var projectRenamer = new FakeProjectRenamer()
67 | {
68 | ProjectName = "TestProjectA",
69 | ProjectNameNew = "TestProjectA_NewName",
70 | ProjectUniqueName = @"TestProjectA\TestProjectA.csproj",
71 | ProjectFullName = projectFullName
72 | };
73 |
74 | return projectRenamer.ProjectFullNameNew;
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /Properties/launchSettings.json
2 | *.vscode
3 | */wwwroot/dist/main.js
4 | */wwwroot/dist/main.js.map
5 |
6 | ## Ignore Visual Studio temporary files, build results, and
7 | ## files generated by popular Visual Studio add-ons.
8 |
9 | # User-specific files
10 | *.suo
11 | *.user
12 | *.userosscache
13 | *.sln.docstates
14 |
15 | # User-specific files (MonoDevelop/Xamarin Studio)
16 | *.userprefs
17 |
18 | # Build results
19 | [Dd]ebug/
20 | [Dd]ebugPublic/
21 | [Rr]elease/
22 | [Rr]eleases/
23 | build/
24 | bld/
25 | [Bb]in/
26 | [Oo]bj/
27 |
28 | # Visual Studo 2015 cache/options directory
29 | .vs/
30 |
31 | # MSTest test Results
32 | [Tt]est[Rr]esult*/
33 | [Bb]uild[Ll]og.*
34 |
35 | # NUNIT
36 | *.VisualState.xml
37 | TestResult.xml
38 |
39 | # Build Results of an ATL Project
40 | [Dd]ebugPS/
41 | [Rr]eleasePS/
42 | dlldata.c
43 |
44 | *_i.c
45 | *_p.c
46 | *_i.h
47 | *.ilk
48 | *.meta
49 | *.obj
50 | *.pch
51 | *.pdb
52 | *.pgc
53 | *.pgd
54 | *.rsp
55 | *.sbr
56 | *.tlb
57 | *.tli
58 | *.tlh
59 | *.tmp
60 | *.tmp_proj
61 | *.log
62 | *.vspscc
63 | *.vssscc
64 | .builds
65 | *.pidb
66 | *.svclog
67 | *.scc
68 |
69 | # Chutzpah Test files
70 | _Chutzpah*
71 |
72 | # Visual C++ cache files
73 | ipch/
74 | *.aps
75 | *.ncb
76 | *.opensdf
77 | *.sdf
78 | *.cachefile
79 |
80 | # Visual Studio profiler
81 | *.psess
82 | *.vsp
83 | *.vspx
84 |
85 | # TFS 2012 Local Workspace
86 | $tf/
87 |
88 | # Guidance Automation Toolkit
89 | *.gpState
90 |
91 | # ReSharper is a .NET coding add-in
92 | _ReSharper*/
93 | *.[Rr]e[Ss]harper
94 | *.DotSettings.user
95 |
96 | # JustCode is a .NET coding addin-in
97 | .JustCode
98 |
99 | # TeamCity is a build add-in
100 | _TeamCity*
101 |
102 | # DotCover is a Code Coverage Tool
103 | *.dotCover
104 |
105 | # NCrunch
106 | _NCrunch_*
107 | .*crunch*.local.xml
108 |
109 | # MightyMoose
110 | *.mm.*
111 | AutoTest.Net/
112 |
113 | # Web workbench (sass)
114 | .sass-cache/
115 |
116 | # Installshield output folder
117 | [Ee]xpress/
118 |
119 | # DocProject is a documentation generator add-in
120 | DocProject/buildhelp/
121 | DocProject/Help/*.HxT
122 | DocProject/Help/*.HxC
123 | DocProject/Help/*.hhc
124 | DocProject/Help/*.hhk
125 | DocProject/Help/*.hhp
126 | DocProject/Help/Html2
127 | DocProject/Help/html
128 |
129 | # Click-Once directory
130 | publish/
131 |
132 | # Publish Web Output
133 | *.[Pp]ublish.xml
134 | *.azurePubxml
135 | # TODO: Comment the next line if you want to checkin your web deploy settings
136 | # but database connection strings (with potential passwords) will be unencrypted
137 | # *.pubxml
138 | *.publishproj
139 |
140 | # NuGet Packages
141 | *.nupkg
142 | # The packages folder can be ignored because of Package Restore
143 | **/packages/*
144 | # except build/, which is used as an MSBuild target.
145 | !**/packages/build/
146 | # Uncomment if necessary however generally it will be regenerated when needed
147 | #!**/packages/repositories.config
148 |
149 | # Windows Azure Build Output
150 | csx/
151 | *.build.csdef
152 |
153 | # Windows Store app package directory
154 | AppPackages/
155 |
156 | # Others
157 | *.[Cc]ache
158 | ClientBin/
159 | [Ss]tyle[Cc]op.*
160 | ~$*
161 | *~
162 | *.dbmdl
163 | *.dbproj.schemaview
164 | *.pfx
165 | *.publishsettings
166 | node_modules/
167 | bower_components/
168 |
169 | # RIA/Silverlight projects
170 | Generated_Code/
171 |
172 | # Backup & report files from converting an old project file
173 | # to a newer Visual Studio version. Backup files are not needed,
174 | # because we have git ;-)
175 | _UpgradeReport_Files/
176 | Backup*/
177 | UpgradeLog*.XML
178 | UpgradeLog*.htm
179 |
180 | # SQL Server files
181 | *.mdf
182 | *.ldf
183 |
184 | # Business Intelligence projects
185 | *.rdl.data
186 | *.bim.layout
187 | *.bim_*.settings
188 |
189 | # Microsoft Fakes
190 | FakesAssemblies/
191 |
192 | # Node.js Tools for Visual Studio
193 | .ntvs_analysis.dat
194 |
195 | # Visual Studio 6 build log
196 | *.plg
197 |
198 | # Visual Studio 6 workspace options file
199 | *.opt
200 |
201 | bundle.*
202 | .idea/
203 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/Helpers/DteSolutionHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using EnvDTE;
7 | using EnvDTE80;
8 | using Microsoft.VisualStudio.Shell;
9 |
10 | namespace VSIX.Helpers
11 | {
12 | internal class DteSolutionHelper
13 | {
14 | public DTE2 GetDte()
15 | {
16 | return Package.GetGlobalService(typeof(DTE)) as DTE2;
17 | }
18 |
19 | public Project GetSelectedProject()
20 | {
21 | var dte = GetDte();
22 | if (dte.SelectedItems.Count == 0)
23 | return null;
24 |
25 | var selectedProject = dte.SelectedItems.Item(1).Project;
26 | return selectedProject;
27 | }
28 |
29 | public string GetSolutionFullName()
30 | {
31 | var dte = GetDte();
32 | return dte.Solution.FullName;
33 | }
34 |
35 | public IEnumerable GetSolutionProjects()
36 | {
37 | var dte = GetDte();
38 |
39 | var projects = new List();
40 | for (int i = 1; i <= dte.Solution.Projects.Count; i++)
41 | {
42 | var project = dte.Solution.Projects.Item(i);
43 | FindProjects(projects, project);
44 | }
45 |
46 | return projects;
47 | }
48 |
49 | public void FindProjects(IList projects, Project project)
50 | {
51 | try
52 | {
53 | if (string.IsNullOrEmpty(project.FullName))
54 | {
55 | for (int j = 1; j <= project.ProjectItems.Count; j++)
56 | {
57 | var projectItem = project.ProjectItems.Item(j);
58 | if (projectItem.SubProject != null)
59 | FindProjects(projects, projectItem.SubProject);
60 | }
61 | }
62 | else
63 | {
64 | projects.Add(project);
65 | }
66 | }
67 | catch {/* ignored */}
68 | }
69 |
70 | public IEnumerable GetProjectFiles(Project project)
71 | {
72 | var projectItems = GetProjectItems(project);
73 | return projectItems
74 | .Select(a => a.Properties?.Item("FullPath")?.Value?.ToString())
75 | .Where(it => !string.IsNullOrEmpty(it));
76 | }
77 |
78 | public IEnumerable GetSolutionFilesExceptSelectedProject(Project selectedProject)
79 | {
80 | var solutionFiles = new List();
81 | foreach (Project project in GetSolutionProjects())
82 | {
83 | if (project.FullName != selectedProject.FullName)
84 | {
85 | solutionFiles.AddRange(GetProjectFiles(project));
86 | }
87 | }
88 | return solutionFiles;
89 | }
90 |
91 | public bool IsProjectFilesSaved(Project project)
92 | {
93 | var projectItems = GetProjectItems(project);
94 | return projectItems.All(a => a.Saved);
95 | }
96 |
97 | private IEnumerable GetProjectItems(Project project)
98 | {
99 | var projectItems = new List();
100 | foreach (ProjectItem projectItem in project.ProjectItems)
101 | {
102 | FindFiles(projectItems, projectItem);
103 | }
104 | return projectItems;
105 | }
106 |
107 | private void FindFiles(IList projectItems, ProjectItem item)
108 | {
109 | if (item.ProjectItems == null || item.ProjectItems.Count == 0)
110 | {
111 | projectItems.Add(item);
112 | return;
113 | }
114 |
115 | var items = item.ProjectItems.GetEnumerator();
116 | while (items.MoveNext())
117 | {
118 | var currentItem = (ProjectItem)items.Current;
119 | FindFiles(projectItems, currentItem);
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/RenameCommandPackage.vsct:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
33 |
34 |
38 |
39 |
42 |
43 |
44 |
45 |
47 |
48 |
55 |
62 |
63 |
64 |
65 |
66 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/RenameCommandPackage.vsct:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
33 |
34 |
38 |
39 |
42 |
43 |
44 |
45 |
47 |
48 |
55 |
62 |
63 |
64 |
65 |
66 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/RenameCommand.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Company. All rights reserved.
4 | //
5 | //------------------------------------------------------------------------------
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.ComponentModel.Design;
10 | using System.Globalization;
11 | using System.IO;
12 | using System.Linq;
13 | using Core;
14 | using EnvDTE;
15 | using EnvDTE80;
16 | using Microsoft.VisualStudio.PlatformUI;
17 | using Microsoft.VisualStudio.Shell;
18 | using Microsoft.VisualStudio.Shell.Interop;
19 | using VSIX.Helpers;
20 |
21 | namespace VSIX
22 | {
23 | ///
24 | /// Command handler
25 | ///
26 | internal sealed class RenameCommand
27 | {
28 | ///
29 | /// Command ID.
30 | ///
31 | public const int CommandId = 0x0100;
32 |
33 | ///
34 | /// Command menu group (command set GUID).
35 | ///
36 | public static readonly Guid CommandSet = new Guid("dcffee83-c24d-4d60-8d48-de509bf2dc6a");
37 |
38 | ///
39 | /// VS Package that provides this command, not null.
40 | ///
41 | private readonly Package package;
42 |
43 | ///
44 | /// Initializes a new instance of the class.
45 | /// Adds our command handlers for menu (commands must exist in the command table file)
46 | ///
47 | /// Owner package, not null.
48 | private RenameCommand(Package package)
49 | {
50 | if (package == null)
51 | {
52 | throw new ArgumentNullException("package");
53 | }
54 |
55 | this.package = package;
56 |
57 | OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
58 | if (commandService != null)
59 | {
60 | var menuCommandID = new CommandID(CommandSet, CommandId);
61 | var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
62 | commandService.AddCommand(menuItem);
63 | }
64 | }
65 |
66 | ///
67 | /// Gets the instance of the command.
68 | ///
69 | public static RenameCommand Instance
70 | {
71 | get;
72 | private set;
73 | }
74 |
75 | ///
76 | /// Gets the service provider from the owner package.
77 | ///
78 | private IServiceProvider ServiceProvider
79 | {
80 | get
81 | {
82 | return this.package;
83 | }
84 | }
85 |
86 | ///
87 | /// Initializes the singleton instance of the command.
88 | ///
89 | /// Owner package, not null.
90 | public static void Initialize(Package package)
91 | {
92 | Instance = new RenameCommand(package);
93 | }
94 |
95 | ///
96 | /// This function is the callback used to execute the command when the menu item is clicked.
97 | /// See the constructor to see how the menu item is associated with this function using
98 | /// OleMenuCommandService service and MenuCommand class.
99 | ///
100 | /// Event sender.
101 | /// Event args.
102 | private void MenuItemCallback(object sender, EventArgs e)
103 | {
104 | var dteSolutionHelper = new DteSolutionHelper();
105 | var messageBoxHelper = new MessageBoxHelper(this.ServiceProvider);
106 |
107 | var selectedProject = dteSolutionHelper.GetSelectedProject();
108 | if (!selectedProject.Saved)
109 | {
110 | messageBoxHelper.ShowInfoMessage("Build/rebuild project before renaming");
111 | return;
112 | }
113 |
114 | if (!dteSolutionHelper.IsProjectFilesSaved(selectedProject))
115 | {
116 | messageBoxHelper.ShowInfoMessage("Some files are not saved. Save them or build/rebuild project");
117 | return;
118 | }
119 |
120 | var renameOptions = new RenameOptions
121 | {
122 | ProjectName = selectedProject.Name,
123 | ProjectFullName = selectedProject.FullName
124 | };
125 | var dialog = new FullRenameDialog(renameOptions);
126 | var isOkButtonClicked = dialog.ShowModal();
127 |
128 | if (isOkButtonClicked == false)
129 | return;
130 | if (renameOptions.ProjectName == selectedProject.Name)
131 | return;
132 |
133 | try
134 | {
135 | var projectRenamer = ProjectRenamerFactory.Create(selectedProject, renameOptions);
136 | projectRenamer.FullRename();
137 | messageBoxHelper.ShowSuccessMessage();
138 | }
139 | catch (UnauthorizedAccessException uae)
140 | {
141 | messageBoxHelper.ShowErrorMessage(uae, "You don't have enough permisssion");
142 | }
143 | catch (IOException ioe)
144 | {
145 | messageBoxHelper.ShowErrorMessage(ioe, "Close all folders, text editors related to the project");
146 | }
147 | catch (Exception ex)
148 | {
149 | messageBoxHelper.ShowErrorMessage(ex);
150 | }
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/Core/ProjectRenamer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Transactions;
9 | using ChinhDo.Transactions;
10 |
11 | namespace Core
12 | {
13 | public class ProjectRenamer
14 | {
15 | protected readonly TxFileManager FileManager;
16 | private string _projectUniqueName;
17 |
18 | public ProjectRenamer()
19 | {
20 | FileManager = new TxFileManager();
21 | }
22 |
23 | public string SolutionFullName { get; set; }
24 | public string ProjectFullName { get; set; }
25 | public string ProjectName { get; set; }
26 |
27 | public string ProjectUniqueName
28 | {
29 | get { return $@"{GetFolderOfUniqueName(_projectUniqueName)}\{_projectUniqueName.GetFileName()}"; }
30 | set { _projectUniqueName = value; }
31 | }
32 |
33 | public string ProjectNameNew { get; set; }
34 | public IEnumerable SolutionProjects { get; set; }
35 |
36 | internal string ProjectUniqueNameNew => ProjectUniqueName.Replace(ProjectName, ProjectNameNew);
37 | internal string ProjectFullNameNew => ProjectFullName.Replace(ProjectUniqueName, ProjectUniqueNameNew);
38 |
39 | public void FullRename()
40 | {
41 | RenameFolder();
42 |
43 | try
44 | {
45 | using (TransactionScope scope = new TransactionScope())
46 | {
47 | RenameFile();
48 | RenameUserExtensionFile();
49 | RenameAssemblyNameAndDefaultNamespace();
50 | RenameAssemblyInformation();
51 | RenameInSolutionFile();
52 | RenameInProjectReferences();
53 | CustomRenameForProjectType();
54 | scope.Complete();
55 | }
56 | }
57 | catch
58 | {
59 | RollbackRenameFolder();
60 | throw;
61 | }
62 | }
63 |
64 | public void RenameFolder()
65 | {
66 | Directory.Move(this.ProjectFullName.GetDirectoryName(), this.ProjectFullNameNew.GetDirectoryName());
67 | }
68 |
69 | public void RenameFile()
70 | {
71 | var fullNameWithRenamedFolder =
72 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectFullName.GetFileName());
73 | FileManager.Move(fullNameWithRenamedFolder, this.ProjectFullNameNew);
74 | }
75 |
76 | public void RenameUserExtensionFile()
77 | {
78 | var fullNameWithRenamedFolder =
79 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectFullName.GetFileName() + ".user");
80 | if (File.Exists(fullNameWithRenamedFolder))
81 | {
82 | FileManager.Move(fullNameWithRenamedFolder, this.ProjectFullNameNew + ".user");
83 | }
84 | }
85 |
86 | public virtual void RenameAssemblyNameAndDefaultNamespace()
87 | {
88 | string projFileText = File.ReadAllText(ProjectFullNameNew);
89 | projFileText = projFileText
90 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "AssemblyName")
91 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "RootNamespace");
92 |
93 | FileManager.WriteAllText(ProjectFullNameNew, projFileText);
94 | }
95 |
96 | public virtual void RenameAssemblyInformation()
97 | {
98 | var projectDirectory = ProjectFullNameNew.GetDirectoryName();
99 | var assemblyInfoFilePath = Path.Combine(projectDirectory, @"Properties\AssemblyInfo.cs");
100 | if (File.Exists(assemblyInfoFilePath))
101 | {
102 | string assemblyInfoFileText = File.ReadAllText(assemblyInfoFilePath);
103 |
104 | assemblyInfoFileText = assemblyInfoFileText.Replace(ProjectName, ProjectNameNew);
105 | FileManager.WriteAllText(assemblyInfoFilePath, assemblyInfoFileText);
106 | }
107 | }
108 |
109 | public void RenameInSolutionFile()
110 | {
111 | string slnFileText = File.ReadAllText(this.SolutionFullName);
112 | slnFileText = slnFileText
113 | .Replace(this.ProjectUniqueName, this.ProjectUniqueNameNew)
114 | .Replace($"\"{this.ProjectName}\"", $"\"{this.ProjectNameNew}\"");
115 | FileManager.WriteAllText(this.SolutionFullName, slnFileText);
116 | }
117 |
118 | public void RenameInProjectReferences()
119 | {
120 | foreach (var projectFullName in SolutionProjects)
121 | {
122 | if (projectFullName != this.ProjectFullName)
123 | {
124 | string projFileText = File.ReadAllText(projectFullName);
125 | if (projFileText.Contains(this.ProjectUniqueName))
126 | {
127 | projFileText = projFileText
128 | .Replace(this.ProjectUniqueName, this.ProjectUniqueNameNew)
129 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "Name");
130 | FileManager.WriteAllText(projectFullName, projFileText);
131 | }
132 | }
133 | }
134 | }
135 |
136 | public void RollbackRenameFolder()
137 | {
138 | Directory.Move(this.ProjectFullNameNew.GetDirectoryName(), this.ProjectFullName.GetDirectoryName());
139 | }
140 |
141 | public string GetFolderOfUniqueName(string projectUniqueName)
142 | {
143 | var directoryName = projectUniqueName.GetDirectoryName();
144 | var directoryInfo = new DirectoryInfo(directoryName);
145 | return directoryInfo.Name;
146 | }
147 |
148 | public virtual void CustomRenameForProjectType()
149 | {
150 |
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/RenameCommand.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Company. All rights reserved.
4 | //
5 | //------------------------------------------------------------------------------
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.ComponentModel.Design;
10 | using System.Globalization;
11 | using System.IO;
12 | using System.Linq;
13 | using Core;
14 | using EnvDTE;
15 | using EnvDTE80;
16 | using Microsoft.VisualStudio.PlatformUI;
17 | using Microsoft.VisualStudio.Shell;
18 | using Microsoft.VisualStudio.Shell.Interop;
19 | using RenameProjectVs2015Extension.Helpers;
20 | using VSIX.Helpers;
21 |
22 | namespace RenameProjectVs2015Extension
23 | {
24 | ///
25 | /// Command handler
26 | ///
27 | internal sealed class RenameCommand
28 | {
29 | ///
30 | /// Command ID.
31 | ///
32 | public const int CommandId = 0x0100;
33 |
34 | ///
35 | /// Command menu group (command set GUID).
36 | ///
37 | public static readonly Guid CommandSet = new Guid("dcffee83-c24d-4d60-8d48-de509bf2dc6a");
38 |
39 | ///
40 | /// VS Package that provides this command, not null.
41 | ///
42 | private readonly Package package;
43 |
44 | ///
45 | /// Initializes a new instance of the class.
46 | /// Adds our command handlers for menu (commands must exist in the command table file)
47 | ///
48 | /// Owner package, not null.
49 | private RenameCommand(Package package)
50 | {
51 | if (package == null)
52 | {
53 | throw new ArgumentNullException("package");
54 | }
55 |
56 | this.package = package;
57 |
58 | OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
59 | if (commandService != null)
60 | {
61 | var menuCommandID = new CommandID(CommandSet, CommandId);
62 | var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
63 | commandService.AddCommand(menuItem);
64 | }
65 | }
66 |
67 | ///
68 | /// Gets the instance of the command.
69 | ///
70 | public static RenameCommand Instance
71 | {
72 | get;
73 | private set;
74 | }
75 |
76 | ///
77 | /// Gets the service provider from the owner package.
78 | ///
79 | private IServiceProvider ServiceProvider
80 | {
81 | get
82 | {
83 | return this.package;
84 | }
85 | }
86 |
87 | ///
88 | /// Initializes the singleton instance of the command.
89 | ///
90 | /// Owner package, not null.
91 | public static void Initialize(Package package)
92 | {
93 | Instance = new RenameCommand(package);
94 | }
95 |
96 | ///
97 | /// This function is the callback used to execute the command when the menu item is clicked.
98 | /// See the constructor to see how the menu item is associated with this function using
99 | /// OleMenuCommandService service and MenuCommand class.
100 | ///
101 | /// Event sender.
102 | /// Event args.
103 | private void MenuItemCallback(object sender, EventArgs e)
104 | {
105 | var dteSolutionHelper = new DteSolutionHelper();
106 | var messageBoxHelper = new MessageBoxHelper(this.ServiceProvider);
107 |
108 | var selectedProject = dteSolutionHelper.GetSelectedProject();
109 |
110 | string newProjectName;
111 | bool isOkButtonClicked = TextInputDialog
112 | .Show("Full Rename", "Enter new project name", selectedProject.Name, out newProjectName);
113 |
114 | if (!isOkButtonClicked)
115 | return;
116 | if (newProjectName == selectedProject.Name)
117 | return;
118 |
119 | var projectRenamer = new ProjectRenamer()
120 | {
121 | SolutionFullName = dteSolutionHelper.GetSolutionFullName(),
122 | ProjectFullName = selectedProject.FullName,
123 | ProjectName = selectedProject.Name,
124 | ProjectUniqueName = selectedProject.UniqueName,
125 | ProjectNameNew = newProjectName,
126 | SolutionProjects = dteSolutionHelper.GetSolutionProjects().Select(it => it.FullName)
127 | };
128 |
129 | if (IsSharedProject(selectedProject))
130 | {
131 | projectRenamer = new SharedTypeProjectRenamer
132 | {
133 | SolutionFullName = projectRenamer.SolutionFullName,
134 | ProjectFullName = selectedProject.FullName,
135 | ProjectName = selectedProject.Name,
136 | ProjectUniqueName = Path.ChangeExtension(selectedProject.UniqueName, null),
137 | ProjectNameNew = newProjectName,
138 | SolutionProjects = projectRenamer.SolutionProjects
139 | };
140 | }
141 |
142 | try
143 | {
144 | projectRenamer.FullRename();
145 | messageBoxHelper.ShowSuccessMessage();
146 | }
147 | catch (IOException ioe)
148 | {
149 | messageBoxHelper.ShowErrorMessage(ioe, "Close all folders, text editors related to the project");
150 | }
151 | catch (Exception ex)
152 | {
153 | messageBoxHelper.ShowErrorMessage(ex);
154 | }
155 | }
156 |
157 | private bool IsSharedProject(Project selectedProject)
158 | {
159 | if (Path.GetExtension(selectedProject.FileName) == ".shproj")
160 | return true;
161 | return false;
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/VSPackage.resx:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | text/microsoft-resx
120 |
121 |
122 | 2.0
123 |
124 |
125 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
126 |
127 |
128 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
129 |
130 |
131 |
132 | RenameCommand Extension
133 |
134 |
135 | RenameCommand Visual Studio Extension Detailed Info
136 |
137 |
138 | Resources\RenameCommandPackage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
139 |
140 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/VSPackage.resx:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | text/microsoft-resx
120 |
121 |
122 | 2.0
123 |
124 |
125 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
126 |
127 |
128 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
129 |
130 |
131 |
132 | RenameCommand Extension
133 |
134 |
135 | RenameCommand Visual Studio Extension Detailed Info
136 |
137 |
138 | Resources\RenameCommandPackage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
139 |
140 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/Core/ProjectRenamer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Security.AccessControl;
7 | using System.Security.Principal;
8 | using System.Text;
9 | using System.Text.RegularExpressions;
10 | using System.Threading.Tasks;
11 | using System.Transactions;
12 | using ChinhDo.Transactions;
13 |
14 | [assembly: InternalsVisibleTo("Core.UnitTests")]
15 | namespace Core
16 | {
17 | public class ProjectRenamer
18 | {
19 | protected readonly TxFileManager FileManager;
20 | private string _projectUniqueName;
21 |
22 | public ProjectRenamer()
23 | {
24 | FileManager = new TxFileManager();
25 | NamespaceRenamer = new NamespaceRenamer();
26 | }
27 |
28 | public string SolutionFullName { get; set; }
29 | public string ProjectFullName { get; set; }
30 | public string ProjectName { get; set; }
31 |
32 | public string ProjectUniqueName
33 | {
34 | get
35 | {
36 | if (HasFolder(_projectUniqueName))
37 | return $@"{GetFolderOfUniqueName(_projectUniqueName)}\{_projectUniqueName.GetFileName()}";
38 | return _projectUniqueName.GetFileName();
39 | }
40 | set => _projectUniqueName = value;
41 | }
42 |
43 | public string ProjectNameNew { get; set; }
44 | public IEnumerable SolutionProjects { get; set; }
45 | public NamespaceRenamer NamespaceRenamer { get; set; }
46 |
47 | internal string ProjectUniqueNameNew => ProjectUniqueName.Replace(ProjectName, ProjectNameNew);
48 | internal string ProjectFullNameNew => ProjectFullName.Replace(ProjectUniqueName, ProjectUniqueNameNew);
49 |
50 | public void FullRename()
51 | {
52 | RenameFolder();
53 |
54 | try
55 | {
56 | using (TransactionScope scope = new TransactionScope())
57 | {
58 | RenameFile();
59 | RenameNamespaces();
60 | RenameUserExtensionFile();
61 | RenameAssemblyNameAndDefaultNamespace();
62 | RenameAssemblyInformation();
63 | RenameInSolutionFile();
64 | RenameInProjectReferences();
65 | CustomRenameForEachProjectType();
66 | scope.Complete();
67 | }
68 | }
69 | catch
70 | {
71 | RollbackRenameFolder();
72 | throw;
73 | }
74 | }
75 |
76 | public void RenameFolder()
77 | {
78 | if (this.ProjectFullName.GetDirectoryName() != this.ProjectFullNameNew.GetDirectoryName())
79 | {
80 | Directory.Move(this.ProjectFullName.GetDirectoryName(), this.ProjectFullNameNew.GetDirectoryName());
81 | }
82 | }
83 |
84 | public void RenameFile()
85 | {
86 | var fullNameWithRenamedFolder =
87 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectFullName.GetFileName());
88 | FileManager.Move(fullNameWithRenamedFolder, this.ProjectFullNameNew);
89 | }
90 |
91 | public void RenameUserExtensionFile()
92 | {
93 | var fullNameWithRenamedFolder =
94 | Path.Combine(ProjectFullNameNew.GetDirectoryName(), ProjectFullName.GetFileName() + ".user");
95 | if (File.Exists(fullNameWithRenamedFolder))
96 | {
97 | FileManager.Move(fullNameWithRenamedFolder, this.ProjectFullNameNew + ".user");
98 | }
99 | }
100 |
101 | public virtual void RenameAssemblyNameAndDefaultNamespace()
102 | {
103 | string projFileText = File.ReadAllText(ProjectFullNameNew);
104 | projFileText = projFileText
105 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "AssemblyName")
106 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "RootNamespace");
107 |
108 | FileManager.WriteAllText(ProjectFullNameNew, projFileText);
109 | }
110 |
111 | public virtual void RenameAssemblyInformation()
112 | {
113 | var projectDirectory = ProjectFullNameNew.GetDirectoryName();
114 | var assemblyInfoFilePath = Path.Combine(projectDirectory, @"Properties\AssemblyInfo.cs");
115 | if (File.Exists(assemblyInfoFilePath))
116 | {
117 | string assemblyInfoFileText = File.ReadAllText(assemblyInfoFilePath);
118 |
119 | assemblyInfoFileText = assemblyInfoFileText.Replace(ProjectName, ProjectNameNew);
120 | FileManager.WriteAllText(assemblyInfoFilePath, assemblyInfoFileText);
121 | }
122 | }
123 |
124 | public void RenameInSolutionFile()
125 | {
126 | string slnFileText = File.ReadAllText(this.SolutionFullName);
127 | slnFileText = slnFileText
128 | .Replace(this.ProjectUniqueName, this.ProjectUniqueNameNew)
129 | .Replace($"\"{this.ProjectName}\"", $"\"{this.ProjectNameNew}\"");
130 | FileManager.WriteAllText(this.SolutionFullName, slnFileText);
131 | }
132 |
133 | public void RenameInProjectReferences()
134 | {
135 | foreach (var projectFullName in SolutionProjects)
136 | {
137 | if (projectFullName != this.ProjectFullName)
138 | {
139 | string projFileText = File.ReadAllText(projectFullName);
140 | if (projFileText.Contains(this.ProjectUniqueName))
141 | {
142 | projFileText = projFileText
143 | .Replace(this.ProjectUniqueName, this.ProjectUniqueNameNew)
144 | .ReplaceWithTag(this.ProjectName, this.ProjectNameNew, "Name");
145 | FileManager.WriteAllText(projectFullName, projFileText);
146 | }
147 | }
148 | }
149 | }
150 |
151 | public void RenameNamespaces()
152 | {
153 | if (NamespaceRenamer.IsNecessaryToRename)
154 | {
155 | var spaces = @"[ ]{1,}";
156 | foreach (string projectFilePath in NamespaceRenamer.ProjectFiles)
157 | {
158 | var filePathWithRenamedFolder = projectFilePath.Replace(ProjectFullName.GetDirectoryName(), ProjectFullNameNew.GetDirectoryName());
159 | string projFileText = File.ReadAllText(filePathWithRenamedFolder);
160 | projFileText = Regex.Replace(
161 | projFileText,
162 | $"namespace{spaces}{ProjectName}",
163 | $"namespace {ProjectNameNew}");
164 | projFileText = Regex.Replace(
165 | projFileText,
166 | $"using{spaces}{ProjectName}",
167 | $"using {ProjectNameNew}");
168 | projFileText = projFileText.Replace($"{ProjectName}.", $"{ProjectNameNew}.");
169 | FileManager.WriteAllText(filePathWithRenamedFolder, projFileText);
170 | }
171 |
172 | foreach (string filePath in NamespaceRenamer.SolutionFiles)
173 | {
174 | string projFileText = File.ReadAllText(filePath);
175 | projFileText = Regex.Replace(
176 | projFileText,
177 | $"using{spaces}{ProjectName}",
178 | $"using {ProjectNameNew}");
179 | projFileText = projFileText.Replace($"{ProjectName}.", $"{ProjectNameNew}.");
180 | FileManager.WriteAllText(filePath, projFileText);
181 | }
182 | }
183 | }
184 |
185 | public virtual void CustomRenameForEachProjectType()
186 | {
187 |
188 | }
189 |
190 | private void RollbackRenameFolder()
191 | {
192 | if (this.ProjectFullNameNew.GetDirectoryName() != this.ProjectFullName.GetDirectoryName())
193 | {
194 | Directory.Move(this.ProjectFullNameNew.GetDirectoryName(), this.ProjectFullName.GetDirectoryName());
195 | }
196 | }
197 |
198 | public string GetFolderOfUniqueName(string projectUniqueName)
199 | {
200 | var directoryName = projectUniqueName.GetDirectoryName();
201 | var directoryInfo = new DirectoryInfo(directoryName);
202 | return directoryInfo.Name;
203 | }
204 |
205 | private bool HasFolder(string projectName)
206 | {
207 | var directoryName = projectName.GetDirectoryName();
208 | if (String.IsNullOrEmpty(directoryName))
209 | return false;
210 | return true;
211 | }
212 | }
213 | }
214 |
--------------------------------------------------------------------------------
/src/RenameProjectVsExtension/VSIX/VSIX.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 15.0
6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
7 |
8 |
9 | true
10 |
11 |
12 | false
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Debug
21 | AnyCPU
22 | 2.0
23 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
24 | {3799872D-D112-4110-AF97-AD7FA0161453}
25 | Library
26 | Properties
27 | VSIX
28 | VSIX
29 | v4.6
30 | true
31 | true
32 | true
33 | true
34 | true
35 | false
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 |
46 |
47 | pdbonly
48 | true
49 | bin\Release\
50 | TRACE
51 | prompt
52 | 4
53 |
54 |
55 |
56 | FullRenameDialog.xaml
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | Designer
69 |
70 |
71 |
72 |
73 | False
74 |
75 |
76 | False
77 |
78 |
79 | False
80 |
81 |
82 | False
83 |
84 |
85 |
86 | False
87 |
88 |
89 | ..\packages\Microsoft.VisualStudio.CoreUtility.15.0.26201\lib\net45\Microsoft.VisualStudio.CoreUtility.dll
90 | True
91 |
92 |
93 | ..\packages\Microsoft.VisualStudio.Imaging.15.0.26201\lib\net45\Microsoft.VisualStudio.Imaging.dll
94 | True
95 |
96 |
97 | ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll
98 | True
99 |
100 |
101 | ..\packages\Microsoft.VisualStudio.Shell.15.0.15.0.26201\lib\Microsoft.VisualStudio.Shell.15.0.dll
102 | True
103 |
104 |
105 | ..\packages\Microsoft.VisualStudio.Shell.Framework.15.0.26201\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll
106 | True
107 |
108 |
109 | ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll
110 | True
111 |
112 |
113 | True
114 | ..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll
115 | True
116 |
117 |
118 | True
119 | ..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll
120 | True
121 |
122 |
123 | True
124 | ..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll
125 | True
126 |
127 |
128 | ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll
129 | True
130 |
131 |
132 | ..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll
133 | True
134 |
135 |
136 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll
137 | True
138 |
139 |
140 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll
141 | True
142 |
143 |
144 | ..\packages\Microsoft.VisualStudio.Threading.15.0.240\lib\net45\Microsoft.VisualStudio.Threading.dll
145 | True
146 |
147 |
148 | ..\packages\Microsoft.VisualStudio.Utilities.15.0.26201\lib\net45\Microsoft.VisualStudio.Utilities.dll
149 | True
150 |
151 |
152 | ..\packages\Microsoft.VisualStudio.Validation.15.0.82\lib\net45\Microsoft.VisualStudio.Validation.dll
153 | True
154 |
155 |
156 |
157 |
158 | False
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | Menus.ctmenu
172 | Designer
173 |
174 |
175 |
176 |
177 | true
178 | VSPackage
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 | {6b7e3634-3f22-4870-9e75-f1e0a4342659}
188 | Core
189 |
190 |
191 |
192 |
193 | Designer
194 | MSBuild:Compile
195 |
196 |
197 |
198 |
199 |
200 |
201 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
202 |
203 |
204 |
205 |
206 |
207 |
214 |
--------------------------------------------------------------------------------
/src/RenameProjectVs2015Extension/RenameProjectVs2015Extension/RenameProjectVs2015Extension.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 14.0
6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
7 |
8 |
9 | true
10 |
11 |
12 | false
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Debug
21 | AnyCPU
22 | 2.0
23 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
24 | {0E4C9F39-2ADD-4349-B31F-A6A4AA5AEFB8}
25 | Library
26 | Properties
27 | RenameProjectVs2015Extension
28 | RenameProjectVs2015Extension
29 | v4.5.2
30 | true
31 | true
32 | true
33 | true
34 | true
35 | false
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 |
46 |
47 | pdbonly
48 | true
49 | bin\Release\
50 | TRACE
51 | prompt
52 | 4
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Designer
65 |
66 |
67 |
68 |
69 | True
70 | ..\packages\EnvDTE.8.0.1\lib\net10\EnvDTE.dll
71 | True
72 |
73 |
74 | True
75 | ..\packages\EnvDTE100.10.0.1\lib\net20\EnvDTE100.dll
76 | True
77 |
78 |
79 | True
80 | ..\packages\EnvDTE80.8.0.1\lib\net10\EnvDTE80.dll
81 | True
82 |
83 |
84 | True
85 | ..\packages\EnvDTE90.9.0.1\lib\net10\EnvDTE90.dll
86 | True
87 |
88 |
89 | True
90 | ..\packages\EnvDTE90a.9.0.1\lib\net10\EnvDTE90a.dll
91 | True
92 |
93 |
94 |
95 |
96 | False
97 |
98 |
99 | ..\packages\Microsoft.VisualStudio.Imaging.14.3.25407\lib\net45\Microsoft.VisualStudio.Imaging.dll
100 | True
101 |
102 |
103 | ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll
104 | True
105 |
106 |
107 | ..\packages\Microsoft.VisualStudio.Shell.14.0.14.3.25407\lib\Microsoft.VisualStudio.Shell.14.0.dll
108 | True
109 |
110 |
111 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.10.0.10.0.30319\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll
112 | True
113 |
114 |
115 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll
116 | True
117 |
118 |
119 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.12.0.12.0.21003\lib\net45\Microsoft.VisualStudio.Shell.Immutable.12.0.dll
120 | True
121 |
122 |
123 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll
124 | True
125 |
126 |
127 | ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll
128 | True
129 |
130 |
131 | True
132 | ..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll
133 | True
134 |
135 |
136 | True
137 | ..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll
138 | True
139 |
140 |
141 | True
142 | ..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll
143 | True
144 |
145 |
146 | ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll
147 | True
148 |
149 |
150 | ..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll
151 | True
152 |
153 |
154 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll
155 | True
156 |
157 |
158 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll
159 | True
160 |
161 |
162 | ..\packages\Microsoft.VisualStudio.Threading.14.1.111\lib\net45\Microsoft.VisualStudio.Threading.dll
163 | True
164 |
165 |
166 | ..\packages\Microsoft.VisualStudio.Utilities.14.3.25407\lib\net45\Microsoft.VisualStudio.Utilities.dll
167 | True
168 |
169 |
170 | ..\packages\Microsoft.VisualStudio.Validation.14.1.111\lib\net45\Microsoft.VisualStudio.Validation.dll
171 | True
172 |
173 |
174 |
175 |
176 | True
177 | ..\packages\stdole.7.0.3301\lib\net10\stdole.dll
178 | True
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | {243c70e3-a440-41f1-a814-a169bcd2bf19}
192 | Core
193 |
194 |
195 |
196 |
197 | Menus.ctmenu
198 |
199 |
200 |
201 |
202 | true
203 | VSPackage
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
215 |
216 |
217 |
218 |
219 |
220 |
227 |
--------------------------------------------------------------------------------