mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Bug fix for https://github.com/Microsoft/azuredatastudio/issues/2923 and misc other fixes (#711)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ project.lock.json
|
|||||||
*.sln.docstates
|
*.sln.docstates
|
||||||
*.exe
|
*.exe
|
||||||
scratch.txt
|
scratch.txt
|
||||||
|
launchSettings.json
|
||||||
|
|
||||||
# mergetool conflict files
|
# mergetool conflict files
|
||||||
*.orig
|
*.orig
|
||||||
|
|||||||
@@ -36,15 +36,12 @@ namespace Microsoft.SqlTools.Credentials
|
|||||||
string logFilePath = commandOptions.LogFilePath;
|
string logFilePath = commandOptions.LogFilePath;
|
||||||
if (string.IsNullOrWhiteSpace(logFilePath))
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
{
|
{
|
||||||
logFilePath = "credentials";
|
logFilePath = Logger.GenerateLogFilePath("credentials");
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
|
|
||||||
{
|
|
||||||
logFilePath = Logger.GenerateLogFilePath(Path.Combine(commandOptions.LoggingDirectory, logFilePath));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.AutoFlush = commandOptions.AutoFlushLog;
|
||||||
|
|
||||||
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "credentials");
|
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "credentials");
|
||||||
Logger.Write(TraceEventType.Information, "Starting SqlTools Credentials Provider");
|
|
||||||
|
|
||||||
// set up the host details and profile paths
|
// set up the host details and profile paths
|
||||||
var hostDetails = new HostDetails(
|
var hostDetails = new HostDetails(
|
||||||
|
|||||||
@@ -28,19 +28,12 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
ErrorMessage = string.Empty;
|
ErrorMessage = string.Empty;
|
||||||
Locale = string.Empty;
|
Locale = string.Empty;
|
||||||
|
|
||||||
//set default log directory
|
|
||||||
LoggingDirectory = DefaultLogRoot;
|
|
||||||
if (!string.IsNullOrWhiteSpace(ServiceName))
|
|
||||||
{
|
|
||||||
LoggingDirectory = Path.Combine(LoggingDirectory, ServiceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; ++i)
|
for (int i = 0; i < args.Length; ++i)
|
||||||
{
|
{
|
||||||
string arg = args[i];
|
string arg = args[i];
|
||||||
if (arg.StartsWith("--") || arg.StartsWith("-"))
|
if (arg != null && (arg.StartsWith("--") || arg.StartsWith("-")))
|
||||||
{
|
{
|
||||||
// Extracting arguments and properties
|
// Extracting arguments and properties
|
||||||
arg = arg.Substring(1).ToLowerInvariant();
|
arg = arg.Substring(1).ToLowerInvariant();
|
||||||
@@ -48,17 +41,15 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
|
|
||||||
switch (argName)
|
switch (argName)
|
||||||
{
|
{
|
||||||
case "-enable-logging":
|
case "-autoflush-log":
|
||||||
break; //ignore this old option for now for backward compat with older opsstudio code - to be removed in a future checkin
|
AutoFlushLog = true;
|
||||||
|
break;
|
||||||
case "-tracing-level":
|
case "-tracing-level":
|
||||||
TracingLevel = args[++i];
|
TracingLevel = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-log-file":
|
case "-log-file":
|
||||||
LogFilePath = args[++i];
|
LogFilePath = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-log-dir":
|
|
||||||
SetLoggingDirectory(args[++i]);
|
|
||||||
break;
|
|
||||||
case "-locale":
|
case "-locale":
|
||||||
SetLocale(args[++i]);
|
SetLocale(args[++i]);
|
||||||
break;
|
break;
|
||||||
@@ -93,11 +84,6 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ErrorMessage { get; private set; }
|
public string ErrorMessage { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the directory where log files are output.
|
|
||||||
/// </summary>
|
|
||||||
public string LoggingDirectory { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -123,11 +109,10 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
var str = string.Format("{0}" + Environment.NewLine +
|
var str = string.Format("{0}" + Environment.NewLine +
|
||||||
ServiceName + " " + Environment.NewLine +
|
ServiceName + " " + Environment.NewLine +
|
||||||
" Options:" + Environment.NewLine +
|
" Options:" + Environment.NewLine +
|
||||||
" [--enable-logging ] (obsolete - present for backward compat. Logging is always on, except -tracing-level Off has the effect of disabling logging)" + Environment.NewLine +
|
" [--autoflush-log] (If passed in auto flushing of log files is enabled., Verbose. Default is to not auto-flush log files)" + Environment.NewLine +
|
||||||
" [--tracing-level **] (** can be any of: All, Off, Critical, Error, Warning, Information, Verbose. Default is Critical)" + Environment.NewLine +
|
|
||||||
" [--log-file **]" + Environment.NewLine +
|
|
||||||
" [--log-dir **] (default: %APPDATA%\\<service name>)" + Environment.NewLine +
|
|
||||||
" [--locale **] (default: 'en')" + Environment.NewLine,
|
" [--locale **] (default: 'en')" + Environment.NewLine,
|
||||||
|
" [--log-file **]" + Environment.NewLine +
|
||||||
|
" [--tracing-level **] (** can be any of: All, Off, Critical, Error, Warning, Information, Verbose. Default is Critical)" + Environment.NewLine +
|
||||||
" [--help]" + Environment.NewLine +
|
" [--help]" + Environment.NewLine +
|
||||||
ErrorMessage);
|
ErrorMessage);
|
||||||
return str;
|
return str;
|
||||||
@@ -138,15 +123,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
|
|
||||||
public string LogFilePath { get; private set; }
|
public string LogFilePath { get; private set; }
|
||||||
|
|
||||||
private void SetLoggingDirectory(string loggingDirectory)
|
public bool AutoFlushLog { get; private set; } = false;
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(loggingDirectory))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.LoggingDirectory = Path.GetFullPath(loggingDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetLocale(string locale)
|
public virtual void SetLocale(string locale)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
get => tracingLevel;
|
get => tracingLevel;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" object instead of "TraceSource" object
|
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" class instead of "TraceSource" object
|
||||||
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
||||||
// configure the listener level filter
|
// configure the listener level filter
|
||||||
tracingLevel = value;
|
tracingLevel = value;
|
||||||
@@ -94,6 +94,8 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool AutoFlush { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the Logger for the current process.
|
/// Initializes the Logger for the current process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -108,9 +110,11 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
public static void Initialize(
|
public static void Initialize(
|
||||||
SourceLevels tracingLevel = defaultTracingLevel,
|
SourceLevels tracingLevel = defaultTracingLevel,
|
||||||
string logFilePath = null,
|
string logFilePath = null,
|
||||||
string traceSource = defaultTraceSource)
|
string traceSource = defaultTraceSource,
|
||||||
|
bool autoFlush = false)
|
||||||
{
|
{
|
||||||
Logger.tracingLevel = tracingLevel;
|
Logger.tracingLevel = tracingLevel;
|
||||||
|
Logger.AutoFlush = autoFlush;
|
||||||
TraceSource = new TraceSource(traceSource, Logger.tracingLevel);
|
TraceSource = new TraceSource(traceSource, Logger.tracingLevel);
|
||||||
if (string.IsNullOrWhiteSpace(logFilePath))
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
{
|
{
|
||||||
@@ -118,7 +122,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogFileFullPath = logFilePath;
|
LogFileFullPath = logFilePath;
|
||||||
Write(TraceEventType.Information, $"Initialized the {traceSource} logger");
|
Write(TraceEventType.Information, $"Initialized the {traceSource} logger. Log file is: {LogFileFullPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -185,7 +189,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make the log path unique
|
// make the log path unique
|
||||||
return $"{logFilePrefix}_{DateTime.Now.Year,4:D4}{DateTime.Now.Month,2:D2}{DateTime.Now.Day,2:D2}{DateTime.Now.Hour,2:D2}{DateTime.Now.Minute,2:D2}{DateTime.Now.Second,2:D2}{uniqueId}.log";
|
return $"{logFilePrefix}_{DateTime.Now.Year,4:D4}{DateTime.Now.Month,2:D2}{DateTime.Now.Day,2:D2}{DateTime.Now.Hour,2:D2}{DateTime.Now.Minute,2:D2}{DateTime.Now.Second,2:D2}_{uniqueId}.log";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureListener()
|
private static void ConfigureListener()
|
||||||
@@ -290,6 +294,10 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (AutoFlush)
|
||||||
|
{
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +439,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{(IsEnabled(TraceOptions.DateTime) ? string.Format(CultureInfo.InvariantCulture, "{0} ", eventCache.DateTime.ToLocalTime().ToString("u", CultureInfo.InvariantCulture)) : string.Empty)}"
|
return $"{(IsEnabled(TraceOptions.DateTime) ? string.Format(CultureInfo.InvariantCulture, "{0} ", eventCache.DateTime.ToLocalTime().ToString("yy-MM-dd H:mm:ss.fffffff", CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ $"{(IsEnabled(TraceOptions.ProcessId) ? string.Format(CultureInfo.InvariantCulture, "pid:{0} ", eventCache.ProcessId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
+ $"{(IsEnabled(TraceOptions.ProcessId) ? string.Format(CultureInfo.InvariantCulture, "pid:{0} ", eventCache.ProcessId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ $"{(IsEnabled(TraceOptions.ThreadId) ? string.Format(CultureInfo.InvariantCulture, "tid:{0} ", eventCache.ThreadId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
+ $"{(IsEnabled(TraceOptions.ThreadId) ? string.Format(CultureInfo.InvariantCulture, "tid:{0} ", eventCache.ThreadId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ message;
|
+ message;
|
||||||
|
|||||||
@@ -28,19 +28,12 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
ErrorMessage = string.Empty;
|
ErrorMessage = string.Empty;
|
||||||
Locale = string.Empty;
|
Locale = string.Empty;
|
||||||
|
|
||||||
//set default log directory
|
|
||||||
LoggingDirectory = DefaultLogRoot;
|
|
||||||
if (!string.IsNullOrWhiteSpace(ServiceName))
|
|
||||||
{
|
|
||||||
LoggingDirectory = Path.Combine(LoggingDirectory, ServiceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; ++i)
|
for (int i = 0; i < args.Length; ++i)
|
||||||
{
|
{
|
||||||
string arg = args[i];
|
string arg = args[i];
|
||||||
if (arg.StartsWith("--") || arg.StartsWith("-"))
|
if (arg != null && (arg.StartsWith("--") || arg.StartsWith("-")))
|
||||||
{
|
{
|
||||||
// Extracting arguments and properties
|
// Extracting arguments and properties
|
||||||
arg = arg.Substring(1).ToLowerInvariant();
|
arg = arg.Substring(1).ToLowerInvariant();
|
||||||
@@ -48,17 +41,15 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
|
|
||||||
switch (argName)
|
switch (argName)
|
||||||
{
|
{
|
||||||
case "-enable-logging":
|
case "-autoflush-log":
|
||||||
break; //ignore this old option for now for backward compat with older opsstudio code - to be removed in a future checkin
|
AutoFlushLog = true;
|
||||||
|
break;
|
||||||
case "-tracing-level":
|
case "-tracing-level":
|
||||||
TracingLevel = args[++i];
|
TracingLevel = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-log-file":
|
case "-log-file":
|
||||||
LogFilePath = args[++i];
|
LogFilePath = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-log-dir":
|
|
||||||
SetLoggingDirectory(args[++i]);
|
|
||||||
break;
|
|
||||||
case "-locale":
|
case "-locale":
|
||||||
SetLocale(args[++i]);
|
SetLocale(args[++i]);
|
||||||
break;
|
break;
|
||||||
@@ -93,11 +84,6 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ErrorMessage { get; private set; }
|
public string ErrorMessage { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the directory where log files are output.
|
|
||||||
/// </summary>
|
|
||||||
public string LoggingDirectory { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -123,11 +109,10 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
var str = string.Format("{0}" + Environment.NewLine +
|
var str = string.Format("{0}" + Environment.NewLine +
|
||||||
ServiceName + " " + Environment.NewLine +
|
ServiceName + " " + Environment.NewLine +
|
||||||
" Options:" + Environment.NewLine +
|
" Options:" + Environment.NewLine +
|
||||||
" [--enable-logging ] (obsolete - present for backward compat. Logging is always on, except -tracing-level Off has the effect of disabling logging)" + Environment.NewLine +
|
" [--autoflush-log] (If passed in auto flushing of log files is enabled., Verbose. Default is to not auto-flush log files)" + Environment.NewLine +
|
||||||
" [--tracing-level **] (** can be any of: All, Off, Critical, Error, Warning, Information, Verbose. Default is Critical)" + Environment.NewLine +
|
|
||||||
" [--log-file **]" + Environment.NewLine +
|
|
||||||
" [--log-dir **] (default: %APPDATA%\\<service name>)" + Environment.NewLine +
|
|
||||||
" [--locale **] (default: 'en')" + Environment.NewLine,
|
" [--locale **] (default: 'en')" + Environment.NewLine,
|
||||||
|
" [--log-file **]" + Environment.NewLine +
|
||||||
|
" [--tracing-level **] (** can be any of: All, Off, Critical, Error, Warning, Information, Verbose. Default is Critical)" + Environment.NewLine +
|
||||||
" [--help]" + Environment.NewLine +
|
" [--help]" + Environment.NewLine +
|
||||||
ErrorMessage);
|
ErrorMessage);
|
||||||
return str;
|
return str;
|
||||||
@@ -138,15 +123,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
|
|
||||||
public string LogFilePath { get; private set; }
|
public string LogFilePath { get; private set; }
|
||||||
|
|
||||||
private void SetLoggingDirectory(string loggingDirectory)
|
public bool AutoFlushLog { get; private set; } = false;
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(loggingDirectory))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.LoggingDirectory = Path.GetFullPath(loggingDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetLocale(string locale)
|
public virtual void SetLocale(string locale)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
get => tracingLevel;
|
get => tracingLevel;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" object instead of "TraceSource" object
|
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" class instead of "TraceSource" object
|
||||||
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
||||||
// configure the listener level filter
|
// configure the listener level filter
|
||||||
tracingLevel = value;
|
tracingLevel = value;
|
||||||
@@ -94,6 +94,8 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool AutoFlush { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the Logger for the current process.
|
/// Initializes the Logger for the current process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -108,9 +110,11 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
public static void Initialize(
|
public static void Initialize(
|
||||||
SourceLevels tracingLevel = defaultTracingLevel,
|
SourceLevels tracingLevel = defaultTracingLevel,
|
||||||
string logFilePath = null,
|
string logFilePath = null,
|
||||||
string traceSource = defaultTraceSource)
|
string traceSource = defaultTraceSource,
|
||||||
|
bool autoFlush = false)
|
||||||
{
|
{
|
||||||
Logger.tracingLevel = tracingLevel;
|
Logger.tracingLevel = tracingLevel;
|
||||||
|
Logger.AutoFlush = autoFlush;
|
||||||
TraceSource = new TraceSource(traceSource, Logger.tracingLevel);
|
TraceSource = new TraceSource(traceSource, Logger.tracingLevel);
|
||||||
if (string.IsNullOrWhiteSpace(logFilePath))
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
{
|
{
|
||||||
@@ -118,7 +122,7 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogFileFullPath = logFilePath;
|
LogFileFullPath = logFilePath;
|
||||||
Write(TraceEventType.Information, $"Initialized the {traceSource} logger");
|
Write(TraceEventType.Information, $"Initialized the {traceSource} logger. Log file is: {LogFileFullPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -185,7 +189,7 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make the log path unique
|
// make the log path unique
|
||||||
return $"{logFilePrefix}_{DateTime.Now.Year,4:D4}{DateTime.Now.Month,2:D2}{DateTime.Now.Day,2:D2}{DateTime.Now.Hour,2:D2}{DateTime.Now.Minute,2:D2}{DateTime.Now.Second,2:D2}{uniqueId}.log";
|
return $"{logFilePrefix}_{DateTime.Now.Year,4:D4}{DateTime.Now.Month,2:D2}{DateTime.Now.Day,2:D2}{DateTime.Now.Hour,2:D2}{DateTime.Now.Minute,2:D2}{DateTime.Now.Second,2:D2}_{uniqueId}.log";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureListener()
|
private static void ConfigureListener()
|
||||||
@@ -290,6 +294,10 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (AutoFlush)
|
||||||
|
{
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +439,7 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{(IsEnabled(TraceOptions.DateTime) ? string.Format(CultureInfo.InvariantCulture, "{0} ", eventCache.DateTime.ToLocalTime().ToString("u", CultureInfo.InvariantCulture)) : string.Empty)}"
|
return $"{(IsEnabled(TraceOptions.DateTime) ? string.Format(CultureInfo.InvariantCulture, "{0} ", eventCache.DateTime.ToLocalTime().ToString("yy-MM-dd H:mm:ss.fffffff", CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ $"{(IsEnabled(TraceOptions.ProcessId) ? string.Format(CultureInfo.InvariantCulture, "pid:{0} ", eventCache.ProcessId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
+ $"{(IsEnabled(TraceOptions.ProcessId) ? string.Format(CultureInfo.InvariantCulture, "pid:{0} ", eventCache.ProcessId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ $"{(IsEnabled(TraceOptions.ThreadId) ? string.Format(CultureInfo.InvariantCulture, "tid:{0} ", eventCache.ThreadId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
+ $"{(IsEnabled(TraceOptions.ThreadId) ? string.Format(CultureInfo.InvariantCulture, "tid:{0} ", eventCache.ThreadId.ToString(CultureInfo.InvariantCulture)) : string.Empty)}"
|
||||||
+ message;
|
+ message;
|
||||||
|
|||||||
@@ -35,11 +35,7 @@ namespace Microsoft.SqlTools.ResourceProvider
|
|||||||
string logFilePath = commandOptions.LogFilePath;
|
string logFilePath = commandOptions.LogFilePath;
|
||||||
if (string.IsNullOrWhiteSpace(logFilePath))
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
{
|
{
|
||||||
logFilePath = "SqlToolsResourceProviderService";
|
logFilePath = Logger.GenerateLogFilePath("SqlToolsResourceProviderService");
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
|
|
||||||
{
|
|
||||||
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn on Verbose logging during early development
|
// turn on Verbose logging during early development
|
||||||
|
|||||||
@@ -23,80 +23,76 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
return SmoColumnCustomNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
return SmoColumnCustomNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
get
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
return new List<NodeSmoProperty>
|
Name = "Computed",
|
||||||
{
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "Computed",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "IsColumnSet",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "IsColumnSet",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "Nullable",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "Nullable",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "DataType",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "DataType",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "InPrimaryKey",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "InPrimaryKey",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "IsForeignKey",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "IsForeignKey",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "SystemType",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "SystemType",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "Length",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "Length",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "NumericPrecision",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "NumericPrecision",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "NumericScale",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "NumericScale",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "XmlSchemaNamespaceSchema",
|
||||||
},
|
ValidFor = ValidForFlag.NotSqlDw
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "XmlSchemaNamespaceSchema",
|
{
|
||||||
ValidFor = ValidForFlag.NotSqlDw
|
Name = "XmlSchemaNamespace",
|
||||||
},
|
ValidFor = ValidForFlag.NotSqlDw
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "XmlSchemaNamespace",
|
{
|
||||||
ValidFor = ValidForFlag.NotSqlDw
|
Name = "XmlDocumentConstraint",
|
||||||
},
|
ValidFor = ValidForFlag.NotSqlDw
|
||||||
new NodeSmoProperty
|
|
||||||
{
|
|
||||||
Name = "XmlDocumentConstraint",
|
|
||||||
ValidFor = ValidForFlag.NotSqlDw
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
||||||
@@ -25,30 +26,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class IndexesChildFactory : SmoChildFactoryBase
|
internal partial class IndexesChildFactory : SmoChildFactoryBase
|
||||||
{
|
{
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
get
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
return new List<NodeSmoProperty>
|
Name = "IsUnique",
|
||||||
{
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "IsUnique",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "IsClustered",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
},
|
||||||
{
|
new NodeSmoProperty
|
||||||
Name = "IsClustered",
|
{
|
||||||
ValidFor = ValidForFlag.All
|
Name = "IndexKeyType",
|
||||||
},
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
|
||||||
{
|
|
||||||
Name = "IndexKeyType",
|
|
||||||
ValidFor = ValidForFlag.All
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
|
|
||||||
public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext)
|
public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
||||||
@@ -18,21 +19,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
return LoginCustomNodeHelper.GetStatus(smoObject);
|
return LoginCustomNodeHelper.GetStatus(smoObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
get
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
return new List<NodeSmoProperty>
|
Name = "IsDisabled",
|
||||||
{
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
|
||||||
{
|
|
||||||
Name = "IsDisabled",
|
|
||||||
ValidFor = ValidForFlag.All
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class LoginCustomNodeHelper
|
internal static class LoginCustomNodeHelper
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
||||||
@@ -14,27 +15,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class TriggersChildFactory : SmoChildFactoryBase
|
internal partial class TriggersChildFactory : SmoChildFactoryBase
|
||||||
{
|
{
|
||||||
public static readonly List<NodeSmoProperty> SmoPropertyList = new List<NodeSmoProperty>
|
public static readonly Lazy<List<NodeSmoProperty>> SmoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
new NodeSmoProperty
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
Name = "IsEnabled",
|
Name = "IsEnabled",
|
||||||
ValidFor = ValidForFlag.All
|
ValidFor = ValidForFlag.All
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
public override string GetNodeStatus(object smoObject, SmoQueryContext smoContext)
|
public override string GetNodeStatus(object smoObject, SmoQueryContext smoContext)
|
||||||
{
|
{
|
||||||
return TriggersCustomeNodeHelper.GetStatus(smoObject);
|
return TriggersCustomeNodeHelper.GetStatus(smoObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
public override IEnumerable<NodeSmoProperty> SmoProperties => SmoPropertiesLazy.Value;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return TriggersChildFactory.SmoPropertyList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal partial class ServerLevelServerTriggersChildFactory : SmoChildFactoryBase
|
internal partial class ServerLevelServerTriggersChildFactory : SmoChildFactoryBase
|
||||||
@@ -48,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return TriggersChildFactory.SmoPropertyList;
|
return TriggersChildFactory.SmoPropertiesLazy.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +59,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return TriggersChildFactory.SmoPropertyList;
|
return TriggersChildFactory.SmoPropertiesLazy.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
|
||||||
@@ -19,20 +20,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
return UserCustomeNodeHelper.GetStatus(smoObject);
|
return UserCustomeNodeHelper.GetStatus(smoObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
get
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
return new List<NodeSmoProperty>
|
Name = "HasDBAccess",
|
||||||
{
|
ValidFor = ValidForFlag.All
|
||||||
new NodeSmoProperty
|
|
||||||
{
|
|
||||||
Name = "HasDBAccess",
|
|
||||||
ValidFor = ValidForFlag.All
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class UserCustomeNodeHelper
|
internal static class UserCustomeNodeHelper
|
||||||
|
|||||||
@@ -180,34 +180,29 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
public override IEnumerable<string> ApplicableParents() { return new[] { "Databases" }; }
|
public override IEnumerable<string> ApplicableParents() { return new[] { "Databases" }; }
|
||||||
|
|
||||||
public override IEnumerable<NodeFilter> Filters
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var filters = new List<NodeFilter>();
|
|
||||||
filters.Add(new NodeFilter
|
|
||||||
{
|
|
||||||
Property = "IsSystemObject",
|
|
||||||
Type = typeof(bool),
|
|
||||||
Values = new List<object> { 0 },
|
|
||||||
});
|
|
||||||
return filters;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeFilter>> filtersLazy = new Lazy<List<NodeFilter>>(() => new List<NodeFilter>
|
||||||
{
|
{
|
||||||
get
|
new NodeFilter
|
||||||
{
|
{
|
||||||
var properties = new List<NodeSmoProperty>();
|
Property = "IsSystemObject",
|
||||||
properties.Add(new NodeSmoProperty
|
Type = typeof(bool),
|
||||||
{
|
Values = new List<object> { 0 },
|
||||||
Name = "Status",
|
}
|
||||||
ValidFor = ValidForFlag.All
|
});
|
||||||
});
|
|
||||||
return properties;
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
}
|
{
|
||||||
}
|
new NodeSmoProperty
|
||||||
|
{
|
||||||
|
Name = "Status",
|
||||||
|
ValidFor = ValidForFlag.All
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public override IEnumerable<NodeFilter> Filters => filtersLazy.Value;
|
||||||
|
|
||||||
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
|
|
||||||
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
|
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
|
||||||
{
|
{
|
||||||
@@ -753,60 +748,54 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
public override IEnumerable<string> ApplicableParents() { return new[] { "Tables" }; }
|
public override IEnumerable<string> ApplicableParents() { return new[] { "Tables" }; }
|
||||||
|
|
||||||
public override IEnumerable<NodeFilter> Filters
|
private readonly Lazy<List<NodeFilter>> filtersLazy = new Lazy<List<NodeFilter>>(() => new List<NodeFilter>
|
||||||
{
|
{
|
||||||
get
|
new NodeFilter
|
||||||
{
|
{
|
||||||
var filters = new List<NodeFilter>();
|
Property = "IsSystemObject",
|
||||||
filters.Add(new NodeFilter
|
Type = typeof(bool),
|
||||||
|
Values = new List<object> { 0 },
|
||||||
|
},
|
||||||
|
new NodeFilter
|
||||||
|
{
|
||||||
|
Property = "TemporalType",
|
||||||
|
Type = typeof(Enum),
|
||||||
|
ValidFor = ValidForFlag.Sql2016 | ValidForFlag.Sql2017 | ValidForFlag.AzureV12,
|
||||||
|
Values = new List<object>
|
||||||
{
|
{
|
||||||
Property = "IsSystemObject",
|
{ TableTemporalType.None },
|
||||||
Type = typeof(bool),
|
{ TableTemporalType.SystemVersioned }
|
||||||
Values = new List<object> { 0 },
|
}
|
||||||
});
|
}
|
||||||
filters.Add(new NodeFilter
|
});
|
||||||
{
|
|
||||||
Property = "TemporalType",
|
|
||||||
Type = typeof(Enum),
|
|
||||||
ValidFor = ValidForFlag.Sql2016|ValidForFlag.Sql2017|ValidForFlag.AzureV12,
|
|
||||||
Values = new List<object>
|
|
||||||
{
|
|
||||||
{ TableTemporalType.None },
|
|
||||||
{ TableTemporalType.SystemVersioned }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return filters;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<NodeSmoProperty> SmoProperties
|
private readonly Lazy<List<NodeSmoProperty>> smoPropertiesLazy = new Lazy<List<NodeSmoProperty>>(() => new List<NodeSmoProperty>
|
||||||
{
|
{
|
||||||
get
|
new NodeSmoProperty
|
||||||
{
|
{
|
||||||
var properties = new List<NodeSmoProperty>();
|
Name = "IsFileTable",
|
||||||
properties.Add(new NodeSmoProperty
|
ValidFor = ValidForFlag.Sql2012 | ValidForFlag.Sql2014 | ValidForFlag.Sql2016 | ValidForFlag.Sql2017
|
||||||
{
|
},
|
||||||
Name = "IsFileTable",
|
new NodeSmoProperty
|
||||||
ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Sql2017
|
{
|
||||||
});
|
Name = "IsSystemVersioned",
|
||||||
properties.Add(new NodeSmoProperty
|
ValidFor = ValidForFlag.Sql2016 | ValidForFlag.Sql2017 | ValidForFlag.AzureV12
|
||||||
{
|
},
|
||||||
Name = "IsSystemVersioned",
|
new NodeSmoProperty
|
||||||
ValidFor = ValidForFlag.Sql2016|ValidForFlag.Sql2017|ValidForFlag.AzureV12
|
{
|
||||||
});
|
Name = "TemporalType",
|
||||||
properties.Add(new NodeSmoProperty
|
ValidFor = ValidForFlag.Sql2016 | ValidForFlag.Sql2017 | ValidForFlag.AzureV12
|
||||||
{
|
},
|
||||||
Name = "TemporalType",
|
new NodeSmoProperty
|
||||||
ValidFor = ValidForFlag.Sql2016|ValidForFlag.Sql2017|ValidForFlag.AzureV12
|
{
|
||||||
});
|
Name = "IsExternal",
|
||||||
properties.Add(new NodeSmoProperty
|
ValidFor = ValidForFlag.Sql2016 | ValidForFlag.Sql2017 | ValidForFlag.AzureV12
|
||||||
{
|
}
|
||||||
Name = "IsExternal",
|
});
|
||||||
ValidFor = ValidForFlag.Sql2016|ValidForFlag.Sql2017|ValidForFlag.AzureV12
|
|
||||||
});
|
public override IEnumerable<NodeFilter> Filters => filtersLazy.Value;
|
||||||
return properties;
|
|
||||||
}
|
public override IEnumerable<NodeSmoProperty> SmoProperties => smoPropertiesLazy.Value;
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
|
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,17 +33,12 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
string logFilePath = commandOptions.LogFilePath;
|
string logFilePath = commandOptions.LogFilePath;
|
||||||
if (string.IsNullOrWhiteSpace(logFilePath))
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
{
|
{
|
||||||
logFilePath = "sqltools";
|
logFilePath = Logger.GenerateLogFilePath("sqltools");
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
|
|
||||||
{
|
|
||||||
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn on Verbose logging during early development
|
Logger.AutoFlush = commandOptions.AutoFlushLog;
|
||||||
// we need to switch to Information when preparing for public preview
|
|
||||||
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "sqltools");
|
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "sqltools");
|
||||||
Logger.Write(TraceEventType.Information, "Starting SQL Tools Service Layer");
|
|
||||||
|
|
||||||
// set up the host details and profile paths
|
// set up the host details and profile paths
|
||||||
var hostDetails = new HostDetails(version: new Version(1, 0));
|
var hostDetails = new HostDetails(version: new Version(1, 0));
|
||||||
|
|||||||
@@ -30,21 +30,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
|||||||
public SourceLevels TracingLevel { get; set; } = SourceLevels.Critical;
|
public SourceLevels TracingLevel { get; set; } = SourceLevels.Critical;
|
||||||
public bool DoNotUseTraceSource { get; set; } = false;
|
public bool DoNotUseTraceSource { get; set; } = false;
|
||||||
|
|
||||||
|
public bool AutoFlush { get; set; } = false;
|
||||||
|
|
||||||
private List<Action> pendingVerifications;
|
private List<Action> pendingVerifications;
|
||||||
private string testName;
|
private string testName;
|
||||||
|
|
||||||
public string CallstackMessage { get => $"Callstack=\\s*{TopFrame}"; }
|
public string CallstackMessage { get => $"Callstack=\\s*{TopFrame}"; }
|
||||||
|
|
||||||
|
public void Close() => Logger.Close();
|
||||||
|
|
||||||
public string LogFileName { get => logFileName ?? Logger.LogFileFullPath; set => logFileName = value; }
|
public string LogFileName { get => logFileName ?? Logger.LogFileFullPath; set => logFileName = value; }
|
||||||
public void Initialize() =>
|
public void Initialize() =>
|
||||||
Logger.Initialize(TracingLevel, LogFilePath, TraceSource); // initialize the logger
|
Logger.Initialize(TracingLevel, LogFilePath, TraceSource, AutoFlush); // initialize the logger
|
||||||
public string LogContents
|
public string LogContents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (logContents == null)
|
if (logContents == null)
|
||||||
{
|
{
|
||||||
Logger.Close();
|
Close();
|
||||||
Assert.True(!string.IsNullOrWhiteSpace(LogFileName));
|
Assert.True(!string.IsNullOrWhiteSpace(LogFileName));
|
||||||
Assert.True(LogFileName.Length > "{TraceSource}_.log".Length);
|
Assert.True(LogFileName.Length > "{TraceSource}_.log".Length);
|
||||||
Assert.True(File.Exists(LogFileName));
|
Assert.True(File.Exists(LogFileName));
|
||||||
@@ -70,24 +74,30 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
|||||||
set => pendingVerifications = value;
|
set => pendingVerifications = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write()
|
public void Write() => Write(LogMessage);
|
||||||
|
|
||||||
|
public void Write(string logMessage)
|
||||||
{
|
{
|
||||||
// write test log
|
// write test log
|
||||||
if (DoNotUseTraceSource)
|
if (DoNotUseTraceSource)
|
||||||
{
|
{
|
||||||
TraceSource savedTraceSource = Logger.TraceSource;
|
TraceSource savedTraceSource = Logger.TraceSource;
|
||||||
Logger.TraceSource = null;
|
Logger.TraceSource = null;
|
||||||
Logger.Write(EventType, LogMessage);
|
Logger.Write(EventType, logMessage);
|
||||||
Logger.TraceSource = savedTraceSource;
|
Logger.TraceSource = savedTraceSource;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Logger.Write(EventType, LogMessage);
|
{
|
||||||
|
Logger.Write(EventType, logMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteWithCallstack()
|
public void WriteWithCallstack() => WriteWithCallstack(LogMessage);
|
||||||
|
|
||||||
|
public void WriteWithCallstack(string logMessage)
|
||||||
{
|
{
|
||||||
// write test log with callstack
|
// write test log with callstack
|
||||||
Logger.WriteWithCallstack(EventType, LogMessage);
|
Logger.WriteWithCallstack(EventType, logMessage);
|
||||||
ShouldVerifyCallstack = true;
|
ShouldVerifyCallstack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +107,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
|||||||
|
|
||||||
public void Verify(TraceEventType eventType, string message, string callstackMessage, bool shouldVerifyCallstack = false, bool expectLogMessage = true)
|
public void Verify(TraceEventType eventType, string message, string callstackMessage, bool shouldVerifyCallstack = false, bool expectLogMessage = true)
|
||||||
{
|
{
|
||||||
Logger.Flush();
|
if (!AutoFlush)
|
||||||
|
{
|
||||||
|
Logger.Flush();
|
||||||
|
}
|
||||||
// The Regex uses .* between the severity and the message to allow SMO to vary the content. 140 SMO has nothing there, 150 has a timestamp
|
// The Regex uses .* between the severity and the message to allow SMO to vary the content. 140 SMO has nothing there, 150 has a timestamp
|
||||||
if (expectLogMessage)
|
if (expectLogMessage)
|
||||||
{
|
{
|
||||||
@@ -138,7 +151,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void VerifyInitialization(SourceLevels expectedTracingLevel, string expectedTraceSource, string logFilePath, bool isLogFileExpectedToExist, int? testNo = null)
|
public static void VerifyInitialization(SourceLevels expectedTracingLevel, string expectedTraceSource, string logFilePath, bool isLogFileExpectedToExist, int? testNo = null)
|
||||||
{
|
{
|
||||||
string FailureMessagePrefix = testNo.HasValue ? $"For Test No:{testNo.Value.ToString()}," : string.Empty;
|
string FailureMessagePrefix = testNo.HasValue ? $"For Test No:{testNo.Value.ToString()}," : string.Empty;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||||
using Microsoft.SqlTools.Utility;
|
using Microsoft.SqlTools.Utility;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@@ -333,6 +334,33 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
|||||||
TestTracingLevelChangeFromWarningToError(test);
|
TestTracingLevelChangeFromWarningToError(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests out AutoFlush funcitonality. The verification is two fold.
|
||||||
|
/// 1st is to verify that the setting is persistent.
|
||||||
|
/// 2nd that after a lot of log entries are written with AutoFlush on, explicitly flushing and closing the Tracing does not increase the file size
|
||||||
|
/// thereby verifying that there was no leftover log entries being left behind to be flushed.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void LoggerAutolFlush()
|
||||||
|
{
|
||||||
|
// setup the test object
|
||||||
|
TestLogger test = new TestLogger()
|
||||||
|
{
|
||||||
|
TraceSource = MethodInfo.GetCurrentMethod().Name,
|
||||||
|
AutoFlush = true,
|
||||||
|
TracingLevel = SourceLevels.All
|
||||||
|
};
|
||||||
|
test.Initialize();
|
||||||
|
// Write 10000 lines of log
|
||||||
|
Parallel.For(0, 100, (i) => test.Write($"Message Number:{i}, Message:{test.LogMessage}"));
|
||||||
|
long logContentsSizeBeforeExplicitFlush = (new FileInfo(test.LogFileName)).Length;
|
||||||
|
// Please note that Logger.Close() first flushes the logs before closing them out.
|
||||||
|
Logger.Flush();
|
||||||
|
long logContentsSizeAfterExplicitFlush = (new FileInfo(test.LogFileName)).Length;
|
||||||
|
Assert.True(logContentsSizeBeforeExplicitFlush == logContentsSizeAfterExplicitFlush, "The length of log file with autoflush before and after explicit flush must be same");
|
||||||
|
test.Cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When not use TraceSource, test to verify that upon changing TracingLevel from Error To Warning,
|
/// When not use TraceSource, test to verify that upon changing TracingLevel from Error To Warning,
|
||||||
/// after the change, messages of Warning as well as of Error type are present in the log.
|
/// after the change, messages of Warning as well as of Error type are present in the log.
|
||||||
|
|||||||
@@ -47,33 +47,45 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
|||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
VerifyCommandOptions(options, testNo++);
|
VerifyCommandOptions(options, testNo++);
|
||||||
}
|
}
|
||||||
// Test 2: All defaults, -logDir as null
|
// Test 2: All defaults, -autoflush-log as null
|
||||||
{
|
{
|
||||||
var args = new string[] { "--log-dir", null };
|
var args = new string[] { "--autoflush-log", null };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
VerifyCommandOptions(options, testNo++);
|
VerifyCommandOptions(options, testNo++, autoFlushLog: true);
|
||||||
}
|
}
|
||||||
// Test 3: All defaults, -logDir as empty string
|
// Test 3: All defaults, -autoflush-log as empty string
|
||||||
{
|
{
|
||||||
var args = new string[] { "--log-dir", string.Empty };
|
var args = new string[] { "--autoflush-log", string.Empty };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
VerifyCommandOptions(options, testNo++);
|
VerifyCommandOptions(options, testNo++, autoFlushLog: true);
|
||||||
}
|
}
|
||||||
// Test 4: All defaults, -log-file as null
|
// Test 4: All defaults, -tracing-level as empty string
|
||||||
{
|
{
|
||||||
var args = new string[] { "--log-file", null };
|
var args = new string[] { "--tracing-level", string.Empty };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
VerifyCommandOptions(options, testNo++, logFilePath: null);
|
VerifyCommandOptions(options, testNo++, tracingLevel: string.Empty);
|
||||||
}
|
}
|
||||||
// Test 5: All defaults, -log-file as empty string
|
// Test 5: All defaults, -tracing-level as null
|
||||||
|
{
|
||||||
|
var args = new string[] { "--tracing-level", null };
|
||||||
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
|
VerifyCommandOptions(options, testNo++, tracingLevel: null);
|
||||||
|
}
|
||||||
|
// Test 6: All defaults, -log-file as empty string
|
||||||
{
|
{
|
||||||
var args = new string[] { "--log-file", string.Empty };
|
var args = new string[] { "--log-file", string.Empty };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
VerifyCommandOptions(options, testNo++, logFilePath: string.Empty);
|
VerifyCommandOptions(options, testNo++, logFilePath: string.Empty);
|
||||||
}
|
}
|
||||||
|
// Test 6: All defaults, -log-file as null
|
||||||
|
{
|
||||||
|
var args = new string[] { "--log-file", null };
|
||||||
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
|
VerifyCommandOptions(options, testNo++, logFilePath: null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void VerifyCommandOptions(ServiceLayerCommandOptions options, int? testNo = null, string errorMessage = "", string tracingLevel = null, string logFilePath = null, bool shouldExit = false, string locale = "", string logDirectory = null)
|
private static void VerifyCommandOptions(ServiceLayerCommandOptions options, int? testNo = null, string errorMessage = "", string tracingLevel = null, string logFilePath = null, bool shouldExit = false, string locale = "", bool autoFlushLog = false)
|
||||||
{
|
{
|
||||||
Assert.NotNull(options);
|
Assert.NotNull(options);
|
||||||
string MsgPrefix = testNo != null ? $"TestNo:{testNo} ::" : string.Empty;
|
string MsgPrefix = testNo != null ? $"TestNo:{testNo} ::" : string.Empty;
|
||||||
@@ -81,12 +93,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
|||||||
Assert.True(tracingLevel == options.TracingLevel, $"{MsgPrefix} options:{nameof(tracingLevel)} should be '{tracingLevel}'");
|
Assert.True(tracingLevel == options.TracingLevel, $"{MsgPrefix} options:{nameof(tracingLevel)} should be '{tracingLevel}'");
|
||||||
Assert.True(logFilePath == options.LogFilePath, $"{MsgPrefix} options:{nameof(logFilePath)} should be '{logFilePath}'");
|
Assert.True(logFilePath == options.LogFilePath, $"{MsgPrefix} options:{nameof(logFilePath)} should be '{logFilePath}'");
|
||||||
Assert.True(shouldExit == options.ShouldExit, $"{MsgPrefix} options:{nameof(shouldExit)} should be '{shouldExit}'");
|
Assert.True(shouldExit == options.ShouldExit, $"{MsgPrefix} options:{nameof(shouldExit)} should be '{shouldExit}'");
|
||||||
Assert.False(string.IsNullOrWhiteSpace(options.LoggingDirectory));
|
Assert.True(autoFlushLog == options.AutoFlushLog, $"{MsgPrefix} options:{nameof(autoFlushLog)} should be '{autoFlushLog}'");
|
||||||
if (string.IsNullOrWhiteSpace(logDirectory))
|
|
||||||
{
|
|
||||||
logDirectory = Path.Combine(options.DefaultLogRoot, options.ServiceName);
|
|
||||||
}
|
|
||||||
Assert.True(logDirectory == options.LoggingDirectory, $"{MsgPrefix} options:{nameof(logDirectory)} should be '{logDirectory}'");
|
|
||||||
Assert.True(options.Locale == locale, $"{MsgPrefix} options:{nameof(locale)} should be '{locale}'");
|
Assert.True(options.Locale == locale, $"{MsgPrefix} options:{nameof(locale)} should be '{locale}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,24 +135,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
|||||||
Assert.Equal(options.Locale, string.Empty);
|
Assert.Equal(options.Locale, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void LoggingDirectorySet()
|
|
||||||
{
|
|
||||||
string logDir = Directory.GetCurrentDirectory();
|
|
||||||
var args = new string[] { "--log-dir", logDir };
|
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
|
||||||
|
|
||||||
// Asserting all options were properly set
|
|
||||||
Assert.NotNull(options);
|
|
||||||
Assert.False(options.ShouldExit);
|
|
||||||
Assert.Equal(options.LoggingDirectory, logDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TracingLevelSet()
|
public void TracingLevelSet()
|
||||||
{
|
{
|
||||||
string expectedLevel = "Critical";
|
string expectedLevel = "Information";
|
||||||
var args = new string[] { "--tracing-level", expectedLevel };
|
var args = new string[] { "--tracing-level", expectedLevel };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
|
|
||||||
@@ -155,11 +149,23 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
|||||||
Assert.Equal(options.TracingLevel, expectedLevel);
|
Assert.Equal(options.TracingLevel, expectedLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AutoFlushLogSet()
|
||||||
|
{
|
||||||
|
bool expectedAutoFlush = true;
|
||||||
|
var args = new string[] { "--autoflush-log"};
|
||||||
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
|
|
||||||
|
// Asserting all options were properly set
|
||||||
|
Assert.NotNull(options);
|
||||||
|
Assert.False(options.ShouldExit);
|
||||||
|
Assert.Equal(options.AutoFlushLog, expectedAutoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void LogFilePathSet()
|
public void LogFilePathSet()
|
||||||
{
|
{
|
||||||
string expectedFilePath = Path.GetRandomFileName();
|
string expectedFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||||
var args = new string[] { "--log-file", expectedFilePath };
|
var args = new string[] { "--log-file", expectedFilePath };
|
||||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||||
|
|
||||||
|
|||||||
@@ -66,10 +66,19 @@ namespace ScriptGenerator.Properties {
|
|||||||
////****** Object: Database [AdventureWorks] Script Date: 9/6/2018 12:11:50 PM ******/
|
////****** Object: Database [AdventureWorks] Script Date: 9/6/2018 12:11:50 PM ******/
|
||||||
///CREATE DATABASE [AdventureWorks]
|
///CREATE DATABASE [AdventureWorks]
|
||||||
/// CONTAINMENT = NONE
|
/// CONTAINMENT = NONE
|
||||||
/// ON PRIMARY
|
///GO
|
||||||
///( NAME = N'AdventureWorks_Data', FILENAME = N'D:\sql\14.0.1000.169\sqlservr\data\AdventureWorks_Data.mdf' , SIZE = 174080KB , MAXSIZE = UNLIMITED, FILEGROWTH = 16384KB )
|
///ALTER DATABASE [AdventureWorks] SET COMPATIBILITY_LEVEL = 100
|
||||||
/// LOG ON
|
///GO
|
||||||
///( NAME = N'AdventureWorks_Log', FILENAME = N'D:\sql\14.0.1000.169\sqlservr\data\AdventureWorks_Log.ldf' , SIZE = 18432KB , MAXSIZE = 2048GB , FILEGROWTH = [rest of string was truncated]";.
|
///IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
|
||||||
|
///begin
|
||||||
|
///EXEC [AdventureWorks].[dbo].[sp_fulltext_database] @action = 'enable'
|
||||||
|
///end
|
||||||
|
///GO
|
||||||
|
///ALTER DATABASE [AdventureWorks] SET ANSI_NULL_DEFAULT OFF
|
||||||
|
///GO
|
||||||
|
///ALTER DATABASE [AdventureWorks] SET ANSI_NULLS ON
|
||||||
|
///GO
|
||||||
|
///ALTER DATABASE [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string AdventureWorks {
|
internal static string AdventureWorks {
|
||||||
get {
|
get {
|
||||||
|
|||||||
Reference in New Issue
Block a user