Upgrade solution to .NET 6.0.9 (Build with .NET SDK v6.0.401) (#1692)

This commit is contained in:
Cheena Malhotra
2022-09-16 11:27:52 -07:00
committed by GitHub
parent 676819f669
commit 006ac60923
74 changed files with 143 additions and 414 deletions

View File

@@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "6.0.301" "version": "6.0.401"
}, },
"msbuild-sdks": { "msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.2.9" "Microsoft.Build.NoTargets": "3.2.9"

View File

@@ -61,10 +61,7 @@ namespace Microsoft.InsightsGenerator
public static string FindMatchedTemplate(List<List<string>> singleHashHeaders, DataArray columnInfo) public static string FindMatchedTemplate(List<List<string>> singleHashHeaders, DataArray columnInfo)
{ {
var resultTemplate = new StringBuilder(); var resultTemplate = new StringBuilder();
if (Templates == null) Templates ??= GetTemplates();
{
Templates = GetTemplates();
}
var headersWithSingleHash = GetTopHeadersWithHash(singleHashHeaders); var headersWithSingleHash = GetTopHeadersWithHash(singleHashHeaders);
foreach (var template in Templates) foreach (var template in Templates)

View File

@@ -60,10 +60,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
{ {
get get
{ {
if (lockedDatabaseManager == null) lockedDatabaseManager ??= DatabaseLocksManager.Instance;
{
lockedDatabaseManager = DatabaseLocksManager.Instance;
}
return lockedDatabaseManager; return lockedDatabaseManager;
} }
set set

View File

@@ -151,10 +151,7 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
{ {
get get
{ {
if (workspaceServiceInstance == null) workspaceServiceInstance ??= WorkspaceService<SqlToolsSettings>.Instance;
{
workspaceServiceInstance = WorkspaceService<SqlToolsSettings>.Instance;
}
return workspaceServiceInstance; return workspaceServiceInstance;
} }
set set
@@ -167,10 +164,7 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
{ {
get get
{ {
if (this.serviceHostInstance == null) this.serviceHostInstance ??= ServiceHost.Instance;
{
this.serviceHostInstance = ServiceHost.Instance;
}
return this.serviceHostInstance; return this.serviceHostInstance;
} }
set set
@@ -872,10 +866,8 @@ namespace Microsoft.Kusto.ServiceLayer.LanguageServices
} }
// if there are no completions then provide the default list // if there are no completions then provide the default list
if (resultCompletionItems == null) // this is the getting default keyword option when its not connected // this is the getting default keyword option when its not connected
{ resultCompletionItems ??= DataSourceFactory.GetDefaultAutoComplete(DataSourceType.Kusto, scriptDocumentInfo, textDocumentPosition.Position);
resultCompletionItems = DataSourceFactory.GetDefaultAutoComplete(DataSourceType.Kusto, scriptDocumentInfo, textDocumentPosition.Position);
}
return resultCompletionItems; return resultCompletionItems;
} }

View File

@@ -70,10 +70,7 @@ namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer.DataSourceModel
path = schema + "." + path; path = schema + "." + path;
} }
if (path == null) path ??= "";
{
path = "";
}
foreach (var matchingNode in matchingNodes) foreach (var matchingNode in matchingNodes)
{ {

View File

@@ -262,10 +262,7 @@ namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer
internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context) internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context)
{ {
var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames); var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames);
if (foundNodes == null) foundNodes ??= new List<TreeNode>();
{
foundNodes = new List<TreeNode>();
}
await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() }); await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() });
} }

View File

@@ -171,9 +171,9 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.DataStorage
AddCell((string)o); AddCell((string)o);
break; break;
default: 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; break;
} }
AddCell(dbCellValue.DisplayValue); AddCell(dbCellValue.DisplayValue);
@@ -510,10 +510,7 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.DataStorage
public ExcelSheet AddSheet(string sheetName = null) public ExcelSheet AddSheet(string sheetName = null)
{ {
string sheetFileName = "sheet" + (sheetNames.Count + 1); string sheetFileName = "sheet" + (sheetNames.Count + 1);
if (sheetName == null) sheetName ??= sheetFileName;
{
sheetName = sheetFileName;
}
EnsureValidSheetName(sheetName); EnsureValidSheetName(sheetName);
sheetNames.Add(sheetName); sheetNames.Add(sheetName);

View File

@@ -68,13 +68,10 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution
{ {
get get
{ {
if (BufferFileStreamFactory == null) BufferFileStreamFactory ??= new ServiceBufferFileStreamFactory
{
BufferFileStreamFactory = new ServiceBufferFileStreamFactory
{ {
ExecutionSettings = Settings.QueryExecutionSettings ExecutionSettings = Settings.QueryExecutionSettings
}; };
}
return BufferFileStreamFactory; return BufferFileStreamFactory;
} }
} }

View File

@@ -20,10 +20,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.sqlTools == null) this.sqlTools ??= new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
{
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
}
return this.sqlTools; return this.sqlTools;
} }
set set
@@ -40,10 +37,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.mssqlTools == null) this.mssqlTools ??= new SqlToolsSettingsValues(false);
{
this.mssqlTools = new SqlToolsSettingsValues(false);
}
return this.mssqlTools; return this.mssqlTools;
} }
set set
@@ -60,10 +54,7 @@ namespace Microsoft.Kusto.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.allSqlTools == null) this.allSqlTools ??= new SqlToolsSettingsValues(false);
{
this.allSqlTools = new SqlToolsSettingsValues(false);
}
return this.allSqlTools; return this.allSqlTools;
} }
set set

