From 9f13448b0eea0bed78d082c513a08b54021c880a Mon Sep 17 00:00:00 2001 From: Abin Abraham Alichan Date: Wed, 14 Apr 2021 12:56:38 -0700 Subject: [PATCH 1/3] migrate to .net standard --- .../Properties/AssemblyInfo.cs | 35 -- .../SampleAuthenticator.csproj | 57 +-- src/TDSProtocol/CallContext.cs | 30 ++ src/TDSProtocol/Properties/AssemblyInfo.cs | 38 -- src/TDSProtocol/TDSProtocol.csproj | 88 +---- src/TDSProtocol/TDSToken.cs | 1 - .../Properties/AssemblyInfo.cs | 35 -- src/TDSProtocolTests/TDSProtocolTests.csproj | 91 +---- .../Properties/AssemblyInfo.cs | 35 -- .../TDSProxy.Authentication.csproj | 55 +-- src/TDSProxy/Program.cs | 39 +- src/TDSProxy/Properties/AssemblyInfo.cs | 33 -- src/TDSProxy/TDSProxy.csproj | 96 +---- src/TDSProxy/TDSProxyService.Designer.cs | 41 --- src/TDSProxy/TDSProxyService.cs | 344 +++++++++--------- src/TestConnection/Properties/AssemblyInfo.cs | 35 -- src/TestConnection/TestConnection.csproj | 50 +-- 17 files changed, 284 insertions(+), 819 deletions(-) delete mode 100644 src/SampleAuthenticator/Properties/AssemblyInfo.cs create mode 100644 src/TDSProtocol/CallContext.cs delete mode 100644 src/TDSProtocol/Properties/AssemblyInfo.cs delete mode 100644 src/TDSProtocolTests/Properties/AssemblyInfo.cs delete mode 100644 src/TDSProxy.Authentication/Properties/AssemblyInfo.cs delete mode 100644 src/TDSProxy/TDSProxyService.Designer.cs delete mode 100644 src/TestConnection/Properties/AssemblyInfo.cs diff --git a/src/SampleAuthenticator/Properties/AssemblyInfo.cs b/src/SampleAuthenticator/Properties/AssemblyInfo.cs deleted file mode 100644 index 665fe94..0000000 --- a/src/SampleAuthenticator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SampleAuthenticator")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Tech Software LLC")] -[assembly: AssemblyProduct("SampleAuthenticator")] -[assembly: AssemblyCopyright("Copyright © 2014-2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1608c147-156a-4eb8-8309-1e3a3dbf228e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SampleAuthenticator/SampleAuthenticator.csproj b/src/SampleAuthenticator/SampleAuthenticator.csproj index c157a7e..40c6b78 100644 --- a/src/SampleAuthenticator/SampleAuthenticator.csproj +++ b/src/SampleAuthenticator/SampleAuthenticator.csproj @@ -1,60 +1,21 @@ - - - + - Debug - AnyCPU {47F41C77-1B67-4CB9-B217-27F1A882A857} - Library - Properties - SampleAuthenticator - SampleAuthenticator - v4.5 - 512 + netstandard2.0 + SampleAuthenticator + Tech Software LLC + SampleAuthenticator + Copyright © 2014-2020 + ..\TDSProxy\bin\$(Configuration)\ - true full - false - ..\TDSProxy\bin\Debug\ - DEBUG;TRACE - prompt - 4 pdbonly - true - ..\TDSProxy\bin\Release\ - TRACE - prompt - 4 - - - - - - - - + + - - - - - - - {87a5b526-ec83-4237-9a08-7aa977da8ef6} - TDSProxy.Authentication - - - - \ No newline at end of file diff --git a/src/TDSProtocol/CallContext.cs b/src/TDSProtocol/CallContext.cs new file mode 100644 index 0000000..33c9e1f --- /dev/null +++ b/src/TDSProtocol/CallContext.cs @@ -0,0 +1,30 @@ +using System.Collections.Concurrent; +using System.Threading; + +namespace TDSProtocol +{ + /// + /// Provides a way to set contextual data that flows with the call and + /// async context of a test or invocation. + /// + internal static class CallContext + { + static ConcurrentDictionary> state = new ConcurrentDictionary>(); + + /// + /// Stores a given object and associates it with the specified name. + /// + /// The name with which to associate the new item in the call context. + /// The object to store in the call context. + public static void LogicalSetData(string name, object data) => + state.GetOrAdd(name, _ => new AsyncLocal()).Value = data; + + /// + /// Retrieves an object with the specified name from the . + /// + /// The name of the item in the call context. + /// The object in the call context associated with the specified name, or if not found. + public static object LogicalGetData(string name) => + state.TryGetValue(name, out AsyncLocal data) ? data.Value : null; + } +} diff --git a/src/TDSProtocol/Properties/AssemblyInfo.cs b/src/TDSProtocol/Properties/AssemblyInfo.cs deleted file mode 100644 index 65def36..0000000 --- a/src/TDSProtocol/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDSProtocol")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TDSProtocol")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2619e04a-0058-45c2-81cc-a05200103595")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: InternalsVisibleTo("TDSProtocolTests")] diff --git a/src/TDSProtocol/TDSProtocol.csproj b/src/TDSProtocol/TDSProtocol.csproj index c9a2a1f..a9ea71e 100644 --- a/src/TDSProtocol/TDSProtocol.csproj +++ b/src/TDSProtocol/TDSProtocol.csproj @@ -1,92 +1,20 @@ - - - + - Debug - AnyCPU {99FCFF04-2F8E-4AC9-8136-C2574D1E0F2F} - Library - Properties - TDSProtocol - TDSProtocol - v4.5 - 512 + netstandard2.0 + TDSProtocol + TDSProtocol + Copyright © 2014 + bin\$(Configuration)\ - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/TDSProtocol/TDSToken.cs b/src/TDSProtocol/TDSToken.cs index 384e20f..0df8376 100644 --- a/src/TDSProtocol/TDSToken.cs +++ b/src/TDSProtocol/TDSToken.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; -using System.Runtime.Remoting.Messaging; using JetBrains.Annotations; namespace TDSProtocol diff --git a/src/TDSProtocolTests/Properties/AssemblyInfo.cs b/src/TDSProtocolTests/Properties/AssemblyInfo.cs deleted file mode 100644 index b338b6c..0000000 --- a/src/TDSProtocolTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDSProtocolTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Tech Software LLC")] -[assembly: AssemblyProduct("TDSProtocolTests")] -[assembly: AssemblyCopyright("Copyright © Tech Software LLC 2014-2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1b1ed7df-e680-44cc-bb7c-fb943ddba745")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/TDSProtocolTests/TDSProtocolTests.csproj b/src/TDSProtocolTests/TDSProtocolTests.csproj index 816b2f9..7eb617a 100644 --- a/src/TDSProtocolTests/TDSProtocolTests.csproj +++ b/src/TDSProtocolTests/TDSProtocolTests.csproj @@ -1,101 +1,38 @@ - - + - Debug - AnyCPU {2ADF0698-4E98-45FA-88EC-413F75BB8FF7} - Library - Properties - TDSProtocolTests - TDSProtocolTests - v4.5 - 512 + net472 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages False UnitTest + TDSProtocolTests + Tech Software LLC + TDSProtocolTests + Copyright © Tech Software LLC 2014-2020 + bin\$(Configuration)\ - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + + + + + ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - - - - - - - - - - - - - - - {99fcff04-2f8e-4ac9-8136-c2574d1e0f2f} - TDSProtocol - - - + - - - - - False - - - False - - - False - - - False - - - - - - - \ No newline at end of file diff --git a/src/TDSProxy.Authentication/Properties/AssemblyInfo.cs b/src/TDSProxy.Authentication/Properties/AssemblyInfo.cs deleted file mode 100644 index bc2db8e..0000000 --- a/src/TDSProxy.Authentication/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDSProxy.Authentication")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Tech Software LLC")] -[assembly: AssemblyProduct("TDSProxy.Authentication")] -[assembly: AssemblyCopyright("Copyright © Tech Software LLC 2014-2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9c524ce3-67c7-4a5f-a71a-47aa9adcbc56")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/TDSProxy.Authentication/TDSProxy.Authentication.csproj b/src/TDSProxy.Authentication/TDSProxy.Authentication.csproj index f30afda..609fb66 100644 --- a/src/TDSProxy.Authentication/TDSProxy.Authentication.csproj +++ b/src/TDSProxy.Authentication/TDSProxy.Authentication.csproj @@ -1,58 +1,17 @@ - - - + - Debug - AnyCPU {87A5B526-EC83-4237-9A08-7AA977DA8EF6} - Library - Properties - TDSProxy.Authentication - TDSProxy.Authentication - v4.5 - 512 + netstandard2.0 + TDSProxy.Authentication + Tech Software LLC + TDSProxy.Authentication + Copyright © Tech Software LLC 2014-2020 + bin\$(Configuration)\ - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/TDSProxy/Program.cs b/src/TDSProxy/Program.cs index 7b49af3..35eda2a 100644 --- a/src/TDSProxy/Program.cs +++ b/src/TDSProxy/Program.cs @@ -1,29 +1,22 @@ using System; -using System.ServiceProcess; +using TDSProxy.Configuration; namespace TDSProxy { - static class Program - { - /// - /// The main entry point for the application. - /// - static void Main(string[] args) - { - Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main(string[] args) + { + Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; - var service = new TDSProxyService(); - if (Environment.UserInteractive) - { - service.Start(args); - Console.Write("Press ESC to end..."); - while (Console.ReadKey(false).Key != ConsoleKey.Escape) {} - service.Stop(); - } - else - { - ServiceBase.Run(new TDSProxyService()); - } - } - } + var service = new TDSProxyService(); + service.Start(args); + Console.Write("Press ESC to end..."); + while (Console.ReadKey(false).Key != ConsoleKey.Escape) { } + service.Stop(); + } + } } diff --git a/src/TDSProxy/Properties/AssemblyInfo.cs b/src/TDSProxy/Properties/AssemblyInfo.cs index b631627..d78ad6d 100644 --- a/src/TDSProxy/Properties/AssemblyInfo.cs +++ b/src/TDSProxy/Properties/AssemblyInfo.cs @@ -1,37 +1,4 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDSProxy")] -[assembly: AssemblyDescription("SQL Server TDS protocol proxy")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Tech Software LLC")] -[assembly: AssemblyProduct("TDSProxy")] -[assembly: AssemblyCopyright("Copyright © Tech Software LLC, 2014-2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("28b760c8-7558-4c28-8bdf-ff78228f1847")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] - [assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net.config", Watch = true)] diff --git a/src/TDSProxy/TDSProxy.csproj b/src/TDSProxy/TDSProxy.csproj index 39f88c9..ca8b394 100644 --- a/src/TDSProxy/TDSProxy.csproj +++ b/src/TDSProxy/TDSProxy.csproj @@ -1,111 +1,53 @@ - - - + - Debug - AnyCPU {0AE9E17C-C69B-44E9-A923-6B9B3D62BD40} Exe - Properties - TDSProxy - TDSProxy - v4.7.2 - 512 - + netcoreapp3.1 + TDSProxy + Tech Software LLC + TDSProxy + SQL Server TDS protocol proxy + Copyright © Tech Software LLC, 2014-2020 + false + 1.0.* + bin\$(Configuration)\ x64 - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 false - false - AnyCPU pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - ..\packages\JetBrains.Annotations.2020.3.0\lib\net20\JetBrains.Annotations.dll - - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - - - - - - - - - - - - - Component - - + + TDSProxyService.cs - - - Designer Designer - - - {99fcff04-2f8e-4ac9-8136-c2574d1e0f2f} - TDSProtocol - - - {87a5b526-ec83-4237-9a08-7aa977da8ef6} - TDSProxy.Authentication - + + - + + + + + TDSProxyService.cs - - - copy /y $(ProjectDir)log4net.config $(TargetPath).log4net.config - - \ No newline at end of file diff --git a/src/TDSProxy/TDSProxyService.Designer.cs b/src/TDSProxy/TDSProxyService.Designer.cs deleted file mode 100644 index 8358cd0..0000000 --- a/src/TDSProxy/TDSProxyService.Designer.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace TDSProxy -{ - sealed partial class TDSProxyService - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - // - // TDSProxyService - // - this.CanPauseAndContinue = true; - this.ServiceName = "TDSProxy"; - - } - - #endregion - } -} diff --git a/src/TDSProxy/TDSProxyService.cs b/src/TDSProxy/TDSProxyService.cs index cb882cb..870be47 100644 --- a/src/TDSProxy/TDSProxyService.cs +++ b/src/TDSProxy/TDSProxyService.cs @@ -7,184 +7,188 @@ namespace TDSProxy { - public sealed partial class TDSProxyService : ServiceBase - { - #region Log4Net - static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - #endregion - - public static bool VerboseLogging { get; private set; } - public static bool VerboseLoggingInWrapper { get; private set; } - public static bool SkipLoginProcessing { get; private set; } - public static bool AllowUnencryptedConnections { get; private set; } - - private readonly HashSet _listeners = new HashSet(); - - private bool _stopRequested; - - private static Configuration.TdsProxySection _configuration; - // ReSharper disable once MemberCanBePrivate.Global - public static Configuration.TdsProxySection Configuration - { - get - { - if (null == _configuration) - try - { - _configuration = (Configuration.TdsProxySection)ConfigurationManager.GetSection("tdsProxy"); - } - catch (Exception e) - { - log.Error("Error reading configuration", e); - throw; - } - return _configuration; - } - } - - public TDSProxyService() - { - InitializeComponent(); - } - - protected override void OnStart(string[] args) => Start(args); - - public void Start(string[] args) - { - log.InfoFormat( - "\r\n-----------------\r\nService Starting on {0} with security protocol {1}.\r\n-----------------\r\n", - AppContext.TargetFrameworkName, - ServicePointManager.SecurityProtocol); - - if (args.Any(a => string.Equals(a, "debug", StringComparison.OrdinalIgnoreCase))) - { - log.Info("Calling Debugger.Break()"); - System.Diagnostics.Debugger.Break(); - } - - VerboseLogging = args.Any(a => string.Equals(a, "verbose", StringComparison.OrdinalIgnoreCase)); - if (VerboseLogging) + public sealed partial class TDSProxyService ////: ServiceBase + { + #region Log4Net + static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + + public static bool VerboseLogging { get; private set; } + public static bool VerboseLoggingInWrapper { get; private set; } + public static bool SkipLoginProcessing { get; private set; } + public static bool AllowUnencryptedConnections { get; private set; } + + private readonly HashSet _listeners = new HashSet(); + + private bool _stopRequested; + + private static Configuration.TdsProxySection _configuration; + // ReSharper disable once MemberCanBePrivate.Global + public static Configuration.TdsProxySection Configuration + { + get + { + if (null == _configuration) + try + { + _configuration = (Configuration.TdsProxySection)ConfigurationManager.GetSection("tdsProxy"); + } + catch (Exception e) + { + log.Error("Error reading configuration", e); + throw; + } + return _configuration; + } + } + + public TDSProxyService() + { + InitializeComponent(); + } + + //protected override void OnStart(string[] args) => Start(args); + + public void Start(string[] args) + { + log.InfoFormat( + "\r\n-----------------\r\nService Starting on {0} with security protocol {1}.\r\n-----------------\r\n", + AppContext.TargetFrameworkName, + ServicePointManager.SecurityProtocol); + + if (args.Any(a => string.Equals(a, "debug", StringComparison.OrdinalIgnoreCase))) + { + log.Info("Calling Debugger.Break()"); + System.Diagnostics.Debugger.Break(); + } + + VerboseLogging = args.Any(a => string.Equals(a, "verbose", StringComparison.OrdinalIgnoreCase)); + if (VerboseLogging) log.Debug("Verbose logging is on."); - // ReSharper disable once StringLiteralTypo - VerboseLoggingInWrapper = args.Any(a => string.Equals(a, "wrapperverbose", StringComparison.OrdinalIgnoreCase)); - if (VerboseLoggingInWrapper) + // ReSharper disable once StringLiteralTypo + VerboseLoggingInWrapper = args.Any(a => string.Equals(a, "wrapperverbose", StringComparison.OrdinalIgnoreCase)); + if (VerboseLoggingInWrapper) log.Debug("Verbose logging is on in TDS/SSL wrapper."); - // ReSharper disable once StringLiteralTypo - TDSProtocol.TDSPacket.DumpPackets = args.Any(a => string.Equals(a, "packetdump", StringComparison.OrdinalIgnoreCase)); - if (TDSProtocol.TDSPacket.DumpPackets) + // ReSharper disable once StringLiteralTypo + TDSProtocol.TDSPacket.DumpPackets = args.Any(a => string.Equals(a, "packetdump", StringComparison.OrdinalIgnoreCase)); + if (TDSProtocol.TDSPacket.DumpPackets) log.Debug("Packet dumping is on."); - // ReSharper disable once StringLiteralTypo - SkipLoginProcessing = args.Any(a => string.Equals(a, "skiplogin", StringComparison.OrdinalIgnoreCase)); - if (SkipLoginProcessing) + // ReSharper disable once StringLiteralTypo + SkipLoginProcessing = args.Any(a => string.Equals(a, "skiplogin", StringComparison.OrdinalIgnoreCase)); + if (SkipLoginProcessing) log.Debug("Skipping login processing."); - // ReSharper disable once StringLiteralTypo - AllowUnencryptedConnections = args.Any(a => string.Equals(a, "allowunencrypted", StringComparison.OrdinalIgnoreCase)); - if (AllowUnencryptedConnections) + // ReSharper disable once StringLiteralTypo + AllowUnencryptedConnections = args.Any(a => string.Equals(a, "allowunencrypted", StringComparison.OrdinalIgnoreCase)); + if (AllowUnencryptedConnections) log.Debug("Allowing unencrypted connections (but encryption must be supported because we will not allow unencrypted login)."); - _stopRequested = false; - - StartListeners(); - - log.Info("TDSProxyService initialization complete."); - } - - protected override void OnStop() => Stop(); - - public new void Stop() - { - log.Info("Stopping TDSProxyService"); - LogStats(); - _stopRequested = true; - StopListeners(); - OnStopping(EventArgs.Empty); - log.Info("\r\n----------------\r\nService stopped.\r\n----------------\r\n"); - } - - public bool StopRequested => _stopRequested; - - protected override void OnPause() - { - StopListeners(); - log.Info("Service paused."); - } - - protected override void OnContinue() - { - log.Info("Resuming service."); - RefreshConfiguration(); - StartListeners(); - } - - protected override void OnCustomCommand(int command) - { - if (_stopRequested) - return; - - switch (command) - { - case 200: - LogStats(); - break; - case 201: - StopListeners(); - RefreshConfiguration(); - StartListeners(); - break; - } - } - - public event EventHandler Stopping; - - private void OnStopping(EventArgs e) => Stopping?.Invoke(this, e); - - private void StartListeners() - { - foreach (Configuration.ListenerElement listenerConfig in Configuration.Listeners) - // ReSharper disable once ObjectCreationAsStatement -- constructed object registers itself - new TDSListener(this, listenerConfig); - } - - private void StopListeners() - { - List listeners; - lock (_listeners) - listeners = new List(_listeners); - - // NOTE: listeners de-register themselves - foreach (var listener in listeners) - listener.Dispose(); - } - - private void RefreshConfiguration() - { - ConfigurationManager.RefreshSection("tdsProxy"); - _configuration = null; - } - - private void LogStats() - { - log.InfoFormat( - "{0} active connections ({1} connections started since last restart, {2} connections collected without being closed first)", - TDSConnection.ActiveConnectionCount, - TDSConnection.TotalConnections, - TDSConnection.UnclosedCollections); - } - - internal void AddListener(TDSListener listener) - { - lock(_listeners) - _listeners.Add(listener); - } - - internal void RemoveListener(TDSListener listener) - { - lock (_listeners) - _listeners.Remove(listener); - } - } + _stopRequested = false; + + StartListeners(); + + log.Info("TDSProxyService initialization complete."); + } + + //protected override void OnStop() => Stop(); + + //new + public void Stop() + { + log.Info("Stopping TDSProxyService"); + LogStats(); + _stopRequested = true; + StopListeners(); + OnStopping(EventArgs.Empty); + log.Info("\r\n----------------\r\nService stopped.\r\n----------------\r\n"); + } + + public bool StopRequested => _stopRequested; + + // override + //protected void OnPause() + //{ + // StopListeners(); + // log.Info("Service paused."); + //} + + // override + //protected void OnContinue() + //{ + // log.Info("Resuming service."); + // RefreshConfiguration(); + // StartListeners(); + //} + + // override + //protected void OnCustomCommand(int command) + //{ + // if (_stopRequested) + // return; + // + // switch (command) + // { + // case 200: + // LogStats(); + // break; + // case 201: + // StopListeners(); + // RefreshConfiguration(); + // StartListeners(); + // break; + // } + //} + + public event EventHandler Stopping; + + private void OnStopping(EventArgs e) => Stopping?.Invoke(this, e); + + private void StartListeners() + { + foreach (Configuration.ListenerElement listenerConfig in Configuration.Listeners) + // ReSharper disable once ObjectCreationAsStatement -- constructed object registers itself + new TDSListener(this, listenerConfig); + } + + private void StopListeners() + { + List listeners; + lock (_listeners) + listeners = new List(_listeners); + + // NOTE: listeners de-register themselves + foreach (var listener in listeners) + listener.Dispose(); + } + + private void RefreshConfiguration() + { + ConfigurationManager.RefreshSection("tdsProxy"); + _configuration = null; + } + + private void LogStats() + { + log.InfoFormat( + "{0} active connections ({1} connections started since last restart, {2} connections collected without being closed first)", + TDSConnection.ActiveConnectionCount, + TDSConnection.TotalConnections, + TDSConnection.UnclosedCollections); + } + + internal void AddListener(TDSListener listener) + { + lock (_listeners) + _listeners.Add(listener); + } + + internal void RemoveListener(TDSListener listener) + { + lock (_listeners) + _listeners.Remove(listener); + } + } } diff --git a/src/TestConnection/Properties/AssemblyInfo.cs b/src/TestConnection/Properties/AssemblyInfo.cs deleted file mode 100644 index 7a4aa3a..0000000 --- a/src/TestConnection/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TestConnection")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Tech Software LLC")] -[assembly: AssemblyProduct("TestConnection")] -[assembly: AssemblyCopyright("Copyright © Tech Software LLC 2014-2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("177d5235-d152-4d56-a0d6-952bfe92ea5d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/TestConnection/TestConnection.csproj b/src/TestConnection/TestConnection.csproj index 352b19b..7fa5418 100644 --- a/src/TestConnection/TestConnection.csproj +++ b/src/TestConnection/TestConnection.csproj @@ -1,59 +1,23 @@ - - - + - Debug - AnyCPU {2B478DDF-E3E5-4C83-B89B-1F1571A72B24} Exe - Properties - TestConnection - TestConnection - v4.5 - 512 + net472 + TestConnection + Tech Software LLC + TestConnection + Copyright © Tech Software LLC 2014-2020 + bin\$(Configuration)\ - AnyCPU - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 false - AnyCPU pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - \ No newline at end of file From ec47125765a5cfbb68db942db30adcc228807945 Mon Sep 17 00:00:00 2001 From: Abin Abraham Alichan Date: Wed, 14 Apr 2021 13:10:45 -0700 Subject: [PATCH 2/3] fix build issues --- src/TDSProtocol/Properties/AssemblyInfo.cs | 5 ++ src/TDSProtocolTests/TDSProtocolTests.csproj | 1 + src/TDSProxy/Program.cs | 1 - src/TDSProxy/TDSProxyService.cs | 51 +------------------- 4 files changed, 7 insertions(+), 51 deletions(-) create mode 100644 src/TDSProtocol/Properties/AssemblyInfo.cs diff --git a/src/TDSProtocol/Properties/AssemblyInfo.cs b/src/TDSProtocol/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2b1a087 --- /dev/null +++ b/src/TDSProtocol/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: InternalsVisibleTo("TDSProtocolTests")] diff --git a/src/TDSProtocolTests/TDSProtocolTests.csproj b/src/TDSProtocolTests/TDSProtocolTests.csproj index 7eb617a..cc99df8 100644 --- a/src/TDSProtocolTests/TDSProtocolTests.csproj +++ b/src/TDSProtocolTests/TDSProtocolTests.csproj @@ -24,6 +24,7 @@ + diff --git a/src/TDSProxy/Program.cs b/src/TDSProxy/Program.cs index 35eda2a..5d23a44 100644 --- a/src/TDSProxy/Program.cs +++ b/src/TDSProxy/Program.cs @@ -1,5 +1,4 @@ using System; -using TDSProxy.Configuration; namespace TDSProxy { diff --git a/src/TDSProxy/TDSProxyService.cs b/src/TDSProxy/TDSProxyService.cs index 870be47..8966111 100644 --- a/src/TDSProxy/TDSProxyService.cs +++ b/src/TDSProxy/TDSProxyService.cs @@ -7,7 +7,7 @@ namespace TDSProxy { - public sealed partial class TDSProxyService ////: ServiceBase + public sealed partial class TDSProxyService { #region Log4Net static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -42,13 +42,6 @@ public static Configuration.TdsProxySection Configuration } } - public TDSProxyService() - { - InitializeComponent(); - } - - //protected override void OnStart(string[] args) => Start(args); - public void Start(string[] args) { log.InfoFormat( @@ -93,8 +86,6 @@ public void Start(string[] args) log.Info("TDSProxyService initialization complete."); } - //protected override void OnStop() => Stop(); - //new public void Stop() { @@ -108,40 +99,6 @@ public void Stop() public bool StopRequested => _stopRequested; - // override - //protected void OnPause() - //{ - // StopListeners(); - // log.Info("Service paused."); - //} - - // override - //protected void OnContinue() - //{ - // log.Info("Resuming service."); - // RefreshConfiguration(); - // StartListeners(); - //} - - // override - //protected void OnCustomCommand(int command) - //{ - // if (_stopRequested) - // return; - // - // switch (command) - // { - // case 200: - // LogStats(); - // break; - // case 201: - // StopListeners(); - // RefreshConfiguration(); - // StartListeners(); - // break; - // } - //} - public event EventHandler Stopping; private void OnStopping(EventArgs e) => Stopping?.Invoke(this, e); @@ -164,12 +121,6 @@ private void StopListeners() listener.Dispose(); } - private void RefreshConfiguration() - { - ConfigurationManager.RefreshSection("tdsProxy"); - _configuration = null; - } - private void LogStats() { log.InfoFormat( From 4847132c800590abb011e5d2d0210721cfbbd1ed Mon Sep 17 00:00:00 2001 From: Abin Abraham Alichan Date: Wed, 14 Apr 2021 13:14:13 -0700 Subject: [PATCH 3/3] fix warning --- src/TDSProxy/TDSProxy.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TDSProxy/TDSProxy.csproj b/src/TDSProxy/TDSProxy.csproj index ca8b394..2ec3798 100644 --- a/src/TDSProxy/TDSProxy.csproj +++ b/src/TDSProxy/TDSProxy.csproj @@ -9,7 +9,7 @@ SQL Server TDS protocol proxy Copyright © Tech Software LLC, 2014-2020 false - 1.0.* + 1.0.0.0 bin\$(Configuration)\