mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Upgrade solution to .NET 6.0.9 (Build with .NET SDK v6.0.401) (#1692)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "6.0.301"
|
||||
"version": "6.0.401"
|
||||
},
|
||||
"msbuild-sdks": {
|
||||
"Microsoft.Build.NoTargets": "3.2.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,7 @@ namespace Microsoft.InsightsGenerator
|
||||
public static string FindMatchedTemplate(List<List<string>> singleHashHeaders, DataArray columnInfo)
|
||||
{
|
||||
var resultTemplate = new StringBuilder();
|
||||
if (Templates == null)
|
||||
{
|
||||
Templates = GetTemplates();
|
||||
}
|
||||
Templates ??= GetTemplates();
|
||||
var headersWithSingleHash = GetTopHeadersWithHash(singleHashHeaders);
|
||||
|
||||
foreach (var template in Templates)
|
||||
|
||||
@@ -60,10 +60,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lockedDatabaseManager == null)
|
||||
{
|
||||
lockedDatabaseManager = DatabaseLocksManager.Instance;
|
||||
}
|
||||
lockedDatabaseManager ??= DatabaseLocksManager.Instance;
|
||||
return lockedDatabaseManager;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -151,10 +151,7 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (workspaceServiceInstance == null)
|
||||
{
|
||||
workspaceServiceInstance = WorkspaceService<SqlToolsSettings>.Instance;
|
||||
}
|
||||
workspaceServiceInstance ??= WorkspaceService<SqlToolsSettings>.Instance;
|
||||
return workspaceServiceInstance;
|
||||
}
|
||||
set
|
||||
@@ -167,10 +164,7 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serviceHostInstance == null)
|
||||
{
|
||||
this.serviceHostInstance = ServiceHost.Instance;
|
||||
}
|
||||
this.serviceHostInstance ??= ServiceHost.Instance;
|
||||
return this.serviceHostInstance;
|
||||
}
|
||||
set
|
||||
@@ -872,10 +866,8 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
|
||||
}
|
||||
|
||||
// if there are no completions then provide the default list
|
||||
if (resultCompletionItems == null) // this is the getting default keyword option when its not connected
|
||||
{
|
||||
resultCompletionItems = DataSourceFactory.GetDefaultAutoComplete(DataSourceType.Kusto, scriptDocumentInfo, textDocumentPosition.Position);
|
||||
}
|
||||
// this is the getting default keyword option when its not connected
|
||||
resultCompletionItems ??= DataSourceFactory.GetDefaultAutoComplete(DataSourceType.Kusto, scriptDocumentInfo, textDocumentPosition.Position);
|
||||
|
||||
return resultCompletionItems;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,7 @@ namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer.DataSourceModel
|
||||
path = schema + "." + path;
|
||||
}
|
||||
|
||||
if (path == null)
|
||||
{
|
||||
path = "";
|
||||
}
|
||||
path ??= "";
|
||||
|
||||
foreach (var matchingNode in matchingNodes)
|
||||
{
|
||||
|
||||
@@ -262,10 +262,7 @@ namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer
|
||||
internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context)
|
||||
{
|
||||
var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames);
|
||||
if (foundNodes == null)
|
||||
{
|
||||
foundNodes = new List<TreeNode>();
|
||||
}
|
||||
foundNodes ??= new List<TreeNode>();
|
||||
await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() });
|
||||
}
|
||||
|
||||
|
||||
@@ -171,9 +171,9 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.DataStorage
|
||||
AddCell((string)o);
|
||||
break;
|
||||
default:
|
||||
if (o is TimeSpan) //TimeSpan doesn't have TypeCode
|
||||
if (o is TimeSpan span) //TimeSpan doesn't have TypeCode
|
||||
{
|
||||
AddCell((TimeSpan)o);
|
||||
AddCell(span);
|
||||
break;
|
||||
}
|
||||
AddCell(dbCellValue.DisplayValue);
|
||||
@@ -510,10 +510,7 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.DataStorage
|
||||
public ExcelSheet AddSheet(string sheetName = null)
|
||||
{
|
||||
string sheetFileName = "sheet" + (sheetNames.Count + 1);
|
||||
if (sheetName == null)
|
||||
{
|
||||
sheetName = sheetFileName;
|
||||
}
|
||||
sheetName ??= sheetFileName;
|
||||
EnsureValidSheetName(sheetName);
|
||||
|
||||
sheetNames.Add(sheetName);
|
||||
|
||||
@@ -68,13 +68,10 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BufferFileStreamFactory == null)
|
||||
BufferFileStreamFactory ??= new ServiceBufferFileStreamFactory
|
||||
{
|
||||
BufferFileStreamFactory = new ServiceBufferFileStreamFactory
|
||||
{
|
||||
ExecutionSettings = Settings.QueryExecutionSettings
|
||||
};
|
||||
}
|
||||
ExecutionSettings = Settings.QueryExecutionSettings
|
||||
};
|
||||
return BufferFileStreamFactory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.sqlTools == null)
|
||||
{
|
||||
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
|
||||
}
|
||||
this.sqlTools ??= new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
|
||||
return this.sqlTools;
|
||||
}
|
||||
set
|
||||
@@ -40,10 +37,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.mssqlTools == null)
|
||||
{
|
||||
this.mssqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
this.mssqlTools ??= new SqlToolsSettingsValues(false);
|
||||
return this.mssqlTools;
|
||||
}
|
||||
set
|
||||
@@ -60,10 +54,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.allSqlTools == null)
|
||||
{
|
||||
this.allSqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
this.allSqlTools ??= new SqlToolsSettingsValues(false);
|
||||
return this.allSqlTools;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -85,12 +85,9 @@ namespace Microsoft.Kusto.ServiceLayer.Utility
|
||||
}
|
||||
else // need to split values into several arrays
|
||||
{
|
||||
if (expandedList == null)
|
||||
{
|
||||
// very inefficient so delay as much as possible
|
||||
// immediately add 0th array
|
||||
expandedList = new List<List<T>> {shortList};
|
||||
}
|
||||
// very inefficient so delay as much as possible
|
||||
// immediately add 0th array
|
||||
expandedList ??= new List<List<T>> {shortList};
|
||||
|
||||
int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based
|
||||
|
||||
|
||||
@@ -185,10 +185,7 @@ namespace Microsoft.SqlTools.Extensibility
|
||||
|
||||
public IEnumerable<T> GetExports<T>()
|
||||
{
|
||||
if (exports == null)
|
||||
{
|
||||
exports = host.GetExports(contractType).ToList();
|
||||
}
|
||||
exports ??= host.GetExports(contractType).ToList();
|
||||
return exports.Cast<T>();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,10 +78,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
public string ResourceGroupName {
|
||||
get
|
||||
{
|
||||
if (this.resourceGroupName == null)
|
||||
{
|
||||
this.resourceGroupName = ParseResourceGroupNameFromId();
|
||||
}
|
||||
this.resourceGroupName ??= ParseResourceGroupNameFromId();
|
||||
return this.resourceGroupName ?? string.Empty;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -42,10 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (AdminService.connectionService == null)
|
||||
{
|
||||
AdminService.connectionService = ConnectionService.Instance;
|
||||
}
|
||||
AdminService.connectionService ??= ConnectionService.Instance;
|
||||
return AdminService.connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,10 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Data;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlServer.Management.Smo.Agent;
|
||||
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
@@ -261,7 +262,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
// Add steps to the job if any
|
||||
var jobSteps = new List<AgentJobStep>();
|
||||
foreach (LogSourceJobHistory.LogEntryJobHistory subEntry in entry.SubEntries)
|
||||
foreach (LogSourceJobHistory.LogEntryJobHistory subEntry in entry.SubEntries.Cast<LogSourceJobHistory.LogEntryJobHistory>())
|
||||
{
|
||||
if (steps.Contains(subEntry.StepName))
|
||||
{
|
||||
@@ -303,7 +304,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
// Add steps to the job if any
|
||||
var jobSteps = new List<AgentJobStep>();
|
||||
foreach (LogSourceJobHistory.LogEntryJobHistory subEntry in entry.SubEntries)
|
||||
foreach (LogSourceJobHistory.LogEntryJobHistory subEntry in entry.SubEntries.Cast<LogSourceJobHistory.LogEntryJobHistory>())
|
||||
{
|
||||
if (steps.Contains(subEntry.StepName))
|
||||
{
|
||||
|
||||
@@ -416,10 +416,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
e.Source = sourceName;
|
||||
|
||||
if (m_exceptionList == null)
|
||||
{
|
||||
m_exceptionList = new List<Exception>();
|
||||
}
|
||||
m_exceptionList ??= new List<Exception>();
|
||||
m_exceptionList.Add(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
@@ -677,7 +678,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this);
|
||||
|
||||
foreach (Match match in matches)
|
||||
foreach (Match match in matches.Cast<Match>())
|
||||
{
|
||||
string propertyName = match.Groups["property"].Value;
|
||||
PropertyDescriptor property = properties[propertyName];
|
||||
|
||||
@@ -31,11 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.AutoParameterizaition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_executionParameters == null)
|
||||
{
|
||||
_executionParameters = new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
_executionParameters ??= new Dictionary<string, int>();
|
||||
return _executionParameters;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,10 +356,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -84,10 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lockedDatabaseManager == null)
|
||||
{
|
||||
lockedDatabaseManager = DatabaseLocksManager.Instance;
|
||||
}
|
||||
lockedDatabaseManager ??= DatabaseLocksManager.Instance;
|
||||
return lockedDatabaseManager;
|
||||
}
|
||||
set
|
||||
@@ -216,10 +213,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.connectionFactory == null)
|
||||
{
|
||||
this.connectionFactory = new SqlConnectionFactory();
|
||||
}
|
||||
this.connectionFactory ??= new SqlConnectionFactory();
|
||||
return this.connectionFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,10 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sqlTaskManagerInstance == null)
|
||||
{
|
||||
sqlTaskManagerInstance = SqlTaskManager.Instance;
|
||||
}
|
||||
sqlTaskManagerInstance ??= SqlTaskManager.Instance;
|
||||
return sqlTaskManagerInstance;
|
||||
}
|
||||
set
|
||||
@@ -366,10 +363,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -52,10 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
@@ -68,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sqlTaskManagerInstance == null)
|
||||
{
|
||||
sqlTaskManagerInstance = SqlTaskManager.Instance;
|
||||
}
|
||||
sqlTaskManagerInstance ??= SqlTaskManager.Instance;
|
||||
return sqlTaskManagerInstance;
|
||||
}
|
||||
set
|
||||
@@ -87,10 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
|
||||
{
|
||||
get
|
||||
{
|
||||
if (fileBrowserService == null)
|
||||
{
|
||||
fileBrowserService = FileBrowserService.Instance;
|
||||
}
|
||||
fileBrowserService ??= FileBrowserService.Instance;
|
||||
return fileBrowserService;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -43,10 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (conditionParser == null)
|
||||
{
|
||||
conditionParser = new ConditionParser();
|
||||
}
|
||||
conditionParser ??= new ConditionParser();
|
||||
return conditionParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (cursorOperationParser == null)
|
||||
{
|
||||
cursorOperationParser = new CursorOperationParser();
|
||||
}
|
||||
cursorOperationParser ??= new CursorOperationParser();
|
||||
return cursorOperationParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
object cursorType = node["CursorActualType"];
|
||||
|
||||
if (cursorType == null)
|
||||
{
|
||||
cursorType = node["StatementType"];
|
||||
}
|
||||
cursorType ??= node["StatementType"];
|
||||
|
||||
Operation cursor = cursorType != null
|
||||
? OperationTable.GetCursorType(cursorType.ToString())
|
||||
@@ -46,10 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (cursorStatementParser == null)
|
||||
{
|
||||
cursorStatementParser = new CursorStatementParser();
|
||||
}
|
||||
cursorStatementParser ??= new CursorStatementParser();
|
||||
return cursorStatementParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
get
|
||||
{
|
||||
object propertyValue = this["EstimateRows"];
|
||||
if (propertyValue == null)
|
||||
{
|
||||
propertyValue = this["StatementEstRows"];
|
||||
}
|
||||
propertyValue ??= this["StatementEstRows"];
|
||||
|
||||
return propertyValue != null ? Convert.ToDouble(propertyValue, CultureInfo.CurrentCulture) : 0;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (filterTypeParser == null)
|
||||
{
|
||||
filterTypeParser = new FilterTypeParser();
|
||||
}
|
||||
filterTypeParser ??= new FilterTypeParser();
|
||||
return filterTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,10 +80,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (functionTypeParser == null)
|
||||
{
|
||||
functionTypeParser = new FunctionTypeParser();
|
||||
}
|
||||
functionTypeParser ??= new FunctionTypeParser();
|
||||
return functionTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (indexOpTypeParser == null)
|
||||
{
|
||||
indexOpTypeParser = new IndexOpTypeParser();
|
||||
}
|
||||
indexOpTypeParser ??= new IndexOpTypeParser();
|
||||
return indexOpTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mergeTypeParser == null)
|
||||
{
|
||||
mergeTypeParser = new MergeTypeParser();
|
||||
}
|
||||
mergeTypeParser ??= new MergeTypeParser();
|
||||
return mergeTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
this.LogicalOpUnlocName = null;
|
||||
this.PhysicalOpUnlocName = null;
|
||||
this.root = context.Graph.Root;
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = this;
|
||||
}
|
||||
this.root ??= this;
|
||||
this.Graph = context.Graph;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
@@ -372,7 +374,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
if (member.Name == enumMemberName)
|
||||
{
|
||||
object[] attributes = member.GetCustomAttributes(typeof(System.Xml.Serialization.XmlEnumAttribute), true);
|
||||
foreach (System.Xml.Serialization.XmlEnumAttribute attribute in attributes)
|
||||
foreach (System.Xml.Serialization.XmlEnumAttribute attribute in attributes.Cast<XmlEnumAttribute>())
|
||||
{
|
||||
return attribute.Name;
|
||||
}
|
||||
|
||||
@@ -139,11 +139,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
|
||||
if (this.displayName != null || this.displayNameKey != null)
|
||||
{
|
||||
if (this.displayName == null)
|
||||
{
|
||||
this.displayName = SR.Keys.GetString(this.displayNameKey);
|
||||
}
|
||||
|
||||
this.displayName ??= SR.Keys.GetString(this.displayNameKey);
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@@ -159,11 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
|
||||
if (this.description != null || this.descriptionKey != null)
|
||||
{
|
||||
if (this.description == null)
|
||||
{
|
||||
this.description = SR.Keys.GetString(this.descriptionKey);
|
||||
}
|
||||
|
||||
this.description ??= SR.Keys.GetString(this.descriptionKey);
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@@ -188,10 +180,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
this.displayNameKey = displayNameDescriptionAttribute.DisplayName;
|
||||
this.descriptionKey = displayNameDescriptionAttribute.Description;
|
||||
if (this.descriptionKey == null)
|
||||
{
|
||||
this.descriptionKey = this.displayNameKey;
|
||||
}
|
||||
this.descriptionKey ??= this.displayNameKey;
|
||||
}
|
||||
|
||||
DisplayOrderAttribute displayOrderAttribute =
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
object value = relOpProperty.GetValue(parsedItem);
|
||||
if (value != null)
|
||||
{
|
||||
if (value is IEnumerable)
|
||||
if (value is IEnumerable enumerable)
|
||||
{
|
||||
foreach (object item in (IEnumerable)value)
|
||||
foreach (object item in enumerable)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
@@ -72,10 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (relOpBaseTypeParser == null)
|
||||
{
|
||||
relOpBaseTypeParser = new RelOpBaseTypeParser();
|
||||
}
|
||||
relOpBaseTypeParser ??= new RelOpBaseTypeParser();
|
||||
return relOpBaseTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,10 +722,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (relOpTypeParser == null)
|
||||
{
|
||||
relOpTypeParser = new RelOpTypeParser();
|
||||
}
|
||||
relOpTypeParser ??= new RelOpTypeParser();
|
||||
return relOpTypeParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +133,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (statementParser == null)
|
||||
{
|
||||
statementParser = new StatementParser();
|
||||
}
|
||||
statementParser ??= new StatementParser();
|
||||
return statementParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,10 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (xmlPlanHierarchyParser == null)
|
||||
{
|
||||
xmlPlanHierarchyParser = new XmlPlanHierarchyParser();
|
||||
}
|
||||
xmlPlanHierarchyParser ??= new XmlPlanHierarchyParser();
|
||||
return xmlPlanHierarchyParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Xml;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
@@ -40,10 +41,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
public ShowPlanGraph[] Execute(object dataSource)
|
||||
{
|
||||
ShowPlanXML plan = dataSource as ShowPlanXML;
|
||||
if (plan == null)
|
||||
{
|
||||
plan = ReadXmlShowPlan(dataSource);
|
||||
}
|
||||
plan ??= ReadXmlShowPlan(dataSource);
|
||||
List<ShowPlanGraph> graphs = new List<ShowPlanGraph>();
|
||||
|
||||
int statementIndex = 0;
|
||||
@@ -238,7 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
ArrayList targetStatementList = new ArrayList();
|
||||
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items)
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
targetStatementList.Add(statement);
|
||||
|
||||
@@ -264,7 +262,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
//add this element and its children
|
||||
if (stmtThen.Statements != null && stmtThen.Statements.Items != null)
|
||||
{
|
||||
foreach (BaseStmtInfoType subStatement in stmtThen.Statements.Items)
|
||||
foreach (BaseStmtInfoType subStatement in stmtThen.Statements.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
targetStatementList.Add(subStatement);
|
||||
FlattenConditionClauses(subStatement, targetStatementList);
|
||||
@@ -280,7 +278,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
//add this element and its children
|
||||
if (stmtElse.Statements != null && stmtElse.Statements.Items != null)
|
||||
{
|
||||
foreach (BaseStmtInfoType subStatement in stmtElse.Statements.Items)
|
||||
foreach (BaseStmtInfoType subStatement in stmtElse.Statements.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
targetStatementList.Add(subStatement);
|
||||
FlattenConditionClauses(subStatement, targetStatementList);
|
||||
@@ -302,7 +300,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
ArrayList targetStatementList = new ArrayList();
|
||||
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items)
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
targetStatementList.Add(statement);
|
||||
|
||||
@@ -351,7 +349,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
// Call itself recursively.
|
||||
if (functionItem.Function.Statements != null && functionItem.Function.Statements.Items != null)
|
||||
{
|
||||
foreach (BaseStmtInfoType functionStatement in functionItem.Function.Statements.Items)
|
||||
foreach (BaseStmtInfoType functionStatement in functionItem.Function.Statements.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
ExtractFunctions(functionStatement, targetStatementList);
|
||||
}
|
||||
@@ -369,7 +367,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
{
|
||||
if (statementBlock != null && statementBlock.Items != null)
|
||||
{
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items)
|
||||
foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
|
||||
{
|
||||
yield return statement;
|
||||
}
|
||||
@@ -402,10 +400,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
// check Memory Optimized table.
|
||||
bool memoryOptimzed = false;
|
||||
XmlNode scan = rootNode.SelectSingleNode("descendant::shp:IndexScan", nsMgr);
|
||||
if (scan == null)
|
||||
{
|
||||
scan = rootNode.SelectSingleNode("descendant::shp:TableScan", nsMgr);
|
||||
}
|
||||
scan ??= rootNode.SelectSingleNode("descendant::shp:TableScan", nsMgr);
|
||||
|
||||
if (scan != null && scan.Attributes["Storage"] != null)
|
||||
{
|
||||
if (0 == string.Compare(scan.Attributes["Storage"].Value, "MemoryOptimized", StringComparison.Ordinal))
|
||||
|
||||
@@ -155,10 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
/// <param name="node">Node being parsed.</param>
|
||||
protected virtual void SetNodeSpecialProperties(Node node)
|
||||
{
|
||||
if (node.Operation == null)
|
||||
{
|
||||
node.Operation = GetNodeOperation(node);
|
||||
}
|
||||
node.Operation ??= GetNodeOperation(node);
|
||||
|
||||
// Retrieve Subtree cost for this node
|
||||
node.SubtreeCost = GetNodeSubtreeCost(node);
|
||||
@@ -242,9 +239,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value is IEnumerable)
|
||||
if (value is IEnumerable enumerable)
|
||||
{
|
||||
foreach (object item in (IEnumerable)value)
|
||||
foreach (object item in enumerable)
|
||||
{
|
||||
if (XmlPlanParserFactory.GetParser(item.GetType()) != null)
|
||||
{
|
||||
|
||||
@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageExtensibility
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
||||
{
|
||||
get
|
||||
{
|
||||
if(this.sqlParserWrapper == null)
|
||||
{
|
||||
this.sqlParserWrapper = new SqlParserWrapper();
|
||||
}
|
||||
this.sqlParserWrapper ??= new SqlParserWrapper();
|
||||
return this.sqlParserWrapper;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -169,14 +169,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.parseOptions == null)
|
||||
{
|
||||
this.parseOptions = new ParseOptions(
|
||||
this.parseOptions ??= new ParseOptions(
|
||||
batchSeparator: LanguageService.DefaultBatchSeperator,
|
||||
isQuotedIdentifierSet: true,
|
||||
compatibilityLevel: DatabaseCompatibilityLevel,
|
||||
transactSqlVersion: TransactSqlVersion);
|
||||
}
|
||||
return this.parseOptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,10 +191,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (workspaceServiceInstance == null)
|
||||
{
|
||||
workspaceServiceInstance = WorkspaceService<SqlToolsSettings>.Instance;
|
||||
}
|
||||
workspaceServiceInstance ??= WorkspaceService<SqlToolsSettings>.Instance;
|
||||
return workspaceServiceInstance;
|
||||
}
|
||||
set
|
||||
@@ -207,10 +204,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serviceHostInstance == null)
|
||||
{
|
||||
this.serviceHostInstance = ServiceHost.Instance;
|
||||
}
|
||||
this.serviceHostInstance ??= ServiceHost.Instance;
|
||||
return this.serviceHostInstance;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -101,11 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_hashTable == null)
|
||||
{
|
||||
m_hashTable = new Hashtable();
|
||||
}
|
||||
|
||||
m_hashTable ??= new Hashtable();
|
||||
return m_hashTable;
|
||||
}
|
||||
}
|
||||
@@ -808,11 +804,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (m_server == null)
|
||||
{
|
||||
// NOTE: ServerConnection property will constuct the object if needed
|
||||
m_server = new Server(ServerConnection);
|
||||
}
|
||||
// NOTE: ServerConnection property will constuct the object if needed
|
||||
m_server ??= new Server(ServerConnection);
|
||||
}
|
||||
else if (this.serverType == ServerType.SQLCE)
|
||||
{
|
||||
@@ -933,10 +926,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
public string GetDocumentPropertyString(string propertyName)
|
||||
{
|
||||
object result = GetDocumentPropertyValue(propertyName);
|
||||
if (result == null)
|
||||
{
|
||||
result = string.Empty;
|
||||
}
|
||||
result ??= string.Empty;
|
||||
|
||||
return (string)result;
|
||||
}
|
||||
@@ -1203,10 +1193,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
bool databaseExists = false,
|
||||
XmlDocument containerDoc = null)
|
||||
{
|
||||
if (containerDoc == null)
|
||||
{
|
||||
containerDoc = CreateDataContainerDocument(connInfo, databaseExists);
|
||||
}
|
||||
containerDoc ??= CreateDataContainerDocument(connInfo, databaseExists);
|
||||
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo, "DataContainer");
|
||||
|
||||
|
||||
@@ -95,24 +95,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
this.connection = (SqlOlapConnectionInfoBase)cloneable.Clone();
|
||||
this.closeOnDispose = true;
|
||||
}
|
||||
else if (sourceConnection is SqlConnectionInfoWithConnection)
|
||||
else if (sourceConnection is SqlConnectionInfoWithConnection connection2)
|
||||
{
|
||||
this.connection = ((SqlConnectionInfoWithConnection)sourceConnection).Copy();
|
||||
this.connection = connection2.Copy();
|
||||
this.closeOnDispose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if everything else has failed just use to passed in connection.
|
||||
if (this.connection == null)
|
||||
{
|
||||
this.connection = sourceConnection;
|
||||
}
|
||||
this.connection ??= sourceConnection;
|
||||
|
||||
// always set the lock timeout to prevent the shell from not responding
|
||||
if (this.connection is SqlConnectionInfoWithConnection)
|
||||
if (this.connection is SqlConnectionInfoWithConnection connection1)
|
||||
{
|
||||
// set lock_timeout to 10 seconds
|
||||
((SqlConnectionInfoWithConnection)this.connection).ServerConnection.LockTimeout = 10;
|
||||
connection1.ServerConnection.LockTimeout = 10;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -190,10 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
{
|
||||
get
|
||||
{
|
||||
if (activeConnections == null)
|
||||
{
|
||||
activeConnections = new Hashtable();
|
||||
}
|
||||
activeConnections ??= new Hashtable();
|
||||
return activeConnections;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,19 +94,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
}
|
||||
|
||||
// allow to be sited only once
|
||||
if (this.serviceProvider == null)
|
||||
{
|
||||
// cache the service provider
|
||||
this.serviceProvider = sp;
|
||||
// cache the service provider
|
||||
this.serviceProvider ??= sp;
|
||||
|
||||
// call protected virtual method to enable derived classes to do initialization
|
||||
// OnHosted();
|
||||
}
|
||||
// call protected virtual method to enable derived classes to do initialization
|
||||
// OnHosted();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region IExecutionAwareManagementAction implementation
|
||||
#region IExecutionAwareManagementAction implementation
|
||||
|
||||
/// <summary>
|
||||
/// called before management action executes onRun method.
|
||||
@@ -502,10 +499,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.cachedExecutionHandlerDelegate == null)
|
||||
{
|
||||
this.cachedExecutionHandlerDelegate = new ExecutionHandlerDelegate(this);
|
||||
}
|
||||
this.cachedExecutionHandlerDelegate ??= new ExecutionHandlerDelegate(this);
|
||||
return this.cachedExecutionHandlerDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
{
|
||||
//first, see if the object implemented this interface to override standard behavior
|
||||
System.Reflection.ICustomAttributeProvider attribProvider = objectToGetAttributeFrom as System.Reflection.ICustomAttributeProvider;
|
||||
if (attribProvider == null)
|
||||
{
|
||||
//if not, get it from its type
|
||||
attribProvider = (System.Reflection.ICustomAttributeProvider)objectToGetAttributeFrom.GetType();
|
||||
}
|
||||
//if not, get it from its type
|
||||
attribProvider ??= (System.Reflection.ICustomAttributeProvider)objectToGetAttributeFrom.GetType();
|
||||
|
||||
object[] attribs = attribProvider.GetCustomAttributes(customAttribute, true);
|
||||
if (attribs != null && attribs.Length > 0)
|
||||
|
||||
@@ -33,10 +33,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,10 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -38,10 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,10 +279,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
||||
internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context)
|
||||
{
|
||||
var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames);
|
||||
if (foundNodes == null)
|
||||
{
|
||||
foundNodes = new List<TreeNode>();
|
||||
}
|
||||
foundNodes ??= new List<TreeNode>();
|
||||
|
||||
await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() });
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
path = schema + "." + path;
|
||||
}
|
||||
|
||||
if (path == null)
|
||||
{
|
||||
path = "";
|
||||
}
|
||||
path ??= "";
|
||||
|
||||
foreach (var matchingNode in matchingNodes)
|
||||
{
|
||||
|
||||
@@ -53,10 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (smoWrapper == null)
|
||||
{
|
||||
smoWrapper = new SmoWrapper();
|
||||
}
|
||||
smoWrapper ??= new SmoWrapper();
|
||||
return smoWrapper;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -55,10 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
@@ -144,11 +141,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (xeSession == null)
|
||||
{
|
||||
// create a new XEvent session and Profiler session
|
||||
xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
|
||||
}
|
||||
// create a new XEvent session and Profiler session
|
||||
xeSession ??= this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
|
||||
|
||||
// start monitoring the profiler session
|
||||
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);
|
||||
|
||||
@@ -76,10 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
||||
lock (this.sessionsLock)
|
||||
{
|
||||
// start the monitoring thread
|
||||
if (this.processorThread == null)
|
||||
{
|
||||
this.processorThread = Task.Factory.StartNew(ProcessSessions);
|
||||
}
|
||||
this.processorThread ??= Task.Factory.StartNew(ProcessSessions);
|
||||
|
||||
// create new profiling session if needed
|
||||
if (!this.monitoredSessions.ContainsKey(session.Id))
|
||||
|
||||
@@ -172,9 +172,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
||||
AddCell((string)o);
|
||||
break;
|
||||
default:
|
||||
if (o is TimeSpan) //TimeSpan doesn't have TypeCode
|
||||
if (o is TimeSpan span) //TimeSpan doesn't have TypeCode
|
||||
{
|
||||
AddCell((TimeSpan)o);
|
||||
AddCell(span);
|
||||
}
|
||||
// We need to handle SqlDecimal and SqlMoney types here because we can't convert them to .NET types due to different precisons in SQL Server and .NET.
|
||||
else if (o is SqlDecimal || o is SqlMoney)
|
||||
@@ -518,10 +518,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
||||
public ExcelSheet AddSheet(string sheetName = null)
|
||||
{
|
||||
string sheetFileName = "sheet" + (sheetNames.Count + 1);
|
||||
if (sheetName == null)
|
||||
{
|
||||
sheetName = sheetFileName;
|
||||
}
|
||||
sheetName ??= sheetFileName;
|
||||
EnsureValidSheetName(sheetName);
|
||||
|
||||
sheetNames.Add(sheetName);
|
||||
|
||||
@@ -72,13 +72,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BufferFileStreamFactory == null)
|
||||
{
|
||||
BufferFileStreamFactory = new ServiceBufferFileStreamFactory
|
||||
BufferFileStreamFactory ??= new ServiceBufferFileStreamFactory
|
||||
{
|
||||
QueryExecutionSettings = Settings.QueryExecutionSettings
|
||||
};
|
||||
}
|
||||
return BufferFileStreamFactory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,10 +405,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sqlTaskManagerInstance == null)
|
||||
{
|
||||
sqlTaskManagerInstance = SqlTaskManager.Instance;
|
||||
}
|
||||
sqlTaskManagerInstance ??= SqlTaskManager.Instance;
|
||||
return sqlTaskManagerInstance;
|
||||
}
|
||||
set
|
||||
@@ -421,10 +418,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -15,6 +15,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
@@ -43,10 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
@@ -117,11 +115,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters.FilePath == null)
|
||||
{
|
||||
// Create a temporary and random path to handle this operation
|
||||
parameters.FilePath = Path.GetTempFileName();
|
||||
}
|
||||
// Create a temporary and random path to handle this operation
|
||||
parameters.FilePath ??= Path.GetTempFileName();
|
||||
|
||||
if (!ShouldCreateScriptAsOperation(parameters))
|
||||
{
|
||||
@@ -229,7 +224,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
{
|
||||
disposed = true;
|
||||
|
||||
foreach (ScriptingScriptOperation operation in this.ActiveOperations.Values)
|
||||
foreach (ScriptingScriptOperation operation in this.ActiveOperations.Values.Cast<ScriptingScriptOperation>())
|
||||
{
|
||||
operation.Dispose();
|
||||
}
|
||||
|
||||
@@ -47,10 +47,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
connectionService ??= ConnectionService.Instance;
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.sqlTools == null)
|
||||
{
|
||||
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
|
||||
}
|
||||
this.sqlTools ??= new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
|
||||
return this.sqlTools;
|
||||
}
|
||||
set
|
||||
@@ -40,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.mssqlTools == null)
|
||||
{
|
||||
this.mssqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
this.mssqlTools ??= new SqlToolsSettingsValues(false);
|
||||
return this.mssqlTools;
|
||||
}
|
||||
set
|
||||
@@ -60,10 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.allSqlTools == null)
|
||||
{
|
||||
this.allSqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
this.allSqlTools ??= new SqlToolsSettingsValues(false);
|
||||
return this.allSqlTools;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -27,10 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lockedDatabaseManager == null)
|
||||
{
|
||||
lockedDatabaseManager = ConnectionService.Instance.LockedDatabaseManager;
|
||||
}
|
||||
lockedDatabaseManager ??= ConnectionService.Instance.LockedDatabaseManager;
|
||||
return lockedDatabaseManager;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if(taskManager == null)
|
||||
{
|
||||
taskManager = SqlTaskManager.Instance;
|
||||
}
|
||||
taskManager ??= SqlTaskManager.Instance;
|
||||
return taskManager;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -85,12 +85,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
||||
}
|
||||
else // need to split values into several arrays
|
||||
{
|
||||
if (expandedList == null)
|
||||
{
|
||||
// very inefficient so delay as much as possible
|
||||
// immediately add 0th array
|
||||
expandedList = new List<List<T>> {shortList};
|
||||
}
|
||||
// very inefficient so delay as much as possible
|
||||
// immediately add 0th array
|
||||
expandedList ??= new List<List<T>> {shortList};
|
||||
|
||||
int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based
|
||||
|
||||
|
||||
@@ -357,10 +357,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
||||
AgentNotebookInfo notebook = null)
|
||||
{
|
||||
var service = new AgentService();
|
||||
if (notebook == null)
|
||||
{
|
||||
notebook = GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master");
|
||||
}
|
||||
notebook ??= GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master");
|
||||
string tempNotebookPath = CreateTemplateNotebookFile();
|
||||
|
||||
await AgentNotebookHelper.CreateNotebook(
|
||||
|
||||
@@ -50,18 +50,12 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
|
||||
|
||||
private async Task VerifyBackupFileCreated()
|
||||
{
|
||||
if (fullBackupFilePath == null)
|
||||
{
|
||||
fullBackupFilePath = await CreateBackupFile();
|
||||
}
|
||||
fullBackupFilePath ??= await CreateBackupFile();
|
||||
}
|
||||
|
||||
private async Task<string[]> GetBackupFilesToRecoverDatabaseCreated()
|
||||
{
|
||||
if (backupFilesToRecoverDatabase == null)
|
||||
{
|
||||
backupFilesToRecoverDatabase = await CreateBackupSetsToRecoverDatabase();
|
||||
}
|
||||
backupFilesToRecoverDatabase ??= await CreateBackupSetsToRecoverDatabase();
|
||||
return backupFilesToRecoverDatabase;
|
||||
}
|
||||
|
||||
|
||||
@@ -283,10 +283,7 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
TestTimer timer = null,
|
||||
[CallerMemberName] string testName = "")
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
timer = new TestTimer { PrintResult = false };
|
||||
}
|
||||
timer ??= new TestTimer { PrintResult = false };
|
||||
bool isReady = !waitForIntelliSense;
|
||||
await testService.ExecuteWithTimeout(timer, 550000, async () =>
|
||||
{
|
||||
|
||||
@@ -146,8 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._baselineSubDir == null)
|
||||
this._baselineSubDir = string.Empty;
|
||||
this._baselineSubDir ??= string.Empty;
|
||||
return this._baselineSubDir;
|
||||
}
|
||||
set { this._baselineSubDir = value; }
|
||||
|
||||
@@ -65,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
get
|
||||
{
|
||||
if (pendingVerifications == null)
|
||||
{
|
||||
pendingVerifications = new List<Action>();
|
||||
}
|
||||
pendingVerifications ??= new List<Action>();
|
||||
return pendingVerifications;
|
||||
}
|
||||
set => pendingVerifications = value;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
|
||||
{
|
||||
class Program
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0210:Convert to top-level statements", Justification = "Structure retained for readability.")]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
|
||||
@@ -236,10 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Messaging
|
||||
|
||||
private byte[] GetMessageBytes(string messageString, Encoding encoding = null)
|
||||
{
|
||||
if (encoding == null)
|
||||
{
|
||||
encoding = Encoding.UTF8;
|
||||
}
|
||||
encoding ??= Encoding.UTF8;
|
||||
|
||||
byte[] messageBytes = Encoding.UTF8.GetBytes(messageString);
|
||||
byte[] headerBytes = Encoding.ASCII.GetBytes(string.Format(Constants.ContentLengthFormatString, messageBytes.Length));
|
||||
|
||||
@@ -24,10 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
|
||||
public static ScriptFile GetTestScriptFile(string initialText = null)
|
||||
{
|
||||
if (initialText == null)
|
||||
{
|
||||
initialText = ScriptFileTests.query;
|
||||
}
|
||||
initialText ??= ScriptFileTests.query;
|
||||
|
||||
string ownerUri = System.IO.Path.GetTempFileName();
|
||||
|
||||
|
||||
@@ -68,10 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
{
|
||||
throw new TestDbException();
|
||||
}
|
||||
if (RowEnumerator == null)
|
||||
{
|
||||
RowEnumerator = ResultSetEnumerator.Current.GetEnumerator();
|
||||
}
|
||||
RowEnumerator ??= ResultSetEnumerator.Current.GetEnumerator();
|
||||
return RowEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user