View File

@@ -84,13 +84,10 @@ namespace Microsoft.Kusto.ServiceLayer.Utility
shortList.Add(val); shortList.Add(val);
} }
else // need to split values into several arrays else // need to split values into several arrays
{
if (expandedList == null)
{ {
// very inefficient so delay as much as possible // very inefficient so delay as much as possible
// immediately add 0th array // immediately add 0th array
expandedList = new List<List<T>> {shortList}; expandedList ??= new List<List<T>> {shortList};
}
int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based

View File

@@ -185,10 +185,7 @@ namespace Microsoft.SqlTools.Extensibility
public IEnumerable<T> GetExports<T>() public IEnumerable<T> GetExports<T>()
{ {
if (exports == null) exports ??= host.GetExports(contractType).ToList();
{
exports = host.GetExports(contractType).ToList();
}
return exports.Cast<T>(); return exports.Cast<T>();
} }

View File

@@ -78,10 +78,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
public string ResourceGroupName { public string ResourceGroupName {
get get
{ {
if (this.resourceGroupName == null) this.resourceGroupName ??= ParseResourceGroupNameFromId();
{
this.resourceGroupName = ParseResourceGroupNameFromId();
}
return this.resourceGroupName ?? string.Empty; return this.resourceGroupName ?? string.Empty;
} }
set set

View File

@@ -42,10 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
{ {
get get
{ {
if (AdminService.connectionService == null) AdminService.connectionService ??= ConnectionService.Instance;
{
AdminService.connectionService = ConnectionService.Instance;
}
return AdminService.connectionService; return AdminService.connectionService;
} }

View File

@@ -51,10 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -8,6 +8,7 @@ using System.Data;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo.Agent; using Microsoft.SqlServer.Management.Smo.Agent;
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts; using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.Agent namespace Microsoft.SqlTools.ServiceLayer.Agent
{ {
@@ -261,7 +262,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
// Add steps to the job if any // Add steps to the job if any
var jobSteps = new List<AgentJobStep>(); 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)) if (steps.Contains(subEntry.StepName))
{ {
@@ -303,7 +304,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
// Add steps to the job if any // Add steps to the job if any
var jobSteps = new List<AgentJobStep>(); 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)) if (steps.Contains(subEntry.StepName))
{ {

View File

@@ -416,10 +416,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
{ {
e.Source = sourceName; e.Source = sourceName;
if (m_exceptionList == null) m_exceptionList ??= new List<Exception>();
{
m_exceptionList = new List<Exception>();
}
m_exceptionList.Add(e); m_exceptionList.Add(e);
} }

View File

@@ -8,6 +8,7 @@ using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Common;
@@ -677,7 +678,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
{ {
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this);
foreach (Match match in matches) foreach (Match match in matches.Cast<Match>())
{ {
string propertyName = match.Groups["property"].Value; string propertyName = match.Groups["property"].Value;
PropertyDescriptor property = properties[propertyName]; PropertyDescriptor property = properties[propertyName];

View File

@@ -31,11 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.AutoParameterizaition
{ {
get get
{ {
if (_executionParameters == null) _executionParameters ??= new Dictionary<string, int>();
{
_executionParameters = new Dictionary<string, int>();
}
return _executionParameters; return _executionParameters;
} }
} }

View File

@@ -356,10 +356,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set

View File

@@ -84,10 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
get get
{ {
if (lockedDatabaseManager == null) lockedDatabaseManager ??= DatabaseLocksManager.Instance;
{
lockedDatabaseManager = DatabaseLocksManager.Instance;
}
return lockedDatabaseManager; return lockedDatabaseManager;
} }
set set
@@ -216,10 +213,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
get get
{ {
if (this.connectionFactory == null) this.connectionFactory ??= new SqlConnectionFactory();
{
this.connectionFactory = new SqlConnectionFactory();
}
return this.connectionFactory; return this.connectionFactory;
} }

View File

@@ -347,10 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
{ {
get get
{ {
if (sqlTaskManagerInstance == null) sqlTaskManagerInstance ??= SqlTaskManager.Instance;
{
sqlTaskManagerInstance = SqlTaskManager.Instance;
}
return sqlTaskManagerInstance; return sqlTaskManagerInstance;
} }
set set
@@ -366,10 +363,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set

View File

@@ -52,10 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set
@@ -68,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
{ {
get get
{ {
if (sqlTaskManagerInstance == null) sqlTaskManagerInstance ??= SqlTaskManager.Instance;
{
sqlTaskManagerInstance = SqlTaskManager.Instance;
}
return sqlTaskManagerInstance; return sqlTaskManagerInstance;
} }
set set
@@ -87,10 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
{ {
get get
{ {
if (fileBrowserService == null) fileBrowserService ??= FileBrowserService.Instance;
{
fileBrowserService = FileBrowserService.Instance;
}
return fileBrowserService; return fileBrowserService;
} }
set set

View File

@@ -43,10 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (conditionParser == null) conditionParser ??= new ConditionParser();
{
conditionParser = new ConditionParser();
}
return conditionParser; return conditionParser;
} }
} }

View File

@@ -67,10 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (cursorOperationParser == null) cursorOperationParser ??= new CursorOperationParser();
{
cursorOperationParser = new CursorOperationParser();
}
return cursorOperationParser; return cursorOperationParser;
} }
} }

View File

@@ -19,10 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
object cursorType = node["CursorActualType"]; object cursorType = node["CursorActualType"];
if (cursorType == null) cursorType ??= node["StatementType"];
{
cursorType = node["StatementType"];
}
Operation cursor = cursorType != null Operation cursor = cursorType != null
? OperationTable.GetCursorType(cursorType.ToString()) ? OperationTable.GetCursorType(cursorType.ToString())
@@ -46,10 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (cursorStatementParser == null) cursorStatementParser ??= new CursorStatementParser();
{
cursorStatementParser = new CursorStatementParser();
}
return cursorStatementParser; return cursorStatementParser;
} }
} }

View File

@@ -101,10 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
get get
{ {
object propertyValue = this["EstimateRows"]; object propertyValue = this["EstimateRows"];
if (propertyValue == null) propertyValue ??= this["StatementEstRows"];
{
propertyValue = this["StatementEstRows"];
}
return propertyValue != null ? Convert.ToDouble(propertyValue, CultureInfo.CurrentCulture) : 0; return propertyValue != null ? Convert.ToDouble(propertyValue, CultureInfo.CurrentCulture) : 0;
} }

View File

@@ -51,10 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (filterTypeParser == null) filterTypeParser ??= new FilterTypeParser();
{
filterTypeParser = new FilterTypeParser();
}
return filterTypeParser; return filterTypeParser;
} }
} }

View File

@@ -80,10 +80,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (functionTypeParser == null) functionTypeParser ??= new FunctionTypeParser();
{
functionTypeParser = new FunctionTypeParser();
}
return functionTypeParser; return functionTypeParser;
} }
} }

