Creating a new Sql Core project that stores OE classes. (#2165)

* init

* More fixes

* moving filters from contracts to core OE classes

* Fixing some tests

* More fixes and added doc comments

* Fixing tests

* Quick refactoring

* more cleanups

* cleanup

* Adding stateless OE

* Adding null checks

* Making group by schema independent of settings

* Fixing tests

* Removing node info from core oe code

* Fixing tests and moving OE code to its own project

* moving oe to own project

* Removing changes to Kusto

* Removing azure access token from service layer

* Fixing project description and title

* Fixing file name typo

* Removing unused  strings from service layer

* Fixing localized strings in tests
Adding comments to stateless OE

* Fixing stuff

* Update src/Microsoft.SqlTools.SqlCore/Microsoft.SqlTools.SqlCore.csproj

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Fixing project nesting

* Fixing more stuff and removing OE class

* Cleanup

* Code cleanup

* fixing oe service provider

* Fixing test name

* Remove using

* Update src/Microsoft.SqlTools.SqlCore/ObjectExplorer/SmoModel/SmoQueryContext.cs

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Fixing syntax error

* Adding project to locproject

* Fixing stuff

* Fixing errors

* sorting usings

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
Aasim Khan
2023-08-17 05:11:35 +00:00
committed by GitHub
parent 4ae9534ac8
commit 73c2a75fba
98 changed files with 6755 additions and 6116 deletions

View File

@@ -50,6 +50,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Credenti
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Hosting", "src\Microsoft.SqlTools.Hosting\Microsoft.SqlTools.Hosting.csproj", "{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Hosting", "src\Microsoft.SqlTools.Hosting\Microsoft.SqlTools.Hosting.csproj", "{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.SqlCore", "src\Microsoft.SqlTools.SqlCore\Microsoft.SqlTools.SqlCore.csproj", "{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ServiceLayer", "src\Microsoft.SqlTools.ServiceLayer\Microsoft.SqlTools.ServiceLayer.csproj", "{835EDEB4-289B-4D6D-A9A0-609E43A87D6E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ServiceLayer", "src\Microsoft.SqlTools.ServiceLayer\Microsoft.SqlTools.ServiceLayer.csproj", "{835EDEB4-289B-4D6D-A9A0-609E43A87D6E}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{3F82F298-700A-48DF-8A69-D048DFBA782C} = {3F82F298-700A-48DF-8A69-D048DFBA782C} {3F82F298-700A-48DF-8A69-D048DFBA782C} = {3F82F298-700A-48DF-8A69-D048DFBA782C}
@@ -118,6 +120,12 @@ Global
{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Integration|Any CPU.Build.0 = Debug|Any CPU {AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Integration|Any CPU.Build.0 = Debug|Any CPU
{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Release|Any CPU.ActiveCfg = Release|Any CPU {AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Release|Any CPU.Build.0 = Release|Any CPU {AAE1F8D1-F7AB-4ABE-A55B-D423393AB352}.Release|Any CPU.Build.0 = Release|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Integration|Any CPU.ActiveCfg = Debug|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Integration|Any CPU.Build.0 = Debug|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC}.Release|Any CPU.Build.0 = Release|Any CPU
{835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU {835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Integration|Any CPU.ActiveCfg = Debug|Any CPU {835EDEB4-289B-4D6D-A9A0-609E43A87D6E}.Integration|Any CPU.ActiveCfg = Debug|Any CPU
@@ -246,6 +254,7 @@ Global
{B7D21727-2926-452B-9610-3ADB0BB6D789} = {F9978D78-78FE-4E92-A7D6-D436B7683EF6} {B7D21727-2926-452B-9610-3ADB0BB6D789} = {F9978D78-78FE-4E92-A7D6-D436B7683EF6}
{0F761F76-E0F3-472E-B539-1815CE2BC696} = {2BBD7364-054F-4693-97CD-1C395E3E84A9} {0F761F76-E0F3-472E-B539-1815CE2BC696} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
{AAE1F8D1-F7AB-4ABE-A55B-D423393AB352} = {2BBD7364-054F-4693-97CD-1C395E3E84A9} {AAE1F8D1-F7AB-4ABE-A55B-D423393AB352} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
{C175C3D4-1AE1-4B62-85EF-8298D37F2BAC} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
{835EDEB4-289B-4D6D-A9A0-609E43A87D6E} = {2BBD7364-054F-4693-97CD-1C395E3E84A9} {835EDEB4-289B-4D6D-A9A0-609E43A87D6E} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
{F18471B5-2042-409D-BF2C-E5403C322DC9} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4} {F18471B5-2042-409D-BF2C-E5403C322DC9} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
{4F250E56-F8B4-4E69-AECC-4D31EDD891E7} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4} {4F250E56-F8B4-4E69-AECC-4D31EDD891E7} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}

View File

@@ -44,6 +44,12 @@
"LclFile": "src\\Microsoft.Kusto.ServiceLayer\\Localization\\LCL\\{Lang}\\sr.xlf.lcl", "LclFile": "src\\Microsoft.Kusto.ServiceLayer\\Localization\\LCL\\{Lang}\\sr.xlf.lcl",
"CopyOption": "LangIDOnName", "CopyOption": "LangIDOnName",
"OutputPath": "src\\Microsoft.Kusto.ServiceLayer\\Localization\\transXliff" "OutputPath": "src\\Microsoft.Kusto.ServiceLayer\\Localization\\transXliff"
},
{
"SourceFile": "src\\Microsoft.SqlTools.SqlCore\\Localization\\sr.xlf",
"LclFile": "src\\Microsoft.SqlTools.SqlCore\\Localization\\LCL\\{Lang}\\sr.xlf.lcl",
"CopyOption": "LangIDOnName",
"OutputPath": "src\\Microsoft.SqlTools.SqlCore\\Localization\\transXliff"
} }
] ]
} }

View File

@@ -17,6 +17,7 @@ using AzureEdition = Microsoft.SqlTools.ServiceLayer.Admin.AzureSqlDbHelper.Azur
using System; using System;
using System.Data; using System.Data;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Microsoft.SqlTools.SqlCore.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Admin namespace Microsoft.SqlTools.ServiceLayer.Admin
{ {
@@ -377,7 +378,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
private static string CreateAzureAlterDbStatement(string dbName, string options) private static string CreateAzureAlterDbStatement(string dbName, string options)
{ {
return string.Format(CultureInfo.InvariantCulture, AlterDbStatementFormat, return string.Format(CultureInfo.InvariantCulture, AlterDbStatementFormat,
CUtils.EscapeString(CUtils.EscapeString(dbName, ']'), '\''), StringUtils.EscapeString(StringUtils.EscapeString(dbName, ']'), '\''),
options); options);
} }
} }

View File

@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Data.Common; using System.Data.Common;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Connection namespace Microsoft.SqlTools.ServiceLayer.Connection

View File

@@ -29,6 +29,7 @@ using Microsoft.SqlTools.Authentication;
using System.IO; using System.IO;
using Microsoft.SqlTools.Hosting.Utility; using Microsoft.SqlTools.Hosting.Utility;
using Constants = Microsoft.SqlTools.Hosting.Protocol.Constants; using Constants = Microsoft.SqlTools.Hosting.Protocol.Constants;
using Microsoft.SqlTools.SqlCore.Connection;
namespace Microsoft.SqlTools.ServiceLayer.Connection namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
@@ -1983,24 +1984,4 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
return databaseName != null ? databaseName.IndexOf('@') != -1 : false; return databaseName != null ? databaseName.IndexOf('@') != -1 : false;
} }
} }
public class AzureAccessToken : IRenewableToken
{
public DateTimeOffset TokenExpiry { get; set; }
public string Resource { get; set; }
public string Tenant { get; set; }
public string UserId { get; set; }
private string accessToken;
public AzureAccessToken(string accessToken)
{
this.accessToken = accessToken;
}
public string GetAccessToken()
{
return this.accessToken;
}
}
} }

View File

@@ -11,7 +11,7 @@ using System.Data.Common;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts; using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.SqlCore.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Connection namespace Microsoft.SqlTools.ServiceLayer.Connection

View File

@@ -11,9 +11,9 @@ using System.Data.Common;
using Microsoft.Data.SqlClient; using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection; using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters; using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.EditData namespace Microsoft.SqlTools.ServiceLayer.EditData

View File

@@ -82,7 +82,8 @@ namespace Microsoft.SqlTools.ServiceLayer
ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider(new string[] { ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider(new string[] {
"microsofsqltoolscredentials.dll", "microsofsqltoolscredentials.dll",
"microsoft.sqltools.hosting.dll", "microsoft.sqltools.hosting.dll",
"microsoftsqltoolsservicelayer.dll" "microsoftsqltoolsservicelayer.dll",
"microsoftsqltoolssqlcore.dll"
}); });
serviceProvider.RegisterSingleService(sqlToolsContext); serviceProvider.RegisterSingleService(sqlToolsContext);
serviceProvider.RegisterSingleService(serviceHost); serviceProvider.RegisterSingleService(serviceHost);

View File

@@ -6,7 +6,7 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.ServiceLayer.LanguageExtensibility.Contracts; using Microsoft.SqlTools.ServiceLayer.LanguageExtensibility.Contracts;
using Microsoft.SqlTools.ServiceLayer.Management; using Microsoft.SqlTools.SqlCore.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -67,7 +67,7 @@ ORDER BY platform";
private string GetDropScript(string languageName) private string GetDropScript(string languageName)
{ {
return $@"{DropScript} [{CUtils.EscapeStringCBracket(languageName)}]"; return $@"{DropScript} [{StringUtils.EscapeStringCBracket(languageName)}]";
} }
/// <summary> /// <summary>
@@ -262,7 +262,7 @@ ORDER BY platform";
contentScript = $"{contentScript}{seperator}{GetLanguageContent(content, i, parameters)}"; contentScript = $"{contentScript}{seperator}{GetLanguageContent(content, i, parameters)}";
} }
string ownerScript = string.IsNullOrWhiteSpace(language.Owner) ? "" : $"AUTHORIZATION [{CUtils.EscapeStringCBracket(language.Owner)}]"; string ownerScript = string.IsNullOrWhiteSpace(language.Owner) ? "" : $"AUTHORIZATION [{StringUtils.EscapeStringCBracket(language.Owner)}]";
string scriptAction = modifyType == ModifyType.Create ? CreateScript : AlterScript; string scriptAction = modifyType == ModifyType.Create ? CreateScript : AlterScript;
string contentAction = "FROM"; string contentAction = "FROM";
if (modifyType == ModifyType.Alter) if (modifyType == ModifyType.Alter)
@@ -281,7 +281,7 @@ ORDER BY platform";
} }
} }
return $@" return $@"
{scriptAction} [{CUtils.EscapeStringCBracket(language.Name)}] {scriptAction} [{StringUtils.EscapeStringCBracket(language.Name)}]
{ownerScript} {ownerScript}
{contentAction} {contentScript} {contentAction} {contentScript}
"; ";
@@ -289,7 +289,7 @@ ORDER BY platform";
private string AddStringParameter(string paramName, string prefix, string paramValue) private string AddStringParameter(string paramName, string prefix, string paramValue)
{ {
string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : CUtils.EscapeStringSQuote(paramValue); string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : StringUtils.EscapeStringSQuote(paramValue);
return $"{prefix} {paramName} = N'{value}'"; return $"{prefix} {paramName} = N'{value}'";
} }

File diff suppressed because it is too large Load Diff

View File

