Skip to content

Commit 925d08e

Browse files
authored
Merge pull request #6 from joaoribe/upgrade-ssms21
Upgrade ssms21
2 parents d754cba + 4550a0e commit 925d08e

File tree

6 files changed

+45
-44
lines changed

6 files changed

+45
-44
lines changed

src/SQLScriptsExplorer.Addin/Controls/FileExplorerTreeView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private void mnuExecuteFile_Click(object sender, RoutedEventArgs e)
238238

239239
if (messageBoxResult == MessageBoxResult.Yes)
240240
{
241-
DocumentManager.ExecuteTemplate(treeNode.FileName, treeNode.FileFullPath, settingsRepository.ConfirmScriptExecution);
241+
DocumentManager.ExecuteTemplate(treeNode.FileName, treeNode.FileFullPath);
242242
}
243243
}
244244
catch (Exception ex)

src/SQLScriptsExplorer.Addin/Infrastructure/DocumentManager.cs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using EnvDTE;
2+
using EnvDTE80;
23
using Microsoft.SqlServer.TransactSql.ScriptDom;
34
using Microsoft.VisualStudio.Shell;
45
using SQLScriptsExplorer.Addin.Repository;
@@ -12,6 +13,15 @@ namespace SQLScriptsExplorer.Addin.Infrastructure
1213
{
1314
public static class DocumentManager
1415
{
16+
private static DTE2 DTE
17+
{
18+
get
19+
{
20+
ThreadHelper.ThrowIfNotOnUIThread();
21+
return Package.GetGlobalService(typeof(DTE)) as DTE2;
22+
}
23+
}
24+
1525
public static void OpenTemplate(string fileName, string fileFullPath)
1626
{
1727
try
@@ -21,9 +31,10 @@ public static void OpenTemplate(string fileName, string fileFullPath)
2131
if (File.Exists(fileFullPath))
2232
{
2333
string fileContent = File.ReadAllText(fileFullPath);
34+
var docName = Path.GetFileNameWithoutExtension(fileName);
35+
var docExtension = Path.GetExtension(fileName);
2436

25-
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
26-
var fileDocument = dte.ItemOperations.NewFile(@"General\Text File", fileName).Document;
37+
var fileDocument = DTE.ItemOperations.NewFile(@"General\Text File", $"{docName}_Copy{docExtension}").Document;
2738

2839
TextSelection textSelection = fileDocument.Selection as TextSelection;
2940
textSelection.SelectAll();
@@ -48,12 +59,9 @@ public static void EditTemplate(string fileName, string fileFullPath)
4859
{
4960
try
5061
{
51-
ThreadHelper.ThrowIfNotOnUIThread();
52-
5362
if (File.Exists(fileFullPath))
5463
{
55-
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
56-
dte.ItemOperations.OpenFile(fileFullPath);
64+
DTE.ItemOperations.OpenFile(fileFullPath);
5765
}
5866
else
5967
{
@@ -66,20 +74,16 @@ public static void EditTemplate(string fileName, string fileFullPath)
6674
}
6775
}
6876

69-
public static void ExecuteTemplate(string fileName, string fileFullPath, bool confirmScriptExecution)
77+
public static void ExecuteTemplate(string fileName, string fileFullPath)
7078
{
7179
string CMD_QUERY_EXECUTE = "Query.Execute";
7280

7381
try
7482
{
75-
ThreadHelper.ThrowIfNotOnUIThread();
76-
77-
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
78-
7983
// Ensure the document we are executing is the document we have opened by checking its name
80-
if (dte.ActiveDocument != null && dte.ActiveDocument.ProjectItem.Name.Equals(fileName))
84+
if (DTE.ActiveDocument != null && DTE.ActiveDocument.ProjectItem.Name.Equals(fileName))
8185
{
82-
dte.ExecuteCommand(CMD_QUERY_EXECUTE);
86+
DTE.ExecuteCommand(CMD_QUERY_EXECUTE);
8387
}
8488
}
8589
catch (Exception ex)
@@ -92,13 +96,9 @@ public static void FormatSelection()
9296
{
9397
try
9498
{
95-
ThreadHelper.ThrowIfNotOnUIThread();
96-
97-
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
98-
99-
if (dte.ActiveDocument != null)
99+
if (DTE.ActiveDocument != null)
100100
{
101-
TextSelection selection = (TextSelection)dte.ActiveDocument.Selection;
101+
TextSelection selection = (TextSelection)DTE.ActiveDocument.Selection;
102102

103103
// Format whole text: selection.SelectAll();
104104
string selectedText = selection.Text;
@@ -150,7 +150,15 @@ private static string FormatSelectionUsingSQLServer(string code)
150150

151151
private static Tuple<TSqlParser, SqlScriptGenerator> GetSQLParser(string targetVersion)
152152
{
153-
if (targetVersion == "SQL Server 2019")
153+
if (targetVersion == "SQL Server 2025")
154+
{
155+
return new Tuple<TSqlParser, SqlScriptGenerator>(new TSql170Parser(false), new Sql170ScriptGenerator());
156+
}
157+
else if (targetVersion == "SQL Server 2022")
158+
{
159+
return new Tuple<TSqlParser, SqlScriptGenerator>(new TSql160Parser(false), new Sql160ScriptGenerator());
160+
}
161+
else if (targetVersion == "SQL Server 2019")
154162
{
155163
return new Tuple<TSqlParser, SqlScriptGenerator>(new TSql150Parser(false), new Sql150ScriptGenerator());
156164
}

src/SQLScriptsExplorer.Addin/SQLScriptsExplorer.Addin.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<ErrorReport>prompt</ErrorReport>
4444
<WarningLevel>4</WarningLevel>
4545
<CopyVsixExtensionFiles>True</CopyVsixExtensionFiles>
46-
<CopyVsixExtensionLocation>C:\Program Files %28x86%29\Microsoft SQL Server Management Studio 20\Common7\IDE\Extensions\SQLScriptsExplorer</CopyVsixExtensionLocation>
46+
<CopyVsixExtensionLocation>C:\Program Files\Microsoft SQL Server Management Studio 21\Release\Common7\IDE\Extensions\SQLScriptsExplorer</CopyVsixExtensionLocation>
4747
</PropertyGroup>
4848
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4949
<DebugType>pdbonly</DebugType>
@@ -130,7 +130,7 @@
130130
</ItemGroup>-->
131131
<ItemGroup>
132132
<PackageReference Include="Microsoft.SqlServer.TransactSql.ScriptDom">
133-
<Version>150.4897.1</Version>
133+
<Version>170.64.0</Version>
134134
</PackageReference>
135135
<PackageReference Include="Microsoft.VisualStudio.CoreUtility">
136136
<Version>15.0.26606</Version>

src/SQLScriptsExplorer.Addin/frmSettings.Designer.cs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SQLScriptsExplorer.Addin/frmSettings.resx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,4 @@
126126
<metadata name="Valid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
127127
<value>True</value>
128128
</metadata>
129-
<metadata name="Alias.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
130-
<value>True</value>
131-
</metadata>
132-
<metadata name="FolderPath.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
133-
<value>True</value>
134-
</metadata>
135-
<metadata name="Valid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
136-
<value>True</value>
137-
</metadata>
138129
</root>

src/SQLScriptsExplorer.Addin/source.extension.vsixmanifest

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
<Description>Collaborate SQL Scripts between teams.</Description>
77
</Metadata>
88
<Installation AllUsers="true">
9-
<InstallationTarget Id="ssms" Version="[13.0,20.0)">
9+
<InstallationTarget Id="ssms" Version="[13.0,)">
1010
<ProductArchitecture>amd64</ProductArchitecture>
1111
</InstallationTarget>
12-
<InstallationTarget Version="[13.0,20.0)" Id="Microsoft.VisualStudio.IntegratedShell">
12+
<InstallationTarget Version="[13.0,)" Id="Microsoft.VisualStudio.IntegratedShell">
1313
<ProductArchitecture>amd64</ProductArchitecture>
1414
</InstallationTarget>
1515
</Installation>
1616
<Dependencies>
1717
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.8.1,)" />
18-
<Dependency Id="Microsoft.VisualStudio.MPF.16.0" DisplayName="Visual Studio MPF 16.0" d:Source="Installed" Version="[16.0,18.0)" />
18+
<Dependency Id="Microsoft.VisualStudio.MPF.16.0" DisplayName="Visual Studio MPF 16.0" d:Source="Installed" Version="[16.0,)" />
1919
</Dependencies>
2020
<Prerequisites>
21-
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,18.0)" DisplayName="Visual Studio core editor" />
21+
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,)" DisplayName="Visual Studio core editor" />
2222
</Prerequisites>
2323
<Assets>
2424

0 commit comments

Comments
 (0)