View File

@@ -28,10 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (indexOpTypeParser == null) indexOpTypeParser ??= new IndexOpTypeParser();
{
indexOpTypeParser = new IndexOpTypeParser();
}
return indexOpTypeParser; return indexOpTypeParser;
} }
} }

View File

@@ -65,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (mergeTypeParser == null) mergeTypeParser ??= new MergeTypeParser();
{
mergeTypeParser = new MergeTypeParser();
}
return mergeTypeParser; return mergeTypeParser;
} }
} }

View File

@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
this.LogicalOpUnlocName = null; this.LogicalOpUnlocName = null;
this.PhysicalOpUnlocName = null; this.PhysicalOpUnlocName = null;
this.root = context.Graph.Root; this.root = context.Graph.Root;
if (this.root == null) this.root ??= this;
{
this.root = this;
}
this.Graph = context.Graph; this.Graph = context.Graph;
} }

View File

@@ -6,7 +6,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Xml.Serialization;
namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
@@ -372,7 +374,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
if (member.Name == enumMemberName) if (member.Name == enumMemberName)
{ {
object[] attributes = member.GetCustomAttributes(typeof(System.Xml.Serialization.XmlEnumAttribute), true); 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; return attribute.Name;
} }

View File

@@ -139,11 +139,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
if (this.displayName != null || this.displayNameKey != null) 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; 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.descriptionKey != null)
{ {
if (this.description == null) this.description ??= SR.Keys.GetString(this.descriptionKey);
{
this.description = SR.Keys.GetString(this.descriptionKey);
}
return this.description; return this.description;
} }
@@ -188,10 +180,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
this.displayNameKey = displayNameDescriptionAttribute.DisplayName; this.displayNameKey = displayNameDescriptionAttribute.DisplayName;
this.descriptionKey = displayNameDescriptionAttribute.Description; this.descriptionKey = displayNameDescriptionAttribute.Description;
if (this.descriptionKey == null) this.descriptionKey ??= this.displayNameKey;
{
this.descriptionKey = this.displayNameKey;
}
} }
DisplayOrderAttribute displayOrderAttribute = DisplayOrderAttribute displayOrderAttribute =