@@ -678,854 +678,6 @@
<value>Scalar column missing scale</value> <value>Scalar column missing scale</value>
<comment></comment> <comment></comment>
</data> </data>
<data name="TreeNodeError" xml:space="preserve">
<value>Error expanding: {0}</value>
<comment></comment>
</data>
<data name="ServerNodeConnectionError" xml:space="preserve">
<value>Error connecting to {0}</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Aggregates" xml:space="preserve">
<value>Aggregates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRoles" xml:space="preserve">
<value>Server Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ApplicationRoles" xml:space="preserve">
<value>Application Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Assemblies" xml:space="preserve">
<value>Assemblies</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AssemblyFiles" xml:space="preserve">
<value>Assembly Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AsymmetricKeys" xml:space="preserve">
<value>Asymmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseAsymmetricKeys" xml:space="preserve">
<value>Asymmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DataCompressionOptions" xml:space="preserve">
<value>Data Compression Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Certificates" xml:space="preserve">
<value>Certificates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FileTables" xml:space="preserve">
<value>FileTables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseCertificates" xml:space="preserve">
<value>Certificates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_CheckConstraints" xml:space="preserve">
<value>Check Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Columns" xml:space="preserve">
<value>Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Constraints" xml:space="preserve">
<value>Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Contracts" xml:space="preserve">
<value>Contracts</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Credentials" xml:space="preserve">
<value>Credentials</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ErrorMessages" xml:space="preserve">
<value>Error Messages</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRoleMembership" xml:space="preserve">
<value>Server Role Membership</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseOptions" xml:space="preserve">
<value>Database Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseRoles" xml:space="preserve">
<value>Database Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_RoleMemberships" xml:space="preserve">
<value>Role Memberships</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseTriggers" xml:space="preserve">
<value>Database Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DefaultConstraints" xml:space="preserve">
<value>Default Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Defaults" xml:space="preserve">
<value>Defaults</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Sequences" xml:space="preserve">
<value>Sequences</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Endpoints" xml:space="preserve">
<value>Endpoints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_EventNotifications" xml:space="preserve">
<value>Event Notifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerEventNotifications" xml:space="preserve">
<value>Server Event Notifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExtendedProperties" xml:space="preserve">
<value>Extended Properties</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FileGroups" xml:space="preserve">
<value>Filegroups</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ForeignKeys" xml:space="preserve">
<value>Foreign Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextCatalogs" xml:space="preserve">
<value>Full-Text Catalogs</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextIndexes" xml:space="preserve">
<value>Full-Text Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Functions" xml:space="preserve">
<value>Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Indexes" xml:space="preserve">
<value>Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_InlineFunctions" xml:space="preserve">
<value>Inline Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Keys" xml:space="preserve">
<value>Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_LinkedServers" xml:space="preserve">
<value>Linked Servers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Logins" xml:space="preserve">
<value>Logins</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MasterKey" xml:space="preserve">
<value>Master Key</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MasterKeys" xml:space="preserve">
<value>Master Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MessageTypes" xml:space="preserve">
<value>Message Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MultiSelectFunctions" xml:space="preserve">
<value>Table-Valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Parameters" xml:space="preserve">
<value>Parameters</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PartitionFunctions" xml:space="preserve">
<value>Partition Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PartitionSchemes" xml:space="preserve">
<value>Partition Schemes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Permissions" xml:space="preserve">
<value>Permissions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PrimaryKeys" xml:space="preserve">
<value>Primary Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Programmability" xml:space="preserve">
<value>Programmability</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Queues" xml:space="preserve">
<value>Queues</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_RemoteServiceBindings" xml:space="preserve">
<value>Remote Service Bindings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ReturnedColumns" xml:space="preserve">
<value>Returned Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Roles" xml:space="preserve">
<value>Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Routes" xml:space="preserve">
<value>Routes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Rules" xml:space="preserve">
<value>Rules</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Schemas" xml:space="preserve">
<value>Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInSchema" xml:space="preserve">
<value>Built-in Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Security" xml:space="preserve">
<value>Security</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerObjects" xml:space="preserve">
<value>Server Objects</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Management" xml:space="preserve">
<value>Management</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerTriggers" xml:space="preserve">
<value>Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServiceBroker" xml:space="preserve">
<value>Service Broker</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Services" xml:space="preserve">
<value>Services</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Signatures" xml:space="preserve">
<value>Signatures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_LogFiles" xml:space="preserve">
<value>Log Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Statistics" xml:space="preserve">
<value>Statistics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Storage" xml:space="preserve">
<value>Storage</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_StoredProcedures" xml:space="preserve">
<value>Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SymmetricKeys" xml:space="preserve">
<value>Symmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Synonyms" xml:space="preserve">
<value>Synonyms</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Tables" xml:space="preserve">
<value>Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Triggers" xml:space="preserve">
<value>Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Types" xml:space="preserve">
<value>Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UniqueKeys" xml:space="preserve">
<value>Unique Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedDataTypes" xml:space="preserve">
<value>User-Defined Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedTypes" xml:space="preserve">
<value>User-Defined Types (CLR)</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Users" xml:space="preserve">
<value>Users</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Views" xml:space="preserve">
<value>Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlIndexes" xml:space="preserve">
<value>XML Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XMLSchemaCollections" xml:space="preserve">
<value>XML Schema Collections</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedTableTypes" xml:space="preserve">
<value>User-Defined Table Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FilegroupFiles" xml:space="preserve">
<value>Files</value>
<comment></comment>
</data>
<data name="MissingCaption" xml:space="preserve">
<value>Missing Caption</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BrokerPriorities" xml:space="preserve">
<value>Broker Priorities</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_CryptographicProviders" xml:space="preserve">
<value>Cryptographic Providers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseAuditSpecifications" xml:space="preserve">
<value>Database Audit Specifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseEncryptionKeys" xml:space="preserve">
<value>Database Encryption Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_EventSessions" xml:space="preserve">
<value>Event Sessions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextStopLists" xml:space="preserve">
<value>Full Text Stoplists</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ResourcePools" xml:space="preserve">
<value>Resource Pools</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerAudits" xml:space="preserve">
<value>Audits</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerAuditSpecifications" xml:space="preserve">
<value>Server Audit Specifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SpatialIndexes" xml:space="preserve">
<value>Spatial Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_WorkloadGroups" xml:space="preserve">
<value>Workload Groups</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlFiles" xml:space="preserve">
<value>SQL Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerFunctions" xml:space="preserve">
<value>Server Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlType" xml:space="preserve">
<value>SQL Type</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerOptions" xml:space="preserve">
<value>Server Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseDiagrams" xml:space="preserve">
<value>Database Diagrams</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemTables" xml:space="preserve">
<value>System Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Databases" xml:space="preserve">
<value>Databases</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemContracts" xml:space="preserve">
<value>System Contracts</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDatabases" xml:space="preserve">
<value>System Databases</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMessageTypes" xml:space="preserve">
<value>System Message Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemQueues" xml:space="preserve">
<value>System Queues</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemServices" xml:space="preserve">
<value>System Services</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemStoredProcedures" xml:space="preserve">
<value>System Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemViews" xml:space="preserve">
<value>System Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DataTierApplications" xml:space="preserve">
<value>Data-tier Applications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExtendedStoredProcedures" xml:space="preserve">
<value>Extended Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemAggregateFunctions" xml:space="preserve">
<value>Aggregate Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemApproximateNumerics" xml:space="preserve">
<value>Approximate Numerics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemBinaryStrings" xml:space="preserve">
<value>Binary Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCharacterStrings" xml:space="preserve">
<value>Character Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCLRDataTypes" xml:space="preserve">
<value>CLR Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemConfigurationFunctions" xml:space="preserve">
<value>Configuration Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCursorFunctions" xml:space="preserve">
<value>Cursor Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDataTypes" xml:space="preserve">
<value>System Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDateAndTime" xml:space="preserve">
<value>Date and Time</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDateAndTimeFunctions" xml:space="preserve">
<value>Date and Time Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemExactNumerics" xml:space="preserve">
<value>Exact Numerics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemFunctions" xml:space="preserve">
<value>System Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemHierarchyIdFunctions" xml:space="preserve">
<value>Hierarchy Id Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMathematicalFunctions" xml:space="preserve">
<value>Mathematical Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMetadataFunctions" xml:space="preserve">
<value>Metadata Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemOtherDataTypes" xml:space="preserve">
<value>Other Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemOtherFunctions" xml:space="preserve">
<value>Other Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemRowsetFunctions" xml:space="preserve">
<value>Rowset Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSecurityFunctions" xml:space="preserve">
<value>Security Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSpatialDataTypes" xml:space="preserve">
<value>Spatial Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemStringFunctions" xml:space="preserve">
<value>String Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSystemStatisticalFunctions" xml:space="preserve">
<value>System Statistical Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemTextAndImageFunctions" xml:space="preserve">
<value>Text and Image Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemUnicodeCharacterStrings" xml:space="preserve">
<value>Unicode Character Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AggregateFunctions" xml:space="preserve">
<value>Aggregate Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ScalarValuedFunctions" xml:space="preserve">
<value>Scalar-valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_TableValuedFunctions" xml:space="preserve">
<value>Table-valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemExtendedStoredProcedures" xml:space="preserve">
<value>System Extended Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInType" xml:space="preserve">
<value>Built-in Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInServerRole" xml:space="preserve">
<value>Built-in Server Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserWithPassword" xml:space="preserve">
<value>User with Password</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SearchPropertyList" xml:space="preserve">
<value>Search Property List</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SecurityPolicies" xml:space="preserve">
<value>Security Policies</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SecurityPredicates" xml:space="preserve">
<value>Security Predicates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRole" xml:space="preserve">
<value>Server Role</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SearchPropertyLists" xml:space="preserve">
<value>Search Property Lists</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnStoreIndexes" xml:space="preserve">
<value>Column Store Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_TableTypeIndexes" xml:space="preserve">
<value>Table Type Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Server" xml:space="preserve">
<value>Server</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SelectiveXmlIndexes" xml:space="preserve">
<value>Selective XML Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlNamespaces" xml:space="preserve">
<value>XML Namespaces</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlTypedPromotedPaths" xml:space="preserve">
<value>XML Typed Promoted Paths</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlTypedPromotedPaths" xml:space="preserve">
<value>T-SQL Typed Promoted Paths</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseScopedCredentials" xml:space="preserve">
<value>Database Scoped Credentials</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalDataSources" xml:space="preserve">
<value>External Data Sources</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalFileFormats" xml:space="preserve">
<value>External File Formats</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalResources" xml:space="preserve">
<value>External Resources</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalTables" xml:space="preserve">
<value>External Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerColumns" xml:space="preserve">
<value>Dropped Ledger Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerTables" xml:space="preserve">
<value>Dropped Ledger Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerViews" xml:space="preserve">
<value>Dropped Ledger Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AlwaysEncryptedKeys" xml:space="preserve">
<value>Always Encrypted Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnMasterKeys" xml:space="preserve">
<value>Column Master Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnEncryptionKeys" xml:space="preserve">
<value>Column Encryption Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterLabelFormatString" xml:space="preserve">
<value>{0} ({1}, {2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterNoDefaultLabel" xml:space="preserve">
<value>No default</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputLabel" xml:space="preserve">
<value>Input</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputOutputLabel" xml:space="preserve">
<value>Input/Output</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputReadOnlyLabel" xml:space="preserve">
<value>Input/ReadOnly</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputOutputReadOnlyLabel" xml:space="preserve">
<value>Input/Output/ReadOnly</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterDefaultLabel" xml:space="preserve">
<value>Default</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_NullColumn_Label" xml:space="preserve">
<value>null</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_NotNullColumn_Label" xml:space="preserve">
<value>not null</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UDDTLabelWithType" xml:space="preserve">
<value>{0} ({1}, {2})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UDDTLabelWithoutType" xml:space="preserve">
<value>{0} ({1})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ComputedColumnLabelWithType" xml:space="preserve">
<value>{0} ({1}Computed, {2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ComputedColumnLabelWithoutType" xml:space="preserve">
<value>{0} ({1}Computed)</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithoutType" xml:space="preserve">
<value>{0} (Column Set, {1})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithType" xml:space="preserve">
<value>{0} (Column Set, {1}{2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithTypeAndKeyString" xml:space="preserve">
<value>{0} (Column Set, {1}, {2}, {3})</value>
<comment></comment>
</data>
<data name="UniqueIndex_LabelPart" xml:space="preserve">
<value>Unique</value>
<comment></comment>
</data>
<data name="NonUniqueIndex_LabelPart" xml:space="preserve">
<value>Non-Unique</value>
<comment></comment>
</data>
<data name="ClusteredIndex_LabelPart" xml:space="preserve">
<value>Clustered</value>
<comment></comment>
</data>
<data name="NonClusteredIndex_LabelPart" xml:space="preserve">
<value>Non-Clustered</value>
<comment></comment>
</data>
<data name="History_LabelPart" xml:space="preserve">
<value>History</value>
<comment></comment>
</data>
<data name="SystemVersioned_LabelPart" xml:space="preserve">
<value>System-Versioned</value>
<comment></comment>
</data>
<data name="UpdatableLedger_LabelPart" xml:space="preserve">
<value>Updatable Ledger</value>
<comment></comment>
</data>
<data name="AppendOnlyLedger_LabelPart" xml:space="preserve">
<value>Append-Only Ledger</value>
<comment></comment>
</data>
<data name="Ledger_LabelPart" xml:space="preserve">
<value>Ledger</value>
<comment></comment>
</data>
<data name="External_LabelPart" xml:space="preserve">
<value>External</value>
<comment></comment>
</data>
<data name="FileTable_LabelPart" xml:space="preserve">
<value>File Table</value>
<comment></comment>
</data>
<data name="DatabaseNotAccessible" xml:space="preserve">
<value>The database {0} is not accessible.</value>
<comment></comment>
</data>
<data name="FilterName" xml:space="preserve">
<value>Name</value>
<comment></comment>
</data>
<data name="FilterNameDescription" xml:space="preserve">
<value>Include or exclude objects based on the name or part of a name.</value>
<comment></comment>
</data>
<data name="FilterSchema" xml:space="preserve">
<value>Schema</value>
<comment></comment>
</data>
<data name="FilterSchemaDescription" xml:space="preserve">
<value> Include or exclude objects based on the schema or part of a schema name.</value>
<comment></comment>
</data>
<data name="FilterOwner" xml:space="preserve">
<value>Owner</value>
<comment></comment>
</data>
<data name="FilterOwnerDescription" xml:space="preserve">
<value>Include or exclude objects based on the owner or part of an owner name.</value>
<comment></comment>
</data>
<data name="FilterDurabilityType" xml:space="preserve">
<value>Durability Type</value>
<comment></comment>
</data>
<data name="FilterDurabilityTypeDescription" xml:space="preserve">
<value>Include or exclude objects based on the durability type.</value>
<comment></comment>
</data>
<data name="FilterDurabilitySchemaOnly" xml:space="preserve">
<value>Schema Only</value>
<comment></comment>
</data>
<data name="FilterDurabilitySchemaAndData" xml:space="preserve">
<value>Schema and Data</value>
<comment></comment>
</data>
<data name="FilterIsMemoryOptimized" xml:space="preserve">
<value>Is Memory Optimized</value>
<comment></comment>
</data>
<data name="FilterIsMemoryOptimizedDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the object is memory optimized.</value>
<comment></comment>
</data>
<data name="FilterCreateDate" xml:space="preserve">
<value>Create Date</value>
<comment></comment>
</data>
<data name="FilterCreateDateDescription" xml:space="preserve">
<value>Include or exclude objects based on their creation date.</value>
<comment></comment>
</data>
<data name="FilterIsNativelyCompiled" xml:space="preserve">
<value>Is Natively Compiled</value>
<comment></comment>
</data>
<data name="FilterIsNativelyCompiledDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the object is natively compiled.</value>
<comment></comment>
</data>
<data name="FilterInPrimaryKey" xml:space="preserve">
<value>In Primary Key</value>
<comment></comment>
</data>
<data name="FilterInPrimaryKeyDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the column is in a primary key.</value>
<comment></comment>
</data>
<data name="ScriptingParams_ConnectionString_Property_Invalid" xml:space="preserve"> <data name="ScriptingParams_ConnectionString_Property_Invalid" xml:space="preserve">
<value>Error parsing ScriptingParams.ConnectionString property.</value> <value>Error parsing ScriptingParams.ConnectionString property.</value>
<comment></comment> <comment></comment>

View File

@@ -327,416 +327,6 @@ SqlScriptFormatterLengthTypeMissingSize = Column with length is missing size
SqlScriptFormatterScalarTypeMissingScale = Scalar column missing scale SqlScriptFormatterScalarTypeMissingScale = Scalar column missing scale
############################################################################
# Object Explorer Service
TreeNodeError = Error expanding: {0}
ServerNodeConnectionError = Error connecting to {0}
SchemaHierarchy_Aggregates = Aggregates
SchemaHierarchy_ServerRoles = Server Roles
SchemaHierarchy_ApplicationRoles = Application Roles
SchemaHierarchy_Assemblies = Assemblies
SchemaHierarchy_AssemblyFiles = Assembly Files
SchemaHierarchy_AsymmetricKeys = Asymmetric Keys
SchemaHierarchy_DatabaseAsymmetricKeys = Asymmetric Keys
SchemaHierarchy_DataCompressionOptions = Data Compression Options
SchemaHierarchy_Certificates = Certificates
SchemaHierarchy_FileTables = FileTables
SchemaHierarchy_DatabaseCertificates = Certificates
SchemaHierarchy_CheckConstraints = Check Constraints
SchemaHierarchy_Columns = Columns
SchemaHierarchy_Constraints = Constraints
SchemaHierarchy_Contracts = Contracts
SchemaHierarchy_Credentials = Credentials
SchemaHierarchy_ErrorMessages = Error Messages
SchemaHierarchy_ServerRoleMembership = Server Role Membership
SchemaHierarchy_DatabaseOptions = Database Options
SchemaHierarchy_DatabaseRoles = Database Roles
SchemaHierarchy_RoleMemberships = Role Memberships
SchemaHierarchy_DatabaseTriggers = Database Triggers
SchemaHierarchy_DefaultConstraints = Default Constraints
SchemaHierarchy_Defaults = Defaults
SchemaHierarchy_Sequences = Sequences
SchemaHierarchy_Endpoints = Endpoints
SchemaHierarchy_EventNotifications = Event Notifications
SchemaHierarchy_ServerEventNotifications = Server Event Notifications
SchemaHierarchy_ExtendedProperties = Extended Properties
SchemaHierarchy_FileGroups = Filegroups
SchemaHierarchy_ForeignKeys = Foreign Keys
SchemaHierarchy_FullTextCatalogs = Full-Text Catalogs
SchemaHierarchy_FullTextIndexes = Full-Text Indexes
SchemaHierarchy_Functions = Functions
SchemaHierarchy_Indexes = Indexes
SchemaHierarchy_InlineFunctions = Inline Functions
SchemaHierarchy_Keys = Keys
SchemaHierarchy_LinkedServers = Linked Servers
SchemaHierarchy_Logins = Logins
SchemaHierarchy_MasterKey = Master Key
SchemaHierarchy_MasterKeys = Master Keys
SchemaHierarchy_MessageTypes = Message Types
SchemaHierarchy_MultiSelectFunctions = Table-Valued Functions
SchemaHierarchy_Parameters = Parameters
SchemaHierarchy_PartitionFunctions = Partition Functions
SchemaHierarchy_PartitionSchemes = Partition Schemes
SchemaHierarchy_Permissions = Permissions
SchemaHierarchy_PrimaryKeys = Primary Keys
SchemaHierarchy_Programmability = Programmability
SchemaHierarchy_Queues = Queues
SchemaHierarchy_RemoteServiceBindings = Remote Service Bindings
SchemaHierarchy_ReturnedColumns = Returned Columns
SchemaHierarchy_Roles = Roles
SchemaHierarchy_Routes = Routes
SchemaHierarchy_Rules = Rules
SchemaHierarchy_Schemas = Schemas
SchemaHierarchy_BuiltInSchema = Built-in Schemas
SchemaHierarchy_Security = Security
SchemaHierarchy_ServerObjects = Server Objects
SchemaHierarchy_Management = Management
SchemaHierarchy_ServerTriggers = Triggers
SchemaHierarchy_ServiceBroker = Service Broker
SchemaHierarchy_Services = Services
SchemaHierarchy_Signatures = Signatures
SchemaHierarchy_LogFiles = Log Files
SchemaHierarchy_Statistics = Statistics
SchemaHierarchy_Storage = Storage
SchemaHierarchy_StoredProcedures = Stored Procedures
SchemaHierarchy_SymmetricKeys = Symmetric Keys
SchemaHierarchy_Synonyms = Synonyms
SchemaHierarchy_Tables = Tables
SchemaHierarchy_Triggers = Triggers
SchemaHierarchy_Types = Types
SchemaHierarchy_UniqueKeys = Unique Keys
SchemaHierarchy_UserDefinedDataTypes = User-Defined Data Types
SchemaHierarchy_UserDefinedTypes = User-Defined Types (CLR)
SchemaHierarchy_Users = Users
SchemaHierarchy_Views = Views
SchemaHierarchy_XmlIndexes = XML Indexes
SchemaHierarchy_XMLSchemaCollections = XML Schema Collections
SchemaHierarchy_UserDefinedTableTypes = User-Defined Table Types
SchemaHierarchy_FilegroupFiles = Files
MissingCaption = Missing Caption
SchemaHierarchy_BrokerPriorities = Broker Priorities
SchemaHierarchy_CryptographicProviders = Cryptographic Providers
SchemaHierarchy_DatabaseAuditSpecifications = Database Audit Specifications
SchemaHierarchy_DatabaseEncryptionKeys = Database Encryption Keys
SchemaHierarchy_EventSessions = Event Sessions
SchemaHierarchy_FullTextStopLists = Full Text Stoplists
SchemaHierarchy_ResourcePools = Resource Pools
SchemaHierarchy_ServerAudits = Audits
SchemaHierarchy_ServerAuditSpecifications = Server Audit Specifications
SchemaHierarchy_SpatialIndexes = Spatial Indexes
SchemaHierarchy_WorkloadGroups = Workload Groups
SchemaHierarchy_SqlFiles = SQL Files
SchemaHierarchy_ServerFunctions = Server Functions
SchemaHierarchy_SqlType = SQL Type
SchemaHierarchy_ServerOptions = Server Options
SchemaHierarchy_DatabaseDiagrams = Database Diagrams
SchemaHierarchy_SystemTables = System Tables
SchemaHierarchy_Databases = Databases
SchemaHierarchy_SystemContracts = System Contracts
SchemaHierarchy_SystemDatabases = System Databases
SchemaHierarchy_SystemMessageTypes = System Message Types
SchemaHierarchy_SystemQueues = System Queues
SchemaHierarchy_SystemServices = System Services
SchemaHierarchy_SystemStoredProcedures = System Stored Procedures
SchemaHierarchy_SystemViews = System Views
SchemaHierarchy_DataTierApplications = Data-tier Applications
SchemaHierarchy_ExtendedStoredProcedures = Extended Stored Procedures
SchemaHierarchy_SystemAggregateFunctions = Aggregate Functions
SchemaHierarchy_SystemApproximateNumerics = Approximate Numerics
SchemaHierarchy_SystemBinaryStrings = Binary Strings
SchemaHierarchy_SystemCharacterStrings = Character Strings
SchemaHierarchy_SystemCLRDataTypes = CLR Data Types
SchemaHierarchy_SystemConfigurationFunctions = Configuration Functions
SchemaHierarchy_SystemCursorFunctions = Cursor Functions
SchemaHierarchy_SystemDataTypes = System Data Types
SchemaHierarchy_SystemDateAndTime = Date and Time
SchemaHierarchy_SystemDateAndTimeFunctions = Date and Time Functions
SchemaHierarchy_SystemExactNumerics = Exact Numerics
SchemaHierarchy_SystemFunctions = System Functions
SchemaHierarchy_SystemHierarchyIdFunctions = Hierarchy Id Functions
SchemaHierarchy_SystemMathematicalFunctions = Mathematical Functions
SchemaHierarchy_SystemMetadataFunctions = Metadata Functions
SchemaHierarchy_SystemOtherDataTypes = Other Data Types
SchemaHierarchy_SystemOtherFunctions = Other Functions
SchemaHierarchy_SystemRowsetFunctions = Rowset Functions
SchemaHierarchy_SystemSecurityFunctions = Security Functions
SchemaHierarchy_SystemSpatialDataTypes = Spatial Data Types
SchemaHierarchy_SystemStringFunctions = String Functions
SchemaHierarchy_SystemSystemStatisticalFunctions = System Statistical Functions
SchemaHierarchy_SystemTextAndImageFunctions = Text and Image Functions
SchemaHierarchy_SystemUnicodeCharacterStrings = Unicode Character Strings
SchemaHierarchy_AggregateFunctions = Aggregate Functions
SchemaHierarchy_ScalarValuedFunctions = Scalar-valued Functions
SchemaHierarchy_TableValuedFunctions = Table-valued Functions
SchemaHierarchy_SystemExtendedStoredProcedures = System Extended Stored Procedures
SchemaHierarchy_BuiltInType = Built-in Types
SchemaHierarchy_BuiltInServerRole = Built-in Server Roles
SchemaHierarchy_UserWithPassword = User with Password
SchemaHierarchy_SearchPropertyList = Search Property List
SchemaHierarchy_SecurityPolicies = Security Policies
SchemaHierarchy_SecurityPredicates = Security Predicates
SchemaHierarchy_ServerRole = Server Role
SchemaHierarchy_SearchPropertyLists = Search Property Lists
SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes
SchemaHierarchy_TableTypeIndexes = Table Type Indexes
SchemaHierarchy_Server = Server
SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes
SchemaHierarchy_XmlNamespaces = XML Namespaces
SchemaHierarchy_XmlTypedPromotedPaths = XML Typed Promoted Paths
SchemaHierarchy_SqlTypedPromotedPaths = T-SQL Typed Promoted Paths
SchemaHierarchy_DatabaseScopedCredentials = Database Scoped Credentials
SchemaHierarchy_ExternalDataSources = External Data Sources
SchemaHierarchy_ExternalFileFormats = External File Formats
SchemaHierarchy_ExternalResources = External Resources
SchemaHierarchy_ExternalTables = External Tables
SchemaHierarchy_DroppedLedgerColumns = Dropped Ledger Columns
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views
SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys
SchemaHierarchy_ColumnMasterKeys = Column Master Keys
SchemaHierarchy_ColumnEncryptionKeys = Column Encryption Keys
SchemaHierarchy_SubroutineParameterLabelFormatString = {0} ({1}, {2}, {3})
SchemaHierarchy_SubroutineParameterNoDefaultLabel = No default
SchemaHierarchy_SubroutineParameterInputLabel = Input
SchemaHierarchy_SubroutineParameterInputOutputLabel = Input/Output
SchemaHierarchy_SubroutineParameterInputReadOnlyLabel = Input/ReadOnly
SchemaHierarchy_SubroutineParameterInputOutputReadOnlyLabel = Input/Output/ReadOnly
SchemaHierarchy_SubroutineParameterDefaultLabel = Default
SchemaHierarchy_NullColumn_Label = null
SchemaHierarchy_NotNullColumn_Label = not null
SchemaHierarchy_UDDTLabelWithType = {0} ({1}, {2})
SchemaHierarchy_UDDTLabelWithoutType = {0} ({1})
SchemaHierarchy_ComputedColumnLabelWithType = {0} ({1}Computed, {2}, {3})
SchemaHierarchy_ComputedColumnLabelWithoutType = {0} ({1}Computed)
SchemaHierarchy_ColumnSetLabelWithoutType = {0} (Column Set, {1})
SchemaHierarchy_ColumnSetLabelWithType = {0} (Column Set, {1}{2}, {3})
SchemaHierarchy_ColumnSetLabelWithTypeAndKeyString = {0} (Column Set, {1}, {2}, {3})
UniqueIndex_LabelPart = Unique
NonUniqueIndex_LabelPart = Non-Unique
ClusteredIndex_LabelPart = Clustered
NonClusteredIndex_LabelPart = Non-Clustered
History_LabelPart = History
SystemVersioned_LabelPart = System-Versioned
UpdatableLedger_LabelPart = Updatable Ledger
AppendOnlyLedger_LabelPart = Append-Only Ledger
Ledger_LabelPart = Ledger
External_LabelPart = External
FileTable_LabelPart = File Table
DatabaseNotAccessible = The database {0} is not accessible.
FilterName = Name
FilterNameDescription = Include or exclude objects based on the name or part of a name.
FilterSchema = Schema
FilterSchemaDescription = Include or exclude objects based on the schema or part of a schema name.
FilterOwner = Owner
FilterOwnerDescription = Include or exclude objects based on the owner or part of an owner name.
FilterDurabilityType = Durability Type
FilterDurabilityTypeDescription = Include or exclude objects based on the durability type.
FilterDurabilitySchemaOnly = Schema Only
FilterDurabilitySchemaAndData = Schema and Data
FilterIsMemoryOptimized = Is Memory Optimized
FilterIsMemoryOptimizedDescription = Include or exclude objects based on whether the object is memory optimized.
FilterCreateDate = Create Date
FilterCreateDateDescription = Include or exclude objects based on their creation date.
FilterIsNativelyCompiled = Is Natively Compiled
FilterIsNativelyCompiledDescription = Include or exclude objects based on whether the object is natively compiled.
FilterInPrimaryKey = In Primary Key
FilterInPrimaryKeyDescription = Include or exclude objects based on whether the column is in a primary key.
############################################################################ ############################################################################
# Scripting Service # Scripting Service

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,9 @@
using System; using System;
using Microsoft.Data.SqlClient; using Microsoft.Data.SqlClient;
using System.Globalization; using System.Globalization;
using System.Text;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using SMO = Microsoft.SqlServer.Management.Smo; using SMO = Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.SqlCore.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Management namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
@@ -173,7 +173,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
string query = string.Format(CultureInfo.InvariantCulture, string query = string.Format(CultureInfo.InvariantCulture,
"select top 1 1 from [{0}].sys.filegroups where type = 'FX'", "select top 1 1 from [{0}].sys.filegroups where type = 'FX'",
CUtils.EscapeString(dbName, ']')); StringUtils.EscapeString(dbName, ']'));
if (server.ConnectionContext.ExecuteScalar(query) != null) if (server.ConnectionContext.ExecuteScalar(query) != null)
{ {
hasMemoryOptimizedFileGroup = true; hasMemoryOptimizedFileGroup = true;
@@ -552,101 +552,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
return sqlerror.Number; return sqlerror.Number;
} }
/// <summary>
/// Function doubles up specified character in a string
/// </summary>
/// <param name="s"></param>
/// <param name="cEsc"></param>
/// <returns></returns>
public static String EscapeString(string s, char cEsc)
{
if (string.IsNullOrWhiteSpace(s))
{
return s;
}
StringBuilder sb = new StringBuilder(s.Length * 2);
foreach (char c in s)
{
sb.Append(c);
if (cEsc == c)
sb.Append(c);
}
return sb.ToString();
}
/// <summary>
/// Function doubles up ']' character in a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String EscapeStringCBracket(string s)
{
return CUtils.EscapeString(s, ']');
}
/// <summary>
/// Function doubles up '\'' character in a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String EscapeStringSQuote(string s)
{
return CUtils.EscapeString(s, '\'');
}
/// <summary>
/// Function removes doubled up specified character from a string
/// </summary>
/// <param name="s"></param>
/// <param name="cEsc"></param>
/// <returns></returns>
public static String UnEscapeString(string s, char cEsc)
{
StringBuilder sb = new StringBuilder(s.Length);
bool foundBefore = false;
foreach (char c in s)
{
if (cEsc == c) // character to unescape
{
if (foundBefore) // skip second occurrence
{
foundBefore = false;
}
else // set the flag to skip next time around
{
sb.Append(c);
foundBefore = true;
}
}
else
{
sb.Append(c);
foundBefore = false;
}
}
return sb.ToString();
}
/// <summary>
/// Function removes doubled up ']' character from a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String UnEscapeStringCBracket(string s)
{
return CUtils.UnEscapeString(s, ']');
}
/// <summary>
/// Function removes doubled up '\'' character from a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String UnEscapeStringSQuote(string s)
{
return CUtils.UnEscapeString(s, '\'');
}
/// <summary> /// <summary>
/// Get the windows login name with the domain portion in all-caps /// Get the windows login name with the domain portion in all-caps

View File

@@ -6,6 +6,7 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts; using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.SqlCore.Metadata;
namespace Microsoft.SqlTools.ServiceLayer.Metadata.Contracts namespace Microsoft.SqlTools.ServiceLayer.Metadata.Contracts
{ {

View File

@@ -14,6 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Hosting; using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts; using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.SqlCore.Metadata;
namespace Microsoft.SqlTools.ServiceLayer.Metadata namespace Microsoft.SqlTools.ServiceLayer.Metadata
{ {

View File

@@ -11,9 +11,9 @@ using System.Data.Common;
using Microsoft.Data.SqlClient; using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection; using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters; using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters;
using Microsoft.SqlTools.SqlCore.Connection;
namespace Microsoft.SqlTools.ServiceLayer.Metadata namespace Microsoft.SqlTools.ServiceLayer.Metadata
{ {

View File

@@ -60,13 +60,13 @@
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" /> <ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
<ProjectReference Include="../Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj" /> <ProjectReference Include="../Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj" />
<ProjectReference Include="../Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj" /> <ProjectReference Include="../Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj" />
<ProjectReference Include="..\Microsoft.SqlTools.Authentication\Microsoft.SqlTools.Authentication.csproj" /> <ProjectReference Include="../Microsoft.SqlTools.Authentication/Microsoft.SqlTools.Authentication.csproj" />
<ProjectReference Include="../Microsoft.SqlTools.SqlCore/Microsoft.SqlTools.SqlCore.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\..\Notice.txt"> <Content Include="..\..\Notice.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<EmbeddedResource Include="ObjectExplorer\SmoModel\SmoTreeNodesDefinition.xml" />
<EmbeddedResource Include="Localization\*.resx" /> <EmbeddedResource Include="Localization\*.resx" />
<None Include="Localization\sr.strings" /> <None Include="Localization\sr.strings" />
</ItemGroup> </ItemGroup>

View File

@@ -5,9 +5,8 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.ServiceLayer.ModelManagement.Contracts; using Microsoft.SqlTools.ServiceLayer.ModelManagement.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.SqlCore.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -253,12 +252,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
private static string GetThreePartsTableName(string dbName, string tableName, string schemaName) private static string GetThreePartsTableName(string dbName, string tableName, string schemaName)
{ {
return $"[{CUtils.EscapeStringCBracket(dbName)}].[{CUtils.EscapeStringCBracket(schemaName)}].[{CUtils.EscapeStringCBracket(tableName)}]"; return $"[{StringUtils.EscapeStringCBracket(dbName)}].[{StringUtils.EscapeStringCBracket(schemaName)}].[{StringUtils.EscapeStringCBracket(tableName)}]";
} }
private static string GetTwoPartsTableName(string tableName, string schemaName) private static string GetTwoPartsTableName(string tableName, string schemaName)
{ {
return $"[{CUtils.EscapeStringCBracket(schemaName)}].[{CUtils.EscapeStringCBracket(tableName)}]"; return $"[{StringUtils.EscapeStringCBracket(schemaName)}].[{StringUtils.EscapeStringCBracket(tableName)}]";
} }
private static string GetSelectModelsQuery(string dbName, string tableName, string schemaName) private static string GetSelectModelsQuery(string dbName, string tableName, string schemaName)
@@ -272,24 +271,24 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
private static string GetConfigTableVerificationQuery(string dbName, string tableName, string schemaName) private static string GetConfigTableVerificationQuery(string dbName, string tableName, string schemaName)
{ {
string twoPartsTableName = GetTwoPartsTableName(CUtils.EscapeStringSQuote(tableName), CUtils.EscapeStringSQuote(schemaName)); string twoPartsTableName = GetTwoPartsTableName(StringUtils.EscapeStringSQuote(tableName), StringUtils.EscapeStringSQuote(schemaName));
return $@" return $@"
IF NOT EXISTS ( IF NOT EXISTS (
SELECT name SELECT name
FROM sys.databases FROM sys.databases
WHERE name = N'{CUtils.EscapeStringSQuote(dbName)}' WHERE name = N'{StringUtils.EscapeStringSQuote(dbName)}'
) )
BEGIN BEGIN
SELECT 0 SELECT 0
END END
ELSE ELSE
BEGIN BEGIN
USE [{CUtils.EscapeStringCBracket(dbName)}] USE [{StringUtils.EscapeStringCBracket(dbName)}]
IF EXISTS IF EXISTS
( SELECT t.name, s.name ( SELECT t.name, s.name
FROM sys.tables t join sys.schemas s on t.schema_id=t.schema_id FROM sys.tables t join sys.schemas s on t.schema_id=t.schema_id
WHERE t.name = '{CUtils.EscapeStringSQuote(tableName)}' WHERE t.name = '{StringUtils.EscapeStringSQuote(tableName)}'
AND s.name = '{CUtils.EscapeStringSQuote(schemaName)}' AND s.name = '{StringUtils.EscapeStringSQuote(schemaName)}'
) )
BEGIN BEGIN
IF EXISTS (SELECT * FROM syscolumns WHERE ID=OBJECT_ID('{twoPartsTableName}') AND NAME='model_name') IF EXISTS (SELECT * FROM syscolumns WHERE ID=OBJECT_ID('{twoPartsTableName}') AND NAME='model_name')
@@ -323,8 +322,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
IF NOT EXISTS IF NOT EXISTS
( SELECT t.name, s.name ( SELECT t.name, s.name
FROM sys.tables t join sys.schemas s on t.schema_id=t.schema_id FROM sys.tables t join sys.schemas s on t.schema_id=t.schema_id
WHERE t.name = '{CUtils.EscapeStringSQuote(tableName)}' WHERE t.name = '{StringUtils.EscapeStringSQuote(tableName)}'
AND s.name = '{CUtils.EscapeStringSQuote(schemaName)}' AND s.name = '{StringUtils.EscapeStringSQuote(schemaName)}'
) )
BEGIN BEGIN
CREATE TABLE {GetTwoPartsTableName(tableName, schemaName)} ( CREATE TABLE {GetTwoPartsTableName(tableName, schemaName)} (
@@ -339,12 +338,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
[deployed_by] [int] NULL, [deployed_by] [int] NULL,
[model_description] [varchar](256) NULL, [model_description] [varchar](256) NULL,
[run_id] [varchar](256) NULL, [run_id] [varchar](256) NULL,
CONSTRAINT [{CUtils.EscapeStringCBracket(tableName)}_models_pk] PRIMARY KEY CLUSTERED CONSTRAINT [{StringUtils.EscapeStringCBracket(tableName)}_models_pk] PRIMARY KEY CLUSTERED
( (
[model_id] ASC [model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
ALTER TABLE {GetTwoPartsTableName(tableName, schemaName)} ADD CONSTRAINT [{CUtils.EscapeStringCBracket(tableName)}_deployment_time] DEFAULT (getdate()) FOR [model_deployment_time] ALTER TABLE {GetTwoPartsTableName(tableName, schemaName)} ADD CONSTRAINT [{StringUtils.EscapeStringCBracket(tableName)}_deployment_time] DEFAULT (getdate()) FOR [model_deployment_time]
END END
"; ";
} }
@@ -357,14 +356,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
INSERT INTO {twoPartsTableName} INSERT INTO {twoPartsTableName}
(model_name, model, model_version, model_description, model_creation_time, model_framework, model_framework_version, run_id, deployed_by) (model_name, model, model_version, model_description, model_creation_time, model_framework, model_framework_version, run_id, deployed_by)
VALUES ( VALUES (
{DatabaseUtils.AddStringParameterForInsert(model.ModelName ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.ModelName ?? "")},
{DatabaseUtils.AddByteArrayParameterForInsert("Content", model.FilePath ?? "", parameters)}, {Utility.DatabaseUtils.AddByteArrayParameterForInsert("Content", model.FilePath ?? "", parameters)},
{DatabaseUtils.AddStringParameterForInsert(model.Version ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.Version ?? "")},
{DatabaseUtils.AddStringParameterForInsert(model.Description ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.Description ?? "")},
{DatabaseUtils.AddStringParameterForInsert(model.Created)}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.Created)},
{DatabaseUtils.AddStringParameterForInsert(model.Framework ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.Framework ?? "")},
{DatabaseUtils.AddStringParameterForInsert(model.FrameworkVersion ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.FrameworkVersion ?? "")},
{DatabaseUtils.AddStringParameterForInsert(model.RunId ?? "")}, {Utility.DatabaseUtils.AddStringParameterForInsert(model.RunId ?? "")},
USER_ID (Current_User) USER_ID (Current_User)
) )
"; ";
@@ -378,13 +377,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
return $@" return $@"
UPDATE {twoPartsTableName} UPDATE {twoPartsTableName}
SET SET
{DatabaseUtils.AddStringParameterForUpdate("model_name", model.ModelName ?? "")}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_name", model.ModelName ?? "")},
{DatabaseUtils.AddStringParameterForUpdate("model_version", model.Version ?? "")}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_version", model.Version ?? "")},
{DatabaseUtils.AddStringParameterForUpdate("model_description", model.Description ?? "")}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_description", model.Description ?? "")},
{DatabaseUtils.AddStringParameterForUpdate("model_creation_time", model.Created)}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_creation_time", model.Created)},
{DatabaseUtils.AddStringParameterForUpdate("model_framework", model.Framework ?? "")}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_framework", model.Framework ?? "")},
{DatabaseUtils.AddStringParameterForUpdate("model_framework_version", model.FrameworkVersion ?? "")}, {Utility.DatabaseUtils.AddStringParameterForUpdate("model_framework_version", model.FrameworkVersion ?? "")},
{DatabaseUtils.AddStringParameterForUpdate("run_id", model.RunId ?? "")} {Utility.DatabaseUtils.AddStringParameterForUpdate("run_id", model.RunId ?? "")}
WHERE model_id = @{ModelIdParameterName} WHERE model_id = @{ModelIdParameterName}
"; ";

View File

@@ -6,7 +6,7 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts; using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.SqlCore.Connection;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
{ {

View File

@@ -5,7 +5,10 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts; using System;
using System.Collections.Generic;
using Microsoft.SqlTools.SqlCore.Metadata;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
@@ -76,6 +79,25 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
/// Filterable properties that this node supports /// Filterable properties that this node supports
/// </summary> /// </summary>
public NodeFilterProperty[] FilterableProperties { get; set; } public NodeFilterProperty[] FilterableProperties { get; set; }
public NodeInfo()
{
}
public NodeInfo(TreeNode treeNode)
{
IsLeaf = treeNode.IsAlwaysLeaf;
Label = treeNode.Label;
NodePath = treeNode.GetNodePath();
ParentNodePath = treeNode.Parent?.GetNodePath() ?? string.Empty;
NodeType = treeNode.NodeType;
Metadata = treeNode.ObjectMetadata;
NodeStatus = treeNode.NodeStatus;
NodeSubType = treeNode.NodeSubType;
ErrorMessage = treeNode.ErrorMessage;
ObjectType = treeNode.NodeTypeId.ToString();
FilterableProperties = treeNode.FilterProperties;
}
} }
/// <summary> /// <summary>
@@ -103,45 +125,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
} }
} }
/// <summary>
/// The filterable properties that a node supports
/// </summary>
public class NodeFilterProperty
{
/// <summary>
/// The name of the filter property
/// </summary>
public string Name { get; set; }
/// <summary>
/// The name of the filter property displayed to the user
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// The description of the filter property
/// </summary>
public string Description { get; set; }
/// <summary>
/// The data type of the filter property
/// </summary>
public NodeFilterPropertyDataType Type { get; set; }
/// <summary>
/// The list of choices for the filter property if the type is choice
/// </summary>
public NodeFilterPropertyChoice[] Choices { get; set; }
}
/// <summary>
/// The data type of the filter property. Matches NodeFilterPropertyDataType enum in ADS : https://github.com/microsoft/azuredatastudio/blob/main/src/sql/azdata.proposed.d.ts#L1847-L1853
/// </summary>
public enum NodeFilterPropertyDataType
{
String = 0,
Number = 1,
Boolean = 2,
Date = 3,
Choice = 4
}
/// <summary> /// <summary>
/// The operator of the filter property. Matches NodeFilterOperator enum in ADS: https://github.com/microsoft/azuredatastudio/blob/main/src/sql/azdata.proposed.d.ts#L1855-L1868 /// The operator of the filter property. Matches NodeFilterOperator enum in ADS: https://github.com/microsoft/azuredatastudio/blob/main/src/sql/azdata.proposed.d.ts#L1855-L1868
/// </summary> /// </summary>
@@ -182,22 +165,109 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
/// The applied values of the filter property /// The applied values of the filter property
/// </summary> /// </summary>
public JToken Value { get; set; } public JToken Value { get; set; }
}
/// <summary>
/// The choice for the filter property if the type is choice
/// </summary>
public class NodeFilterPropertyChoice
{
/// <summary>
/// The dropdown display value for the choice
/// </summary>
/// <value></value>
public string DisplayName { get; set; }
/// <summary> public INodeFilter ToINodeFilter(NodeFilterProperty filterProperty)
/// The value of the choice {
/// </summary> Type type = typeof(string);
public string Value { get; set; }
var IsDateTime = filterProperty.Type == NodeFilterPropertyDataType.Date;
FilterType filterType = FilterType.EQUALS;
bool isNotFilter = false;
object filterValue = null;
switch (filterProperty.Type)
{
case NodeFilterPropertyDataType.String:
case NodeFilterPropertyDataType.Date:
case NodeFilterPropertyDataType.Choice:
type = typeof(string);
filterValue = this.Value.ToString();
break;
case NodeFilterPropertyDataType.Number:
type = typeof(int);
filterValue = this.Value.ToObject<int>();
break;
case NodeFilterPropertyDataType.Boolean:
type = typeof(bool);
filterValue = this.Value.ToObject<bool>() ? 1 : 0;
break;
}
switch (this.Operator)
{
case NodeFilterOperator.Equals:
filterType = FilterType.EQUALS;
break;
case NodeFilterOperator.NotEquals:
filterType = FilterType.EQUALS;
isNotFilter = true;
break;
case NodeFilterOperator.LessThan:
filterType = FilterType.LESSTHAN;
break;
case NodeFilterOperator.LessThanOrEquals:
filterType = FilterType.LESSTHANOREQUAL;
break;
case NodeFilterOperator.GreaterThan:
filterType = FilterType.GREATERTHAN;
break;
case NodeFilterOperator.GreaterThanOrEquals:
filterType = FilterType.GREATERTHANOREQUAL;
break;
case NodeFilterOperator.Between:
filterType = FilterType.BETWEEN;
break;
case NodeFilterOperator.NotBetween:
filterType = FilterType.NOTBETWEEN;
isNotFilter = true;
break;
case NodeFilterOperator.Contains:
filterType = FilterType.CONTAINS;
break;
case NodeFilterOperator.NotContains:
filterType = FilterType.CONTAINS;
isNotFilter = true;
break;
case NodeFilterOperator.StartsWith:
filterType = FilterType.STARTSWITH;
break;
case NodeFilterOperator.NotStartsWith:
filterType = FilterType.STARTSWITH;
isNotFilter = true;
break;
case NodeFilterOperator.EndsWith:
filterType = FilterType.ENDSWITH;
break;
case NodeFilterOperator.NotEndsWith:
filterType = FilterType.ENDSWITH;
isNotFilter = true;
break;
}
if (this.Operator == NodeFilterOperator.Between || this.Operator == NodeFilterOperator.NotBetween)
{
if (filterProperty.Type == NodeFilterPropertyDataType.Number)
{
filterValue = this.Value.ToObject<int[]>();
}
else if (filterProperty.Type == NodeFilterPropertyDataType.Date)
{
filterValue = this.Value.ToObject<string[]>();
}
}
return new NodePropertyFilter
{
Property = filterProperty.Name,
Type = type,
Values = new List<object> { filterValue },
IsNotFilter = isNotFilter,
FilterType = filterType,
IsDateTime = IsDateTime
};
}
} }
} }

View File

@@ -23,12 +23,14 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.LanguageServices; using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.TableDesigner; using Microsoft.SqlTools.ServiceLayer.TableDesigner;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace; using Microsoft.SqlTools.ServiceLayer.Workspace;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
@@ -46,7 +48,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
private ConnectionService connectionService; private ConnectionService connectionService;
private IProtocolEndpoint serviceHost; private IProtocolEndpoint serviceHost;
private ConcurrentDictionary<string, ObjectExplorerSession> sessionMap; private ConcurrentDictionary<string, ObjectExplorerSession> sessionMap;
private readonly Lazy<Dictionary<string, HashSet<ChildFactory>>> applicableNodeChildFactories;
private IMultiServiceProvider serviceProvider; private IMultiServiceProvider serviceProvider;
private ConnectedBindingQueue bindingQueue = new ConnectedBindingQueue(needsMetadata: false); private ConnectedBindingQueue bindingQueue = new ConnectedBindingQueue(needsMetadata: false);
private string connectionName = "ObjectExplorer"; private string connectionName = "ObjectExplorer";
@@ -62,7 +63,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
public ObjectExplorerService() public ObjectExplorerService()
{ {
sessionMap = new ConcurrentDictionary<string, ObjectExplorerSession>(); sessionMap = new ConcurrentDictionary<string, ObjectExplorerSession>();
applicableNodeChildFactories = new Lazy<Dictionary<string, HashSet<ChildFactory>>>(PopulateFactories);
NodePathGenerator.Initialize(); NodePathGenerator.Initialize();
} }
@@ -78,14 +78,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
} }
} }
private Dictionary<string, HashSet<ChildFactory>> ApplicableNodeChildFactories
{
get
{
return applicableNodeChildFactories.Value;
}
}
/// <summary> /// <summary>
/// Returns the session ids /// Returns the session ids
/// </summary> /// </summary>
@@ -286,7 +278,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames); var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames);
foundNodes ??= new List<TreeNode>(); foundNodes ??= new List<TreeNode>();
await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() }); await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => new NodeInfo(node)).ToList() });
} }
internal void CloseSession(string uri) internal void CloseSession(string uri)
@@ -365,7 +357,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
response = new SessionCreatedParameters response = new SessionCreatedParameters
{ {
Success = true, Success = true,
RootNode = session.Root.ToNodeInfo(), RootNode = new NodeInfo(session.Root),
SessionId = uri, SessionId = uri,
ErrorNumber = session.ErrorNumber, ErrorNumber = session.ErrorNumber,
ErrorMessage = session.ErrorMessage ErrorMessage = session.ErrorMessage
@@ -444,17 +436,30 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
securityToken = null; securityToken = null;
} }
var filterDefinitions = node.FilterProperties;
var appliedFilters = new List<INodeFilter>();
if (filters != null)
{
foreach (var f in filters)
{
NodeFilterProperty filterProperty = filterDefinitions.FirstOrDefault(x => x.Name == f.Name);
appliedFilters.Add(f.ToINodeFilter(filterProperty));
}
}
if (forceRefresh) if (forceRefresh)
{ {
Logger.Verbose($"Forcing refresh for {nodePath}"); Logger.Verbose($"Forcing refresh for {nodePath}");
nodes = node.Refresh(cancelToken, securityToken?.Token, filters).Select(x => x.ToNodeInfo()).ToArray(); nodes = node.Refresh(cancelToken, securityToken?.Token, appliedFilters).Select(x => new NodeInfo(x)).ToArray();
} }
else else
{ {
Logger.Verbose($"Expanding {nodePath}"); Logger.Verbose($"Expanding {nodePath}");
try try
{ {
nodes = node.Expand(cancelToken, securityToken?.Token, filters).Select(x => x.ToNodeInfo()).ToArray(); nodes = node.Expand(cancelToken, securityToken?.Token, appliedFilters).Select(x => new NodeInfo(x)).ToArray();
} }
catch (ConnectionFailureException ex) catch (ConnectionFailureException ex)
{ {
@@ -534,7 +539,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
waitForLockTimeout: timeout, waitForLockTimeout: timeout,
bindOperation: (bindingContext, cancelToken) => bindOperation: (bindingContext, cancelToken) =>
{ {
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection, isDefaultOrSystemDatabase); session = ObjectExplorerSession.CreateSession(connectionResult, bindingContext.ServerConnection, isDefaultOrSystemDatabase, serviceProvider, () =>
{
return WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema;
});
session.ConnectionInfo = connectionInfo; session.ConnectionInfo = connectionInfo;
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session); sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
@@ -687,39 +695,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
return ConnectedBindingQueue.GetConnectionContextKey(details); return ConnectedBindingQueue.GetConnectionContextKey(details);
} }
public IEnumerable<ChildFactory> GetApplicableChildFactories(TreeNode item)
{
if (ApplicableNodeChildFactories != null)
{
HashSet<ChildFactory> applicableFactories;
if (ApplicableNodeChildFactories.TryGetValue(item.NodeTypeId.ToString(), out applicableFactories))
{
return applicableFactories;
}
}
return null;
}
internal Dictionary<string, HashSet<ChildFactory>> PopulateFactories()
{
VerifyServicesInitialized();
var childFactories = new Dictionary<string, HashSet<ChildFactory>>();
// Create our list of all NodeType to ChildFactory objects so we can expand appropriately
foreach (var factory in serviceProvider.GetServices<ChildFactory>())
{
var parents = factory.ApplicableParents();
if (parents != null)
{
foreach (var parent in parents)
{
AddToApplicableChildFactories(childFactories, factory, parent);
}
}
}
return childFactories;
}
private void VerifyServicesInitialized() private void VerifyServicesInitialized()
{ {
if (serviceProvider == null) if (serviceProvider == null)
@@ -821,27 +796,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
return string.Empty; return string.Empty;
} }
internal class ObjectExplorerSession internal class ObjectExplorerSession : IObjectExplorerSession
{ {
private ConnectionService connectionService;
private IMultiServiceProvider serviceProvider;
// TODO decide whether a cache is needed to handle lookups in elements with a large # children // TODO decide whether a cache is needed to handle lookups in elements with a large # children
//private const int Cachesize = 10000; //private const int Cachesize = 10000;
//private Cache<string, NodeMapping> cache; //private Cache<string, NodeMapping> cache;
public ObjectExplorerSession(string uri, TreeNode root, IMultiServiceProvider serviceProvider, ConnectionService connectionService) public ObjectExplorerSession(string uri, TreeNode root)
{ {
Validate.IsNotNullOrEmptyString("uri", uri); Validate.IsNotNullOrEmptyString("uri", uri);
Validate.IsNotNull("root", root); Validate.IsNotNull("root", root);
Uri = uri; Uri = uri;
Root = root; Root = root;
this.serviceProvider = serviceProvider;
this.connectionService = connectionService;
} }
public string Uri { get; private set; } public string Uri { get; private set; }
public TreeNode Root { get; private set; }
public ConnectionInfo ConnectionInfo { get; set; } public ConnectionInfo ConnectionInfo { get; set; }
@@ -849,10 +818,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection, bool isDefaultOrSystemDatabase) public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, ServerConnection serverConnection, bool isDefaultOrSystemDatabase, IMultiServiceProvider serviceProvider, Func<bool> groupBySchemaFlagGetter)
{ {
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection); ServerNode rootNode = new ServerNode(new ObjectExplorerServerInfo()
var session = new ObjectExplorerSession(response.OwnerUri, rootNode, serviceProvider, serviceProvider.GetService<ConnectionService>()); {
ServerName = response.ConnectionSummary.ServerName,
DatabaseName = response.ConnectionSummary.DatabaseName,
UserName = response.ConnectionSummary.UserName,
ServerVersion = response.ServerInfo.ServerVersion,
EngineEditionId = response.ServerInfo.EngineEditionId,
IsCloud = response.ServerInfo.IsCloud,
}, serverConnection, serviceProvider, () =>
{
return WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema;
});
var session = new ObjectExplorerSession(response.OwnerUri, rootNode);
if (!isDefaultOrSystemDatabase) if (!isDefaultOrSystemDatabase)
{ {
// Assuming the databases are in a folder under server node // Assuming the databases are in a folder under server node

View File

@@ -7,9 +7,7 @@
using System; using System;
using System.Threading; using System.Threading;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using System.Collections.Generic;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
{ {
@@ -53,7 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
/// determines whether to stop going further up the tree</param> /// determines whether to stop going further up the tree</param>
/// <param name="filter">Predicate function to filter the children when traversing</param> /// <param name="filter">Predicate function to filter the children when traversing</param>
/// <returns>A Tree Node that matches the condition, or null if no matching node could be found</returns> /// <returns>A Tree Node that matches the condition, or null if no matching node could be found</returns>
public static TreeNode? FindNode(TreeNode node, Predicate<TreeNode> condition, Predicate<TreeNode> filter, bool expandIfNeeded = false) public static TreeNode? FindNode(TreeNode node, Predicate<TreeNode> condition, Predicate<TreeNode> filter, bool expandIfNeeded = false, CancellationToken cancellationToken = new CancellationToken())
{ {
if (node == null) if (node == null)
{ {
@@ -64,7 +62,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
{ {
return node; return node;
} }
var children = expandIfNeeded && !node.IsAlwaysLeaf ? node.Expand(new CancellationToken()) : node.GetChildren(); var children = expandIfNeeded && !node.IsAlwaysLeaf ? node.Expand(cancellationToken) : node.GetChildren();
foreach (var child in children) foreach (var child in children)
{ {
if (filter != null && filter(child)) if (filter != null && filter(child))
@@ -78,108 +76,5 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
} }
return null; return null;
} }
public static INodeFilter ConvertExpandNodeFilterToNodeFilter(NodeFilter filter, NodeFilterProperty filterProperty)
{
Type type = typeof(string);
var IsDateTime = filterProperty.Type == NodeFilterPropertyDataType.Date;
FilterType filterType = FilterType.EQUALS;
bool isNotFilter = false;
object filterValue = null;
switch (filterProperty.Type)
{
case NodeFilterPropertyDataType.String:
case NodeFilterPropertyDataType.Date:
case NodeFilterPropertyDataType.Choice:
type = typeof(string);
filterValue = filter.Value.ToString();
break;
case NodeFilterPropertyDataType.Number:
type = typeof(int);
filterValue = filter.Value.ToObject<int>();
break;
case NodeFilterPropertyDataType.Boolean:
type = typeof(bool);
filterValue = filter.Value.ToObject<bool>() ? 1 : 0;
break;
}
switch (filter.Operator)
{
case NodeFilterOperator.Equals:
filterType = FilterType.EQUALS;
break;
case NodeFilterOperator.NotEquals:
filterType = FilterType.EQUALS;
isNotFilter = true;
break;
case NodeFilterOperator.LessThan:
filterType = FilterType.LESSTHAN;
break;
case NodeFilterOperator.LessThanOrEquals:
filterType = FilterType.LESSTHANOREQUAL;
break;
case NodeFilterOperator.GreaterThan:
filterType = FilterType.GREATERTHAN;
break;
case NodeFilterOperator.GreaterThanOrEquals:
filterType = FilterType.GREATERTHANOREQUAL;
break;
case NodeFilterOperator.Between:
filterType = FilterType.BETWEEN;
break;
case NodeFilterOperator.NotBetween:
filterType = FilterType.NOTBETWEEN;
isNotFilter = true;
break;
case NodeFilterOperator.Contains:
filterType = FilterType.CONTAINS;
break;
case NodeFilterOperator.NotContains:
filterType = FilterType.CONTAINS;
isNotFilter = true;
break;
case NodeFilterOperator.StartsWith:
filterType = FilterType.STARTSWITH;
break;
case NodeFilterOperator.NotStartsWith:
filterType = FilterType.STARTSWITH;
isNotFilter = true;
break;
case NodeFilterOperator.EndsWith:
filterType = FilterType.ENDSWITH;
break;
case NodeFilterOperator.NotEndsWith:
filterType = FilterType.ENDSWITH;
isNotFilter = true;
break;
}
if (filter.Operator == NodeFilterOperator.Between || filter.Operator == NodeFilterOperator.NotBetween)
{
if (filterProperty.Type == NodeFilterPropertyDataType.Number)
{
filterValue = filter.Value.ToObject<int[]>();
}
else if (filterProperty.Type == NodeFilterPropertyDataType.Date)
{
filterValue = filter.Value.ToObject<string[]>();
}
}
return new NodePropertyFilter
{
Property = filterProperty.Name,
Type = type,
Values = new List<object> { filterValue },
IsNotFilter = isNotFilter,
FilterType = filterType,
IsDateTime = IsDateTime
};
}
} }
} }

View File

@@ -20,6 +20,7 @@ using Microsoft.SqlTools.Utility;
using System.Text; using System.Text;
using System.IO; using System.IO;
using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters; using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters;
using Microsoft.SqlTools.SqlCore.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{ {
@@ -529,7 +530,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
// Update database file names now that we have a database name // Update database file names now that we have a database name
if (viewParams.IsNewObject && !prototype.HideFileSettings) if (viewParams.IsNewObject && !prototype.HideFileSettings)
{ {
var sanitizedName = DatabaseUtils.SanitizeDatabaseFileName(prototype.Name); var sanitizedName = Utility.DatabaseUtils.SanitizeDatabaseFileName(prototype.Name);
var dataFile = prototype.Files[0]; var dataFile = prototype.Files[0];
if (dataFile.DatabaseFileType != FileType.Data) if (dataFile.DatabaseFileType != FileType.Data)

View File

@@ -7,18 +7,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Data.SqlClient;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.Utility;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Text;
using System.Globalization; using System.Globalization;
using Microsoft.SqlServer.Management.SqlScriptPublish; using System.Text;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.SqlScriptPublish;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.SqlCore.Utility;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Scripting namespace Microsoft.SqlTools.ServiceLayer.Scripting
{ {

View File

@@ -5,14 +5,14 @@
#nullable disable #nullable disable
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.Utility;
using System; using System;
using Microsoft.Data.SqlClient;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.Utility;
using static Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptOptions; using static Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptOptions;
namespace Microsoft.SqlTools.ServiceLayer.Scripting namespace Microsoft.SqlTools.ServiceLayer.Scripting

View File

@@ -9,9 +9,9 @@ using System;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.ServiceLayer.SqlAssessment.Contracts; using Microsoft.SqlTools.ServiceLayer.SqlAssessment.Contracts;
using Microsoft.SqlTools.ServiceLayer.TaskServices; using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.SqlCore.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.SqlAssessment namespace Microsoft.SqlTools.ServiceLayer.SqlAssessment
@@ -129,7 +129,7 @@ INSERT INTO [dbo].[AssessmentResult] ([CheckName],[CheckId],[RulesetName],[Rules
{ {
sb.Append( sb.Append(
$@" $@"
('{CUtils.EscapeStringSQuote(item.DisplayName)}','{CUtils.EscapeStringSQuote(item.CheckId)}','{CUtils.EscapeStringSQuote(item.RulesetName)}','{item.RulesetVersion}','{item.Level}','{CUtils.EscapeStringSQuote(item.Message)}','{CUtils.EscapeStringSQuote(item.TargetName)}','{item.TargetType}','{CUtils.EscapeStringSQuote(item.HelpLink)}','{item.Timestamp:yyyy-MM-dd hh:mm:ss.fff zzz}'),"); ('{StringUtils.EscapeStringSQuote(item.DisplayName)}','{StringUtils.EscapeStringSQuote(item.CheckId)}','{StringUtils.EscapeStringSQuote(item.RulesetName)}','{item.RulesetVersion}','{item.Level}','{StringUtils.EscapeStringSQuote(item.Message)}','{StringUtils.EscapeStringSQuote(item.TargetName)}','{item.TargetType}','{StringUtils.EscapeStringSQuote(item.HelpLink)}','{item.Timestamp:yyyy-MM-dd hh:mm:ss.fff zzz}'),");
} }
} }

View File

@@ -10,6 +10,7 @@ using Microsoft.SqlServer.Management.Dmf;
using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Management; using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.SqlCore.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -37,13 +38,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
public static string AddStringParameterForInsert(string paramValue) public static string AddStringParameterForInsert(string paramValue)
{ {
string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : CUtils.EscapeStringSQuote(paramValue); string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : StringUtils.EscapeStringSQuote(paramValue);
return $"'{value}'"; return $"'{value}'";
} }
public static string AddStringParameterForUpdate(string columnName, string paramValue) public static string AddStringParameterForUpdate(string columnName, string paramValue)
{ {
string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : CUtils.EscapeStringSQuote(paramValue); string value = string.IsNullOrWhiteSpace(paramValue) ? paramValue : StringUtils.EscapeStringSQuote(paramValue);
return $"{columnName} = N'{value}'"; return $"{columnName} = N'{value}'";
} }

View File

@@ -0,0 +1,32 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using Microsoft.SqlServer.Management.Common;
namespace Microsoft.SqlTools.SqlCore.Connection
{
public class AzureAccessToken : IRenewableToken
{
public DateTimeOffset TokenExpiry { get; set; }
public string Resource { get; set; }
public string Tenant { get; set; }
public string UserId { get; set; }
private string accessToken;
public AzureAccessToken(string accessToken)
{
this.accessToken = accessToken;
}
public string GetAccessToken()
{
return this.accessToken;
}
}
}

View File

@@ -3,9 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable namespace Microsoft.SqlTools.SqlCore.Connection
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
{ {
public class SecurityToken public class SecurityToken
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,968 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype=">text/microsoft-resx</resheader>
<resheader name="version=">2.0</resheader>
<resheader name="reader=">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer=">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1="><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing=">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64=">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64=">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata=">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true=">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TreeNodeError" xml:space="preserve">
<value>Error expanding: {0}</value>
<comment></comment>
</data>
<data name="ServerNodeConnectionError" xml:space="preserve">
<value>Error connecting to {0}</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Aggregates" xml:space="preserve">
<value>Aggregates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRoles" xml:space="preserve">
<value>Server Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ApplicationRoles" xml:space="preserve">
<value>Application Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Assemblies" xml:space="preserve">
<value>Assemblies</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AssemblyFiles" xml:space="preserve">
<value>Assembly Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AsymmetricKeys" xml:space="preserve">
<value>Asymmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseAsymmetricKeys" xml:space="preserve">
<value>Asymmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DataCompressionOptions" xml:space="preserve">
<value>Data Compression Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Certificates" xml:space="preserve">
<value>Certificates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FileTables" xml:space="preserve">
<value>FileTables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseCertificates" xml:space="preserve">
<value>Certificates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_CheckConstraints" xml:space="preserve">
<value>Check Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Columns" xml:space="preserve">
<value>Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Constraints" xml:space="preserve">
<value>Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Contracts" xml:space="preserve">
<value>Contracts</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Credentials" xml:space="preserve">
<value>Credentials</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ErrorMessages" xml:space="preserve">
<value>Error Messages</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRoleMembership" xml:space="preserve">
<value>Server Role Membership</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseOptions" xml:space="preserve">
<value>Database Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseRoles" xml:space="preserve">
<value>Database Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_RoleMemberships" xml:space="preserve">
<value>Role Memberships</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseTriggers" xml:space="preserve">
<value>Database Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DefaultConstraints" xml:space="preserve">
<value>Default Constraints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Defaults" xml:space="preserve">
<value>Defaults</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Sequences" xml:space="preserve">
<value>Sequences</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Endpoints" xml:space="preserve">
<value>Endpoints</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_EventNotifications" xml:space="preserve">
<value>Event Notifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerEventNotifications" xml:space="preserve">
<value>Server Event Notifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExtendedProperties" xml:space="preserve">
<value>Extended Properties</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FileGroups" xml:space="preserve">
<value>Filegroups</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ForeignKeys" xml:space="preserve">
<value>Foreign Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextCatalogs" xml:space="preserve">
<value>Full-Text Catalogs</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextIndexes" xml:space="preserve">
<value>Full-Text Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Functions" xml:space="preserve">
<value>Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Indexes" xml:space="preserve">
<value>Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_InlineFunctions" xml:space="preserve">
<value>Inline Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Keys" xml:space="preserve">
<value>Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_LinkedServers" xml:space="preserve">
<value>Linked Servers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Logins" xml:space="preserve">
<value>Logins</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MasterKey" xml:space="preserve">
<value>Master Key</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MasterKeys" xml:space="preserve">
<value>Master Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MessageTypes" xml:space="preserve">
<value>Message Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_MultiSelectFunctions" xml:space="preserve">
<value>Table-Valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Parameters" xml:space="preserve">
<value>Parameters</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PartitionFunctions" xml:space="preserve">
<value>Partition Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PartitionSchemes" xml:space="preserve">
<value>Partition Schemes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Permissions" xml:space="preserve">
<value>Permissions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_PrimaryKeys" xml:space="preserve">
<value>Primary Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Programmability" xml:space="preserve">
<value>Programmability</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Queues" xml:space="preserve">
<value>Queues</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_RemoteServiceBindings" xml:space="preserve">
<value>Remote Service Bindings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ReturnedColumns" xml:space="preserve">
<value>Returned Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Roles" xml:space="preserve">
<value>Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Routes" xml:space="preserve">
<value>Routes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Rules" xml:space="preserve">
<value>Rules</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Schemas" xml:space="preserve">
<value>Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInSchema" xml:space="preserve">
<value>Built-in Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Security" xml:space="preserve">
<value>Security</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerObjects" xml:space="preserve">
<value>Server Objects</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Management" xml:space="preserve">
<value>Management</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerTriggers" xml:space="preserve">
<value>Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServiceBroker" xml:space="preserve">
<value>Service Broker</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Services" xml:space="preserve">
<value>Services</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Signatures" xml:space="preserve">
<value>Signatures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_LogFiles" xml:space="preserve">
<value>Log Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Statistics" xml:space="preserve">
<value>Statistics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Storage" xml:space="preserve">
<value>Storage</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_StoredProcedures" xml:space="preserve">
<value>Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SymmetricKeys" xml:space="preserve">
<value>Symmetric Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Synonyms" xml:space="preserve">
<value>Synonyms</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Tables" xml:space="preserve">
<value>Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Triggers" xml:space="preserve">
<value>Triggers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Types" xml:space="preserve">
<value>Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UniqueKeys" xml:space="preserve">
<value>Unique Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedDataTypes" xml:space="preserve">
<value>User-Defined Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedTypes" xml:space="preserve">
<value>User-Defined Types (CLR)</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Users" xml:space="preserve">
<value>Users</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Views" xml:space="preserve">
<value>Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlIndexes" xml:space="preserve">
<value>XML Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XMLSchemaCollections" xml:space="preserve">
<value>XML Schema Collections</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserDefinedTableTypes" xml:space="preserve">
<value>User-Defined Table Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FilegroupFiles" xml:space="preserve">
<value>Files</value>
<comment></comment>
</data>
<data name="MissingCaption" xml:space="preserve">
<value>Missing Caption</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BrokerPriorities" xml:space="preserve">
<value>Broker Priorities</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_CryptographicProviders" xml:space="preserve">
<value>Cryptographic Providers</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseAuditSpecifications" xml:space="preserve">
<value>Database Audit Specifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseEncryptionKeys" xml:space="preserve">
<value>Database Encryption Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_EventSessions" xml:space="preserve">
<value>Event Sessions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_FullTextStopLists" xml:space="preserve">
<value>Full Text Stoplists</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ResourcePools" xml:space="preserve">
<value>Resource Pools</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerAudits" xml:space="preserve">
<value>Audits</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerAuditSpecifications" xml:space="preserve">
<value>Server Audit Specifications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SpatialIndexes" xml:space="preserve">
<value>Spatial Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_WorkloadGroups" xml:space="preserve">
<value>Workload Groups</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlFiles" xml:space="preserve">
<value>SQL Files</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerFunctions" xml:space="preserve">
<value>Server Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlType" xml:space="preserve">
<value>SQL Type</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerOptions" xml:space="preserve">
<value>Server Options</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseDiagrams" xml:space="preserve">
<value>Database Diagrams</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemTables" xml:space="preserve">
<value>System Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Databases" xml:space="preserve">
<value>Databases</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemContracts" xml:space="preserve">
<value>System Contracts</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDatabases" xml:space="preserve">
<value>System Databases</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMessageTypes" xml:space="preserve">
<value>System Message Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemQueues" xml:space="preserve">
<value>System Queues</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemServices" xml:space="preserve">
<value>System Services</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemStoredProcedures" xml:space="preserve">
<value>System Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemViews" xml:space="preserve">
<value>System Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DataTierApplications" xml:space="preserve">
<value>Data-tier Applications</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExtendedStoredProcedures" xml:space="preserve">
<value>Extended Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemAggregateFunctions" xml:space="preserve">
<value>Aggregate Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemApproximateNumerics" xml:space="preserve">
<value>Approximate Numerics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemBinaryStrings" xml:space="preserve">
<value>Binary Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCharacterStrings" xml:space="preserve">
<value>Character Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCLRDataTypes" xml:space="preserve">
<value>CLR Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemConfigurationFunctions" xml:space="preserve">
<value>Configuration Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemCursorFunctions" xml:space="preserve">
<value>Cursor Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDataTypes" xml:space="preserve">
<value>System Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDateAndTime" xml:space="preserve">
<value>Date and Time</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemDateAndTimeFunctions" xml:space="preserve">
<value>Date and Time Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemExactNumerics" xml:space="preserve">
<value>Exact Numerics</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemFunctions" xml:space="preserve">
<value>System Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemHierarchyIdFunctions" xml:space="preserve">
<value>Hierarchy Id Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMathematicalFunctions" xml:space="preserve">
<value>Mathematical Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemMetadataFunctions" xml:space="preserve">
<value>Metadata Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemOtherDataTypes" xml:space="preserve">
<value>Other Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemOtherFunctions" xml:space="preserve">
<value>Other Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemRowsetFunctions" xml:space="preserve">
<value>Rowset Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSecurityFunctions" xml:space="preserve">
<value>Security Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSpatialDataTypes" xml:space="preserve">
<value>Spatial Data Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemStringFunctions" xml:space="preserve">
<value>String Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemSystemStatisticalFunctions" xml:space="preserve">
<value>System Statistical Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemTextAndImageFunctions" xml:space="preserve">
<value>Text and Image Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemUnicodeCharacterStrings" xml:space="preserve">
<value>Unicode Character Strings</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AggregateFunctions" xml:space="preserve">
<value>Aggregate Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ScalarValuedFunctions" xml:space="preserve">
<value>Scalar-valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_TableValuedFunctions" xml:space="preserve">
<value>Table-valued Functions</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SystemExtendedStoredProcedures" xml:space="preserve">
<value>System Extended Stored Procedures</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInType" xml:space="preserve">
<value>Built-in Types</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_BuiltInServerRole" xml:space="preserve">
<value>Built-in Server Roles</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UserWithPassword" xml:space="preserve">
<value>User with Password</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SearchPropertyList" xml:space="preserve">
<value>Search Property List</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SecurityPolicies" xml:space="preserve">
<value>Security Policies</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SecurityPredicates" xml:space="preserve">
<value>Security Predicates</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerRole" xml:space="preserve">
<value>Server Role</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SearchPropertyLists" xml:space="preserve">
<value>Search Property Lists</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnStoreIndexes" xml:space="preserve">
<value>Column Store Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_TableTypeIndexes" xml:space="preserve">
<value>Table Type Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Server" xml:space="preserve">
<value>Server</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SelectiveXmlIndexes" xml:space="preserve">
<value>Selective XML Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlNamespaces" xml:space="preserve">
<value>XML Namespaces</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_XmlTypedPromotedPaths" xml:space="preserve">
<value>XML Typed Promoted Paths</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SqlTypedPromotedPaths" xml:space="preserve">
<value>T-SQL Typed Promoted Paths</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DatabaseScopedCredentials" xml:space="preserve">
<value>Database Scoped Credentials</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalDataSources" xml:space="preserve">
<value>External Data Sources</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalFileFormats" xml:space="preserve">
<value>External File Formats</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalResources" xml:space="preserve">
<value>External Resources</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ExternalTables" xml:space="preserve">
<value>External Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerColumns" xml:space="preserve">
<value>Dropped Ledger Columns</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerTables" xml:space="preserve">
<value>Dropped Ledger Tables</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_DroppedLedgerViews" xml:space="preserve">
<value>Dropped Ledger Views</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_AlwaysEncryptedKeys" xml:space="preserve">
<value>Always Encrypted Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnMasterKeys" xml:space="preserve">
<value>Column Master Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnEncryptionKeys" xml:space="preserve">
<value>Column Encryption Keys</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterLabelFormatString" xml:space="preserve">
<value>{0} ({1}, {2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterNoDefaultLabel" xml:space="preserve">
<value>No default</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputLabel" xml:space="preserve">
<value>Input</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputOutputLabel" xml:space="preserve">
<value>Input/Output</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputReadOnlyLabel" xml:space="preserve">
<value>Input/ReadOnly</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterInputOutputReadOnlyLabel" xml:space="preserve">
<value>Input/Output/ReadOnly</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SubroutineParameterDefaultLabel" xml:space="preserve">
<value>Default</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_NullColumn_Label" xml:space="preserve">
<value>null</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_NotNullColumn_Label" xml:space="preserve">
<value>not null</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UDDTLabelWithType" xml:space="preserve">
<value>{0} ({1}, {2})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_UDDTLabelWithoutType" xml:space="preserve">
<value>{0} ({1})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ComputedColumnLabelWithType" xml:space="preserve">
<value>{0} ({1}Computed, {2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ComputedColumnLabelWithoutType" xml:space="preserve">
<value>{0} ({1}Computed)</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithoutType" xml:space="preserve">
<value>{0} (Column Set, {1})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithType" xml:space="preserve">
<value>{0} (Column Set, {1}{2}, {3})</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ColumnSetLabelWithTypeAndKeyString" xml:space="preserve">
<value>{0} (Column Set, {1}, {2}, {3})</value>
<comment></comment>
</data>
<data name="UniqueIndex_LabelPart" xml:space="preserve">
<value>Unique</value>
<comment></comment>
</data>
<data name="NonUniqueIndex_LabelPart" xml:space="preserve">
<value>Non-Unique</value>
<comment></comment>
</data>
<data name="ClusteredIndex_LabelPart" xml:space="preserve">
<value>Clustered</value>
<comment></comment>
</data>
<data name="NonClusteredIndex_LabelPart" xml:space="preserve">
<value>Non-Clustered</value>
<comment></comment>
</data>
<data name="History_LabelPart" xml:space="preserve">
<value>History</value>
<comment></comment>
</data>
<data name="SystemVersioned_LabelPart" xml:space="preserve">
<value>System-Versioned</value>
<comment></comment>
</data>
<data name="UpdatableLedger_LabelPart" xml:space="preserve">
<value>Updatable Ledger</value>
<comment></comment>
</data>
<data name="AppendOnlyLedger_LabelPart" xml:space="preserve">
<value>Append-Only Ledger</value>
<comment></comment>
</data>
<data name="Ledger_LabelPart" xml:space="preserve">
<value>Ledger</value>
<comment></comment>
</data>
<data name="External_LabelPart" xml:space="preserve">
<value>External</value>
<comment></comment>
</data>
<data name="FileTable_LabelPart" xml:space="preserve">
<value>File Table</value>
<comment></comment>
</data>
<data name="DatabaseNotAccessible" xml:space="preserve">
<value>The database {0} is not accessible.</value>
<comment></comment>
</data>
<data name="FilterName" xml:space="preserve">
<value>Name</value>
<comment></comment>
</data>
<data name="FilterNameDescription" xml:space="preserve">
<value>Include or exclude objects based on the name or part of a name.</value>
<comment></comment>
</data>
<data name="FilterSchema" xml:space="preserve">
<value>Schema</value>
<comment></comment>
</data>
<data name="FilterSchemaDescription" xml:space="preserve">
<value> Include or exclude objects based on the schema or part of a schema name.</value>
<comment></comment>
</data>
<data name="FilterOwner" xml:space="preserve">
<value>Owner</value>
<comment></comment>
</data>
<data name="FilterOwnerDescription" xml:space="preserve">
<value>Include or exclude objects based on the owner or part of an owner name.</value>
<comment></comment>
</data>
<data name="FilterDurabilityType" xml:space="preserve">
<value>Durability Type</value>
<comment></comment>
</data>
<data name="FilterDurabilityTypeDescription" xml:space="preserve">
<value>Include or exclude objects based on the durability type.</value>
<comment></comment>
</data>
<data name="FilterDurabilitySchemaOnly" xml:space="preserve">
<value>Schema Only</value>
<comment></comment>
</data>
<data name="FilterDurabilitySchemaAndData" xml:space="preserve">
<value>Schema and Data</value>
<comment></comment>
</data>
<data name="FilterIsMemoryOptimized" xml:space="preserve">
<value>Is Memory Optimized</value>
<comment></comment>
</data>
<data name="FilterIsMemoryOptimizedDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the object is memory optimized.</value>
<comment></comment>
</data>
<data name="FilterCreateDate" xml:space="preserve">
<value>Create Date</value>
<comment></comment>
</data>
<data name="FilterCreateDateDescription" xml:space="preserve">
<value>Include or exclude objects based on their creation date.</value>
<comment></comment>
</data>
<data name="FilterIsNativelyCompiled" xml:space="preserve">
<value>Is Natively Compiled</value>
<comment></comment>
</data>
<data name="FilterIsNativelyCompiledDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the object is natively compiled.</value>
<comment></comment>
</data>
<data name="FilterInPrimaryKey" xml:space="preserve">
<value>In Primary Key</value>
<comment></comment>
</data>
<data name="FilterInPrimaryKeyDescription" xml:space="preserve">
<value>Include or exclude objects based on whether the column is in a primary key.</value>
<comment></comment>
</data>
</root>

View File

@@ -0,0 +1,432 @@
# String resource file
#
# When processed by the String Resource Tool, this file generates
# both a .CS and a .RESX file with the same name as the file.
# The .CS file contains a class which can be used to access these
# string resources, including the ability to format in
# parameters, which are identified with the .NET {x} format
# (see String.Format help).
#
# Comments below assume the file name is SR.strings.
#
# Lines starting with a semicolon ";" are also treated as comments, but
# in a future version they will be extracted and made available in LocStudio
# Put your comments to localizers _before_ the string they apply to.
#
# SMO build specific comment
# after generating the .resx file, run srgen on it and get the .resx file
# please remember to also check that .resx in, along with the
# .strings and .cs files
[strings]
############################################################################
# Object Explorer Service
TreeNodeError = Error expanding: {0}
ServerNodeConnectionError = Error connecting to {0}
SchemaHierarchy_Aggregates = Aggregates
SchemaHierarchy_ServerRoles = Server Roles
SchemaHierarchy_ApplicationRoles = Application Roles
SchemaHierarchy_Assemblies = Assemblies
SchemaHierarchy_AssemblyFiles = Assembly Files
SchemaHierarchy_AsymmetricKeys = Asymmetric Keys
SchemaHierarchy_DatabaseAsymmetricKeys = Asymmetric Keys
SchemaHierarchy_DataCompressionOptions = Data Compression Options
SchemaHierarchy_Certificates = Certificates
SchemaHierarchy_FileTables = FileTables
SchemaHierarchy_DatabaseCertificates = Certificates
SchemaHierarchy_CheckConstraints = Check Constraints
SchemaHierarchy_Columns = Columns
SchemaHierarchy_Constraints = Constraints
SchemaHierarchy_Contracts = Contracts
SchemaHierarchy_Credentials = Credentials
SchemaHierarchy_ErrorMessages = Error Messages
SchemaHierarchy_ServerRoleMembership = Server Role Membership
SchemaHierarchy_DatabaseOptions = Database Options
SchemaHierarchy_DatabaseRoles = Database Roles
SchemaHierarchy_RoleMemberships = Role Memberships
SchemaHierarchy_DatabaseTriggers = Database Triggers
SchemaHierarchy_DefaultConstraints = Default Constraints
SchemaHierarchy_Defaults = Defaults
SchemaHierarchy_Sequences = Sequences
SchemaHierarchy_Endpoints = Endpoints
SchemaHierarchy_EventNotifications = Event Notifications
SchemaHierarchy_ServerEventNotifications = Server Event Notifications
SchemaHierarchy_ExtendedProperties = Extended Properties
SchemaHierarchy_FileGroups = Filegroups
SchemaHierarchy_ForeignKeys = Foreign Keys
SchemaHierarchy_FullTextCatalogs = Full-Text Catalogs
SchemaHierarchy_FullTextIndexes = Full-Text Indexes
SchemaHierarchy_Functions = Functions
SchemaHierarchy_Indexes = Indexes
SchemaHierarchy_InlineFunctions = Inline Functions
SchemaHierarchy_Keys = Keys
SchemaHierarchy_LinkedServers = Linked Servers
SchemaHierarchy_Logins = Logins
SchemaHierarchy_MasterKey = Master Key
SchemaHierarchy_MasterKeys = Master Keys
SchemaHierarchy_MessageTypes = Message Types
SchemaHierarchy_MultiSelectFunctions = Table-Valued Functions
SchemaHierarchy_Parameters = Parameters
SchemaHierarchy_PartitionFunctions = Partition Functions
SchemaHierarchy_PartitionSchemes = Partition Schemes
SchemaHierarchy_Permissions = Permissions
SchemaHierarchy_PrimaryKeys = Primary Keys
SchemaHierarchy_Programmability = Programmability
SchemaHierarchy_Queues = Queues
SchemaHierarchy_RemoteServiceBindings = Remote Service Bindings
SchemaHierarchy_ReturnedColumns = Returned Columns
SchemaHierarchy_Roles = Roles
SchemaHierarchy_Routes = Routes
SchemaHierarchy_Rules = Rules
SchemaHierarchy_Schemas = Schemas
SchemaHierarchy_BuiltInSchema = Built-in Schemas
SchemaHierarchy_Security = Security
SchemaHierarchy_ServerObjects = Server Objects
SchemaHierarchy_Management = Management
SchemaHierarchy_ServerTriggers = Triggers
SchemaHierarchy_ServiceBroker = Service Broker
SchemaHierarchy_Services = Services
SchemaHierarchy_Signatures = Signatures
SchemaHierarchy_LogFiles = Log Files
SchemaHierarchy_Statistics = Statistics
SchemaHierarchy_Storage = Storage
SchemaHierarchy_StoredProcedures = Stored Procedures
SchemaHierarchy_SymmetricKeys = Symmetric Keys
SchemaHierarchy_Synonyms = Synonyms
SchemaHierarchy_Tables = Tables
SchemaHierarchy_Triggers = Triggers
SchemaHierarchy_Types = Types
SchemaHierarchy_UniqueKeys = Unique Keys
SchemaHierarchy_UserDefinedDataTypes = User-Defined Data Types
SchemaHierarchy_UserDefinedTypes = User-Defined Types (CLR)
SchemaHierarchy_Users = Users
SchemaHierarchy_Views = Views
SchemaHierarchy_XmlIndexes = XML Indexes
SchemaHierarchy_XMLSchemaCollections = XML Schema Collections
SchemaHierarchy_UserDefinedTableTypes = User-Defined Table Types
SchemaHierarchy_FilegroupFiles = Files
MissingCaption = Missing Caption
SchemaHierarchy_BrokerPriorities = Broker Priorities
SchemaHierarchy_CryptographicProviders = Cryptographic Providers
SchemaHierarchy_DatabaseAuditSpecifications = Database Audit Specifications
SchemaHierarchy_DatabaseEncryptionKeys = Database Encryption Keys
SchemaHierarchy_EventSessions = Event Sessions
SchemaHierarchy_FullTextStopLists = Full Text Stoplists
SchemaHierarchy_ResourcePools = Resource Pools
SchemaHierarchy_ServerAudits = Audits
SchemaHierarchy_ServerAuditSpecifications = Server Audit Specifications
SchemaHierarchy_SpatialIndexes = Spatial Indexes
SchemaHierarchy_WorkloadGroups = Workload Groups
SchemaHierarchy_SqlFiles = SQL Files
SchemaHierarchy_ServerFunctions = Server Functions
SchemaHierarchy_SqlType = SQL Type
SchemaHierarchy_ServerOptions = Server Options
SchemaHierarchy_DatabaseDiagrams = Database Diagrams
SchemaHierarchy_SystemTables = System Tables
SchemaHierarchy_Databases = Databases
SchemaHierarchy_SystemContracts = System Contracts
SchemaHierarchy_SystemDatabases = System Databases
SchemaHierarchy_SystemMessageTypes = System Message Types
SchemaHierarchy_SystemQueues = System Queues
SchemaHierarchy_SystemServices = System Services
SchemaHierarchy_SystemStoredProcedures = System Stored Procedures
SchemaHierarchy_SystemViews = System Views
SchemaHierarchy_DataTierApplications = Data-tier Applications
SchemaHierarchy_ExtendedStoredProcedures = Extended Stored Procedures
SchemaHierarchy_SystemAggregateFunctions = Aggregate Functions
SchemaHierarchy_SystemApproximateNumerics = Approximate Numerics
SchemaHierarchy_SystemBinaryStrings = Binary Strings
SchemaHierarchy_SystemCharacterStrings = Character Strings
SchemaHierarchy_SystemCLRDataTypes = CLR Data Types
SchemaHierarchy_SystemConfigurationFunctions = Configuration Functions
SchemaHierarchy_SystemCursorFunctions = Cursor Functions
SchemaHierarchy_SystemDataTypes = System Data Types
SchemaHierarchy_SystemDateAndTime = Date and Time
SchemaHierarchy_SystemDateAndTimeFunctions = Date and Time Functions
SchemaHierarchy_SystemExactNumerics = Exact Numerics
SchemaHierarchy_SystemFunctions = System Functions
SchemaHierarchy_SystemHierarchyIdFunctions = Hierarchy Id Functions
SchemaHierarchy_SystemMathematicalFunctions = Mathematical Functions
SchemaHierarchy_SystemMetadataFunctions = Metadata Functions
SchemaHierarchy_SystemOtherDataTypes = Other Data Types
SchemaHierarchy_SystemOtherFunctions = Other Functions
SchemaHierarchy_SystemRowsetFunctions = Rowset Functions
SchemaHierarchy_SystemSecurityFunctions = Security Functions
SchemaHierarchy_SystemSpatialDataTypes = Spatial Data Types
SchemaHierarchy_SystemStringFunctions = String Functions
SchemaHierarchy_SystemSystemStatisticalFunctions = System Statistical Functions
SchemaHierarchy_SystemTextAndImageFunctions = Text and Image Functions
SchemaHierarchy_SystemUnicodeCharacterStrings = Unicode Character Strings
SchemaHierarchy_AggregateFunctions = Aggregate Functions
SchemaHierarchy_ScalarValuedFunctions = Scalar-valued Functions
SchemaHierarchy_TableValuedFunctions = Table-valued Functions
SchemaHierarchy_SystemExtendedStoredProcedures = System Extended Stored Procedures
SchemaHierarchy_BuiltInType = Built-in Types
SchemaHierarchy_BuiltInServerRole = Built-in Server Roles
SchemaHierarchy_UserWithPassword = User with Password
SchemaHierarchy_SearchPropertyList = Search Property List
SchemaHierarchy_SecurityPolicies = Security Policies
SchemaHierarchy_SecurityPredicates = Security Predicates
SchemaHierarchy_ServerRole = Server Role
SchemaHierarchy_SearchPropertyLists = Search Property Lists
SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes
SchemaHierarchy_TableTypeIndexes = Table Type Indexes
SchemaHierarchy_Server = Server
SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes
SchemaHierarchy_XmlNamespaces = XML Namespaces
SchemaHierarchy_XmlTypedPromotedPaths = XML Typed Promoted Paths
SchemaHierarchy_SqlTypedPromotedPaths = T-SQL Typed Promoted Paths
SchemaHierarchy_DatabaseScopedCredentials = Database Scoped Credentials
SchemaHierarchy_ExternalDataSources = External Data Sources
SchemaHierarchy_ExternalFileFormats = External File Formats
SchemaHierarchy_ExternalResources = External Resources
SchemaHierarchy_ExternalTables = External Tables
SchemaHierarchy_DroppedLedgerColumns = Dropped Ledger Columns
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views
SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys
SchemaHierarchy_ColumnMasterKeys = Column Master Keys
SchemaHierarchy_ColumnEncryptionKeys = Column Encryption Keys
SchemaHierarchy_SubroutineParameterLabelFormatString = {0} ({1}, {2}, {3})
SchemaHierarchy_SubroutineParameterNoDefaultLabel = No default
SchemaHierarchy_SubroutineParameterInputLabel = Input
SchemaHierarchy_SubroutineParameterInputOutputLabel = Input/Output
SchemaHierarchy_SubroutineParameterInputReadOnlyLabel = Input/ReadOnly
SchemaHierarchy_SubroutineParameterInputOutputReadOnlyLabel = Input/Output/ReadOnly
SchemaHierarchy_SubroutineParameterDefaultLabel = Default
SchemaHierarchy_NullColumn_Label = null
SchemaHierarchy_NotNullColumn_Label = not null
SchemaHierarchy_UDDTLabelWithType = {0} ({1}, {2})
SchemaHierarchy_UDDTLabelWithoutType = {0} ({1})
SchemaHierarchy_ComputedColumnLabelWithType = {0} ({1}Computed, {2}, {3})
SchemaHierarchy_ComputedColumnLabelWithoutType = {0} ({1}Computed)
SchemaHierarchy_ColumnSetLabelWithoutType = {0} (Column Set, {1})
SchemaHierarchy_ColumnSetLabelWithType = {0} (Column Set, {1}{2}, {3})
SchemaHierarchy_ColumnSetLabelWithTypeAndKeyString = {0} (Column Set, {1}, {2}, {3})
UniqueIndex_LabelPart = Unique
NonUniqueIndex_LabelPart = Non-Unique
ClusteredIndex_LabelPart = Clustered
NonClusteredIndex_LabelPart = Non-Clustered
History_LabelPart = History
SystemVersioned_LabelPart = System-Versioned
UpdatableLedger_LabelPart = Updatable Ledger
AppendOnlyLedger_LabelPart = Append-Only Ledger
Ledger_LabelPart = Ledger
External_LabelPart = External
FileTable_LabelPart = File Table
DatabaseNotAccessible = The database {0} is not accessible.
FilterName = Name
FilterNameDescription = Include or exclude objects based on the name or part of a name.
FilterSchema = Schema
FilterSchemaDescription = Include or exclude objects based on the schema or part of a schema name.
FilterOwner = Owner
FilterOwnerDescription = Include or exclude objects based on the owner or part of an owner name.
FilterDurabilityType = Durability Type
FilterDurabilityTypeDescription = Include or exclude objects based on the durability type.
FilterDurabilitySchemaOnly = Schema Only
FilterDurabilitySchemaAndData = Schema and Data
FilterIsMemoryOptimized = Is Memory Optimized
FilterIsMemoryOptimizedDescription = Include or exclude objects based on whether the object is memory optimized.
FilterCreateDate = Create Date
FilterCreateDateDescription = Include or exclude objects based on their creation date.
FilterIsNativelyCompiled = Is Natively Compiled
FilterIsNativelyCompiledDescription = Include or exclude objects based on whether the object is natively compiled.
FilterInPrimaryKey = In Primary Key
FilterInPrimaryKeyDescription = Include or exclude objects based on whether the column is in a primary key.

File diff suppressed because it is too large Load Diff

View File

@@ -3,9 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable namespace Microsoft.SqlTools.SqlCore.Metadata
namespace Microsoft.SqlTools.ServiceLayer.Metadata.Contracts
{ {
/// <summary> /// <summary>
/// Metadata type enumeration /// Metadata type enumeration

View File

@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>MicrosoftSqlToolsSqlCore</AssemblyName>
<Nullable>disable</Nullable>
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<DefineConstants>$(DefineConstants);NETCOREAPP1_0;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyTitle>SqlTools SqlCore Library</AssemblyTitle>
<Description>Provides core sql functionality for SQL server editors like Object explorer, Query Execution and Scripting</Description>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="**/obj/**/*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\*.resx" />
<None Include="Localization\sr.strings" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ObjectExplorer\SmoModel\SmoTreeNodesDefinition.xml" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.SqlTools.ServiceLayer.UnitTests" />
<InternalsVisibleTo Include="Microsoft.SqlTools.ServiceLayer.IntegrationTests" />
<InternalsVisibleTo Include="Microsoft.SqlTools.ServiceLayer.Test.Common" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{
public class IObjectExplorerSession
{
public TreeNode Root { get; protected set; }
}
}

View File

@@ -3,14 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// A <see cref="ChildFactory"/> supports creation of <see cref="TreeNode"/> children /// A <see cref="ChildFactory"/> supports creation of <see cref="TreeNode"/> children
@@ -36,7 +33,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// <param name="includeSystemObjects">include system objects</param> /// <param name="includeSystemObjects">include system objects</param>
/// <param name="cancellationToken">cancellation token</param> /// <param name="cancellationToken">cancellation token</param>
/// <param name="filters">filters to apply</param> /// <param name="filters">filters to apply</param>
public abstract IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects, CancellationToken cancellationToken, IEnumerable<NodeFilter>? filters); public abstract IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects, CancellationToken cancellationToken, IEnumerable<INodeFilter>? filters);
/// <summary> /// <summary>
/// The list of filters that should be applied on the smo object list /// The list of filters that should be applied on the smo object list

View File

@@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Has information for filtering a SMO object by properties /// Has information for filtering a SMO object by properties

View File

@@ -0,0 +1,66 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{
/// <summary>
/// The filterable properties that a node supports
/// </summary>
public class NodeFilterProperty
{
/// <summary>
/// The name of the filter property
/// </summary>
public string? Name { get; set; }
/// <summary>
/// The name of the filter property displayed to the user
/// </summary>
public string? DisplayName { get; set; }
/// <summary>
/// The description of the filter property
/// </summary>
public string? Description { get; set; }
/// <summary>
/// The data type of the filter property
/// </summary>
public NodeFilterPropertyDataType Type { get; set; }
/// <summary>
/// The list of choices for the filter property if the type is choice
/// </summary>
public NodeFilterPropertyChoice[]? Choices { get; set; }
}
/// <summary>
/// The data type of the filter property. Matches NodeFilterPropertyDataType enum in ADS : https://github.com/microsoft/azuredatastudio/blob/main/src/sql/azdata.proposed.d.ts#L1847-L1853
/// </summary>
public enum NodeFilterPropertyDataType
{
String = 0,
Number = 1,
Boolean = 2,
Date = 3,
Choice = 4
}
/// <summary>
/// The choice for the filter property if the type is choice
/// </summary>
public class NodeFilterPropertyChoice
{
/// <summary>
/// The dropdown display value for the choice
/// </summary>
/// <value></value>
public string? DisplayName { get; set; }
/// <summary>
/// The value of the choice
/// </summary>
public string? Value { get; set; }
}
}

View File

@@ -2,16 +2,14 @@
// Copyright (c) Microsoft. All rights reserved. // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// A collection class for <see cref="TreeNode"/> /// A collection class for <see cref="TreeNode"/>

View File

@@ -3,13 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Has information for filtering a SMO object by properties /// Has information for filtering a SMO object by properties

View File

@@ -2,17 +2,14 @@
// Copyright (c) Microsoft. All rights reserved. // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.SqlCore.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Has information for filtering a SMO object by properties /// Has information for filtering a SMO object by properties
@@ -186,7 +183,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
if (Type == typeof(string)) if (Type == typeof(string))
{ {
//Replacing quotes with double quotes //Replacing quotes with double quotes
var escapedString = CUtils.EscapeStringSQuote(propertyValue.ToString()); var escapedString = StringUtils.EscapeStringSQuote(propertyValue.ToString());
if (this.FilterType == FilterType.STARTSWITH || this.FilterType == FilterType.ENDSWITH) if (this.FilterType == FilterType.STARTSWITH || this.FilterType == FilterType.ENDSWITH)
{ {
escapedString = EscapeLikeURNRegex().Replace(escapedString, "[$0]"); escapedString = EscapeLikeURNRegex().Replace(escapedString, "[$0]");

View File

@@ -3,10 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Has information for SMO object properties to be loaded with the SMO object /// Has information for SMO object properties to be loaded with the SMO object

View File

@@ -7,7 +7,7 @@
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen" // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen"
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Enum listing possible node types in the object explorer tree /// Enum listing possible node types in the object explorer tree

View File

@@ -18,7 +18,7 @@
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen" // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen"
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Enum listing possible node types in the object explorer tree /// Enum listing possible node types in the object explorer tree

View File

@@ -2,22 +2,18 @@
// Copyright (c) Microsoft. All rights reserved. // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts; using Microsoft.SqlTools.SqlCore.Metadata;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.Utility;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
/// <summary> /// <summary>
/// Base class for elements in the object explorer tree. Provides common methods for tree navigation /// Base class for elements in the object explorer tree. Provides common methods for tree navigation
@@ -30,6 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
private string nodePath; private string nodePath;
private string label; private string label;
private string nodePathName; private string nodePathName;
private static Lazy<Dictionary<string, HashSet<ChildFactory>>> ApplicableNodeChildFactories;
public const char PathPartSeperator = '/'; public const char PathPartSeperator = '/';
/// <summary> /// <summary>
@@ -206,7 +203,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
nodePath = path; nodePath = path;
} }
public TreeNode? FindNodeByPath(string path, bool expandIfNeeded = false) public TreeNode? FindNodeByPath(string path, bool expandIfNeeded = false, CancellationToken cancellationToken = new CancellationToken())
{ {
TreeNode? nodeForPath = ObjectExplorerUtils.FindNode(this, node => TreeNode? nodeForPath = ObjectExplorerUtils.FindNode(this, node =>
{ {
@@ -214,39 +211,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
}, nodeToFilter => }, nodeToFilter =>
{ {
return path.StartsWith(nodeToFilter.GetNodePath()); return path.StartsWith(nodeToFilter.GetNodePath());
}, expandIfNeeded); }, expandIfNeeded, cancellationToken);
return nodeForPath; return nodeForPath;
} }
/// <summary>
/// Converts to a <see cref="NodeInfo"/> object for serialization with just the relevant properties
/// needed to identify the node
/// </summary>
/// <returns></returns>
public NodeInfo ToNodeInfo()
{
return new NodeInfo()
{
IsLeaf = this.IsAlwaysLeaf,
Label = this.Label,
NodePath = this.GetNodePath(),
ParentNodePath = this.Parent?.GetNodePath() ?? "",
NodeType = this.NodeType,
Metadata = this.ObjectMetadata,
NodeStatus = this.NodeStatus,
NodeSubType = this.NodeSubType,
ErrorMessage = this.ErrorMessage,
ObjectType = this.NodeTypeId.ToString(),
FilterableProperties = this.FilterProperties
};
}
/// <summary> /// <summary>
/// Expands this node and returns its children /// Expands this node and returns its children
/// </summary> /// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns> /// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public IList<TreeNode> Expand(string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<NodeFilter>? filters = null) public IList<TreeNode> Expand(string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<INodeFilter>? filters = null)
{ {
// TODO consider why solution explorer has separate Children and Items options // TODO consider why solution explorer has separate Children and Items options
if (children.IsInitialized) if (children.IsInitialized)
@@ -261,7 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// Expands this node and returns its children /// Expands this node and returns its children
/// </summary> /// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns> /// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public IList<TreeNode> Expand(CancellationToken cancellationToken, string? accessToken = null, IEnumerable<NodeFilter>? filters = null) public IList<TreeNode> Expand(CancellationToken cancellationToken, string? accessToken = null, IEnumerable<INodeFilter>? filters = null)
{ {
return Expand(null, cancellationToken, accessToken, filters); return Expand(null, cancellationToken, accessToken, filters);
} }
@@ -270,7 +245,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// Refresh this node and returns its children /// Refresh this node and returns its children
/// </summary> /// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns> /// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public virtual IList<TreeNode> Refresh(CancellationToken cancellationToken, string? accessToken = null, IEnumerable<NodeFilter>? filters = null) public virtual IList<TreeNode> Refresh(CancellationToken cancellationToken, string? accessToken = null, IEnumerable<INodeFilter>? filters = null)
{ {
// TODO consider why solution explorer has separate Children and Items options // TODO consider why solution explorer has separate Children and Items options
PopulateChildren(true, null, cancellationToken, accessToken, filters); PopulateChildren(true, null, cancellationToken, accessToken, filters);
@@ -325,7 +300,48 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
return Parent as T; return Parent as T;
} }
protected virtual void PopulateChildren(bool refresh, string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<NodeFilter>? filters = null) private void PopulateFactories()
{
var factories = new Dictionary<string, HashSet<ChildFactory>>();
var serviceProvider = this.GetContextAs<SmoQueryContext>().ServiceProvider;
foreach (var factory in serviceProvider.GetServices<ChildFactory>())
{
var parents = factory.ApplicableParents();
if (parents != null)
{
foreach (var parent in parents)
{
HashSet<ChildFactory> applicableFactories;
if (!factories.TryGetValue(parent, out applicableFactories))
{
applicableFactories = new HashSet<ChildFactory>();
factories[parent] = applicableFactories;
}
applicableFactories.Add(factory);
}
}
}
ApplicableNodeChildFactories = new Lazy<Dictionary<string, HashSet<ChildFactory>>>(factories);
}
public IEnumerable<ChildFactory> GetApplicableChildFactories()
{
if (TreeNode.ApplicableNodeChildFactories == null)
{
this.PopulateFactories();
}
HashSet<ChildFactory> applicableFactories;
if (ApplicableNodeChildFactories.Value.TryGetValue(NodeTypeId.ToString(), out applicableFactories))
{
return applicableFactories;
}
return null;
}
protected virtual void PopulateChildren(bool refresh, string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<INodeFilter>? filters = null)
{ {
Logger.Verbose(string.Format(CultureInfo.InvariantCulture, "Populating oe node :{0}", this.GetNodePath())); Logger.Verbose(string.Format(CultureInfo.InvariantCulture, "Populating oe node :{0}", this.GetNodePath()));
Debug.Assert(IsAlwaysLeaf == false); Debug.Assert(IsAlwaysLeaf == false);
@@ -347,7 +363,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
try try
{ {
ErrorMessage = null; ErrorMessage = null;
IEnumerable<ChildFactory> childFactories = context.GetObjectExplorerService().GetApplicableChildFactories(this); IEnumerable<ChildFactory> childFactories = this.GetApplicableChildFactories();
if (childFactories != null) if (childFactories != null)
{ {
foreach (var factory in childFactories) foreach (var factory in childFactories)

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
{ {
public class TreeNodeWithContext public class TreeNodeWithContext
{ {

View File

@@ -0,0 +1,22 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{
public class ObjectExplorerOptions
{
/// <summary>
/// Function that returns flag to group nodes by schema. Default is false
/// </summary>
public Func<bool> GroupBySchemaFlagGetter { get; set; } = () => false;
/// <summary>
/// Timeout for OE session operations in seconds. Default is 60 seconds
/// </summary>
public int OperationTimeoutSeconds { get; set; } = 60;
}
}

View File

@@ -0,0 +1,42 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{
public class ObjectExplorerServerInfo
{
/// <summary>
/// Server name for the OE session
/// </summary>
public string? ServerName { get; set; }
/// <summary>
/// Database name for the OE session
/// </summary>
public string? DatabaseName { get; set; }
/// <summary>
/// User name for the OE session
/// </summary>
public string? UserName { get; set; }
/// <summary>
/// SQL Server version for the OE session
/// </summary>
public string? ServerVersion { get; set; }
/// <summary>
/// SQL Server edition for the OE session
/// </summary>
public int EngineEditionId { get; set; }
/// <summary>
/// Checks if the OE session is for Azure SQL DB
/// </summary>
public bool IsCloud { get; set; }
/// <summary>
/// Indicates if the OE session is for default or system database
/// </summary>
public bool isDefaultOrSystemDatabase { get; set; }
}
}

View File

@@ -0,0 +1,78 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Threading;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{
/// <summary>
/// Utility class for Object Explorer related operations
/// </summary>
public static class ObjectExplorerUtils
{
/// <summary>
/// Visitor that walks all nodes from the child to the root node, unless the
/// <paramref name="visitor"/> function indicates that this should stop traversing
/// </summary>
/// <param name="child">node to start traversing at</param>
/// <param name="visitor">Predicate function that accesses the tree and
/// determines whether to stop going further up the tree</param>
/// <returns>
/// boolean - true to continue navigating up the tree, false to end the loop
/// and return early
/// </returns>
public static bool VisitChildAndParents(TreeNode child, Predicate<TreeNode> visitor)
{
if (child == null)
{
// End case: all nodes have been visited
return true;
}
// Visit the child first, then go up the parents
if (!visitor(child))
{
return false;
}
return VisitChildAndParents(child.Parent, visitor);
}
/// <summary>
/// Finds a node by traversing the tree starting from the given node through all the children
/// </summary>
/// <param name="node">node to start traversing at</param>
/// <param name="condition">Predicate function that accesses the tree and
/// determines whether to stop going further up the tree</param>
/// <param name="filter">Predicate function to filter the children when traversing</param>
/// <returns>A Tree Node that matches the condition, or null if no matching node could be found</returns>
public static TreeNode? FindNode(TreeNode node, Predicate<TreeNode> condition, Predicate<TreeNode> filter, bool expandIfNeeded = false, CancellationToken cancellationToken = new CancellationToken())
{
if (node == null)
{
return null;
}
if (condition(node))
{
return node;
}
var children = expandIfNeeded && !node.IsAlwaysLeaf ? node.Expand(cancellationToken) : node.GetChildren();
foreach (var child in children)
{
if (filter != null && filter(child))
{
TreeNode? childNode = FindNode(child, condition, filter, expandIfNeeded);
if (childNode != null)
{
return childNode;
}
}
}
return null;
}
}
}

View File

@@ -3,21 +3,18 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
internal partial class DatabaseTreeNode public partial class DatabaseTreeNode
{ {
public DatabaseTreeNode(ServerNode serverNode, string databaseName) : this() public DatabaseTreeNode(ServerNode serverNode, string databaseName) : this()
{ {
@@ -55,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
protected override void PopulateChildren(bool refresh, string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<NodeFilter>? filters = null) protected override void PopulateChildren(bool refresh, string name, CancellationToken cancellationToken, string? accessToken = null, IEnumerable<INodeFilter>? filters = null)
{ {
var smoQueryContext = this.GetContextAs<SmoQueryContext>(); var smoQueryContext = this.GetContextAs<SmoQueryContext>();
if (IsAccessible(smoQueryContext)) if (IsAccessible(smoQueryContext))

View File

@@ -3,12 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Represents a folder node in the tree /// Represents a folder node in the tree

View File

@@ -3,14 +3,13 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Reflection;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
public class NodePathGenerator public class NodePathGenerator
{ {
@@ -18,15 +17,15 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
private static Dictionary<string, HashSet<Node>> NodeTypeDictionary { get; set; } private static Dictionary<string, HashSet<Node>> NodeTypeDictionary { get; set; }
internal static void Initialize() public static void Initialize()
{ {
if (TreeRoot != null) if (TreeRoot != null)
{ {
return; return;
} }
var assembly = typeof(ObjectExplorerService).Assembly; var assembly = Assembly.GetExecutingAssembly();
var resource = assembly.GetManifestResourceStream("Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel.SmoTreeNodesDefinition.xml"); var resource = assembly.GetManifestResourceStream("Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel.SmoTreeNodesDefinition.xml");
var serializer = new XmlSerializer(typeof(ServerExplorerTree)); var serializer = new XmlSerializer(typeof(ServerExplorerTree));
NodeTypeDictionary = new Dictionary<string, HashSet<Node>>(); NodeTypeDictionary = new Dictionary<string, HashSet<Node>>();
using (var reader = new StreamReader(resource)) using (var reader = new StreamReader(resource))
@@ -52,7 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
NodeTypeDictionary.Add("Server", serverSet); NodeTypeDictionary.Add("Server", serverSet);
} }
internal static HashSet<string> FindNodePaths(ObjectExplorerService.ObjectExplorerSession objectExplorerSession, string typeName, string schema, string name, string databaseName, List<string> parentNames = null) public static HashSet<string> FindNodePaths(IObjectExplorerSession objectExplorerSession, string typeName, string schema, string name, string databaseName, List<string> parentNames = null)
{ {
if (TreeRoot == null) if (TreeRoot == null)
{ {
@@ -85,7 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
return returnSet; return returnSet;
} }
private static HashSet<string> GenerateNodePath(ObjectExplorerService.ObjectExplorerSession objectExplorerSession, Node currentNode, string databaseName, List<string> parentNames, string path) private static HashSet<string> GenerateNodePath(IObjectExplorerSession objectExplorerSession, Node currentNode, string databaseName, List<string> parentNames, string path)
{ {
if (parentNames != null) if (parentNames != null)
{ {

View File

@@ -3,47 +3,43 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Globalization; using System.Globalization;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.SqlCore.Utility;
using System.IO;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Server node implementation /// Server node implementation
/// </summary> /// </summary>
public class ServerNode : TreeNode public class ServerNode : TreeNode
{ {
private ConnectionSummary connectionSummary; private ObjectExplorerServerInfo serverInfo;
private ServerInfo serverInfo;
private Lazy<SmoQueryContext> context; private Lazy<SmoQueryContext> context;
private SmoWrapper smoWrapper; private SmoWrapper smoWrapper;
private SqlServerType sqlServerType; private SqlServerType sqlServerType;
private ServerConnection serverConnection; public ServerConnection serverConnection;
public ServerNode(ConnectionCompleteParams connInfo, IMultiServiceProvider serviceProvider, ServerConnection serverConnection) public ServerNode(ObjectExplorerServerInfo serverInfo, ServerConnection serverConnection, IMultiServiceProvider serviceProvider = null, Func<bool> groupBySchemaFlag = null)
: base() : base()
{ {
Validate.IsNotNull(nameof(connInfo), connInfo); Validate.IsNotNull(nameof(ObjectExplorerServerInfo), serverInfo);
Validate.IsNotNull("connInfo.ConnectionSummary", connInfo.ConnectionSummary);
Validate.IsNotNull(nameof(serviceProvider), serviceProvider);
this.connectionSummary = connInfo.ConnectionSummary; this.serverInfo = serverInfo;
this.serverInfo = connInfo.ServerInfo;
this.sqlServerType = ServerVersionHelper.CalculateServerType(this.serverInfo); this.sqlServerType = ServerVersionHelper.CalculateServerType(this.serverInfo);
this.context = new Lazy<SmoQueryContext>(() => CreateContext(serviceProvider)); var assembly = typeof(SqlCore.ObjectExplorer.SmoModel.SmoQuerier).Assembly;
serviceProvider ??= ExtensionServiceProvider.CreateFromAssembliesInDirectory(Path.GetDirectoryName(assembly.Location), new string[] { Path.GetFileName(assembly.Location) });
this.context = new Lazy<SmoQueryContext>(() => CreateContext(serviceProvider, groupBySchemaFlag));
this.serverConnection = serverConnection; this.serverConnection = serverConnection;
NodeValue = connectionSummary.ServerName; NodeValue = serverInfo.ServerName;
IsAlwaysLeaf = false; IsAlwaysLeaf = false;
NodeType = NodeTypes.Server.ToString(); NodeType = NodeTypes.Server.ToString();
NodeTypeId = NodeTypes.Server; NodeTypeId = NodeTypes.Server;
@@ -68,7 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
/// </summary> /// </summary>
internal string GetConnectionLabel() internal string GetConnectionLabel()
{ {
string userName = connectionSummary.UserName; string userName = serverInfo.UserName;
// TODO Domain and username is not yet supported on .Net Core. // TODO Domain and username is not yet supported on .Net Core.
// Consider passing as an input from the extension where this can be queried // Consider passing as an input from the extension where this can be queried
@@ -79,16 +75,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
// TODO Consider adding IsAuthenticatingDatabaseMaster check in the code and // TODO Consider adding IsAuthenticatingDatabaseMaster check in the code and
// referencing result here // referencing result here
if (!DatabaseUtils.IsSystemDatabaseConnection(connectionSummary.DatabaseName)) if (!DatabaseUtils.IsSystemDatabaseConnection(serverInfo.DatabaseName))
{ {
// We either have an azure with a database specified or a Denali database using a contained user // We either have an azure with a database specified or a Denali database using a contained user
if (string.IsNullOrWhiteSpace(userName)) if (string.IsNullOrWhiteSpace(userName))
{ {
userName = connectionSummary.DatabaseName; userName = serverInfo.DatabaseName;
} }
else else
{ {
userName += ", " + connectionSummary.DatabaseName; userName += ", " + serverInfo.DatabaseName;
} }
} }
@@ -98,7 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
label = string.Format( label = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{0} ({1} {2})", "{0} ({1} {2})",
connectionSummary.ServerName, serverInfo.ServerName,
"SQL Server", "SQL Server",
serverInfo.ServerVersion); serverInfo.ServerVersion);
} }
@@ -107,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
label = string.Format( label = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{0} ({1} {2} - {3})", "{0} ({1} {2} - {3})",
connectionSummary.ServerName, serverInfo.ServerName,
"SQL Server", "SQL Server",
serverInfo.ServerVersion, serverInfo.ServerVersion,
userName); userName);
@@ -118,7 +114,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
private SmoQueryContext CreateContext(IMultiServiceProvider serviceProvider) private SmoQueryContext CreateContext(IMultiServiceProvider serviceProvider, Func<bool> groupBySchemaFlag = null)
{ {
string exceptionMessage; string exceptionMessage;
@@ -127,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
Server server = SmoWrapper.CreateServer(this.serverConnection); Server server = SmoWrapper.CreateServer(this.serverConnection);
if (server != null) if (server != null)
{ {
return new SmoQueryContext(server, serviceProvider, SmoWrapper) return new SmoQueryContext(server, serviceProvider, SmoWrapper, groupBySchemaFlag)
{ {
Parent = server, Parent = server,
SqlServerType = this.sqlServerType SqlServerType = this.sqlServerType

View File

@@ -3,8 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -12,11 +10,10 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
public class SmoChildFactoryBase : ChildFactory public class SmoChildFactoryBase : ChildFactory
{ {
@@ -27,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
return null; return null;
} }
public override IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects, CancellationToken cancellationToken, IEnumerable<NodeFilter>? filters = null) public override IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects, CancellationToken cancellationToken, IEnumerable<INodeFilter>? filters = null)
{ {
List<TreeNode> allChildren = new List<TreeNode>(); List<TreeNode> allChildren = new List<TreeNode>();
@@ -112,11 +109,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
/// </summary> /// </summary>
/// <param name="allChildren">List to which nodes should be added</param> /// <param name="allChildren">List to which nodes should be added</param>
/// <param name="parent">Parent the nodes are being added to</param> /// <param name="parent">Parent the nodes are being added to</param>
protected virtual void OnExpandPopulateNonFolders(IList<TreeNode> allChildren, TreeNode parent, bool refresh, string name, CancellationToken cancellationToken, IEnumerable<NodeFilter>? appliedFilters = null) protected virtual void OnExpandPopulateNonFolders(IList<TreeNode> allChildren, TreeNode parent, bool refresh, string name, CancellationToken cancellationToken, IEnumerable<INodeFilter>? appliedFilters = null)
{ {
Logger.Verbose(string.Format(CultureInfo.InvariantCulture, "child factory parent :{0}", parent.GetNodePath())); Logger.Verbose(string.Format(CultureInfo.InvariantCulture, "child factory parent :{0}", parent.GetNodePath()));
if (ChildQuerierTypes == null) if (this.GetChildQuerierTypes(parent) == null)
{ {
// This node does not support non-folder children // This node does not support non-folder children
return; return;
@@ -130,10 +127,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
return; return;
} }
IEnumerable<SmoQuerier> queriers = context.ServiceProvider.GetServices<SmoQuerier>(IsCompatibleQuerier); IEnumerable<SmoQuerier> queriers = context.ServiceProvider.GetServices<SmoQuerier>((q) => IsCompatibleQuerier(q, parent));
var filters = this.Filters.ToList(); var filters = this.Filters.ToList();
var smoProperties = this.SmoProperties.Where(p => ServerVersionHelper.IsValidFor(serverValidFor, p.ValidFor)).Select(x => x.Name); var smoProperties = this.SmoProperties.Where(p => ServerVersionHelper.IsValidFor(serverValidFor, p.ValidFor)).Select(x => x.Name);
var filterDefinitions = parent.FilterProperties;
if (!string.IsNullOrEmpty(name)) if (!string.IsNullOrEmpty(name))
{ {
filters.Add(new NodePropertyFilter filters.Add(new NodePropertyFilter
@@ -145,11 +141,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
if (appliedFilters != null) if (appliedFilters != null)
{ {
foreach (var f in appliedFilters) filters.AddRange(appliedFilters);
{
NodeFilterProperty filterProperty = filterDefinitions.FirstOrDefault(x => x.Name == f.Name);
filters.Add(ObjectExplorerUtils.ConvertExpandNodeFilterToNodeFilter(f, filterProperty));
}
} }
foreach (var querier in queriers) foreach (var querier in queriers)
@@ -203,15 +195,15 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
return filterTheNode; return filterTheNode;
} }
private bool IsCompatibleQuerier(SmoQuerier querier) private bool IsCompatibleQuerier(SmoQuerier querier, TreeNode parent)
{ {
if (ChildQuerierTypes == null) if (this.GetChildQuerierTypes(parent) == null)
{ {
return false; return false;
} }
Type actualType = querier.GetType(); Type actualType = querier.GetType();
foreach (Type childType in ChildQuerierTypes) foreach (Type childType in this.GetChildQuerierTypes(parent))
{ {
// We will accept any querier that is compatible with the listed querier type // We will accept any querier that is compatible with the listed querier type
if (childType.IsAssignableFrom(actualType)) if (childType.IsAssignableFrom(actualType))
@@ -306,6 +298,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
protected virtual Type[] GetChildQuerierTypes(TreeNode parent)
{
return ChildQuerierTypes;
}
/// <summary> /// <summary>
/// Returns true if any final validation of the object to be added passes, and false /// Returns true if any final validation of the object to be added passes, and false
/// if validation fails. This provides a chance to filter specific items out of a list /// if validation fails. This provides a chance to filter specific items out of a list

View File

@@ -3,14 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Wrapper to convert non-generic Smo enumerables to generic enumerable types for easier use in /// Wrapper to convert non-generic Smo enumerables to generic enumerable types for easier use in

View File

@@ -3,16 +3,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Custom name for Columns /// Custom name for Columns

View File

@@ -3,15 +3,13 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using System; using System;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Status for databases /// Status for databases

View File

@@ -3,11 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.SqlCore.Connection;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
internal static class SmoExtensions internal static class SmoExtensions
{ {

View File

@@ -3,15 +3,13 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Index = Microsoft.SqlServer.Management.Smo.Index; using Index = Microsoft.SqlServer.Management.Smo.Index;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Subtye for keys /// Subtye for keys

View File

@@ -3,14 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Status for logins /// Status for logins

View File

@@ -3,12 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System.Globalization; using System.Globalization;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Custom name for parameters /// Custom name for parameters

View File

@@ -3,15 +3,13 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Extensibility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// A <see cref="SmoQuerier"/> handles SMO queries for one or more SMO object types. /// A <see cref="SmoQuerier"/> handles SMO queries for one or more SMO object types.
@@ -69,30 +67,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
/// <summary> /// <summary>
/// Mthod used to do custom filtering on smo objects if cannot be implemented using the filters /// Mthod used to do custom filtering on smo objects if cannot be implemented using the filters
/// </summary> /// </summary>
protected virtual bool PassesFinalFilters(SqlSmoObject parent, SqlSmoObject smoObject) protected virtual bool PassesFinalFilters(SqlSmoObject parent, SqlSmoObject smoObject) => true;
{
return true;
}
/// <summary> /// <summary>
/// Returns true if the querier is valid for the given server version /// Returns true if the querier is valid for the given server version
/// </summary> /// </summary>
/// <param name="serverValidFor"></param> /// <param name="serverValidFor"></param>
/// <returns></returns> /// <returns></returns>
public bool IsValidFor(ValidForFlag serverValidFor) public bool IsValidFor(ValidForFlag serverValidFor) => ServerVersionHelper.IsValidFor(serverValidFor, ValidFor);
{
return ServerVersionHelper.IsValidFor(serverValidFor, ValidFor);
}
/// <summary> /// <summary>
/// Indicates which platforms the querier is valid for /// Indicates which platforms the querier is valid for
/// </summary> /// </summary>
public virtual ValidForFlag ValidFor public virtual ValidForFlag ValidFor
{ {
get get => ValidForFlag.All;
{
return ValidForFlag.All;
}
} }
} }
} }

View File

@@ -3,14 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Context object containing key properties needed to query for SMO objects /// Context object containing key properties needed to query for SMO objects
@@ -22,21 +20,23 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
private SmoObjectBase parent; private SmoObjectBase parent;
private SmoWrapper smoWrapper; private SmoWrapper smoWrapper;
private ValidForFlag validFor = 0; private ValidForFlag validFor = 0;
private Func<bool> groupBySchemaFlag;
/// <summary> /// <summary>
/// Creates a context object with a server to use as the basis for any queries /// Creates a context object with a server to use as the basis for any queries
/// </summary> /// </summary>
/// <param name="server"></param> /// <param name="server"></param>
public SmoQueryContext(Server server, IMultiServiceProvider serviceProvider) public SmoQueryContext(Server server, IMultiServiceProvider serviceProvider, Func<bool> groupBySchemaFlag = null)
: this(server, serviceProvider, null) : this(server, serviceProvider, null, groupBySchemaFlag)
{ {
} }
internal SmoQueryContext(Server server, IMultiServiceProvider serviceProvider, SmoWrapper serverManager) internal SmoQueryContext(Server server, IMultiServiceProvider serviceProvider, SmoWrapper serverManager, Func<bool> groupBySchemaFlag = null)
{ {
this.server = server; this.server = server;
ServiceProvider = serviceProvider; ServiceProvider = serviceProvider;
this.smoWrapper = serverManager ?? new SmoWrapper(); this.smoWrapper = serverManager ?? new SmoWrapper();
this.groupBySchemaFlag = groupBySchemaFlag ?? new Func<bool>(() => false);
} }
/// <summary> /// <summary>
@@ -85,6 +85,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
public bool GroupBySchema
{
get => groupBySchemaFlag();
}
/// <summary> /// <summary>
/// A query loader that can be used to find <see cref="SmoQuerier"/> objects /// A query loader that can be used to find <see cref="SmoQuerier"/> objects
/// for specific SMO types /// for specific SMO types
@@ -102,26 +107,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
return Parent as T; return Parent as T;
} }
/// <summary>
/// Gets the <see cref="ObjectExplorerService"/> if available, by looking it up
/// from the <see cref="ServiceProvider"/>
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidOperationException">
/// Thrown if the <see cref="ServiceProvider"/> is not set or the <see cref="ObjectExplorerService"/>
/// isn't available from that provider
/// </exception>
public ObjectExplorerService GetObjectExplorerService()
{
if (ServiceProvider == null)
{
throw new InvalidOperationException(SR.ServiceProviderNotSet);
}
return ServiceProvider.GetService<ObjectExplorerService>()
?? throw new InvalidOperationException(SR.ServiceNotFound(nameof(ObjectExplorerService)));
}
/// <summary> /// <summary>
/// Copies the context for use by another node /// Copies the context for use by another node
/// </summary> /// </summary>
@@ -129,7 +114,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
/// <returns>new <see cref="SmoQueryContext"/> with all fields except <see cref="Parent"/> the same</returns> /// <returns>new <see cref="SmoQueryContext"/> with all fields except <see cref="Parent"/> the same</returns>
public SmoQueryContext CopyWithParent(SmoObjectBase parent) public SmoQueryContext CopyWithParent(SmoObjectBase parent)
{ {
SmoQueryContext context = new SmoQueryContext(this.Server, this.ServiceProvider, this.smoWrapper) SmoQueryContext context = new SmoQueryContext(this.Server, this.ServiceProvider, this.smoWrapper, this.groupBySchemaFlag)
{ {
database = this.Database, database = this.Database,
Parent = parent, Parent = parent,

View File

@@ -3,8 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
// This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file // This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen".
@@ -15,11 +13,11 @@ using System.Composition;
using System.Linq; using System.Linq;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Broker; using Microsoft.SqlServer.Management.Smo.Broker;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Index = Microsoft.SqlServer.Management.Smo.Index; using Index = Microsoft.SqlServer.Management.Smo.Index;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
[Export(typeof(SmoQuerier))] [Export(typeof(SmoQuerier))]

View File

@@ -12,8 +12,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
// This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file // This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen".
@@ -24,11 +22,11 @@ using System.Composition;
using System.Linq; using System.Linq;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Broker; using Microsoft.SqlServer.Management.Smo.Broker;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Index = Microsoft.SqlServer.Management.Smo.Index; using Index = Microsoft.SqlServer.Management.Smo.Index;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
<# <#
var directory = Path.GetDirectoryName(Host.TemplateFile); var directory = Path.GetDirectoryName(Host.TemplateFile);

View File

@@ -3,11 +3,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Custom name for table /// Custom name for table

View File

@@ -3,12 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.Metadata;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// A Node in the tree representing a SMO-based object /// A Node in the tree representing a SMO-based object
@@ -45,10 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
/// </summary> /// </summary>
public static int NextSortPriority public static int NextSortPriority
{ {
get get => System.Threading.Interlocked.Increment(ref _nextSortPriority);
{
return System.Threading.Interlocked.Increment(ref _nextSortPriority);
}
} }
public NamedSmoObject SmoObject { get; private set; } public NamedSmoObject SmoObject { get; private set; }
@@ -58,7 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
SmoObject = smoObject; SmoObject = smoObject;
NodeValue = smoObject.Name; NodeValue = smoObject.Name;
ScriptSchemaObjectBase schemaBaseObject = smoObject as ScriptSchemaObjectBase; ScriptSchemaObjectBase schemaBaseObject = smoObject as ScriptSchemaObjectBase;
ObjectMetadata = new Metadata.Contracts.ObjectMetadata(); ObjectMetadata = new ObjectMetadata();
ObjectMetadata.Name = smoObject.Name; ObjectMetadata.Name = smoObject.Name;
try try

View File

@@ -3,8 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
// This file was generated by a T4 Template. Do not modify directly, instead update the SmoTreeNodesDefinition.xml file // This file was generated by a T4 Template. Do not modify directly, instead update the SmoTreeNodesDefinition.xml file
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen".
@@ -13,47 +11,23 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Composition; using System.Composition;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Workspace;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
internal sealed partial class DatabaseTreeNode : SmoTreeNode public partial class DatabaseTreeNode : SmoTreeNode
{ {
public DatabaseTreeNode() : base() public DatabaseTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "Database"; this.NodeType = "Database";
this.NodeTypeId = NodeTypes.Database; this.NodeTypeId = NodeTypes.Database;
if(WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema)
{
this.FilterProperties = new NodeFilterProperty[]
{
new NodeFilterProperty
{
Name = "Name",
DisplayName = SR.FilterName,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterNameDescription,
},
new NodeFilterProperty
{
Name = "Owner",
DisplayName = SR.FilterOwner,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterOwnerDescription,
},
};
}
OnInitialize(); OnInitialize();
} }
} }
internal sealed partial class TableTreeNode : SmoTreeNode public partial class TableTreeNode : SmoTreeNode
{ {
public TableTreeNode() : base() public TableTreeNode() : base()
{ {
@@ -64,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class ViewTreeNode : SmoTreeNode public partial class ViewTreeNode : SmoTreeNode
{ {
public ViewTreeNode() : base() public ViewTreeNode() : base()
{ {
@@ -75,7 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class UserDefinedTableTypeTreeNode : SmoTreeNode public partial class UserDefinedTableTypeTreeNode : SmoTreeNode
{ {
public UserDefinedTableTypeTreeNode() : base() public UserDefinedTableTypeTreeNode() : base()
{ {
@@ -86,7 +60,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class StoredProcedureTreeNode : SmoTreeNode public partial class StoredProcedureTreeNode : SmoTreeNode
{ {
public StoredProcedureTreeNode() : base() public StoredProcedureTreeNode() : base()
{ {
@@ -97,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class TableValuedFunctionTreeNode : SmoTreeNode public partial class TableValuedFunctionTreeNode : SmoTreeNode
{ {
public TableValuedFunctionTreeNode() : base() public TableValuedFunctionTreeNode() : base()
{ {
@@ -108,7 +82,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class ScalarValuedFunctionTreeNode : SmoTreeNode public partial class ScalarValuedFunctionTreeNode : SmoTreeNode
{ {
public ScalarValuedFunctionTreeNode() : base() public ScalarValuedFunctionTreeNode() : base()
{ {
@@ -119,7 +93,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class AggregateFunctionTreeNode : SmoTreeNode public partial class AggregateFunctionTreeNode : SmoTreeNode
{ {
public AggregateFunctionTreeNode() : base() public AggregateFunctionTreeNode() : base()
{ {
@@ -130,7 +104,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class FileGroupTreeNode : SmoTreeNode public partial class FileGroupTreeNode : SmoTreeNode
{ {
public FileGroupTreeNode() : base() public FileGroupTreeNode() : base()
{ {
@@ -141,7 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class ExternalTableTreeNode : SmoTreeNode public partial class ExternalTableTreeNode : SmoTreeNode
{ {
public ExternalTableTreeNode() : base() public ExternalTableTreeNode() : base()
{ {
@@ -152,7 +126,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class ExternalResourceTreeNode : SmoTreeNode public partial class ExternalResourceTreeNode : SmoTreeNode
{ {
public ExternalResourceTreeNode() : base() public ExternalResourceTreeNode() : base()
{ {
@@ -163,7 +137,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class HistoryTableTreeNode : SmoTreeNode public partial class HistoryTableTreeNode : SmoTreeNode
{ {
public HistoryTableTreeNode() : base() public HistoryTableTreeNode() : base()
{ {
@@ -174,7 +148,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
} }
internal sealed partial class ExpandableSchemaTreeNode : SmoTreeNode public partial class ExpandableSchemaTreeNode : SmoTreeNode
{ {
public ExpandableSchemaTreeNode() : base() public ExpandableSchemaTreeNode() : base()
{ {
@@ -303,6 +277,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
var child = new DatabaseTreeNode(); var child = new DatabaseTreeNode();
InitializeChild(parent, child, context); InitializeChild(parent, child, context);
if((parent.GetContext() as SmoQueryContext).GroupBySchema)
{
child.FilterProperties = new NodeFilterProperty[]
{
new NodeFilterProperty
{
Name = "Name",
DisplayName = SR.FilterName,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterNameDescription,
},
new NodeFilterProperty
{
Name = "Owner",
DisplayName = SR.FilterOwner,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterOwnerDescription,
},
};
}
return child; return child;
} }
} }
@@ -444,6 +438,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
var child = new DatabaseTreeNode(); var child = new DatabaseTreeNode();
InitializeChild(parent, child, context); InitializeChild(parent, child, context);
if((parent.GetContext() as SmoQueryContext).GroupBySchema)
{
child.FilterProperties = new NodeFilterProperty[]
{
new NodeFilterProperty
{
Name = "Name",
DisplayName = SR.FilterName,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterNameDescription,
},
new NodeFilterProperty
{
Name = "Owner",
DisplayName = SR.FilterOwner,
Type = NodeFilterPropertyDataType.String,
Description = SR.FilterOwnerDescription,
},
};
}
return child; return child;
} }
} }
@@ -769,7 +783,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Tables, NodeValue = SR.SchemaHierarchy_Tables,
@@ -833,7 +847,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
}); });
} }
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Views, NodeValue = SR.SchemaHierarchy_Views,
@@ -873,7 +887,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
}); });
} }
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Synonyms, NodeValue = SR.SchemaHierarchy_Synonyms,
@@ -883,7 +897,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
SortPriority = SmoTreeNode.NextSortPriority, SortPriority = SmoTreeNode.NextSortPriority,
}); });
} }
if (WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if ((parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_BuiltInSchema, NodeValue = SR.SchemaHierarchy_BuiltInSchema,
@@ -928,19 +942,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
}); });
} }
internal override Type[] ChildQuerierTypes protected override Type[] GetChildQuerierTypes(TreeNode parent)
{ {
get List<Type> conditionalTypesList = new List<Type>();
{ if ((parent.GetContext() as SmoQueryContext).GroupBySchema)
List<Type> conditionalTypesList = new List<Type>(); {
if (WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) conditionalTypesList.Add(typeof(SqlSchemaQuerier));
{ }
conditionalTypesList.Add(typeof(SqlSchemaQuerier)); return conditionalTypesList.ToArray();
}
return conditionalTypesList.ToArray();
}
} }
public override TreeNode CreateChild(TreeNode parent, object context) public override TreeNode CreateChild(TreeNode parent, object context)
{ {
var child = new ExpandableSchemaTreeNode(); var child = new ExpandableSchemaTreeNode();
@@ -1557,7 +1569,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_StoredProcedures, NodeValue = SR.SchemaHierarchy_StoredProcedures,
@@ -1604,7 +1616,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
} }
}); });
} }
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Functions, NodeValue = SR.SchemaHierarchy_Functions,
@@ -1628,7 +1640,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
ValidFor = ValidForFlag.AllOnPrem|ValidForFlag.AzureV12, ValidFor = ValidForFlag.AllOnPrem|ValidForFlag.AzureV12,
SortPriority = SmoTreeNode.NextSortPriority, SortPriority = SmoTreeNode.NextSortPriority,
}); });
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Types, NodeValue = SR.SchemaHierarchy_Types,
@@ -1638,7 +1650,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
SortPriority = SmoTreeNode.NextSortPriority, SortPriority = SmoTreeNode.NextSortPriority,
}); });
} }
if (!WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.GroupBySchema) if (!(parent.GetContext() as SmoQueryContext).GroupBySchema)
{ {
currentChildren.Add(new FolderNode { currentChildren.Add(new FolderNode {
NodeValue = SR.SchemaHierarchy_Sequences, NodeValue = SR.SchemaHierarchy_Sequences,

View File

@@ -14,8 +14,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
// This file was generated by a T4 Template. Do not modify directly, instead update the SmoTreeNodesDefinition.xml file // This file was generated by a T4 Template. Do not modify directly, instead update the SmoTreeNodesDefinition.xml file
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", // and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". // or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen".
@@ -24,13 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Composition; using System.Composition;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Workspace;
namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
<# <#
@@ -79,76 +73,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
var name = TreeNode.GetAttribute("Name"); var name = TreeNode.GetAttribute("Name");
var type = !string.IsNullOrWhiteSpace(TreeNode.GetAttribute("Type")) ? TreeNode.GetAttribute("Type") : TreeNode.GetAttribute("Name"); var type = !string.IsNullOrWhiteSpace(TreeNode.GetAttribute("Type")) ? TreeNode.GetAttribute("Type") : TreeNode.GetAttribute("Name");
WriteLine(" internal sealed partial class {0} : SmoTreeNode", name); WriteLine(" public partial class {0} : SmoTreeNode", name);
WriteLine(" {"); WriteLine(" {");
WriteLine(" public {0}() : base()", name); WriteLine(" public {0}() : base()", name);
WriteLine(" {"); WriteLine(" {");
WriteLine(" NodeValue = string.Empty;"); WriteLine(" NodeValue = string.Empty;");
WriteLine(" this.NodeType = \"{0}\";", type.Replace("TreeNode", string.Empty)); WriteLine(" this.NodeType = \"{0}\";", type.Replace("TreeNode", string.Empty));
WriteLine(" this.NodeTypeId = NodeTypes.{0};", name.Replace("TreeNode", string.Empty)); WriteLine(" this.NodeTypeId = NodeTypes.{0};", name.Replace("TreeNode", string.Empty));
List<XmlElement> filterProperties = GetFilterProperties(xmlFile, type.Replace("TreeNode", string.Empty));
string settingsFlag = GetFilterSettingsFlag(xmlFile, type.Replace("TreeNode", string.Empty));
if(!String.IsNullOrEmpty(settingsFlag))
{
WriteLine(" if({0})", GetSettingsString(settingsFlag));
WriteLine(" {");
}
if(filterProperties.Count > 0){
WriteLine(" this.FilterProperties = new NodeFilterProperty[]");
WriteLine(" {");
foreach (var filterDef in filterProperties)
{
var filterName = filterDef.GetAttribute("Name");
var filterDisplayName = filterDef.GetAttribute("LocLabel");
var filterType = filterDef.GetAttribute("Type");
var enumString = "NodeFilterPropertyDataType";
switch (filterType)
{
case "string":
enumString += ".String";
break;
case "bool":
enumString += ".Boolean";
break;
case "date":
enumString += ".Date";
break;
case "choice":
enumString += ".Choice";
break;
}
var filterDescription = filterDef.GetAttribute("Description");
WriteLine(" new NodeFilterProperty");
WriteLine(" {");
WriteLine(" Name = \"{0}\",", filterName);
WriteLine(" DisplayName = {0},", filterDisplayName);
WriteLine(" Type = {0},", enumString);
WriteLine(" Description = {0},", filterDescription);
if(filterType == "choice")
{
var choiceValues = filterDef.ChildNodes;
WriteLine(" Choices = new NodeFilterPropertyChoice[] {");
foreach (XmlElement choice in choiceValues)
{
var choiceName = choice.GetAttribute("LocLabel");
var choiceValue = choice.GetAttribute("Value");
WriteLine(" new NodeFilterPropertyChoice {");
WriteLine(" DisplayName = {0},", choiceName);
WriteLine(" Value = \"{0}\",", choiceValue);
WriteLine(" },");
}
WriteLine(" }");
}
WriteLine(" },");
}
WriteLine(" };");
}
if(!String.IsNullOrEmpty(settingsFlag))
{
WriteLine(" }");
}
WriteLine(" OnInitialize();"); WriteLine(" OnInitialize();");
WriteLine(" }"); WriteLine(" }");
WriteLine(" }"); WriteLine(" }");
@@ -435,11 +366,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
if(ConditionalChildQuerierTypes.Count > 0) if(ConditionalChildQuerierTypes.Count > 0)
{ {
WriteLine(""); WriteLine("");
WriteLine(" internal override Type[] ChildQuerierTypes"); WriteLine(" protected override Type[] GetChildQuerierTypes(TreeNode parent)");
WriteLine(" {"); WriteLine(" {");
WriteLine(" get");
WriteLine(" {"); WriteLine(" List<Type> conditionalTypesList = new List<Type>();");
WriteLine(" List<Type> conditionalTypesList = new List<Type>();");
foreach(XmlElement Querier in ConditionalChildQuerierTypes) foreach(XmlElement Querier in ConditionalChildQuerierTypes)
{ {
var settingsFlag = Querier.GetAttribute("SettingsFlag"); var settingsFlag = Querier.GetAttribute("SettingsFlag");
@@ -447,19 +377,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
if(!string.IsNullOrEmpty(settingsFlag)) if(!string.IsNullOrEmpty(settingsFlag))
{ {
WriteLine(" if ({0})", GetSettingsString(settingsFlag)); WriteLine(" if ({0})", GetSettingsString(settingsFlag));
WriteLine(" {"); WriteLine(" {");
WriteLine(" conditionalTypesList.Add(typeof({0}Querier));", QuerierName); WriteLine(" conditionalTypesList.Add(typeof({0}Querier));", QuerierName);
WriteLine(" }"); WriteLine(" }");
} }
else else
{ {
WriteLine(" conditionalTypesList.Add(typeof({0}Querier));", QuerierName); WriteLine(" conditionalTypesList.Add(typeof({0}Querier));", QuerierName);
} }
} }
WriteLine(" return conditionalTypesList.ToArray();"); WriteLine(" return conditionalTypesList.ToArray();");
WriteLine(" }");
WriteLine(" }"); WriteLine(" }");
WriteLine("");
} }
else else
{ {
@@ -514,6 +444,67 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
WriteLine(" child.SortPriority = SmoTreeNode.NextSortPriority;"); WriteLine(" child.SortPriority = SmoTreeNode.NextSortPriority;");
} }
WriteLine(" InitializeChild(parent, child, context);"); WriteLine(" InitializeChild(parent, child, context);");
List<XmlElement> filterProperties = GetFilterProperties(xmlFile, TreeNode.Replace("TreeNode", string.Empty));
string filterFlag = GetFilterSettingsFlag(xmlFile, TreeNode.Replace("TreeNode", string.Empty));
if(!String.IsNullOrEmpty(filterFlag))
{
WriteLine(" if((parent.GetContext() as SmoQueryContext).{0})", filterFlag);
WriteLine(" {");
}
if(filterProperties.Count > 0){
WriteLine(" child.FilterProperties = new NodeFilterProperty[]");
WriteLine(" {");
foreach (var filterDef in filterProperties)
{
var filterName = filterDef.GetAttribute("Name");
var filterDisplayName = filterDef.GetAttribute("LocLabel");
var filterType = filterDef.GetAttribute("Type");
var enumString = "NodeFilterPropertyDataType";
switch (filterType)
{
case "string":
enumString += ".String";
break;
case "bool":
enumString += ".Boolean";
break;
case "date":
enumString += ".Date";
break;
case "choice":
enumString += ".Choice";
break;
}
var filterDescription = filterDef.GetAttribute("Description");
WriteLine(" new NodeFilterProperty");
WriteLine(" {");
WriteLine(" Name = \"{0}\",", filterName);
WriteLine(" DisplayName = {0},", filterDisplayName);
WriteLine(" Type = {0},", enumString);
WriteLine(" Description = {0},", filterDescription);
if(filterType == "choice")
{
var choiceValues = filterDef.ChildNodes;
WriteLine(" Choices = new NodeFilterPropertyChoice[] {");
foreach (XmlElement choice in choiceValues)
{
var choiceName = choice.GetAttribute("LocLabel");
var choiceValue = choice.GetAttribute("Value");
WriteLine(" new NodeFilterPropertyChoice {");
WriteLine(" DisplayName = {0},", choiceName);
WriteLine(" Value = \"{0}\",", choiceValue);
WriteLine(" },");
}
WriteLine(" }");
}
WriteLine(" },");
}
WriteLine(" };");
WriteLine(" }");
}
WriteLine(" return child;"); WriteLine(" return child;");
WriteLine(" }"); WriteLine(" }");
} }
@@ -849,6 +840,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
notOperator = "!"; notOperator = "!";
settingsName = settingsName.Substring(1, settingsName.Length-1); settingsName = settingsName.Substring(1, settingsName.Length-1);
} }
return String.Format("{0}WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer.{1}", notOperator, settingsName); return String.Format("{0}(parent.GetContext() as SmoQueryContext).{1}", notOperator, settingsName);
} }
#> #>

View File

@@ -677,4 +677,3 @@
<FilterProperty Name="IsNativelyCompiled" LocLabel="SR.FilterIsNativelyCompiled" Type="bool" Description="SR.FilterIsNativelyCompiledDescription"/> <FilterProperty Name="IsNativelyCompiled" LocLabel="SR.FilterIsNativelyCompiled" Type="bool" Description="SR.FilterIsNativelyCompiledDescription"/>
<FilterProperty Name="InPrimaryKey" LocLabel="SR.FilterInPrimaryKey" Type="bool" Description="SR.FilterInPrimaryKeyDescription"/> <FilterProperty Name="InPrimaryKey" LocLabel="SR.FilterInPrimaryKey" Type="bool" Description="SR.FilterInPrimaryKeyDescription"/>
</ServerExplorerTree> </ServerExplorerTree>

View File

@@ -3,14 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Status for triggers /// Status for triggers

View File

@@ -3,14 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Status for logins /// Status for logins

View File

@@ -3,11 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Custom name for view /// Custom name for view

View File

@@ -3,12 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Internal for testing purposes only. This class provides wrapper functionality /// Internal for testing purposes only. This class provides wrapper functionality

View File

@@ -3,12 +3,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
/// <summary> /// <summary>
/// Filters the history tables to only return ones related to the parent table /// Filters the history tables to only return ones related to the parent table

View File

@@ -3,13 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{ {
internal partial class SystemExactNumericsChildFactory internal partial class SystemExactNumericsChildFactory
{ {

View File

@@ -3,15 +3,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{ {
/// <summary> /// <summary>
/// Server Types /// Server Types
@@ -102,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
/// <summary> /// <summary>
/// Creates a server type from the server version /// Creates a server type from the server version
/// </summary> /// </summary>
public static SqlServerType CalculateServerType(ServerInfo serverInfo) public static SqlServerType CalculateServerType(ObjectExplorerServerInfo serverInfo)
{ {
string serverVersion = serverInfo.ServerVersion; string serverVersion = serverInfo.ServerVersion;

View File

@@ -0,0 +1,119 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlTools.SqlCore.Connection;
using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
namespace Microsoft.SqlTools.CoreSql.ObjectExplorer
{
/// <summary>
/// Stateless object explorer class can be used to handle object explorer requests without creating a session. It requires a connection string and a node path to query objects from the server.
/// </summary>
public class StatelessObjectExplorer
{
/// <summary>
/// Expands the node at the given path and returns the child nodes.
/// </summary>
/// <param name="connectionString"> Connection string to connect to the server </param>
/// <param name="accessToken"> Access token to connect to the server. To be used in case of AAD based connections </param>
/// <param name="nodePath"> Path of the node to expand </param>
/// <param name="serverInfo"> Server information </param>
/// <param name="options"> Object explorer options </param>
/// <param name="filters"> Filters to be applied on the leaf nodes </param>
/// <returns> Array of child nodes </returns>
/// <exception cref="ArgumentNullException"> Thrown when the parent node is not found </exception>
/// <exception cref="TimeoutException"> Thrown when the operation times out.</exception> <summary>
/// </summary>
public static TreeNode[] Expand(string connectionString, SecurityToken? accessToken, string nodePath, ObjectExplorerServerInfo serverInfo, ObjectExplorerOptions options, INodeFilter[]? filters = null)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
ServerConnection connection;
if (accessToken != null)
{
connection = new ServerConnection(conn, accessToken as IRenewableToken);
}
else
{
connection = new ServerConnection(conn);
}
ServerNode serverNode = new ServerNode(serverInfo, connection, null, options.GroupBySchemaFlagGetter);
TreeNode rootNode = new DatabaseTreeNode(serverNode, serverInfo.DatabaseName);
if(nodePath == null || nodePath == string.Empty)
{
nodePath = rootNode.GetNodePath();
}
using (var taskCancellationTokenSource = new CancellationTokenSource())
{
TreeNode? node = rootNode;
if (node == null)
{
// Return empty array if node is not found
return new TreeNode[0];
}
if (Monitor.TryEnter(node.BuildingMetadataLock, options.OperationTimeoutSeconds))
{
try
{
var token = accessToken == null ? null : accessToken.Token;
var task = Task.Run(() =>
{
var node = rootNode.FindNodeByPath(nodePath, true, taskCancellationTokenSource.Token);
if (node != null)
{
return node.Expand(taskCancellationTokenSource.Token, token, filters);
} else
{
throw new InvalidArgumentException($"Parent node not found for path {nodePath}");
}
});
if (task.Wait(TimeSpan.FromSeconds(options.OperationTimeoutSeconds)))
{
if (taskCancellationTokenSource.IsCancellationRequested)
{
throw new TimeoutException("The operation has timed out.");
}
return task.Result.ToArray();
}
else
{
throw new TimeoutException("The operation has timed out.");
}
}
finally
{
if (connection.IsOpen)
{
connection.Disconnect();
}
Monitor.Exit(node.BuildingMetadataLock);
}
}
else
{
throw new TimeoutException("The operation has timed out. Could not acquire the lock to build metadata for the node.");
}
}
}
}
}
}

View File

@@ -3,11 +3,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable
using System; using System;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer namespace Microsoft.SqlTools.SqlCore.ObjectExplorer
{ {
/// <summary> /// <summary>
/// Indicates which type of server a given node type is valid for /// Indicates which type of server a given node type is valid for

View File

@@ -3,10 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
#nullable disable namespace Microsoft.SqlTools.SqlCore.Utility
namespace Microsoft.SqlTools.ServiceLayer.Utility
{ {
/// <summary> /// <summary>
/// Common Constant values used across multiple services /// Common Constant values used across multiple services

View File

@@ -0,0 +1,27 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
namespace Microsoft.SqlTools.SqlCore.Utility
{
public static class DatabaseUtils
{
/// <summary>
/// Check if the database is a system database
/// </summary>
/// <param name="databaseName">the name of database</param>
/// <returns>return true if the database is a system database</returns>
public static bool IsSystemDatabaseConnection(string databaseName)
{
return (string.IsNullOrWhiteSpace(databaseName) ||
string.Compare(databaseName, CommonConstants.MasterDatabaseName, StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(databaseName, CommonConstants.MsdbDatabaseName, StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(databaseName, CommonConstants.ModelDatabaseName, StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(databaseName, CommonConstants.TempDbDatabaseName, StringComparison.OrdinalIgnoreCase) == 0);
}
}
}

View File

@@ -0,0 +1,109 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Text;
namespace Microsoft.SqlTools.SqlCore.Utility
{
public class StringUtils
{
/// <summary>
/// Function doubles up specified character in a string
/// </summary>
/// <param name="s"></param>
/// <param name="cEsc"></param>
/// <returns></returns>
public static String EscapeString(string s, char cEsc)
{
if (string.IsNullOrWhiteSpace(s))
{
return s;
}
StringBuilder sb = new StringBuilder(s.Length * 2);
foreach (char c in s)
{
sb.Append(c);
if (cEsc == c)
sb.Append(c);
}
return sb.ToString();
}
/// <summary>
/// Function doubles up ']' character in a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String EscapeStringCBracket(string s)
{
return EscapeString(s, ']');
}
/// <summary>
/// Function doubles up '\'' character in a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String EscapeStringSQuote(string s)
{
return EscapeString(s, '\'');
}
/// <summary>
/// Function removes doubled up specified character from a string
/// </summary>
/// <param name="s"></param>
/// <param name="cEsc"></param>
/// <returns></returns>
public static String UnEscapeString(string s, char cEsc)
{
StringBuilder sb = new StringBuilder(s.Length);
bool foundBefore = false;
foreach (char c in s)
{
if (cEsc == c) // character to unescape
{
if (foundBefore) // skip second occurrence
{
foundBefore = false;
}
else // set the flag to skip next time around
{
sb.Append(c);
foundBefore = true;
}
}
else
{
sb.Append(c);
foundBefore = false;
}
}
return sb.ToString();
}
/// <summary>
/// Function removes doubled up ']' character from a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String UnEscapeStringCBracket(string s)
{
return UnEscapeString(s, ']');
}
/// <summary>
/// Function removes doubled up '\'' character from a string
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static String UnEscapeStringSQuote(string s)
{
return UnEscapeString(s, '\'');
}
}
}

View File

@@ -21,6 +21,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using NUnit.Framework; using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper; using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
using Microsoft.SqlTools.SqlCore.Metadata;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
{ {

View File

@@ -18,7 +18,7 @@ using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions; using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions;
@@ -70,9 +70,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, "TepmDb", async (testDbName, session) => await RunTest(databaseName, query, "TepmDb", async (testDbName, session) =>
{ {
var serverChildren = (await _service.ExpandNode(session, session.Root.GetNodePath())).Nodes; var serverChildren = (await _service.ExpandNode(session, session.Root.GetNodePath())).Nodes;
var securityNode = serverChildren.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_Security); var securityNode = serverChildren.FirstOrDefault(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Security);
var securityChildren = (await _service.ExpandNode(session, securityNode.NodePath)).Nodes; var securityChildren = (await _service.ExpandNode(session, securityNode.NodePath)).Nodes;
var loginsNode = securityChildren.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_Logins); var loginsNode = securityChildren.FirstOrDefault(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Logins);
var loginsChildren = (await _service.ExpandNode(session, loginsNode.NodePath)).Nodes; var loginsChildren = (await _service.ExpandNode(session, loginsNode.NodePath)).Nodes;
var login = loginsChildren.FirstOrDefault(x => x.Label == "OEServerLogin"); var login = loginsChildren.FirstOrDefault(x => x.Label == "OEServerLogin");
Assert.NotNull(login); Assert.NotNull(login);
@@ -106,9 +106,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, "TepmDb", async (testDbName, session) => await RunTest(databaseName, query, "TepmDb", async (testDbName, session) =>
{ {
var serverChildren = (await _service.ExpandNode(session, session.Root.GetNodePath())).Nodes; var serverChildren = (await _service.ExpandNode(session, session.Root.GetNodePath())).Nodes;
var serverObjectsNode = serverChildren.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_ServerObjects); var serverObjectsNode = serverChildren.FirstOrDefault(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_ServerObjects);
var serverObjectsChildren = (await _service.ExpandNode(session, serverObjectsNode.NodePath)).Nodes; var serverObjectsChildren = (await _service.ExpandNode(session, serverObjectsNode.NodePath)).Nodes;
var triggersNode = serverObjectsChildren.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_Triggers); var triggersNode = serverObjectsChildren.FirstOrDefault(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Triggers);
var triggersChildren = await _service.ExpandNode(session, triggersNode.NodePath); var triggersChildren = await _service.ExpandNode(session, triggersNode.NodePath);
var trigger = triggersChildren.Nodes.FirstOrDefault(x => x.Label == "OE_ddl_trig_database"); var trigger = triggersChildren.Nodes.FirstOrDefault(x => x.Label == "OE_ddl_trig_database");
Assert.NotNull(trigger); Assert.NotNull(trigger);
@@ -134,7 +134,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
string databaseName = "#testDb#"; string databaseName = "#testDb#";
await RunTest(databaseName, query, "TestDb", async (testDbName, session) => await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
{ {
var tablesNode = await FindNodeByLabel(session.Root.ToNodeInfo(), session, SR.SchemaHierarchy_Tables); var tablesNode = await FindNodeByLabel(new NodeInfo(session.Root), session, SqlTools.SqlCore.SR.SchemaHierarchy_Tables);
var tableChildren = (await _service.ExpandNode(session, tablesNode.NodePath)).Nodes; var tableChildren = (await _service.ExpandNode(session, tablesNode.NodePath)).Nodes;
string dropTableScript = "Drop Table t1"; string dropTableScript = "Drop Table t1";
Assert.True(tableChildren.Any(t => t.Label == "dbo.t1")); Assert.True(tableChildren.Any(t => t.Label == "dbo.t1"));
@@ -161,7 +161,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
var databaseNode = await ExpandServerNodeAndVerifyDatabaseHierachy(testDbName, session); var databaseNode = await ExpandServerNodeAndVerifyDatabaseHierachy(testDbName, session);
var response = await _service.ExpandNode(session, databaseNode.NodePath); var response = await _service.ExpandNode(session, databaseNode.NodePath);
Assert.True(response.ErrorMessage.Contains(string.Format(CultureInfo.InvariantCulture, SR.DatabaseNotAccessible, testDbName))); Assert.True(response.ErrorMessage.Contains(string.Format(CultureInfo.InvariantCulture, SqlTools.SqlCore.SR.DatabaseNotAccessible, testDbName)));
}); });
} }
@@ -178,7 +178,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
string databaseName = "#testDb#"; string databaseName = "#testDb#";
await RunTest(databaseName, query, "TestDb", async (testDbName, session) => await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
{ {
var tablesNode = await FindNodeByLabel(session.Root.ToNodeInfo(), session, SR.SchemaHierarchy_Tables); var tablesNode = await FindNodeByLabel(new NodeInfo(session.Root), session, SqlTools.SqlCore.SR.SchemaHierarchy_Tables);
//Expand Tables node //Expand Tables node
var tableChildren = await _service.ExpandNode(session, tablesNode.NodePath); var tableChildren = await _service.ExpandNode(session, tablesNode.NodePath);
@@ -198,7 +198,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
//Verify the tables cache has items //Verify the tables cache has items
var rootChildrenCache = session.Root.GetChildren(); var rootChildrenCache = session.Root.GetChildren();
var tablesCache = rootChildrenCache.First(x => x.Label == SR.SchemaHierarchy_Tables).GetChildren(); var tablesCache = rootChildrenCache.First(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables).GetChildren();
Assert.True(tablesCache.Any()); Assert.True(tablesCache.Any());
await VerifyRefresh(session, tablesNode.NodePath, "dbo.t1"); await VerifyRefresh(session, tablesNode.NodePath, "dbo.t1");
@@ -220,10 +220,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, "TestDb", async (testDbName, session) => await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
{ {
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = false }; WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = false };
var databaseNode = session.Root.ToNodeInfo(); var databaseNode = new NodeInfo(session.Root);
var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath); var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath);
Assert.True(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Tables), "Tables node should be found in database node when group by schema is disabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables), "Tables node should be found in database node when group by schema is disabled");
Assert.True(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Views), "Views node should be found in database node when group by schema is disabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Views), "Views node should be found in database node when group by schema is disabled");
}); });
} }
@@ -238,13 +238,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, "TestDb", async (testDbName, session) => await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
{ {
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = true }; WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = true };
var databaseNode = session.Root.ToNodeInfo(); var databaseNode = new NodeInfo(session.Root);
var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath); var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath);
Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t1"), "Schema node t1 should be found in database node when group by schema is enabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t1"), "Schema node t1 should be found in database node when group by schema is enabled");
Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t2"), "Schema node t2 should be found in database node when group by schema is enabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t2"), "Schema node t2 should be found in database node when group by schema is enabled");
Assert.False(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Tables), "Tables node should not be found in database node when group by schema is enabled"); Assert.False(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables), "Tables node should not be found in database node when group by schema is enabled");
Assert.False(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Views), "Views node should not be found in database node when group by schema is enabled"); Assert.False(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Views), "Views node should not be found in database node when group by schema is enabled");
Assert.True(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Programmability), "Programmability node should be found in database node when group by schema is enabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Programmability), "Programmability node should be found in database node when group by schema is enabled");
var lastSchemaPosition = Array.FindLastIndex(databaseChildren.Nodes, t => t.ObjectType == nameof(NodeTypes.ExpandableSchema)); var lastSchemaPosition = Array.FindLastIndex(databaseChildren.Nodes, t => t.ObjectType == nameof(NodeTypes.ExpandableSchema));
var firstNonSchemaPosition = Array.FindIndex(databaseChildren.Nodes, t => t.ObjectType != nameof(NodeTypes.ExpandableSchema)); var firstNonSchemaPosition = Array.FindIndex(databaseChildren.Nodes, t => t.ObjectType != nameof(NodeTypes.ExpandableSchema));
Assert.True(lastSchemaPosition < firstNonSchemaPosition, "Schema nodes should be before non-schema nodes"); Assert.True(lastSchemaPosition < firstNonSchemaPosition, "Schema nodes should be before non-schema nodes");
@@ -263,7 +263,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, "TestDb", async (testDbName, session) => await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
{ {
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = true }; WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = true };
var databaseNode = session.Root.ToNodeInfo(); var databaseNode = new NodeInfo(session.Root);
var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath); var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath);
Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t1"), "Non legacy schema node t1 should be found in database node when group by schema is enabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t1"), "Non legacy schema node t1 should be found in database node when group by schema is enabled");
Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t2"), "Non legacy schema node t2 should be found in database node when group by schema is enabled"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == "t2"), "Non legacy schema node t2 should be found in database node when group by schema is enabled");
@@ -283,7 +283,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
Assert.That(legacySchemas, Does.Not.Contain(nodes.Label), "Legacy schema node should not be found in database node when group by schema is enabled"); Assert.That(legacySchemas, Does.Not.Contain(nodes.Label), "Legacy schema node should not be found in database node when group by schema is enabled");
} }
var legacySchemasNode = databaseChildren.Nodes.First(t => t.Label == SR.SchemaHierarchy_BuiltInSchema); var legacySchemasNode = databaseChildren.Nodes.First(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_BuiltInSchema);
var legacySchemasChildren = await _service.ExpandNode(session, legacySchemasNode.NodePath); var legacySchemasChildren = await _service.ExpandNode(session, legacySchemasNode.NodePath);
foreach (var nodes in legacySchemasChildren.Nodes) foreach (var nodes in legacySchemasChildren.Nodes)
{ {
@@ -306,10 +306,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
string databaseName = "#testDb#"; string databaseName = "#testDb#";
await RunTest(databaseName, query, "Testdb", async (testDbName, session) => await RunTest(databaseName, query, "Testdb", async (testDbName, session) =>
{ {
var databaseNode = session.Root.ToNodeInfo(); var databaseNode = new NodeInfo(session.Root);
var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath); var databaseChildren = await _service.ExpandNode(session, databaseNode.NodePath);
Assert.True(databaseChildren.Nodes.Any(t => t.Label == SR.SchemaHierarchy_Tables), "Tables node should be found in database node"); Assert.True(databaseChildren.Nodes.Any(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables), "Tables node should be found in database node");
var tablesNode = databaseChildren.Nodes.First(t => t.Label == SR.SchemaHierarchy_Tables); var tablesNode = databaseChildren.Nodes.First(t => t.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables);
var NameProperty = tablesNode.FilterableProperties.First(t => t.Name == "Name"); var NameProperty = tablesNode.FilterableProperties.First(t => t.Name == "Name");
Assert.True(NameProperty != null, "Name property should be found in tables node"); Assert.True(NameProperty != null, "Name property should be found in tables node");
@@ -385,11 +385,11 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
private async Task VerifyRefresh(ObjectExplorerSession session, string tablePath, string tableName, bool deleted = true) private async Task VerifyRefresh(ObjectExplorerSession session, string tablePath, string tableName, bool deleted = true)
{ {
//Refresh Root //Refresh Root
var rootChildren = await _service.ExpandNode(session, session.Root.ToNodeInfo().NodePath, true); var rootChildren = await _service.ExpandNode(session, new NodeInfo(session.Root).NodePath, true);
//Verify tables cache is empty //Verify tables cache is empty
var rootChildrenCache = session.Root.GetChildren(); var rootChildrenCache = session.Root.GetChildren();
var tablesCache = rootChildrenCache.First(x => x.Label == SR.SchemaHierarchy_Tables).GetChildren(); var tablesCache = rootChildrenCache.First(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables).GetChildren();
Assert.False(tablesCache.Any()); Assert.False(tablesCache.Any());
//Expand Tables //Expand Tables
@@ -400,7 +400,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
//Verify tables cache has items //Verify tables cache has items
rootChildrenCache = session.Root.GetChildren(); rootChildrenCache = session.Root.GetChildren();
tablesCache = rootChildrenCache.First(x => x.Label == SR.SchemaHierarchy_Tables).GetChildren(); tablesCache = rootChildrenCache.First(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables).GetChildren();
Assert.True(tablesCache.Any()); Assert.True(tablesCache.Any());
} }
@@ -473,7 +473,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
Assert.That(session, Is.Not.Null, nameof(session)); Assert.That(session, Is.Not.Null, nameof(session));
Assert.That(session.Root, Is.Not.Null, nameof(session.Root)); Assert.That(session.Root, Is.Not.Null, nameof(session.Root));
var nodeInfo = session.Root.ToNodeInfo(); var nodeInfo = new NodeInfo(session.Root);
Assert.That(nodeInfo.IsLeaf, Is.False, "Should not be a leaf node"); Assert.That(nodeInfo.IsLeaf, Is.False, "Should not be a leaf node");
NodeInfo databaseNode = null; NodeInfo databaseNode = null;
@@ -496,8 +496,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
// Verify the test databases is in the list // Verify the test databases is in the list
Assert.False(databases.Any(x => x.Label == "master")); Assert.False(databases.Any(x => x.Label == "master"));
Assert.That(databases, Has.None.Matches<NodeInfo>(n => n.Label == "master"), "master database not expected in user databases folder"); Assert.That(databases, Has.None.Matches<NodeInfo>(n => n.Label == "master"), "master database not expected in user databases folder");
var systemDatabasesNodes = databasesChildren.Where(x => x.Label == SR.SchemaHierarchy_SystemDatabases).ToList(); var systemDatabasesNodes = databasesChildren.Where(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemDatabases).ToList();
Assert.That(systemDatabasesNodes, Has.Count.EqualTo(1), $"Exactly one {SR.SchemaHierarchy_SystemDatabases} node expected"); Assert.That(systemDatabasesNodes, Has.Count.EqualTo(1), $"Exactly one {SqlTools.SqlCore.SR.SchemaHierarchy_SystemDatabases} node expected");
var expandResponse = await _service.ExpandNode(session, systemDatabasesNodes.First().NodePath); var expandResponse = await _service.ExpandNode(session, systemDatabasesNodes.First().NodePath);
Assert.That(expandResponse.Nodes, Has.One.Matches<NodeInfo>(n => n.Label == "master"), "master database expected in system databases folder"); Assert.That(expandResponse.Nodes, Has.One.Matches<NodeInfo>(n => n.Label == "master"), "master database expected in system databases folder");
@@ -507,10 +507,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
else else
{ {
Assert.That(nodeInfo.NodeType, Is.EqualTo(NodeTypes.Database.ToString()), $"Database node {nodeInfo.Label} has incorrect type"); Assert.That(nodeInfo.NodeType, Is.EqualTo(NodeTypes.Database.ToString()), $"Database node {nodeInfo.Label} has incorrect type");
databaseNode = session.Root.ToNodeInfo(); databaseNode = new NodeInfo(session.Root);
Assert.True(databaseNode.Label.Contains(databaseName)); Assert.True(databaseNode.Label.Contains(databaseName));
var databasesChildren = (await _service.ExpandNode(session, databaseNode.NodePath)).Nodes; var databasesChildren = (await _service.ExpandNode(session, databaseNode.NodePath)).Nodes;
Assert.False(databasesChildren.Any(x => x.Label == SR.SchemaHierarchy_SystemDatabases)); Assert.False(databasesChildren.Any(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemDatabases));
} }
Assert.That(databaseNode, Is.Not.Null, "Database node should not be null"); Assert.That(databaseNode, Is.Not.Null, "Database node should not be null");
@@ -521,7 +521,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
Assert.NotNull(session); Assert.NotNull(session);
Assert.NotNull(session.Root); Assert.NotNull(session.Root);
var nodeInfo = session.Root.ToNodeInfo(); var nodeInfo = new NodeInfo(session.Root);
Assert.AreEqual(false, nodeInfo.IsLeaf); Assert.AreEqual(false, nodeInfo.IsLeaf);
Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Database.ToString()); Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Database.ToString());
Assert.True(nodeInfo.Label.Contains(databaseName)); Assert.True(nodeInfo.Label.Contains(databaseName));
@@ -533,7 +533,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.AreEqual("Folder", item.NodeType); Assert.AreEqual("Folder", item.NodeType);
} }
var tablesRoot = children.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_Tables); var tablesRoot = children.FirstOrDefault(x => x.Label == SqlTools.SqlCore.SR.SchemaHierarchy_Tables);
Assert.NotNull(tablesRoot); Assert.NotNull(tablesRoot);
} }
@@ -555,10 +555,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
stringBuilder.Append($"NodeType: {child.NodeType} Label: {child.Label} SubType:{child.NodeSubType} Status:{child.NodeStatus}{Environment.NewLine}"); stringBuilder.Append($"NodeType: {child.NodeType} Label: {child.Label} SubType:{child.NodeSubType} Status:{child.NodeStatus}{Environment.NewLine}");
} }
if (!verifySystemObjects && (child.Label == SR.SchemaHierarchy_SystemStoredProcedures || if (!verifySystemObjects && (child.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemStoredProcedures ||
child.Label == SR.SchemaHierarchy_SystemViews || child.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemViews ||
child.Label == SR.SchemaHierarchy_SystemFunctions || child.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemFunctions ||
child.Label == SR.SchemaHierarchy_SystemDataTypes)) child.Label == SqlTools.SqlCore.SR.SchemaHierarchy_SystemDataTypes))
{ {
// don't expand the system folders because then the test will take for ever // don't expand the system folders because then the test will take for ever
} }
@@ -642,7 +642,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await RunTest(databaseName, query, testDbPrefix, async (testDbName, session) => await RunTest(databaseName, query, testDbPrefix, async (testDbName, session) =>
{ {
await ExpandServerNodeAndVerifyDatabaseHierachy(testDbName, session, false); await ExpandServerNodeAndVerifyDatabaseHierachy(testDbName, session, false);
await ExpandTree(session.Root.ToNodeInfo(), session, stringBuilder, verifySystemObjects); await ExpandTree(new NodeInfo(session.Root), session, stringBuilder, verifySystemObjects);
string baseline = string.IsNullOrEmpty(baselineFileName) ? string.Empty : LoadBaseLine(baselineFileName); string baseline = string.IsNullOrEmpty(baselineFileName) ? string.Empty : LoadBaseLine(baselineFileName);
if (!string.IsNullOrEmpty(baseline)) if (!string.IsNullOrEmpty(baseline))
{ {

View File

@@ -0,0 +1,84 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Threading.Tasks;
using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.CoreSql.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions;
using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{
public class StatelessObjectExplorerServiceTests
{
string databaseName = "tempdb";
ObjectExplorerServerInfo serverInfo = new ObjectExplorerServerInfo()
{
DatabaseName = "tempdb",
ServerName = "testserver",
UserName = "testuser",
IsCloud = true,
isDefaultOrSystemDatabase = false
};
ObjectExplorerOptions options = new ObjectExplorerOptions()
{
GroupBySchemaFlagGetter = () => true,
OperationTimeoutSeconds = 10000,
};
[Test]
[TestCase("", "dbo")]
[TestCase("testserver/{0}/dbo", "Tables")]
[TestCase("testserver/{0}/dbo/Tables", "dbo.t1")]
[TestCase("testserver/{0}/dbo/Tables", "dbo.t2")]
public async Task ExpandingPathShouldReturnCorrectNodes(string oePath, string childLabel)
{
var query = @"Create table t1 (c1 int)
GO
Create table t2 (c1 int)
GO";
await RunTest(databaseName, query, "testdb", async (testdbName, connectionString) =>
{
serverInfo.DatabaseName = testdbName;
var pathWithDb = string.Format(oePath, testdbName);
var nodes = StatelessObjectExplorer.Expand(connectionString, null, pathWithDb, serverInfo, options);
Assert.True(nodes.Any(node => node.Label == childLabel), $"Expansion result for {pathWithDb} does not contain node {childLabel}");
});
}
private async Task RunTest(string databaseName, string query, string testDbPrefix, Func<string, string, Task> test)
{
SqlTestDb? testDb = null;
try
{
testDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, query, testDbPrefix);
if (databaseName == "#testDb#")
{
databaseName = testDb.DatabaseName;
}
await test(testDb.DatabaseName, testDb.ConnectionString);
}
catch (Exception ex)
{
string msg = ex.BuildRecursiveErrorMessage();
throw new Exception($"Failed to run OE test. error:{msg} {ex.StackTrace}");
}
finally
{
if (testDb != null)
{
await testDb.CleanupAsync();
}
}
}
}
}

View File

@@ -34,6 +34,7 @@
<ProjectReference Include="../../src/Microsoft.SqlTools.ResourceProvider.Core/Microsoft.SqlTools.ResourceProvider.Core.csproj" /> <ProjectReference Include="../../src/Microsoft.SqlTools.ResourceProvider.Core/Microsoft.SqlTools.ResourceProvider.Core.csproj" />
<ProjectReference Include="../../src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj" /> <ProjectReference Include="../../src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj" />
<ProjectReference Include="../../test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj" /> <ProjectReference Include="../../test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj" />
<ProjectReference Include="../../src/Microsoft.SqlTools.SqlCore/Microsoft.SqlTools.SqlCore.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />

View File

@@ -4,13 +4,17 @@
// //
using System; using System;
using System.Linq; using System.Linq;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Workspace; using Microsoft.SqlTools.ServiceLayer.Workspace;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
@@ -19,20 +23,28 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
{ {
Mock<DatabaseChildFactory> factory; Mock<DatabaseChildFactory> factory;
Mock<TreeNode> node; Mock<TreeNode> node;
Mock<SmoQueryContext> context;
bool enableGroupBySchema = false;
[SetUp] [SetUp]
public void init() public void init()
{ {
factory = new Mock<DatabaseChildFactory>(); factory = new Mock<DatabaseChildFactory>();
factory.SetupGet(c => c.ChildQuerierTypes).Returns(null as Type[]); factory.SetupGet(c => c.ChildQuerierTypes).Returns(null as Type[]);
factory.Setup(c => c.CreateChild(It.IsAny<TreeNode>(), It.IsAny<SqlSmoObject>())).Returns((TreeNode node, Schema obj) => { factory.Setup(c => c.CreateChild(It.IsAny<TreeNode>(), It.IsAny<SqlSmoObject>())).Returns((TreeNode node, Schema obj) =>
return new TreeNode(){ {
return new TreeNode()
{
Label = obj.Name, Label = obj.Name,
NodeType = nameof(NodeTypes.Schemas) NodeType = nameof(NodeTypes.Schemas)
}; };
}); });
factory.CallBase = true; factory.CallBase = true;
Mock<SmoQueryContext> context = new Mock<SmoQueryContext>(new Server(), null); context = new Mock<SmoQueryContext>(new Server(), ExtensionServiceProvider.CreateDefaultServiceProvider(), () =>
{
return enableGroupBySchema;
});
context.CallBase = true; context.CallBase = true;
context.Object.ValidFor = ValidForFlag.None; context.Object.ValidFor = ValidForFlag.None;
@@ -43,7 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
[Test] [Test]
public void SchemaBasedFoldersExcludedWhenGroupBySchemaIsEnabled() public void SchemaBasedFoldersExcludedWhenGroupBySchemaIsEnabled()
{ {
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = true }; enableGroupBySchema = true;
var children = factory.Object.Expand(node.Object, true, "TestDB", true, new System.Threading.CancellationToken()); var children = factory.Object.Expand(node.Object, true, "TestDB", true, new System.Threading.CancellationToken());
Assert.False(children.Any(c => c.Label == "Tables"), "Tables subfolder in database should be excluded when group by schema is enabled"); Assert.False(children.Any(c => c.Label == "Tables"), "Tables subfolder in database should be excluded when group by schema is enabled");
Assert.False(children.Any(c => c.Label == "Views"), "Views subfolder in database should be excluded when group by schema is enabled"); Assert.False(children.Any(c => c.Label == "Views"), "Views subfolder in database should be excluded when group by schema is enabled");
@@ -53,6 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
[Test] [Test]
public void SchemaBasedFoldersIncludedWhenGroupBySchemaIsDisabled() public void SchemaBasedFoldersIncludedWhenGroupBySchemaIsDisabled()
{ {
enableGroupBySchema = false;
WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = false }; WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.SqlTools.ObjectExplorer = new ObjectExplorerSettings() { GroupBySchema = false };
var children = factory.Object.Expand(node.Object, true, "TestDB", true, new System.Threading.CancellationToken()); var children = factory.Object.Expand(node.Object, true, "TestDB", true, new System.Threading.CancellationToken());
Assert.True(children.Any(c => c.Label == "Tables"), "Tables subfolder in database should be included when group by schema is disabled"); Assert.True(children.Any(c => c.Label == "Tables"), "Tables subfolder in database should be included when group by schema is disabled");

View File

@@ -9,9 +9,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using NUnit.Framework; using NUnit.Framework;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -908,7 +908,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
[TestCaseSource("ConvertExpandNodeFilterToNodeFilterTestCases")] [TestCaseSource("ConvertExpandNodeFilterToNodeFilterTestCases")]
public void TestConvertExpandNodeFilterToNodeFilter(NodeFilter filter, NodeFilterProperty prop, INodeFilter expectedParsedFilter) public void TestConvertExpandNodeFilterToNodeFilter(NodeFilter filter, NodeFilterProperty prop, INodeFilter expectedParsedFilter)
{ {
INodeFilter actualParsedFilter = ObjectExplorerUtils.ConvertExpandNodeFilterToNodeFilter(filter, prop); INodeFilter actualParsedFilter = filter.ToINodeFilter(prop);
Assert.That( Assert.That(
JsonConvert.SerializeObject(actualParsedFilter), JsonConvert.SerializeObject(actualParsedFilter),
Is.EqualTo(JsonConvert.SerializeObject(expectedParsedFilter)), Is.EqualTo(JsonConvert.SerializeObject(expectedParsedFilter)),

View File

@@ -7,8 +7,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using NUnit.Framework; using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
@@ -29,7 +29,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
NodeValue = serverName NodeValue = serverName
}; };
serverSession = new ObjectExplorerService.ObjectExplorerSession("serverUri", serverRoot, null, null); serverSession = new ObjectExplorerService.ObjectExplorerSession("serverUri", serverRoot);
var databaseRoot = new TreeNode var databaseRoot = new TreeNode
{ {
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
Parent = serverRoot Parent = serverRoot
}; };
databaseSession = new ObjectExplorerService.ObjectExplorerSession("databaseUri", databaseRoot, null, null); databaseSession = new ObjectExplorerService.ObjectExplorerSession("databaseUri", databaseRoot);
} }
[Test] [Test]

View File

@@ -4,24 +4,28 @@
// //
#nullable disable #nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Data.SqlClient;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Threading; using System.Threading;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility; using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Connection;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
{ {
@@ -31,16 +35,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
public class NodeTests : ObjectExplorerTestBase public class NodeTests : ObjectExplorerTestBase
{ {
private string defaultOwnerUri = "objectexplorer://myserver"; private string defaultOwnerUri = "objectexplorer://myserver";
private ServerInfo defaultServerInfo; private ObjectExplorerServerInfo oeServerInfo = null;
private ConnectionDetails defaultConnectionDetails; private ConnectionDetails defaultConnectionDetails;
private ConnectionCompleteParams defaultConnParams; private ConnectionCompleteParams defaultConnParams;
private string fakeConnectionString = "Data Source=server;Initial Catalog=database;Integrated Security=False;User Id=user"; private string fakeConnectionString = "Data Source=server;Initial Catalog=database;Integrated Security=False;User Id=user";
private ServerConnection serverConnection = null; private ServerConnection serverConnection = null;
[SetUp] [SetUp]
public void InitNodeTests() public void InitNodeTests()
{ {
defaultServerInfo = TestObjects.GetTestServerInfo(); var defaultServerInfo = TestObjects.GetTestServerInfo();
serverConnection = new ServerConnection(new SqlConnection(fakeConnectionString)); serverConnection = new ServerConnection(new SqlConnection(fakeConnectionString));
defaultConnectionDetails = new ConnectionDetails() defaultConnectionDetails = new ConnectionDetails()
@@ -53,31 +58,41 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
defaultConnParams = new ConnectionCompleteParams() defaultConnParams = new ConnectionCompleteParams()
{ {
ServerInfo = defaultServerInfo, ServerInfo = defaultServerInfo,
ConnectionSummary = defaultConnectionDetails != null ? ((IConnectionSummary)defaultConnectionDetails).Clone(): null, ConnectionSummary = defaultConnectionDetails != null ? ((IConnectionSummary)defaultConnectionDetails).Clone() : null,
OwnerUri = defaultOwnerUri OwnerUri = defaultOwnerUri
}; };
oeServerInfo = new ObjectExplorerServerInfo()
{
ServerName = defaultConnectionDetails.ServerName,
DatabaseName = defaultConnectionDetails.DatabaseName,
UserName = defaultConnectionDetails.UserName,
ServerVersion = defaultServerInfo.ServerVersion,
EngineEditionId = defaultServerInfo.EngineEditionId,
IsCloud = defaultServerInfo.IsCloud
};
var smoquery = typeof(SqlCore.ObjectExplorer.SmoModel.SmoQuerier).Assembly;
// TODO can all tests use the standard service provider? // TODO can all tests use the standard service provider?
ServiceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider(); ServiceProvider = ExtensionServiceProvider.CreateFromAssembliesInDirectory(Path.GetDirectoryName(smoquery.Location),new string[] { Path.GetFileName(smoquery.Location) });
} }
[Test] [Test]
public void ServerNodeConstructorValidatesFields() public void ServerNodeConstructorValidatesFields()
{ {
Assert.Throws<ArgumentNullException>(() => new ServerNode(null, ServiceProvider, serverConnection)); Assert.Throws<ArgumentNullException>(() => new ServerNode(null, serverConnection, ServiceProvider));
Assert.Throws<ArgumentNullException>(() => new ServerNode(defaultConnParams, null, serverConnection));
} }
[Test] [Test]
public void ServerNodeConstructorShouldSetValuesCorrectly() public void ServerNodeConstructorShouldSetValuesCorrectly()
{ {
// Given a server node with valid inputs // Given a server node with valid inputs
ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection); ServerNode node = new ServerNode(oeServerInfo, serverConnection, ServiceProvider);
// Then expect all fields set correctly // Then expect all fields set correctly
Assert.False(node.IsAlwaysLeaf, "Server node should never be a leaf"); Assert.False(node.IsAlwaysLeaf, "Server node should never be a leaf");
Assert.AreEqual(defaultConnectionDetails.ServerName, node.NodeValue); Assert.AreEqual(defaultConnectionDetails.ServerName, node.NodeValue);
string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + oeServerInfo.ServerVersion + " - "
+ defaultConnectionDetails.UserName + ")"; + defaultConnectionDetails.UserName + ")";
Assert.AreEqual(expectedLabel, node.Label); Assert.AreEqual(expectedLabel, node.Label);
@@ -91,55 +106,43 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
public void ServerNodeLabelShouldIgnoreUserNameIfEmptyOrNull() public void ServerNodeLabelShouldIgnoreUserNameIfEmptyOrNull()
{ {
// Given no username set // Given no username set
ConnectionSummary integratedAuthSummary = new ConnectionSummary() oeServerInfo.UserName = null;
{
DatabaseName = defaultConnectionDetails.DatabaseName,
ServerName = defaultConnectionDetails.ServerName,
UserName = null
};
ConnectionCompleteParams connParams = new ConnectionCompleteParams()
{
ConnectionSummary = integratedAuthSummary,
ServerInfo = defaultServerInfo,
OwnerUri = defaultOwnerUri
};
// When querying label // When querying label
string label = new ServerNode(connParams, ServiceProvider, serverConnection).Label; string label = new ServerNode(oeServerInfo, serverConnection, ServiceProvider).Label;
// Then only server name and version shown // Then only server name and version shown
string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + ")"; string expectedLabel = oeServerInfo.ServerName + " (SQL Server " + oeServerInfo.ServerVersion + ")";
Assert.AreEqual(expectedLabel, label); Assert.AreEqual(expectedLabel, label);
} }
[Test] [Test]
public void ServerNodeConstructorShouldShowDbNameForCloud() public void ServerNodeConstructorShouldShowDbNameForCloud()
{ {
defaultServerInfo.IsCloud = true; oeServerInfo.IsCloud = true;
// Given a server node for a cloud DB, with master name // Given a server node for a cloud DB, with master name
ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection); ServerNode node = new ServerNode(oeServerInfo, serverConnection);
// Then expect label to not include db name // Then expect label to not include db name
string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " string expectedLabel = oeServerInfo.ServerName + " (SQL Server " + oeServerInfo.ServerVersion + " - "
+ defaultConnectionDetails.UserName + ")"; + oeServerInfo.UserName + ")";
Assert.AreEqual(expectedLabel, node.Label); Assert.AreEqual(expectedLabel, node.Label);
// But given a server node for a cloud DB that's not master // But given a server node for a cloud DB that's not master
defaultConnectionDetails.DatabaseName = "NotMaster"; oeServerInfo.DatabaseName = "NotMaster";
defaultConnParams.ConnectionSummary.DatabaseName = defaultConnectionDetails.DatabaseName; node = new ServerNode(oeServerInfo, serverConnection, ServiceProvider);
node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection);
// Then expect label to include db name // Then expect label to include db name
expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " expectedLabel = oeServerInfo.ServerName + " (SQL Server " + oeServerInfo.ServerVersion + " - "
+ defaultConnectionDetails.UserName + ", " + defaultConnectionDetails.DatabaseName + ")"; + oeServerInfo.UserName + ", " + oeServerInfo.DatabaseName + ")";
Assert.AreEqual(expectedLabel, node.Label); Assert.AreEqual(expectedLabel, node.Label);
} }
[Test] [Test]
public void ToNodeInfoIncludeAllFields() public void NodeInfoConstructorPopulatesAllFieldsFromTreeNode()
{ {
// Given a server connection // Given a server connection
ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection); ServerNode node = new ServerNode(oeServerInfo, serverConnection, ServiceProvider);
// When converting to NodeInfo // When converting to NodeInfo
NodeInfo info = node.ToNodeInfo(); NodeInfo info = new NodeInfo(node);
// Then all fields should match // Then all fields should match
Assert.AreEqual(node.IsAlwaysLeaf, info.IsLeaf); Assert.AreEqual(node.IsAlwaysLeaf, info.IsLeaf);
Assert.AreEqual(node.Label, info.Label); Assert.AreEqual(node.Label, info.Label);
@@ -192,14 +195,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
public void MultiLevelTreeShouldFormatPath() public void MultiLevelTreeShouldFormatPath()
{ {
TreeNode root = new TreeNode("root"); TreeNode root = new TreeNode("root");
Assert.AreEqual("root" , root.GetNodePath()); Assert.AreEqual("root", root.GetNodePath());
TreeNode level1Child1 = new TreeNode("L1C1 (with extra info)"); TreeNode level1Child1 = new TreeNode("L1C1 (with extra info)");
level1Child1.NodePathName = "L1C1"; level1Child1.NodePathName = "L1C1";
TreeNode level1Child2 = new TreeNode("L1C2"); TreeNode level1Child2 = new TreeNode("L1C2");
root.AddChild(level1Child1); root.AddChild(level1Child1);
root.AddChild(level1Child2); root.AddChild(level1Child2);
Assert.AreEqual("root/L1C1" , level1Child1.GetNodePath()); Assert.AreEqual("root/L1C1", level1Child1.GetNodePath());
Assert.AreEqual("root/L1C2", level1Child2.GetNodePath()); Assert.AreEqual("root/L1C2", level1Child2.GetNodePath());
TreeNode level2Child1 = new TreeNode("L2C2"); TreeNode level2Child1 = new TreeNode("L2C2");
@@ -254,7 +257,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
// Then I expect it to be in an error state // Then I expect it to be in an error state
Assert.Null(context); Assert.Null(context);
Assert.AreEqual( Assert.AreEqual(
string.Format(CultureInfo.CurrentCulture, SR.TreeNodeError, expectedMsg), string.Format(CultureInfo.CurrentCulture, SqlTools.SqlCore.SR.TreeNodeError, expectedMsg),
node.ErrorStateMessage); node.ErrorStateMessage);
} }
@@ -272,7 +275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
// Then I expect it to be in an error state // Then I expect it to be in an error state
Assert.Null(context); Assert.Null(context);
Assert.AreEqual( Assert.AreEqual(
string.Format(CultureInfo.CurrentCulture, SR.TreeNodeError, expectedMsg), string.Format(CultureInfo.CurrentCulture, SqlTools.SqlCore.SR.TreeNodeError, expectedMsg),
node.ErrorStateMessage); node.ErrorStateMessage);
} }
@@ -378,7 +381,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private ServerNode SetupServerNodeWithCreator(SmoWrapper creator) private ServerNode SetupServerNodeWithCreator(SmoWrapper creator)
{ {
ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, new ServerConnection(new SqlConnection(fakeConnectionString))); ServerNode node = new ServerNode(oeServerInfo, new ServerConnection(new SqlConnection(fakeConnectionString)), ServiceProvider, () => false);
node.SmoWrapper = creator; node.SmoWrapper = creator;
return node; return node;
} }
@@ -408,14 +411,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
// Then I expect it to contain server-level folders // Then I expect it to contain server-level folders
Assert.AreEqual(3, children.Count); Assert.AreEqual(3, children.Count);
VerifyTreeNode<FolderNode>(children[0], "Folder", SR.SchemaHierarchy_Databases); VerifyTreeNode<FolderNode>(children[0], "Folder", SqlTools.SqlCore.SR.SchemaHierarchy_Databases);
VerifyTreeNode<FolderNode>(children[1], "Folder", SR.SchemaHierarchy_Security); VerifyTreeNode<FolderNode>(children[1], "Folder", SqlTools.SqlCore.SR.SchemaHierarchy_Security);
VerifyTreeNode<FolderNode>(children[2], "Folder", SR.SchemaHierarchy_ServerObjects); VerifyTreeNode<FolderNode>(children[2], "Folder", SqlTools.SqlCore.SR.SchemaHierarchy_ServerObjects);
// And the database is contained under it // And the database is contained under it
TreeNode databases = children[0]; TreeNode databases = children[0];
IList<TreeNode> dbChildren = databases.Expand(new CancellationToken()); IList<TreeNode> dbChildren = databases.Expand(new CancellationToken());
Assert.AreEqual(2, dbChildren.Count); Assert.AreEqual(2, dbChildren.Count);
Assert.AreEqual(SR.SchemaHierarchy_SystemDatabases, dbChildren[0].NodeValue); Assert.AreEqual(SqlTools.SqlCore.SR.SchemaHierarchy_SystemDatabases, dbChildren[0].NodeValue);
TreeNode dbNode = dbChildren[1]; TreeNode dbNode = dbChildren[1];
Assert.AreEqual(dbName, dbNode.NodeValue); Assert.AreEqual(dbName, dbNode.NodeValue);

View File

@@ -16,7 +16,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility; using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
@@ -282,7 +282,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
var foundNodes = service.FindNodes(session.SessionId, "Server", null, null, null); var foundNodes = service.FindNodes(session.SessionId, "Server", null, null, null);
Assert.AreEqual(1, foundNodes.Count); Assert.AreEqual(1, foundNodes.Count);
Assert.AreEqual("Server", foundNodes[0].NodeType); Assert.AreEqual("Server", foundNodes[0].NodeType);
Assert.AreEqual(session.RootNode.NodePath, foundNodes[0].ToNodeInfo().NodePath); Assert.AreEqual(session.RootNode.NodePath, new NodeInfo(foundNodes[0]).NodePath);
} }
[Test] [Test]
@@ -298,7 +298,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
public void FindNodeCanExpandParentNodes() public void FindNodeCanExpandParentNodes()
{ {
var mockTreeNode = new Mock<TreeNode>(); var mockTreeNode = new Mock<TreeNode>();
object[] populateChildrenArguments = { ItExpr.Is<bool>(x => x == false), ItExpr.IsNull<string>(), new CancellationToken(), ItExpr.IsNull<string>(), ItExpr.IsNull<IEnumerable<NodeFilter>>() }; object[] populateChildrenArguments = { ItExpr.Is<bool>(x => x == false), ItExpr.IsNull<string>(), new CancellationToken(), ItExpr.IsNull<string>(), ItExpr.IsNull<IEnumerable<INodeFilter>>() };
mockTreeNode.Protected().Setup("PopulateChildren", populateChildrenArguments); mockTreeNode.Protected().Setup("PopulateChildren", populateChildrenArguments);
mockTreeNode.Object.IsAlwaysLeaf = false; mockTreeNode.Object.IsAlwaysLeaf = false;

View File

@@ -8,8 +8,8 @@
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
{ {

View File

@@ -5,8 +5,7 @@
#nullable disable #nullable disable
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using NUnit.Framework; using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
@@ -59,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
[TestCase("16.1.2.3", SqlServerType.Sql2022)] [TestCase("16.1.2.3", SqlServerType.Sql2022)]
public void CalculateServerTypeShouldReturnExpectedValue(string serverVersion, SqlServerType expectedServerType) public void CalculateServerTypeShouldReturnExpectedValue(string serverVersion, SqlServerType expectedServerType)
{ {
ServerInfo serverInfo = new ServerInfo ObjectExplorerServerInfo serverInfo = new ObjectExplorerServerInfo
{ {
ServerVersion = serverVersion ServerVersion = serverVersion
}; };
@@ -128,7 +127,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private void VerifyCalculateServerTypeForEngineEdition(int engineEdition, SqlServerType expected) private void VerifyCalculateServerTypeForEngineEdition(int engineEdition, SqlServerType expected)
{ {
ServerInfo serverInfo = new ServerInfo ObjectExplorerServerInfo serverInfo = new ObjectExplorerServerInfo
{ {
EngineEditionId = engineEdition EngineEditionId = engineEdition
}; };

View File

@@ -6,24 +6,32 @@
#nullable disable #nullable disable
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.SqlCore.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; using Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes;
using NUnit.Framework; using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
{ {
public class SmoQueryModelTests public class SmoQueryModelTests
{ {
IMultiServiceProvider serviceProvider;
[SetUp]
public void Setup()
{
// Given the extension type loader is set to find SmoCollectionQuerier objects
var assembly = typeof(SmoQuerier).Assembly;
serviceProvider = ExtensionServiceProvider.CreateFromAssembliesInDirectory(Path.GetDirectoryName(assembly.Location), new string[] { Path.GetFileName(assembly.Location) });
}
[Test] [Test]
public void ShouldFindDatabaseQuerierFromRealPath() public void ShouldFindDatabaseQuerierFromRealPath()
{ {
// Given the extension type loader is set to find SmoCollectionQuerier objects
IMultiServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider();
// When I request a database compatible querier // When I request a database compatible querier
SmoQuerier querier = serviceProvider.GetService<SmoQuerier>(q => q.SupportedObjectTypes.Contains(typeof(Database))); SmoQuerier querier = serviceProvider.GetService<SmoQuerier>(q => q.SupportedObjectTypes.Contains(typeof(Database)));
// Then I expect to get back the SqlDatabaseQuerier // Then I expect to get back the SqlDatabaseQuerier
@@ -87,8 +95,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private SmoQuerier GetSmoQuerier(Type querierType) private SmoQuerier GetSmoQuerier(Type querierType)
{ {
// Given the extension type loader is set to find SmoCollectionQuerier objects
IMultiServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider();
// When I request a compatible querier // When I request a compatible querier
SmoQuerier querier = serviceProvider.GetService<SmoQuerier>(q => q.SupportedObjectTypes.Contains(querierType)); SmoQuerier querier = serviceProvider.GetService<SmoQuerier>(q => q.SupportedObjectTypes.Contains(querierType));
// Then I expect to get back the Querier // Then I expect to get back the Querier

View File

@@ -6,7 +6,7 @@
#nullable disable #nullable disable
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel;
using NUnit.Framework; using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer