mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 01:25:41 -05:00
Add Scripter class and use it in the ScriptingService (#286)
* Initial scripting commit * Fix the script CREATE integration test * Use language service binding queue for scripting * Update scripting service to have methods for each operation * Add scripter class * Fix build break. * Fix a few bugs * Use scripter class instead of PeekDefinition class. * Fix scripting test break * Fix header incorrectly saying file is generated. * Add localization tests to address a large block of code not covered by automation. * Moving system usings to top of using list
This commit is contained in:
@@ -17,15 +17,16 @@ using Microsoft.SqlServer.Management.SqlParser.Parser;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
@@ -816,8 +817,8 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
string schemaName = this.GetSchemaName(scriptParseInfo, textDocumentPosition.Position, scriptFile);
|
||||
// Script object using SMO
|
||||
PeekDefinition peekDefinition = new PeekDefinition(bindingContext.ServerConnection, connInfo);
|
||||
return peekDefinition.GetScript(
|
||||
Scripter scripter = new Scripter(bindingContext.ServerConnection, connInfo);
|
||||
return scripter.GetScript(
|
||||
scriptParseInfo.ParseResult,
|
||||
textDocumentPosition.Position,
|
||||
bindingContext.MetadataDisplayInfoProvider,
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
||||
ReadMetadata(sqlConn, metadata);
|
||||
}
|
||||
|
||||
await requestContext.SendResult(new MetadataQueryResult()
|
||||
await requestContext.SendResult(new MetadataQueryResult
|
||||
{
|
||||
Metadata = metadata.ToArray()
|
||||
});
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
// THIS FILE IS GENERATED BY A CODEGEN TOOL. DO NOT EDIT!!!!
|
||||
// IF YOU NEED TO MAKE CHANGES, EDIT THE .TT FILE!!!
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
internal partial class PeekDefinition
|
||||
{
|
||||
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
// THIS FILE IS GENERATED BY A CODEGEN TOOL. DO NOT EDIT!!!!
|
||||
// IF YOU NEED TO MAKE CHANGES, EDIT THE .TT FILE!!!
|
||||
|
||||
// To regenerate either (1) save the .TT file from Visual Studio or (2) run the build script codegen task.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
internal partial class Scripter
|
||||
{
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
AddSupportedType(DeclarationType.Table, GetTableScripts, "Table", "table");
|
||||
@@ -27,7 +29,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
AddSupportedType(DeclarationType.Synonym, GetSynonymScripts, "Synonym", "");
|
||||
AddSupportedType(DeclarationType.ScalarValuedFunction, GetScalarValuedFunctionScripts, "Function", "scalar-valued function");
|
||||
AddSupportedType(DeclarationType.TableValuedFunction, GetTableValuedFunctionScripts, "Function", "table-valued function");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a Table using SMO
|
||||
@@ -35,7 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">Table name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetTableScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetTableScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -48,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetTableScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a View using SMO
|
||||
@@ -56,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">View name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetViewScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetViewScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -69,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetViewScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a StoredProcedure using SMO
|
||||
@@ -77,7 +79,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">StoredProcedure name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetStoredProcedureScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetStoredProcedureScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -90,7 +92,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetStoredProcedureScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a UserDefinedDataType using SMO
|
||||
@@ -98,7 +100,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">UserDefinedDataType name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetUserDefinedDataTypeScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetUserDefinedDataTypeScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -111,7 +113,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetUserDefinedDataTypeScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a UserDefinedTableType using SMO
|
||||
@@ -119,7 +121,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">UserDefinedTableType name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetUserDefinedTableTypeScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetUserDefinedTableTypeScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -132,7 +134,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetUserDefinedTableTypeScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a Synonym using SMO
|
||||
@@ -140,7 +142,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">Synonym name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetSynonymScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetSynonymScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -153,7 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetSynonymScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a ScalarValuedFunction using SMO
|
||||
@@ -161,7 +163,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">ScalarValuedFunction name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetScalarValuedFunctionScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetScalarValuedFunctionScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -174,7 +176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetScalarValuedFunctionScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script a TableValuedFunction using SMO
|
||||
@@ -182,7 +184,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <param name="objectName">TableValuedFunction name</param>
|
||||
/// <param name="schemaName">Schema name</param>
|
||||
/// <returns>String collection of scripts</returns>
|
||||
internal StringCollection GetTableValuedFunctionScripts(string objectName, string schemaName)
|
||||
internal StringCollection GetTableValuedFunctionScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -195,8 +197,8 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
Logger.Write(LogLevel.Error,"Exception at PeekDefinition GetTableValuedFunctionScripts : " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
// THIS FILE IS GENERATED BY A CODEGEN TOOL. DO NOT EDIT!!!!
|
||||
// IF YOU NEED TO MAKE CHANGES, EDIT THE .TT FILE!!!
|
||||
|
||||
// To regenerate either (1) save the .TT file from Visual Studio or (2) run the build script codegen task.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
@@ -21,9 +23,9 @@ using System.Collections.Specialized;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
internal partial class PeekDefinition
|
||||
internal partial class Scripter
|
||||
{
|
||||
|
||||
<#
|
||||
@@ -32,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
///
|
||||
var indent = " ";
|
||||
var directory = Path.GetDirectoryName(Host.TemplateFile);
|
||||
string xmlFile = Path.Combine(directory, "PeekDefinitionSupportedTypes.xml");
|
||||
string xmlFile = Path.Combine(directory, "ScripterSupportedTypes.xml");
|
||||
var supportedTypes = GetSupportedTypes(xmlFile);
|
||||
if (supportedTypes != null && supportedTypes.Count > 0)
|
||||
{
|
||||
@@ -64,7 +66,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
WriteLine(string.Format("/// <param name=\"schemaName\">Schema name</param>"));
|
||||
WriteLine("/// <returns>String collection of scripts</returns>");
|
||||
|
||||
WriteLine(string.Format("internal StringCollection Get{0}Scripts(string objectName, string schemaName)", typeProperty["Name"]));
|
||||
WriteLine(string.Format("internal StringCollection Get{0}Scripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null)", typeProperty["Name"]));
|
||||
WriteLine("{");
|
||||
PushIndent(indent);
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
//
|
||||
//
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data.Common;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Parser;
|
||||
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Parser;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using ConnectionType = Microsoft.SqlTools.ServiceLayer.Connection.ConnectionType;
|
||||
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Peek Definition/ Go to definition implementation
|
||||
/// Script sql objects and write create scripts to file
|
||||
/// </summary>
|
||||
internal partial class PeekDefinition
|
||||
internal partial class Scripter
|
||||
{
|
||||
private bool error;
|
||||
private string errorMessage;
|
||||
@@ -36,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
private Database database;
|
||||
private string tempPath;
|
||||
|
||||
internal delegate StringCollection ScriptGetter(string objectName, string schemaName);
|
||||
internal delegate StringCollection ScriptGetter(string objectName, string schemaName, ScriptingOptions scriptingOptions);
|
||||
|
||||
// Dictionary that holds the script getter for each type
|
||||
private Dictionary<DeclarationType, ScriptGetter> sqlScriptGetters =
|
||||
@@ -54,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// Initialize a Peek Definition helper object
|
||||
/// </summary>
|
||||
/// <param name="serverConnection">SMO Server connection</param>
|
||||
internal PeekDefinition(ServerConnection serverConnection, ConnectionInfo connInfo)
|
||||
internal Scripter(ServerConnection serverConnection, ConnectionInfo connInfo)
|
||||
{
|
||||
this.serverConnection = serverConnection;
|
||||
this.connectionInfo = connInfo;
|
||||
@@ -85,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connection.Database))
|
||||
{
|
||||
dbName = connection.Database;
|
||||
dbName = connection.Database;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +151,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
StringComparison caseSensitivity = this.Database.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
|
||||
// if declarationItem matches the selected token, script SMO using that type
|
||||
if (declarationItem.Title.Equals (tokenText, caseSensitivity))
|
||||
if (declarationItem.Title.Equals(tokenText, caseSensitivity))
|
||||
{
|
||||
return GetDefinitionUsingDeclarationType(declarationItem.Type, declarationItem.DatabaseQualifiedName, tokenText, schemaName);
|
||||
}
|
||||
@@ -273,7 +271,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
string schemaName,
|
||||
string objectType)
|
||||
{
|
||||
StringCollection scripts = sqlScriptGetter(objectName, schemaName);
|
||||
StringCollection scripts = sqlScriptGetter(objectName, schemaName, null);
|
||||
string tempFileName = (schemaName != null) ? Path.Combine(this.tempPath, string.Format("{0}.{1}.sql", schemaName, objectName))
|
||||
: Path.Combine(this.tempPath, string.Format("{0}.sql", objectName));
|
||||
|
||||
@@ -312,7 +310,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <returns>Schema name</returns>
|
||||
internal string GetSchemaFromDatabaseQualifiedName(string fullObjectName, string objectName)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(fullObjectName))
|
||||
if (!string.IsNullOrEmpty(fullObjectName))
|
||||
{
|
||||
string[] tokens = fullObjectName.Split('.');
|
||||
for (int i = tokens.Length - 1; i > 0; i--)
|
||||
@@ -417,7 +415,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
// extract string denoting the token type from quickInfo text
|
||||
string[] tokens = quickInfoText.Split(' ');
|
||||
List<int> indexList = tokens.Select((s, i) => new { i, s }).Where(el => (el.s).IndexOf(tokenText, caseSensitivity) >= 0 ).Select(el => el.i).ToList();
|
||||
List<int> indexList = tokens.Select((s, i) => new { i, s }).Where(el => (el.s).IndexOf(tokenText, caseSensitivity) >= 0).Select(el => el.i).ToList();
|
||||
return (indexList?.Count() > 0) ? String.Join(" ", tokens.Take(indexList[0])) : null;
|
||||
}
|
||||
|
||||
@@ -454,5 +452,6 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
parseResult, parserLine, parserColumn, metadataDisplayInfoProvider);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,16 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
@@ -15,11 +22,56 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
/// Main class for Scripting Service functionality
|
||||
/// </summary>
|
||||
public sealed class ScriptingService
|
||||
{
|
||||
{
|
||||
private const int ScriptingOperationTimeout = 60000;
|
||||
|
||||
private static readonly Lazy<ScriptingService> LazyInstance = new Lazy<ScriptingService>(() => new ScriptingService());
|
||||
|
||||
public static ScriptingService Instance => LazyInstance.Value;
|
||||
|
||||
private static ConnectionService connectionService = null;
|
||||
|
||||
private static LanguageService languageServices = null;
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only
|
||||
/// </summary>
|
||||
internal static ConnectionService ConnectionServiceInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
connectionService = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only
|
||||
/// </summary>
|
||||
internal static LanguageService LanguageServiceInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (languageServices == null)
|
||||
{
|
||||
languageServices = LanguageService.Instance;
|
||||
}
|
||||
return languageServices;
|
||||
}
|
||||
set
|
||||
{
|
||||
languageServices = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Scripting Service instance
|
||||
/// </summary>
|
||||
@@ -30,6 +82,135 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
serviceHost.SetRequestHandler(ScriptingScriptAsRequest.Type, HandleScriptingScriptAsRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script create statements for metadata object
|
||||
/// </summary>
|
||||
private static string ScriptAsCreate(
|
||||
IBindingContext bindingContext,
|
||||
ConnectionInfo connInfo,
|
||||
ObjectMetadata metadata)
|
||||
{
|
||||
Scripter scripter = new Scripter(bindingContext.ServerConnection, connInfo);
|
||||
StringCollection results = null;
|
||||
if (metadata.MetadataType == MetadataType.Table)
|
||||
{
|
||||
results = scripter.GetTableScripts(metadata.Name, metadata.Schema);
|
||||
}
|
||||
else if (metadata.MetadataType == MetadataType.SProc)
|
||||
{
|
||||
results = scripter.GetStoredProcedureScripts(metadata.Name, metadata.Schema);
|
||||
}
|
||||
else if (metadata.MetadataType == MetadataType.View)
|
||||
{
|
||||
results = scripter.GetViewScripts(metadata.Name, metadata.Schema);
|
||||
}
|
||||
|
||||
StringBuilder builder = null;
|
||||
if (results != null)
|
||||
{
|
||||
builder = new StringBuilder();
|
||||
foreach (var result in results)
|
||||
{
|
||||
builder.AppendLine(result);
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
return builder != null ? builder.ToString() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not yet implemented
|
||||
/// </summary>
|
||||
private static string ScriptAsUpdate(
|
||||
IBindingContext bindingContext,
|
||||
ConnectionInfo connInfo,
|
||||
ObjectMetadata metadata)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not yet implemented
|
||||
/// </summary>
|
||||
private static string ScriptAsInsert(
|
||||
IBindingContext bindingContext,
|
||||
ConnectionInfo connInfo,
|
||||
ObjectMetadata metadata)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not yet implemented
|
||||
/// </summary>
|
||||
private static string ScriptAsDelete(
|
||||
IBindingContext bindingContext,
|
||||
ConnectionInfo connInfo,
|
||||
ObjectMetadata metadata)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle Script As Update requests
|
||||
/// </summary>
|
||||
private static string QueueScriptOperation(
|
||||
ScriptOperation operation,
|
||||
ConnectionInfo connInfo,
|
||||
ObjectMetadata metadata)
|
||||
{
|
||||
// get or create the current parse info object
|
||||
ScriptParseInfo parseInfo = LanguageServiceInstance.GetScriptParseInfo(connInfo.OwnerUri);
|
||||
if (Monitor.TryEnter(parseInfo.BuildingMetadataLock, LanguageService.BindingTimeout))
|
||||
{
|
||||
try
|
||||
{
|
||||
QueueItem queueItem = LanguageServiceInstance.BindingQueue.QueueBindingOperation(
|
||||
key: parseInfo.ConnectionKey,
|
||||
bindingTimeout: ScriptingService.ScriptingOperationTimeout,
|
||||
bindOperation: (bindingContext, cancelToken) =>
|
||||
{
|
||||
if (operation == ScriptOperation.Select)
|
||||
{
|
||||
return string.Format(
|
||||
@"SELECT TOP 100 * " + Environment.NewLine + @"FROM {0}.{1}",
|
||||
metadata.Schema, metadata.Name);
|
||||
}
|
||||
else if (operation == ScriptOperation.Create)
|
||||
{
|
||||
return ScriptAsCreate(bindingContext, connInfo, metadata);
|
||||
}
|
||||
else if (operation == ScriptOperation.Update)
|
||||
{
|
||||
return ScriptAsUpdate(bindingContext, connInfo, metadata);
|
||||
}
|
||||
else if (operation == ScriptOperation.Insert)
|
||||
{
|
||||
return ScriptAsInsert(bindingContext, connInfo, metadata);
|
||||
}
|
||||
else if (operation == ScriptOperation.Delete)
|
||||
{
|
||||
return ScriptAsDelete(bindingContext, connInfo, metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
queueItem.ItemProcessed.WaitOne();
|
||||
|
||||
return queueItem.GetResultAsT<string>();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(parseInfo.BuildingMetadataLock);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles script as request messages
|
||||
/// </summary>
|
||||
@@ -39,44 +220,31 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
ScriptingScriptAsParams scriptingParams,
|
||||
RequestContext<ScriptingScriptAsResult> requestContext)
|
||||
{
|
||||
string script = string.Empty;
|
||||
if (scriptingParams.Operation == ScriptOperation.Select)
|
||||
try
|
||||
{
|
||||
script = string.Format(
|
||||
@"SELECT *
|
||||
FROM {0}.{1}",
|
||||
scriptingParams.Metadata.Schema, scriptingParams.Metadata.Name);
|
||||
}
|
||||
else if (scriptingParams.Operation == ScriptOperation.Create)
|
||||
{
|
||||
script = string.Format(
|
||||
@"CREATE {0}.{1}",
|
||||
scriptingParams.Metadata.Schema, scriptingParams.Metadata.Name);
|
||||
}
|
||||
else if (scriptingParams.Operation == ScriptOperation.Update)
|
||||
{
|
||||
script = string.Format(
|
||||
@"UPDATE {0}.{1}",
|
||||
scriptingParams.Metadata.Schema, scriptingParams.Metadata.Name);
|
||||
}
|
||||
else if (scriptingParams.Operation == ScriptOperation.Insert)
|
||||
{
|
||||
script = string.Format(
|
||||
@"INSERT {0}.{1}",
|
||||
scriptingParams.Metadata.Schema, scriptingParams.Metadata.Name);
|
||||
}
|
||||
else if (scriptingParams.Operation == ScriptOperation.Delete)
|
||||
{
|
||||
script = string.Format(
|
||||
@"DELETE {0}.{1}",
|
||||
scriptingParams.Metadata.Schema, scriptingParams.Metadata.Name);
|
||||
}
|
||||
ConnectionInfo connInfo;
|
||||
ScriptingService.ConnectionServiceInstance.TryFindConnection(
|
||||
scriptingParams.OwnerUri,
|
||||
out connInfo);
|
||||
|
||||
await requestContext.SendResult(new ScriptingScriptAsResult()
|
||||
ObjectMetadata metadata = scriptingParams.Metadata;
|
||||
string script = string.Empty;
|
||||
|
||||
if (connInfo != null)
|
||||
{
|
||||
script = QueueScriptOperation(scriptingParams.Operation, connInfo, metadata);
|
||||
}
|
||||
|
||||
await requestContext.SendResult(new ScriptingScriptAsResult
|
||||
{
|
||||
OwnerUri = scriptingParams.OwnerUri,
|
||||
Script = script
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OwnerUri = scriptingParams.OwnerUri,
|
||||
Script = script
|
||||
});
|
||||
await requestContext.SendError(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,19 @@
|
||||
// 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.Data.Common;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Xunit;
|
||||
using ConnectionType = Microsoft.SqlTools.ServiceLayer.Connection.ConnectionType;
|
||||
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
|
||||
@@ -88,14 +89,14 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "spt_monitor";
|
||||
|
||||
string schemaName = null;
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for valid table object
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -110,13 +111,13 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "test_invalid";
|
||||
string schemaName = null;
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for invalid table object
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -130,14 +131,14 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "spt_monitor";
|
||||
|
||||
string schemaName = "dbo";
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for valid table object with schema name
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -151,11 +152,11 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "objects";
|
||||
string schemaName = "sys";
|
||||
// When I try to get definition for 'Collation'
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Collation, "master.sys.objects", objectName, schemaName);
|
||||
DefinitionResult result = scripter.GetDefinitionUsingDeclarationType(DeclarationType.Collation, "master.sys.objects", objectName, schemaName);
|
||||
// Then I expect non null result with error flag set
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.IsErrorResult);
|
||||
@@ -170,7 +171,7 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "from";
|
||||
Position position = new Position()
|
||||
{
|
||||
@@ -179,7 +180,7 @@ GO";
|
||||
};
|
||||
ScriptParseInfo scriptParseInfo = new ScriptParseInfo() { IsConnected = true };
|
||||
Mock<IBindingContext> bindingContextMock = new Mock<IBindingContext>();
|
||||
DefinitionResult result = peekDefinition.GetScript(scriptParseInfo.ParseResult, position, bindingContextMock.Object.MetadataDisplayInfoProvider, objectName, null);
|
||||
DefinitionResult result = scripter.GetScript(scriptParseInfo.ParseResult, position, bindingContextMock.Object.MetadataDisplayInfoProvider, objectName, null);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.IsErrorResult);
|
||||
@@ -252,12 +253,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "objects";
|
||||
string schemaName = "sys";
|
||||
string objectType = "VIEW";
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetViewScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -272,12 +273,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "objects";
|
||||
string schemaName = null;
|
||||
string objectType = "VIEW";
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetViewScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -291,13 +292,13 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "sp_MSrepl_startup";
|
||||
|
||||
string schemaName = "dbo";
|
||||
string objectType = "PROCEDURE";
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -312,12 +313,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "SP2";
|
||||
string schemaName = "dbo";
|
||||
string objectType = "PROCEDURE";
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -331,12 +332,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "sp_MSrepl_startup";
|
||||
string schemaName = null;
|
||||
string objectType = "PROCEDURE";
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(peekDefinition.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -371,42 +372,42 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition(databaseName);
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
|
||||
PeekDefinition.ScriptGetter sqlScriptGetter = null;
|
||||
Scripter.ScriptGetter sqlScriptGetter = null;
|
||||
switch (objectType)
|
||||
{
|
||||
case SynonymTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetSynonymScripts;
|
||||
sqlScriptGetter = scripter.GetSynonymScripts;
|
||||
break;
|
||||
case ScalarValuedFunctionTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetScalarValuedFunctionScripts;
|
||||
sqlScriptGetter = scripter.GetScalarValuedFunctionScripts;
|
||||
objectType = "Function";
|
||||
break;
|
||||
case TableValuedFunctionTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetTableValuedFunctionScripts;
|
||||
sqlScriptGetter = scripter.GetTableValuedFunctionScripts;
|
||||
objectType = "Function";
|
||||
break;
|
||||
case TableTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetTableScripts;
|
||||
sqlScriptGetter = scripter.GetTableScripts;
|
||||
break;
|
||||
case ViewTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetViewScripts;
|
||||
sqlScriptGetter = scripter.GetViewScripts;
|
||||
break;
|
||||
case StoredProcedureTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetStoredProcedureScripts;
|
||||
sqlScriptGetter = scripter.GetStoredProcedureScripts;
|
||||
break;
|
||||
case UserDefinedDataTypeTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetUserDefinedDataTypeScripts;
|
||||
sqlScriptGetter = scripter.GetUserDefinedDataTypeScripts;
|
||||
objectType = "Type";
|
||||
break;
|
||||
case UserDefinedTableTypeTypeName:
|
||||
sqlScriptGetter = peekDefinition.GetUserDefinedTableTypeScripts;
|
||||
sqlScriptGetter = scripter.GetUserDefinedTableTypeScripts;
|
||||
objectType = "Type";
|
||||
break;
|
||||
}
|
||||
|
||||
Location[] locations = peekDefinition.GetSqlObjectDefinition(sqlScriptGetter, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(sqlScriptGetter, objectName, schemaName, objectType);
|
||||
if (shouldReturnValidResult)
|
||||
{
|
||||
Assert.NotNull(locations);
|
||||
@@ -573,11 +574,11 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "objects";
|
||||
string schemaName = "sys";
|
||||
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.View, "master.sys.objects", objectName, schemaName);
|
||||
DefinitionResult result = scripter.GetDefinitionUsingDeclarationType(DeclarationType.View, "master.sys.objects", objectName, schemaName);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Locations);
|
||||
Assert.False(result.IsErrorResult);
|
||||
@@ -595,11 +596,11 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "doesNotExist";
|
||||
string schemaName = "sys";
|
||||
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.View, "master.sys.objects", objectName, schemaName);
|
||||
DefinitionResult result = scripter.GetDefinitionUsingDeclarationType(DeclarationType.View, "master.sys.objects", objectName, schemaName);
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.IsErrorResult);
|
||||
}
|
||||
@@ -614,12 +615,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "objects";
|
||||
string schemaName = "sys";
|
||||
string quickInfoText = "view master.sys.objects";
|
||||
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingQuickInfoText(quickInfoText, objectName, schemaName);
|
||||
DefinitionResult result = scripter.GetDefinitionUsingQuickInfoText(quickInfoText, objectName, schemaName);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Locations);
|
||||
Assert.False(result.IsErrorResult);
|
||||
@@ -637,12 +638,12 @@ GO";
|
||||
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
|
||||
ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "doesNotExist";
|
||||
string schemaName = "sys";
|
||||
string quickInfoText = "view master.sys.objects";
|
||||
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingQuickInfoText(quickInfoText, objectName, schemaName);
|
||||
DefinitionResult result = scripter.GetDefinitionUsingQuickInfoText(quickInfoText, objectName, schemaName);
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.IsErrorResult);
|
||||
}
|
||||
@@ -661,9 +662,9 @@ GO";
|
||||
//Check if query connection is present
|
||||
Assert.False(connInfo.TryGetConnection(ConnectionType.Query, out connection));
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
//Check if database name is the default server connection database name
|
||||
Assert.Equal(peekDefinition.Database.Name, "master");
|
||||
Assert.Equal(scripter.Database.Name, "master");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -684,9 +685,9 @@ GO";
|
||||
//Check if query connection is present
|
||||
Assert.True(connInfo.TryGetConnection(ConnectionType.Query, out connection));
|
||||
|
||||
PeekDefinition peekDefinition = new PeekDefinition(serverConnection, connInfo);
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
//Check if database name is the database name in the query connection
|
||||
Assert.Equal(peekDefinition.Database.Name, "testdb");
|
||||
Assert.Equal(scripter.Database.Name, "testdb");
|
||||
|
||||
// remove mock from ConnectionInfo
|
||||
Assert.True(connInfo.ConnectionTypeToConnectionMap.TryRemove(ConnectionType.Query, out connection));
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
|
||||
/// </summary>
|
||||
public class ScriptingServiceTests
|
||||
{
|
||||
private const string SchemaName = "sys";
|
||||
private const string TableName = "all_objects";
|
||||
private const string SchemaName = "dbo";
|
||||
private const string TableName = "spt_monitor";
|
||||
|
||||
private LiveConnectionHelper.TestConnectionResult GetLiveAutoCompleteTestObjects()
|
||||
{
|
||||
@@ -49,12 +49,12 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
|
||||
|
||||
var scriptingParams = new ScriptingScriptAsParams
|
||||
{
|
||||
OwnerUri = Test.Common.Constants.OwnerUri,
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri,
|
||||
Operation = operation,
|
||||
Metadata = new ObjectMetadata()
|
||||
{
|
||||
MetadataType = MetadataType.Table,
|
||||
MetadataTypeName = "View",
|
||||
MetadataTypeName = "Table",
|
||||
Schema = SchemaName,
|
||||
Name = TableName
|
||||
}
|
||||
@@ -62,11 +62,6 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
|
||||
|
||||
await ScriptingService.HandleScriptingScriptAsRequest(scriptingParams, requestContext.Object);
|
||||
|
||||
requestContext.Verify(x => x.SendResult(It.Is<ScriptingScriptAsResult>(
|
||||
i => i.Script.Contains(operation.ToString().ToUpper())
|
||||
&& i.Script.Contains(TableName)
|
||||
&& i.Script.Contains(SchemaName))));
|
||||
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,14 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Moq;
|
||||
using GlobalCommon = Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Xunit;
|
||||
using GlobalCommon = Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
@@ -138,7 +139,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
public void GetLocationFromFileForValidFilePathTest()
|
||||
{
|
||||
string filePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\test\\script.sql" : "/test/script.sql";
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
Location[] locations = peekDefinition.GetLocationFromFile(filePath, 0);
|
||||
|
||||
string expectedFilePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "file:///C:/test/script.sql" : "file:/test/script.sql";
|
||||
@@ -151,7 +152,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetSchemaFromDatabaseQualifiedNameWithValidNameTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string validDatabaseQualifiedName = "master.test.test_table";
|
||||
string objectName = "test_table";
|
||||
string expectedSchemaName = "test";
|
||||
@@ -167,7 +168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetSchemaFromDatabaseQualifiedNameWithNoSchemaTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string validDatabaseQualifiedName = "test_table";
|
||||
string objectName = "test_table";
|
||||
string expectedSchemaName = "dbo";
|
||||
@@ -182,7 +183,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetSchemaFromDatabaseQualifiedNameWithInvalidNameTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string validDatabaseQualifiedName = "x.y.z";
|
||||
string objectName = "test_table";
|
||||
string expectedSchemaName = "dbo";
|
||||
@@ -197,7 +198,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void DeletePeekDefinitionScriptsTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
var languageService = LanguageService.Instance;
|
||||
Assert.True(Directory.Exists(FileUtilities.PeekDefinitionTempFolder));
|
||||
languageService.DeletePeekDefinitionScripts();
|
||||
@@ -211,7 +212,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
public void DeletePeekDefinitionScriptsWhenFolderDoesNotExistTest()
|
||||
{
|
||||
var languageService = LanguageService.Instance;
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
FileUtilities.SafeDirectoryDelete(FileUtilities.PeekDefinitionTempFolder, true);
|
||||
Assert.False(Directory.Exists(FileUtilities.PeekDefinitionTempFolder));
|
||||
// Expected not to throw any exception
|
||||
@@ -226,7 +227,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetFullObjectNameFromQuickInfoWithValidStringsTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "testTable";
|
||||
string quickInfoText = "table master.dbo.testTable";
|
||||
string result = peekDefinition.GetFullObjectNameFromQuickInfo(quickInfoText, objectName, StringComparison.Ordinal);
|
||||
@@ -242,7 +243,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetFullObjectNameFromQuickInfoWithValidStringsandIgnoreCaseTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "testtable";
|
||||
string quickInfoText = "table master.dbo.testTable";
|
||||
string result = peekDefinition.GetFullObjectNameFromQuickInfo(quickInfoText, objectName, StringComparison.OrdinalIgnoreCase);
|
||||
@@ -258,7 +259,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetFullObjectNameFromQuickInfoWithNullStringsTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string expected = null;
|
||||
|
||||
string objectName = null;
|
||||
@@ -285,7 +286,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetFullObjectNameFromQuickInfoWithIncorrectObjectNameTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "test";
|
||||
string quickInfoText = "table master.dbo.tableName";
|
||||
string result = peekDefinition.GetFullObjectNameFromQuickInfo(quickInfoText, objectName, StringComparison.Ordinal);
|
||||
@@ -301,7 +302,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetTokenTypeFromQuickInfoWithValidStringsTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "tableName";
|
||||
string quickInfoText = "table master.dbo.tableName";
|
||||
string result = peekDefinition.GetTokenTypeFromQuickInfo(quickInfoText, objectName, StringComparison.Ordinal);
|
||||
@@ -318,7 +319,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetTokenTypeFromQuickInfoWithValidStringsandIgnoreCaseTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "tablename";
|
||||
string quickInfoText = "table master.dbo.tableName";
|
||||
string result = peekDefinition.GetTokenTypeFromQuickInfo(quickInfoText, objectName, StringComparison.OrdinalIgnoreCase);
|
||||
@@ -334,7 +335,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetTokenTypeFromQuickInfoWithNullStringsTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string expected = null;
|
||||
|
||||
string objectName = null;
|
||||
@@ -361,7 +362,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetTokenTypeFromQuickInfoWithIncorrectObjectNameTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "test";
|
||||
string quickInfoText = "table master.dbo.tableName";
|
||||
string result = peekDefinition.GetTokenTypeFromQuickInfo(quickInfoText, objectName, StringComparison.Ordinal);
|
||||
@@ -376,7 +377,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetDefinitionUsingQuickInfoWithoutConnectionTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "tableName";
|
||||
string quickInfoText = "table master.dbo.tableName";
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingQuickInfoText(quickInfoText, objectName, null);
|
||||
@@ -391,7 +392,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
[Fact]
|
||||
public void GetDefinitionUsingDeclarationItemWithoutConnectionTest()
|
||||
{
|
||||
PeekDefinition peekDefinition = new PeekDefinition(null, null);
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "tableName";
|
||||
string fullObjectName = "master.dbo.tableName";
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Table, fullObjectName, objectName, null);
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Globalization;
|
||||
using Xunit;
|
||||
|
||||
using ServiceLayerSr = Microsoft.SqlTools.ServiceLayer.Localization.sr;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
{
|
||||
public class SrTests
|
||||
@@ -15,10 +18,114 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
[Fact]
|
||||
public void SrPropertiesTest()
|
||||
{
|
||||
Assert.NotNull(ServiceLayer.SR.QueryServiceSubsetBatchNotCompleted);
|
||||
Assert.NotNull(ServiceLayer.SR.QueryServiceFileWrapperWriteOnly);
|
||||
Assert.NotNull(ServiceLayer.SR.QueryServiceFileWrapperNotInitialized);
|
||||
Assert.NotNull(ServiceLayer.SR.QueryServiceColumnNull);
|
||||
Assert.NotNull(SR.QueryServiceSubsetBatchNotCompleted);
|
||||
Assert.NotNull(SR.QueryServiceFileWrapperWriteOnly);
|
||||
Assert.NotNull(SR.QueryServiceFileWrapperNotInitialized);
|
||||
Assert.NotNull(SR.QueryServiceColumnNull);
|
||||
|
||||
var sr = new ServiceLayerSr();
|
||||
Assert.NotNull(ServiceLayerSr.ResourceManager);
|
||||
ServiceLayerSr.Culture = CultureInfo.CurrentCulture;
|
||||
Assert.NotNull(ServiceLayerSr.Culture);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParser_CircularReference);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParser_CommentNotTerminated);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParser_IncorrectSyntax);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParser_StringNotTerminated);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParser_VariableNotDefined);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionEngineBatchCancelling);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionEngineBatchMessage);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionEngineBatchResultSetFinished);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionEngineBatchResultSetProcessing);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionEngineError);
|
||||
Assert.NotNull(ServiceLayerSr.BatchParserWrapperExecutionError);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionParamsValidateNullConnection);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionParamsValidateNullOwnerUri);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionParamsValidateNullServerName);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionParamsValidateNullSqlAuth);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceConnectErrorNullParams);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceConnectionCanceled);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceConnStringInvalidAuthType);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceConnStringInvalidIntent);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceDbErrorDefaultNotConnected);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceListDbErrorNotConnected);
|
||||
Assert.NotNull(ServiceLayerSr.ConnectionServiceListDbErrorNullOwnerUri);
|
||||
Assert.Null(ServiceLayerSr.CredentialServiceWin32CredentialDisposed);
|
||||
Assert.Null(ServiceLayerSr.CredentialsServiceInvalidCriticalHandle);
|
||||
Assert.Null(ServiceLayerSr.CredentialsServicePasswordLengthExceeded);
|
||||
Assert.Null(ServiceLayerSr.CredentialsServiceTargetForDelete);
|
||||
Assert.Null(ServiceLayerSr.CredentialsServiceTargetForLookup);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchError_Exception);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchExecutionError_Halting);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchExecutionError_Ignoring);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchExecutionInfo_RowsAffected);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchSqlMessageNoLineInfo);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchSqlMessageNoProcedureInfo);
|
||||
Assert.NotNull(ServiceLayerSr.EE_BatchSqlMessageWithProcedureInfo);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionError_CommandNotSupported);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionError_VariableNotFound);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionInfo_FinalizingLoop);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionInfo_InitilizingLoop);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionInfo_QueryCancelledbyUser);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ExecutionNotYetCompleteError);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ScriptError_Error);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ScriptError_FatalError);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ScriptError_ParsingSyntax);
|
||||
Assert.NotNull(ServiceLayerSr.EE_ScriptError_Warning);
|
||||
Assert.NotNull(ServiceLayerSr.ErrorEmptyStringReplacement);
|
||||
Assert.NotNull(ServiceLayerSr.ErrorUnexpectedCodeObjectType);
|
||||
Assert.Null(ServiceLayerSr.HostingHeaderMissingColon);
|
||||
Assert.Null(ServiceLayerSr.HostingHeaderMissingContentLengthHeader);
|
||||
Assert.Null(ServiceLayerSr.HostingHeaderMissingContentLengthValue);
|
||||
Assert.Null(ServiceLayerSr.HostingUnexpectedEndOfStream);
|
||||
Assert.Null(ServiceLayerSr.IncompatibleServiceForExtensionLoader);
|
||||
Assert.Null(ServiceLayerSr.MultipleServicesFound);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionAzureError);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionDatabaseError);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionError);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionNoResultsError);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionNotConnectedError);
|
||||
Assert.NotNull(ServiceLayerSr.PeekDefinitionTimedoutError);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceAffectedOneRow);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceAffectedRows);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceCancelAlreadyCompleted);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceCancelDisposeFailed);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceColumnNull);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceCompletedSuccessfully);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceDataReaderByteCountInvalid);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceDataReaderCharCountInvalid);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceDataReaderXmlCountInvalid);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceErrorFormat);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceExecutionPlanNotFound);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceFileWrapperNotInitialized);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceFileWrapperReadOnly);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceFileWrapperWriteOnly);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceMessageSenderNotSql);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceQueryCancelled);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceQueryFailed);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceQueryInProgress);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceQueryInvalidOwnerUri);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceRequestsNoQuery);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceResultSetNoColumnSchema);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceResultSetNotRead);
|
||||
Assert.Null(ServiceLayerSr.QueryServiceResultSetReaderNull);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceResultSetRowCountOutOfRange);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceResultSetStartRowOutOfRange);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSaveAsFail);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSaveAsInProgress);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSaveAsMiscStartingError);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSaveAsResultSetNotComplete);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSubsetBatchNotCompleted);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSubsetBatchOutOfRange);
|
||||
Assert.NotNull(ServiceLayerSr.QueryServiceSubsetResultSetOutOfRange);
|
||||
Assert.Null(ServiceLayerSr.ServiceAlreadyRegistered);
|
||||
Assert.Null(ServiceLayerSr.ServiceNotFound);
|
||||
Assert.Null(ServiceLayerSr.ServiceNotOfExpectedType);
|
||||
Assert.Null(ServiceLayerSr.ServiceProviderNotSet);
|
||||
Assert.NotNull(ServiceLayerSr.TestLocalizationConstant);
|
||||
Assert.NotNull(ServiceLayerSr.TroubleshootingAssistanceMessage);
|
||||
Assert.NotNull(ServiceLayerSr.WorkspaceServiceBufferPositionOutOfOrder);
|
||||
Assert.NotNull(ServiceLayerSr.WorkspaceServicePositionColumnOutOfRange);
|
||||
Assert.NotNull(ServiceLayerSr.WorkspaceServicePositionLineOutOfRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user