View File

@@ -40,9 +40,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
object value = relOpProperty.GetValue(parsedItem); object value = relOpProperty.GetValue(parsedItem);
if (value != null) 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; yield return item;
} }
@@ -72,10 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (relOpBaseTypeParser == null) relOpBaseTypeParser ??= new RelOpBaseTypeParser();
{
relOpBaseTypeParser = new RelOpBaseTypeParser();
}
return relOpBaseTypeParser; return relOpBaseTypeParser;
} }
} }

View File

@@ -722,10 +722,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (relOpTypeParser == null) relOpTypeParser ??= new RelOpTypeParser();
{
relOpTypeParser = new RelOpTypeParser();
}
return relOpTypeParser; return relOpTypeParser;
} }
} }

View File

@@ -133,10 +133,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (statementParser == null) statementParser ??= new StatementParser();
{
statementParser = new StatementParser();
}
return statementParser; return statementParser;
} }
} }

View File

@@ -56,10 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
get get
{ {
if (xmlPlanHierarchyParser == null) xmlPlanHierarchyParser ??= new XmlPlanHierarchyParser();
{
xmlPlanHierarchyParser = new XmlPlanHierarchyParser();
}
return xmlPlanHierarchyParser; return xmlPlanHierarchyParser;
} }
} }

View File

@@ -12,6 +12,7 @@ using System.Xml;
using System.Text; using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Reflection; using System.Reflection;
using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
@@ -40,10 +41,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
public ShowPlanGraph[] Execute(object dataSource) public ShowPlanGraph[] Execute(object dataSource)
{ {
ShowPlanXML plan = dataSource as ShowPlanXML; ShowPlanXML plan = dataSource as ShowPlanXML;
if (plan == null) plan ??= ReadXmlShowPlan(dataSource);
{
plan = ReadXmlShowPlan(dataSource);
}
List<ShowPlanGraph> graphs = new List<ShowPlanGraph>(); List<ShowPlanGraph> graphs = new List<ShowPlanGraph>();
int statementIndex = 0; int statementIndex = 0;
@@ -238,7 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
ArrayList targetStatementList = new ArrayList(); ArrayList targetStatementList = new ArrayList();
foreach (BaseStmtInfoType statement in statementBlock.Items) foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
{ {
targetStatementList.Add(statement); targetStatementList.Add(statement);
@@ -264,7 +262,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
//add this element and its children //add this element and its children
if (stmtThen.Statements != null && stmtThen.Statements.Items != null) 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); targetStatementList.Add(subStatement);
FlattenConditionClauses(subStatement, targetStatementList); FlattenConditionClauses(subStatement, targetStatementList);
@@ -280,7 +278,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
//add this element and its children //add this element and its children
if (stmtElse.Statements != null && stmtElse.Statements.Items != null) 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); targetStatementList.Add(subStatement);
FlattenConditionClauses(subStatement, targetStatementList); FlattenConditionClauses(subStatement, targetStatementList);
@@ -302,7 +300,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
ArrayList targetStatementList = new ArrayList(); ArrayList targetStatementList = new ArrayList();
foreach (BaseStmtInfoType statement in statementBlock.Items) foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
{ {
targetStatementList.Add(statement); targetStatementList.Add(statement);
@@ -351,7 +349,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
// Call itself recursively. // Call itself recursively.
if (functionItem.Function.Statements != null && functionItem.Function.Statements.Items != null) 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); ExtractFunctions(functionStatement, targetStatementList);
} }
@@ -369,7 +367,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{ {
if (statementBlock != null && statementBlock.Items != null) if (statementBlock != null && statementBlock.Items != null)
{ {
foreach (BaseStmtInfoType statement in statementBlock.Items) foreach (BaseStmtInfoType statement in statementBlock.Items.Cast<BaseStmtInfoType>())
{ {
yield return statement; yield return statement;
} }
@@ -402,10 +400,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
// check Memory Optimized table. // check Memory Optimized table.
bool memoryOptimzed = false; bool memoryOptimzed = false;
XmlNode scan = rootNode.SelectSingleNode("descendant::shp:IndexScan", nsMgr); 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 (scan != null && scan.Attributes["Storage"] != null)
{ {
if (0 == string.Compare(scan.Attributes["Storage"].Value, "MemoryOptimized", StringComparison.Ordinal)) if (0 == string.Compare(scan.Attributes["Storage"].Value, "MemoryOptimized", StringComparison.Ordinal))

View File

@@ -155,10 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
/// <param name="node">Node being parsed.</param> /// <param name="node">Node being parsed.</param>
protected virtual void SetNodeSpecialProperties(Node node) protected virtual void SetNodeSpecialProperties(Node node)
{ {
if (node.Operation == null) node.Operation ??= GetNodeOperation(node);
{
node.Operation = GetNodeOperation(node);
}
// Retrieve Subtree cost for this node // Retrieve Subtree cost for this node
node.SubtreeCost = GetNodeSubtreeCost(node); node.SubtreeCost = GetNodeSubtreeCost(node);
@@ -242,9 +239,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
continue; 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) if (XmlPlanParserFactory.GetParser(item.GetType()) != null)
{ {

View File

@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageExtensibility
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -37,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
{ {
get get
{ {
if(this.sqlParserWrapper == null) this.sqlParserWrapper ??= new SqlParserWrapper();
{
this.sqlParserWrapper = new SqlParserWrapper();
}
return this.sqlParserWrapper; return this.sqlParserWrapper;
} }
set set

View File

@@ -169,14 +169,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{ {
get get
{ {
if (this.parseOptions == null) this.parseOptions ??= new ParseOptions(
{
this.parseOptions = new ParseOptions(
batchSeparator: LanguageService.DefaultBatchSeperator, batchSeparator: LanguageService.DefaultBatchSeperator,
isQuotedIdentifierSet: true, isQuotedIdentifierSet: true,
compatibilityLevel: DatabaseCompatibilityLevel, compatibilityLevel: DatabaseCompatibilityLevel,
transactSqlVersion: TransactSqlVersion); transactSqlVersion: TransactSqlVersion);
}
return this.parseOptions; return this.parseOptions;
} }
} }

View File

@@ -191,10 +191,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{ {
get get
{ {
if (workspaceServiceInstance == null) workspaceServiceInstance ??= WorkspaceService<SqlToolsSettings>.Instance;
{
workspaceServiceInstance = WorkspaceService<SqlToolsSettings>.Instance;
}
return workspaceServiceInstance; return workspaceServiceInstance;
} }
set set
@@ -207,10 +204,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{ {
get get
{ {
if (this.serviceHostInstance == null) this.serviceHostInstance ??= ServiceHost.Instance;
{
this.serviceHostInstance = ServiceHost.Instance;
}
return this.serviceHostInstance; return this.serviceHostInstance;
} }
set set

View File

@@ -101,11 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
get get
{ {
if (m_hashTable == null) m_hashTable ??= new Hashtable();
{
m_hashTable = new Hashtable();
}
return m_hashTable; return m_hashTable;
} }
} }
@@ -808,11 +804,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
if (m_server == null)
{
// NOTE: ServerConnection property will constuct the object if needed // NOTE: ServerConnection property will constuct the object if needed
m_server = new Server(ServerConnection); m_server ??= new Server(ServerConnection);
}
} }
else if (this.serverType == ServerType.SQLCE) else if (this.serverType == ServerType.SQLCE)
{ {
@@ -933,10 +926,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
public string GetDocumentPropertyString(string propertyName) public string GetDocumentPropertyString(string propertyName)
{ {
object result = GetDocumentPropertyValue(propertyName); object result = GetDocumentPropertyValue(propertyName);
if (result == null) result ??= string.Empty;
{
result = string.Empty;
}
return (string)result; return (string)result;
} }
@@ -1203,10 +1193,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
bool databaseExists = false, bool databaseExists = false,
XmlDocument containerDoc = null) XmlDocument containerDoc = null)
{ {
if (containerDoc == null) containerDoc ??= CreateDataContainerDocument(connInfo, databaseExists);
{
containerDoc = CreateDataContainerDocument(connInfo, databaseExists);
}
var serverConnection = ConnectionService.OpenServerConnection(connInfo, "DataContainer"); var serverConnection = ConnectionService.OpenServerConnection(connInfo, "DataContainer");

View File

@@ -95,24 +95,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
this.connection = (SqlOlapConnectionInfoBase)cloneable.Clone(); this.connection = (SqlOlapConnectionInfoBase)cloneable.Clone();
this.closeOnDispose = true; 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; this.closeOnDispose = true;
} }
} }
} }
// if everything else has failed just use to passed in connection. // 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 // 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 // set lock_timeout to 10 seconds
((SqlConnectionInfoWithConnection)this.connection).ServerConnection.LockTimeout = 10; connection1.ServerConnection.LockTimeout = 10;
} }
} }
#endregion #endregion
@@ -190,10 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
get get
{ {
if (activeConnections == null) activeConnections ??= new Hashtable();
{
activeConnections = new Hashtable();
}
return activeConnections; return activeConnections;
} }
} }

View File

@@ -94,15 +94,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
} }
// allow to be sited only once // allow to be sited only once
if (this.serviceProvider == null)
{
// cache the service provider // cache the service provider
this.serviceProvider = sp; this.serviceProvider ??= sp;
// call protected virtual method to enable derived classes to do initialization // call protected virtual method to enable derived classes to do initialization
// OnHosted(); // OnHosted();
} }
}
#endregion #endregion
@@ -502,10 +499,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
get get
{ {
if (this.cachedExecutionHandlerDelegate == null) this.cachedExecutionHandlerDelegate ??= new ExecutionHandlerDelegate(this);
{
this.cachedExecutionHandlerDelegate = new ExecutionHandlerDelegate(this);
}
return this.cachedExecutionHandlerDelegate; return this.cachedExecutionHandlerDelegate;
} }
} }

View File

@@ -32,11 +32,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
{ {
//first, see if the object implemented this interface to override standard behavior //first, see if the object implemented this interface to override standard behavior
System.Reflection.ICustomAttributeProvider attribProvider = objectToGetAttributeFrom as System.Reflection.ICustomAttributeProvider; System.Reflection.ICustomAttributeProvider attribProvider = objectToGetAttributeFrom as System.Reflection.ICustomAttributeProvider;
if (attribProvider == null)
{
//if not, get it from its type //if not, get it from its type
attribProvider = (System.Reflection.ICustomAttributeProvider)objectToGetAttributeFrom.GetType(); attribProvider ??= (System.Reflection.ICustomAttributeProvider)objectToGetAttributeFrom.GetType();
}
object[] attribs = attribProvider.GetCustomAttributes(customAttribute, true); object[] attribs = attribProvider.GetCustomAttributes(customAttribute, true);
if (attribs != null && attribs.Length > 0) if (attribs != null && attribs.Length > 0)

View File

@@ -33,10 +33,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Metadata
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -75,10 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set

View File

@@ -38,10 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ModelManagement
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -279,10 +279,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context) internal async Task HandleFindNodesRequest(FindNodesParams findNodesParams, RequestContext<FindNodesResponse> context)
{ {
var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames); var foundNodes = FindNodes(findNodesParams.SessionId, findNodesParams.Type, findNodesParams.Schema, findNodesParams.Name, findNodesParams.Database, findNodesParams.ParentObjectNames);
if (foundNodes == null) foundNodes ??= new List<TreeNode>();
{
foundNodes = new List<TreeNode>();
}
await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() }); await context.SendResult(new FindNodesResponse { Nodes = foundNodes.Select(node => node.ToNodeInfo()).ToList() });
} }

View File

@@ -70,10 +70,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
path = schema + "." + path; path = schema + "." + path;
} }
if (path == null) path ??= "";
{
path = "";
}
foreach (var matchingNode in matchingNodes) foreach (var matchingNode in matchingNodes)
{ {

View File

@@ -53,10 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
get get
{ {
if (smoWrapper == null) smoWrapper ??= new SmoWrapper();
{
smoWrapper = new SmoWrapper();
}
return smoWrapper; return smoWrapper;
} }
set set

View File

@@ -55,10 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
@@ -144,11 +141,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
} }
catch { } catch { }
if (xeSession == null)
{
// create a new XEvent session and Profiler session // create a new XEvent session and Profiler session
xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo); xeSession ??= this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
}
// start monitoring the profiler session // start monitoring the profiler session
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession); monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);

View File

@@ -76,10 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
lock (this.sessionsLock) lock (this.sessionsLock)
{ {
// start the monitoring thread // 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 // create new profiling session if needed
if (!this.monitoredSessions.ContainsKey(session.Id)) if (!this.monitoredSessions.ContainsKey(session.Id))

View File

@@ -172,9 +172,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
AddCell((string)o); AddCell((string)o);
break; break;
default: 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. // 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) else if (o is SqlDecimal || o is SqlMoney)
@@ -518,10 +518,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
public ExcelSheet AddSheet(string sheetName = null) public ExcelSheet AddSheet(string sheetName = null)
{ {
string sheetFileName = "sheet" + (sheetNames.Count + 1); string sheetFileName = "sheet" + (sheetNames.Count + 1);
if (sheetName == null) sheetName ??= sheetFileName;
{
sheetName = sheetFileName;
}
EnsureValidSheetName(sheetName); EnsureValidSheetName(sheetName);
sheetNames.Add(sheetName); sheetNames.Add(sheetName);

View File

@@ -72,13 +72,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
{ {
get get
{ {
if (BufferFileStreamFactory == null) BufferFileStreamFactory ??= new ServiceBufferFileStreamFactory
{
BufferFileStreamFactory = new ServiceBufferFileStreamFactory
{ {
QueryExecutionSettings = Settings.QueryExecutionSettings QueryExecutionSettings = Settings.QueryExecutionSettings
}; };
}
return BufferFileStreamFactory; return BufferFileStreamFactory;
} }
} }

View File

@@ -405,10 +405,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
{ {
get get
{ {
if (sqlTaskManagerInstance == null) sqlTaskManagerInstance ??= SqlTaskManager.Instance;
{
sqlTaskManagerInstance = SqlTaskManager.Instance;
}
return sqlTaskManagerInstance; return sqlTaskManagerInstance;
} }
set set
@@ -421,10 +418,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set

View File

@@ -15,6 +15,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts; using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.ServiceLayer.Utility;
using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.Scripting namespace Microsoft.SqlTools.ServiceLayer.Scripting
{ {
@@ -43,10 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }
set set
@@ -117,11 +115,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
} }
} }
if (parameters.FilePath == null)
{
// Create a temporary and random path to handle this operation // Create a temporary and random path to handle this operation
parameters.FilePath = Path.GetTempFileName(); parameters.FilePath ??= Path.GetTempFileName();
}
if (!ShouldCreateScriptAsOperation(parameters)) if (!ShouldCreateScriptAsOperation(parameters))
{ {
@@ -229,7 +224,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
{ {
disposed = true; disposed = true;
foreach (ScriptingScriptOperation operation in this.ActiveOperations.Values) foreach (ScriptingScriptOperation operation in this.ActiveOperations.Values.Cast<ScriptingScriptOperation>())
{ {
operation.Dispose(); operation.Dispose();
} }

View File

@@ -47,10 +47,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -37,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
{ {
get get
{ {
if (connectionService == null) connectionService ??= ConnectionService.Instance;
{
connectionService = ConnectionService.Instance;
}
return connectionService; return connectionService;
} }

View File

@@ -20,10 +20,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.sqlTools == null) this.sqlTools ??= new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
{
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
}
return this.sqlTools; return this.sqlTools;
} }
set set
@@ -40,10 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.mssqlTools == null) this.mssqlTools ??= new SqlToolsSettingsValues(false);
{
this.mssqlTools = new SqlToolsSettingsValues(false);
}
return this.mssqlTools; return this.mssqlTools;
} }
set set
@@ -60,10 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
{ {
get get
{ {
if (this.allSqlTools == null) this.allSqlTools ??= new SqlToolsSettingsValues(false);
{
this.allSqlTools = new SqlToolsSettingsValues(false);
}
return this.allSqlTools; return this.allSqlTools;
} }
set set

View File

@@ -27,10 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
{ {
get get
{ {
if (lockedDatabaseManager == null) lockedDatabaseManager ??= ConnectionService.Instance.LockedDatabaseManager;
{
lockedDatabaseManager = ConnectionService.Instance.LockedDatabaseManager;
}
return lockedDatabaseManager; return lockedDatabaseManager;
} }
set set

View File

@@ -36,10 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
{ {
get get
{ {
if(taskManager == null) taskManager ??= SqlTaskManager.Instance;
{
taskManager = SqlTaskManager.Instance;
}
return taskManager; return taskManager;
} }
set set

View File

@@ -84,13 +84,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
shortList.Add(val); shortList.Add(val);
} }
else // need to split values into several arrays else // need to split values into several arrays
{
if (expandedList == null)
{ {
// very inefficient so delay as much as possible // very inefficient so delay as much as possible
// immediately add 0th array // immediately add 0th array
expandedList = new List<List<T>> {shortList}; expandedList ??= new List<List<T>> {shortList};
}
int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based int arrayIndex = (int)(Count / this.ExpandListSize); // 0 based

View File

@@ -357,10 +357,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
AgentNotebookInfo notebook = null) AgentNotebookInfo notebook = null)
{ {
var service = new AgentService(); var service = new AgentService();
if (notebook == null) notebook ??= GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master");
{
notebook = GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master");
}
string tempNotebookPath = CreateTemplateNotebookFile(); string tempNotebookPath = CreateTemplateNotebookFile();
await AgentNotebookHelper.CreateNotebook( await AgentNotebookHelper.CreateNotebook(

View File

@@ -50,18 +50,12 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
private async Task VerifyBackupFileCreated() private async Task VerifyBackupFileCreated()
{ {
if (fullBackupFilePath == null) fullBackupFilePath ??= await CreateBackupFile();
{
fullBackupFilePath = await CreateBackupFile();
}
} }
private async Task<string[]> GetBackupFilesToRecoverDatabaseCreated() private async Task<string[]> GetBackupFilesToRecoverDatabaseCreated()
{ {
if (backupFilesToRecoverDatabase == null) backupFilesToRecoverDatabase ??= await CreateBackupSetsToRecoverDatabase();
{
backupFilesToRecoverDatabase = await CreateBackupSetsToRecoverDatabase();
}
return backupFilesToRecoverDatabase; return backupFilesToRecoverDatabase;
} }

View File

@@ -283,10 +283,7 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
TestTimer timer = null, TestTimer timer = null,
[CallerMemberName] string testName = "") [CallerMemberName] string testName = "")
{ {
if (timer == null) timer ??= new TestTimer { PrintResult = false };
{
timer = new TestTimer { PrintResult = false };
}
bool isReady = !waitForIntelliSense; bool isReady = !waitForIntelliSense;
await testService.ExecuteWithTimeout(timer, 550000, async () => await testService.ExecuteWithTimeout(timer, 550000, async () =>
{ {

View File

@@ -146,8 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined
{ {
get get
{ {
if (this._baselineSubDir == null) this._baselineSubDir ??= string.Empty;
this._baselineSubDir = string.Empty;
return this._baselineSubDir; return this._baselineSubDir;
} }
set { this._baselineSubDir = value; } set { this._baselineSubDir = value; }

View File

@@ -65,10 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{ {
get get
{ {
if (pendingVerifications == null) pendingVerifications ??= new List<Action>();
{
pendingVerifications = new List<Action>();
}
return pendingVerifications; return pendingVerifications;
} }
set => pendingVerifications = value; set => pendingVerifications = value;

View File

@@ -13,6 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
{ {
class Program class Program
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0210:Convert to top-level statements", Justification = "Structure retained for readability.")]
static void Main(string[] args) static void Main(string[] args)
{ {
if (args.Length == 1) if (args.Length == 1)

View File

@@ -236,10 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Messaging
private byte[] GetMessageBytes(string messageString, Encoding encoding = null) private byte[] GetMessageBytes(string messageString, Encoding encoding = null)
{ {
if (encoding == null) encoding ??= Encoding.UTF8;
{
encoding = Encoding.UTF8;
}
byte[] messageBytes = Encoding.UTF8.GetBytes(messageString); byte[] messageBytes = Encoding.UTF8.GetBytes(messageString);
byte[] headerBytes = Encoding.ASCII.GetBytes(string.Format(Constants.ContentLengthFormatString, messageBytes.Length)); byte[] headerBytes = Encoding.ASCII.GetBytes(string.Format(Constants.ContentLengthFormatString, messageBytes.Length));

View File

@@ -24,10 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
public static ScriptFile GetTestScriptFile(string initialText = null) public static ScriptFile GetTestScriptFile(string initialText = null)
{ {
if (initialText == null) initialText ??= ScriptFileTests.query;
{
initialText = ScriptFileTests.query;
}
string ownerUri = System.IO.Path.GetTempFileName(); string ownerUri = System.IO.Path.GetTempFileName();

View File

@@ -68,10 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{ {
throw new TestDbException(); throw new TestDbException();
} }
if (RowEnumerator == null) RowEnumerator ??= ResultSetEnumerator.Current.GetEnumerator();
{
RowEnumerator = ResultSetEnumerator.Current.GetEnumerator();
}
return RowEnumerator.MoveNext(); return RowEnumerator.MoveNext();
} }