diff --git a/.vscode/launch.json b/.vscode/launch.json index 3d5fc0f5..310e6db0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.SqlTools.ServiceLayer/bin/Debug/net6.0/MicrosoftSqlToolsServiceLayer.dll", + "program": "${workspaceFolder}/src/Microsoft.SqlTools.ServiceLayer/bin/Debug/net7.0/MicrosoftSqlToolsServiceLayer.dll", "args": [], "cwd": "${workspaceFolder}/src/Microsoft.SqlTools.ServiceLayer", // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window @@ -24,7 +24,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.Kusto.ServiceLayer/bin/Debug/net6.0/MicrosoftKustoServiceLayer.dll", + "program": "${workspaceFolder}/src/Microsoft.Kusto.ServiceLayer/bin/Debug/net7.0/MicrosoftKustoServiceLayer.dll", "args": [], "cwd": "${workspaceFolder}/src/Microsoft.Kusto.ServiceLayer", // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window diff --git a/Directory.Build.props b/Directory.Build.props index 7a5a3434..86379272 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ true true - net6.0 + net7.0 $(MSBuildThisFileDirectory) diff --git a/RefreshDllsForTestRun.cmd b/RefreshDllsForTestRun.cmd index 3360ca20..f79896a0 100644 --- a/RefreshDllsForTestRun.cmd +++ b/RefreshDllsForTestRun.cmd @@ -5,8 +5,8 @@ IF [%_BuildConfiguration%] NEQ [] GOTO Start SET _BuildConfiguration=Debug :Start -SET _PerfTestSourceLocation="%WORKINGDIR%\test\Microsoft.SqlTools.ServiceLayer.PerfTests\bin\%_BuildConfiguration%\net6.0\win-x64\publish" -SET _ServiceSourceLocation="%WORKINGDIR%\src\Microsoft.SqlTools.ServiceLayer\bin\%_BuildConfiguration%\net6.0\win-x64\publish" +SET _PerfTestSourceLocation="%WORKINGDIR%\test\Microsoft.SqlTools.ServiceLayer.PerfTests\bin\%_BuildConfiguration%\net7.0\win-x64\publish" +SET _ServiceSourceLocation="%WORKINGDIR%\src\Microsoft.SqlTools.ServiceLayer\bin\%_BuildConfiguration%\net7.0\win-x64\publish" diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index e5cb6d10..d7995657 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -40,8 +40,17 @@ parameters: - 'Microsoft.SqlTools.Migration' steps: +# .NET Core 2.1 SDK is installed for ESRP Code signing task, +# ESRP currently uses DLL from this path: ~\1.9.111\netcoreapp2.1\esrpcli.dll (found in logs) +# Can be removed once ESRP codesigning task gets an upgrade and a newer SDK DLL is used. - task: UseDotNet@2 - displayName: 'Use defined .NET Core sdk' + displayName: 'Use .NET Core 2 sdk' + inputs: + useGlobalJson: false + version: 2.x + +- task: UseDotNet@2 + displayName: 'Use defined .NET sdk' inputs: useGlobalJson: true @@ -245,10 +254,10 @@ steps: - task: ArchiveFiles@1 displayName: 'Archive ${{ platform.displayName }} ${{ project }} build' inputs: - rootFolder: '$(Build.SourcesDirectory)/artifacts/publish/${{ project }}/${{ platform.name }}/net6.0' + rootFolder: '$(Build.SourcesDirectory)/artifacts/publish/${{ project }}/${{ platform.name }}/net7.0' includeRootFolder: false archiveType: ${{ platform.archiveType }} - archiveFile: '$(Build.SourcesDirectory)/artifacts/package/${{ project }}-${{ platform.archiveName }}-net6.0.${{ platform.archiveFileFormat }}' + archiveFile: '$(Build.SourcesDirectory)/artifacts/package/${{ project }}-${{ platform.archiveName }}-net7.0.${{ platform.archiveFileFormat }}' - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: build archives' diff --git a/azure-pipelines/createBuildDirectories.sh b/azure-pipelines/createBuildDirectories.sh index 136683b2..d8156411 100755 --- a/azure-pipelines/createBuildDirectories.sh +++ b/azure-pipelines/createBuildDirectories.sh @@ -13,7 +13,7 @@ # The script need to run from the repo root -net6projectArray=( +dotnetProjectArray=( "./src/Microsoft.Kusto.ServiceLayer" "./src/Microsoft.SqlTools.Credentials" "./src/Microsoft.SqlTools.Hosting" @@ -34,13 +34,8 @@ net6projectArray=( "./test/Microsoft.SqlTools.Test.CompletionExtension" ) -netStandard2ProjectArray=( - "./src/Microsoft.SqlTools.ManagedBatchParser" -) - # Please update the framework vars when updating target framework for the projects -framework6="/bin/Debug/net6.0/" -framework2="/bin/Debug/netstandard2.1/" +framework7="/bin/Debug/net7.0/" requiredLocDirectories=( "cs" @@ -74,24 +69,13 @@ requiredLocDirectories=( "zh-hant" ) -for i in "${net6projectArray[@]}" +for i in "${dotnetProjectArray[@]}" do : for k in "${requiredLocDirectories[@]}" do : - output=`mkdir -v -p $i$framework6$k` + output=`mkdir -v -p $i$framework7$k` echo $output done done - -for i in "${netStandard2ProjectArray[@]}" -do - : - for k in "${requiredLocDirectories[@]}" - do - : - output=`mkdir -v -p $i$framework2$k` - echo $output - done -done \ No newline at end of file diff --git a/build.cake b/build.cake index df56727a..063fe457 100644 --- a/build.cake +++ b/build.cake @@ -470,7 +470,7 @@ void PublishProject(string packageName, string[] projects) var publishArguments = "publish"; if (!runtime.Equals("default")) { - publishArguments = $"{publishArguments} --runtime {runtime}"; + publishArguments = $"{publishArguments} --runtime {runtime} --self-contained"; } publishArguments = $"{publishArguments} --framework {framework} --configuration {configuration}"; publishArguments = $"{publishArguments} --output \"{outputFolder}\" \"{projectFolder}\""; diff --git a/build.json b/build.json index 9d3d094b..c8b3a2ac 100644 --- a/build.json +++ b/build.json @@ -9,24 +9,24 @@ "PackageName": "Microsoft.SqlTools.ServiceLayer", "TestProjects": { "Microsoft.SqlTools.ServiceLayer.UnitTests": [ - "net6.0" + "net7.0" ], "Microsoft.Kusto.ServiceLayer.UnitTests": [ - "net6.0" + "net7.0" ], "Microsoft.SqlTools.ServiceLayer.TestEnvConfig": [ - "net6.0" + "net7.0" ], "Microsoft.SqlTools.ServiceLayer.IntegrationTests": [ - "net6.0" + "net7.0" ] }, "Frameworks": [ - "net6.0" + "net7.0" ], "FxFrameworks":[ "net472", - "net6.0" + "net7.0" ], "MainProjects": [ "Microsoft.SqlTools.Credentials", diff --git a/global.json b/global.json index 3e9daa9c..c0b5ed76 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.403", + "version": "7.0.101", "rollForward": "latestFeature" }, "msbuild-sdks": { diff --git a/packages/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.nuspec b/packages/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.nuspec index cf0ffb15..b518fc89 100644 --- a/packages/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.nuspec +++ b/packages/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.nuspec @@ -18,7 +18,7 @@ - + @@ -42,19 +42,19 @@ - - - - - - - - - - + + + + + + + + + + - - - + + + \ No newline at end of file diff --git a/src/Microsoft.Kusto.ServiceLayer/Localization/sr.cs b/src/Microsoft.Kusto.ServiceLayer/Localization/sr.cs index 4d947f7e..dbf4393f 100644 --- a/src/Microsoft.Kusto.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.Kusto.ServiceLayer/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.Kusto.ServiceLayer/Microsoft.Kusto.ServiceLayer.csproj b/src/Microsoft.Kusto.ServiceLayer/Microsoft.Kusto.ServiceLayer.csproj index 933a7e85..576df58f 100644 --- a/src/Microsoft.Kusto.ServiceLayer/Microsoft.Kusto.ServiceLayer.csproj +++ b/src/Microsoft.Kusto.ServiceLayer/Microsoft.Kusto.ServiceLayer.csproj @@ -14,6 +14,8 @@ true portable $(ToolsServiceTargetRuntimes) + + $(NoWarn);SYSLIB1045;CA1311;CA1854 diff --git a/src/Microsoft.Kusto.ServiceLayer/Program.cs b/src/Microsoft.Kusto.ServiceLayer/Program.cs index 06bb7b90..91cb0749 100644 --- a/src/Microsoft.Kusto.ServiceLayer/Program.cs +++ b/src/Microsoft.Kusto.ServiceLayer/Program.cs @@ -8,6 +8,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.Kusto.ServiceLayer.Utility; using Microsoft.SqlTools.Utility; using System.Diagnostics; +using System.Threading.Tasks; namespace Microsoft.Kusto.ServiceLayer { @@ -21,7 +22,7 @@ namespace Microsoft.Kusto.ServiceLayer /// /// Main entry point into the SQL Tools API Service Layer /// - internal static void Main(string[] args) + internal static async Task Main(string[] args) { try { @@ -54,7 +55,7 @@ namespace Microsoft.Kusto.ServiceLayer ProcessExitTimer.Start(commandOptions.ParentProcessId.Value); } - serviceHost.WaitForExit(); + await serviceHost.WaitForExitAsync(); } catch (Exception e) { diff --git a/src/Microsoft.Kusto.ServiceLayer/QueryExecution/DataStorage/StorageDataReader.cs b/src/Microsoft.Kusto.ServiceLayer/QueryExecution/DataStorage/StorageDataReader.cs index 26a14755..f6c7ac3e 100644 --- a/src/Microsoft.Kusto.ServiceLayer/QueryExecution/DataStorage/StorageDataReader.cs +++ b/src/Microsoft.Kusto.ServiceLayer/QueryExecution/DataStorage/StorageDataReader.cs @@ -73,7 +73,7 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.DataStorage /// public Task ReadAsync(CancellationToken cancellationToken) { - return Task.Run(() => DataReader.Read()); + return Task.Run(DataReader.Read); } /// diff --git a/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Errors.cs b/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Errors.cs index dbe5d81e..ac8ccd70 100644 --- a/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Errors.cs +++ b/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Errors.cs @@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.Credentials // which obtains the raw errno that varies between unixes. The strong typing as an enum is meant to // prevent confusing the two. Casting to or from int is suspect. Use GetLastErrorInfo() if you need to // correlate these to the underlying platform values or obtain the corresponding error message. - // + // SUCCESS = 0, @@ -185,7 +185,7 @@ namespace Microsoft.SqlTools.Credentials // so here in the future if necessary. message = buffer; } - + string returnMsg = Marshal.PtrToStringAnsi(message); return returnMsg; } diff --git a/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Sys.cs b/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Sys.cs index b80764e6..8937653b 100644 --- a/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Sys.cs +++ b/src/Microsoft.SqlTools.Credentials/Credentials/Linux/Interop.Sys.cs @@ -19,7 +19,7 @@ namespace Microsoft.SqlTools.Credentials { [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChMod", SetLastError = true)] internal static extern int ChMod(string path, int mode); - + internal struct Passwd { internal IntPtr Name; // char* diff --git a/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.CoreFoundation.cs b/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.CoreFoundation.cs index 8c71ee46..5da3207f 100644 --- a/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.CoreFoundation.cs +++ b/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.CoreFoundation.cs @@ -43,10 +43,10 @@ namespace Microsoft.SqlTools.Credentials /// For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that [DllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)] private static extern SafeCreateHandle CFStringCreateWithCString( - IntPtr allocator, - string str, + IntPtr allocator, + string str, CFStringBuiltInEncodings encoding); - + /// /// Creates a CFStringRef from a 8-bit String object. Follows the "Create Rule" where if you create it, you delete it. /// @@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.Credentials /// /// You should retain a Core Foundation object when you receive it from elsewhere - /// (that is, you did not create or copy it) and you want it to persist. If you + /// (that is, you did not create or copy it) and you want it to persist. If you /// retain a Core Foundation object you are responsible for releasing it /// /// The CFType object to retain. This value must not be NULL diff --git a/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.Security.cs b/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.Security.cs index 9e54e90a..40b44f46 100644 --- a/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.Security.cs +++ b/src/Microsoft.SqlTools.Credentials/Credentials/OSX/Interop.Security.cs @@ -16,11 +16,11 @@ namespace Microsoft.SqlTools.Credentials { [DllImport(Libraries.SecurityLibrary, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern OSStatus SecKeychainAddGenericPassword(IntPtr keyChainRef, UInt32 serviceNameLength, string serviceName, + internal static extern OSStatus SecKeychainAddGenericPassword(IntPtr keyChainRef, UInt32 serviceNameLength, string serviceName, UInt32 accountNameLength, string accountName, UInt32 passwordLength, IntPtr password, [Out] IntPtr itemRef); - + /// - /// Find a generic password based on the attributes passed + /// Find a generic password based on the attributes passed /// /// /// A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list. @@ -31,22 +31,22 @@ namespace Microsoft.SqlTools.Credentials /// A pointer to a string containing the account name. /// On return, the length of the buffer pointed to by passwordData. /// - /// On return, a pointer to a data buffer containing the password. - /// Your application must call SecKeychainItemFreeContent(NULL, passwordData) + /// On return, a pointer to a data buffer containing the password. + /// Your application must call SecKeychainItemFreeContent(NULL, passwordData) /// to release this data buffer when it is no longer needed.Pass NULL if you are not interested in retrieving the password data at /// this time, but simply want to find the item reference. /// /// On return, a reference to the keychain item which was found. /// A result code that should be in /// - /// The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. - /// Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. + /// The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. + /// Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. /// SecKeychainFindGenericPassword optionally returns a reference to the found item. /// [DllImport(Libraries.SecurityLibrary, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern OSStatus SecKeychainFindGenericPassword(IntPtr keyChainRef, UInt32 serviceNameLength, string serviceName, + internal static extern OSStatus SecKeychainFindGenericPassword(IntPtr keyChainRef, UInt32 serviceNameLength, string serviceName, UInt32 accountNameLength, string accountName, out UInt32 passwordLength, out IntPtr password, out IntPtr itemRef); - + /// /// Releases the memory used by the keychain attribute list and the keychain data retrieved in a previous call to SecKeychainItemCopyContent. /// @@ -55,15 +55,15 @@ namespace Microsoft.SqlTools.Credentials /// A result code that should be in [DllImport(Libraries.SecurityLibrary, SetLastError = true)] internal static extern OSStatus SecKeychainItemFreeContent([In] IntPtr attrList, [In] IntPtr data); - + /// /// Deletes a keychain item from the default keychain's permanent data store. /// /// A keychain item reference of the item to delete. /// A result code that should be in /// - /// If itemRef has not previously been added to the keychain, SecKeychainItemDelete does nothing and returns ErrSecSuccess. - /// IMPORTANT: SecKeychainItemDelete does not dispose the memory occupied by the item reference itself; + /// If itemRef has not previously been added to the keychain, SecKeychainItemDelete does nothing and returns ErrSecSuccess. + /// IMPORTANT: SecKeychainItemDelete does not dispose the memory occupied by the item reference itself; /// use the CFRelease function when you are completely * * finished with an item. /// [DllImport(Libraries.SecurityLibrary, SetLastError = true)] diff --git a/src/Microsoft.SqlTools.Credentials/Credentials/Win32/NativeMethods.cs b/src/Microsoft.SqlTools.Credentials/Credentials/Win32/NativeMethods.cs index 20b0ed2f..07a8e6db 100644 --- a/src/Microsoft.SqlTools.Credentials/Credentials/Win32/NativeMethods.cs +++ b/src/Microsoft.SqlTools.Credentials/Credentials/Win32/NativeMethods.cs @@ -1,6 +1,6 @@ // -// Code originally from http://credentialmanagement.codeplex.com/, -// Licensed under the Apache License 2.0 +// Code originally from http://credentialmanagement.codeplex.com/, +// Licensed under the Apache License 2.0 // using System; @@ -11,7 +11,7 @@ namespace Microsoft.SqlTools.Credentials.Win32 { internal class NativeMethods { - + [StructLayout(LayoutKind.Sequential)] internal struct CREDENTIAL { @@ -32,7 +32,7 @@ namespace Microsoft.SqlTools.Credentials.Win32 [MarshalAs(UnmanagedType.LPWStr)] public string UserName; } - + [DllImport("Advapi32.dll", EntryPoint = "CredReadW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CredRead(string target, CredentialType type, int reservedFlag, out IntPtr CredentialPtr); @@ -47,7 +47,7 @@ namespace Microsoft.SqlTools.Credentials.Win32 [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] internal static extern bool CredEnumerateW(string filter, int flag, out uint count, out IntPtr pCredentials); - + [DllImport("ole32.dll")] internal static extern void CoTaskMemFree(IntPtr ptr); @@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.Credentials.Win32 } // Perform any specific actions to release the handle in the ReleaseHandle method. - // Often, you need to use Pinvoke to make a call into the Win32 API to release the + // Often, you need to use Pinvoke to make a call into the Win32 API to release the // handle. In this case, however, we can use the Marshal class to release the unmanaged memory. protected override bool ReleaseHandle() @@ -101,7 +101,7 @@ namespace Microsoft.SqlTools.Credentials.Win32 SetHandleAsInvalid(); return true; } - // Return false. + // Return false. return false; } } diff --git a/src/Microsoft.SqlTools.Credentials/Localization/sr.cs b/src/Microsoft.SqlTools.Credentials/Localization/sr.cs index bcd5a04a..fbe37677 100755 --- a/src/Microsoft.SqlTools.Credentials/Localization/sr.cs +++ b/src/Microsoft.SqlTools.Credentials/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj b/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj index 397d744f..fd684cfe 100644 --- a/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj +++ b/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj @@ -13,6 +13,8 @@ true true $(ToolsServiceTargetRuntimes) + + $(NoWarn);SYSLIB1054 diff --git a/src/Microsoft.SqlTools.Credentials/Program.cs b/src/Microsoft.SqlTools.Credentials/Program.cs index 9cea8ba9..b270df5c 100644 --- a/src/Microsoft.SqlTools.Credentials/Program.cs +++ b/src/Microsoft.SqlTools.Credentials/Program.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.SqlTools.Credentials.Utility; using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.Utility; @@ -20,7 +21,7 @@ namespace Microsoft.SqlTools.Credentials /// /// Main entry point into the Credentials Service Host /// - internal static void Main(string[] args) + internal static async Task Main(string[] args) { try { @@ -48,7 +49,7 @@ namespace Microsoft.SqlTools.Credentials SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails); UtilityServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext); - serviceHost.WaitForExit(); + await serviceHost.WaitForExitAsync(); } catch (Exception e) { diff --git a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs index 44d913af..a68ae552 100644 --- a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs +++ b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs @@ -112,7 +112,7 @@ namespace Microsoft.SqlTools.Extensibility if (!services.ContainsKey(typeof(T))) { ExtensionStore store = new ExtensionStore(typeof(T), config); - base.Register(() => store.GetExports()); + base.Register(store.GetExports); } } @@ -136,11 +136,11 @@ namespace Microsoft.SqlTools.Extensibility // If the service type is already registered, replace the existing registration with the new one if (this.services.ContainsKey(typeof(T))) { - this.services[typeof(T)] = () => store.GetExports(); + this.services[typeof(T)] = store.GetExports; } else { - base.Register(() => store.GetExports()); + base.Register(store.GetExports); } } diff --git a/src/Microsoft.SqlTools.Hosting/Hosting/Protocol/ProtocolEndpoint.cs b/src/Microsoft.SqlTools.Hosting/Hosting/Protocol/ProtocolEndpoint.cs index e6b65b30..6ea05512 100644 --- a/src/Microsoft.SqlTools.Hosting/Hosting/Protocol/ProtocolEndpoint.cs +++ b/src/Microsoft.SqlTools.Hosting/Hosting/Protocol/ProtocolEndpoint.cs @@ -119,10 +119,10 @@ namespace Microsoft.SqlTools.Hosting.Protocol } } - public void WaitForExit() + public async Task WaitForExitAsync() { this.endpointExitedTask = new TaskCompletionSource(); - this.endpointExitedTask.Task.Wait(); + await this.endpointExitedTask.Task.WaitAsync(CancellationToken.None); } public async Task Stop() diff --git a/src/Microsoft.SqlTools.Hosting/Localization/sr.cs b/src/Microsoft.SqlTools.Hosting/Localization/sr.cs index 5e48d9fb..ef9923d8 100755 --- a/src/Microsoft.SqlTools.Hosting/Localization/sr.cs +++ b/src/Microsoft.SqlTools.Hosting/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.Hosting/Utility/ConcurrentCache.cs b/src/Microsoft.SqlTools.Hosting/Utility/ConcurrentCache.cs index 006b260c..90993acc 100644 --- a/src/Microsoft.SqlTools.Hosting/Utility/ConcurrentCache.cs +++ b/src/Microsoft.SqlTools.Hosting/Utility/ConcurrentCache.cs @@ -23,10 +23,7 @@ namespace Microsoft.SqlTools.Utility { foreach (var key in keys) { - if (_cache.ContainsKey(key)) - { - _cache.Remove(key); - } + _cache.Remove(key); } } }, out exception); diff --git a/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs b/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs index 4f39e6fe..eb14e77a 100644 --- a/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs +++ b/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs @@ -19,6 +19,7 @@ namespace Microsoft.SqlTools.Utility public T GetOptionValue(string name, T defaultValue = default(T)) { + #pragma warning disable CA1854 T result = defaultValue; if (Options != null && Options.ContainsKey(name)) { @@ -34,6 +35,7 @@ namespace Microsoft.SqlTools.Utility "Cannot convert option value {0}:{1} to {2}", name, value ?? "", typeof(T))); } } + #pragma warning restore CA1854 return result; } diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/BatchParserSqlCmd.cs b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/BatchParserSqlCmd.cs index a07633bd..19edaf79 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/BatchParserSqlCmd.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/BatchParserSqlCmd.cs @@ -89,10 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode if (value == null) { - if (internalVariables.ContainsKey(name)) - { - internalVariables.Remove(name); - } + internalVariables.Remove(name); } else { diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/PositionStruct.cs b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/PositionStruct.cs index 25654eea..fda9e3bb 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/PositionStruct.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/PositionStruct.cs @@ -8,7 +8,7 @@ using System; namespace Microsoft.SqlTools.ServiceLayer.BatchParser { [Serializable] - public struct PositionStruct + public readonly struct PositionStruct { private readonly int line; private readonly int column; diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/Localization/sr.cs b/src/Microsoft.SqlTools.ManagedBatchParser/Localization/sr.cs index 6d1940df..00c174cd 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj b/src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj index 5e332dd4..f5496a8b 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj +++ b/src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj @@ -1,7 +1,7 @@  - - net6.0;net472 + + net7.0;net472 9.0 disable Microsoft.SqlTools.ManagedBatchParser @@ -13,6 +13,8 @@ false false Microsoft SqlTools Managed batch parser + + $(NoWarn);CA1852 @@ -25,7 +27,7 @@ - + diff --git a/src/Microsoft.SqlTools.Migration/Localization/sr.cs b/src/Microsoft.SqlTools.Migration/Localization/sr.cs index 8e8986e2..64efe6fe 100644 --- a/src/Microsoft.SqlTools.Migration/Localization/sr.cs +++ b/src/Microsoft.SqlTools.Migration/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.Migration/Program.cs b/src/Microsoft.SqlTools.Migration/Program.cs index 0a23da03..10e1d73c 100644 --- a/src/Microsoft.SqlTools.Migration/Program.cs +++ b/src/Microsoft.SqlTools.Migration/Program.cs @@ -10,6 +10,7 @@ using System.IO; using System.Diagnostics; using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Utility; +using System.Threading.Tasks; namespace Microsoft.SqlTools.Migration { @@ -17,7 +18,7 @@ namespace Microsoft.SqlTools.Migration { private const string ServiceName = "MicrosoftSqlToolsMigration.exe"; - internal static void Main(string[] args) + internal static async Task Main(string[] args) { try { @@ -51,7 +52,7 @@ namespace Microsoft.SqlTools.Migration }); serviceHost.RegisterAndInitializeService(new MigrationService()); - serviceHost.WaitForExit(); + await serviceHost.WaitForExitAsync(); Logger.Verbose("SqlTools Migration Server exiting...."); } catch (Exception ex) diff --git a/src/Microsoft.SqlTools.Migration/Utils/ExtensionMethods.cs b/src/Microsoft.SqlTools.Migration/Utils/ExtensionMethods.cs index 3df1cf3e..c24e46d4 100644 --- a/src/Microsoft.SqlTools.Migration/Utils/ExtensionMethods.cs +++ b/src/Microsoft.SqlTools.Migration/Utils/ExtensionMethods.cs @@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.Migration.Utils foreach (var keyValuePair2 in exceptionMap2) { // If the dictionary already contains the key then merge them - if (exceptionMap1.ContainsKey(keyValuePair2.Key)) + if (exceptionMap1.TryGetValue(keyValuePair2.Key, out _)) { foreach (var value in keyValuePair2.Value) { diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs index c30e3279..46f47e4e 100644 --- a/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs +++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs @@ -69,10 +69,12 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall clientIp = null; try { + #pragma warning disable SYSLIB1045 Regex regex = new Regex( @"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b", RegexOptions.IgnoreCase); + #pragma warning restore SYSLIB1045 Match match = regex.Match(message); if (match.Success) diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs index 5b329b07..24fc4644 100644 --- a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs b/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs index 0198ea45..791c7bc1 100644 --- a/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj b/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj index 82d13939..9eae498b 100644 --- a/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj +++ b/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj @@ -10,6 +10,8 @@ Provides the default for SqlTools applications. � Microsoft Corporation. All rights reserved. + + $(NoWarn);CA1852 diff --git a/src/Microsoft.SqlTools.ResourceProvider/Localization/sr.cs b/src/Microsoft.SqlTools.ResourceProvider/Localization/sr.cs index bdf40374..4f55d4ab 100755 --- a/src/Microsoft.SqlTools.ResourceProvider/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ResourceProvider/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.ResourceProvider/Microsoft.SqlTools.ResourceProvider.csproj b/src/Microsoft.SqlTools.ResourceProvider/Microsoft.SqlTools.ResourceProvider.csproj index 66c1e656..af33038f 100644 --- a/src/Microsoft.SqlTools.ResourceProvider/Microsoft.SqlTools.ResourceProvider.csproj +++ b/src/Microsoft.SqlTools.ResourceProvider/Microsoft.SqlTools.ResourceProvider.csproj @@ -12,6 +12,8 @@ false false $(ToolsServiceTargetRuntimes) + + $(NoWarn);CA1852 TRACE;DEBUG;NETCOREAPP1_0;NETCOREAPP2_0 diff --git a/src/Microsoft.SqlTools.ResourceProvider/Program.cs b/src/Microsoft.SqlTools.ResourceProvider/Program.cs index 9b4332a6..5609bcae 100644 --- a/src/Microsoft.SqlTools.ResourceProvider/Program.cs +++ b/src/Microsoft.SqlTools.ResourceProvider/Program.cs @@ -7,6 +7,7 @@ using System; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.Utility; @@ -22,7 +23,7 @@ namespace Microsoft.SqlTools.ResourceProvider /// /// Main entry point into the Credentials Service Host /// - internal static void Main(string[] args) + internal static async Task Main(string[] args) { try { @@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.ResourceProvider SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails); UtilityServiceHost serviceHost = ResourceProviderHostLoader.CreateAndStartServiceHost(sqlToolsContext); - serviceHost.WaitForExit(); + await serviceHost.WaitForExitAsync(); } catch (Exception e) { diff --git a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GetObjectsFromTSqlModelOperation.cs b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GetObjectsFromTSqlModelOperation.cs index 245c5f36..53643589 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GetObjectsFromTSqlModelOperation.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GetObjectsFromTSqlModelOperation.cs @@ -36,7 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx { try { - var filters = Parameters.ObjectTypes.Select(t => MapType(t)).ToArray(); + var filters = Parameters.ObjectTypes.Select(MapType).ToArray(); var objects = Model.GetObjects(DacQueryScopes.UserDefined, filters).ToList(); return objects.Select(o => new TSqlObjectInfo diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs index 34774e2f..7529c615 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs @@ -81,8 +81,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan Subtext = currentNode.GetDisplayLinesOfText(true), RelativeCost = currentNode.RelativeCost, Properties = GetProperties(currentNode.Properties), - Children = currentNode.Children.Select(x => ConvertShowPlanTreeToExecutionPlanTree(x)).ToList(), - Edges = currentNode.Edges.Select(x => ConvertShowPlanEdgeToExecutionPlanEdge(x)).ToList(), + Children = currentNode.Children.Select(ConvertShowPlanTreeToExecutionPlanTree).ToList(), + Edges = currentNode.Edges.Select(ConvertShowPlanEdgeToExecutionPlanEdge).ToList(), Badges = GenerateNodeOverlay(currentNode), Name = currentNode.DisplayName, ElapsedTimeInMs = currentNode.ElapsedTimeInMs, diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs index aaa04ab0..7b8c3906 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs @@ -599,7 +599,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices { if (currentList != null && token != null && !string.IsNullOrWhiteSpace(token.Text) && - token.Text.All(ch => char.IsLetter(ch)) && + token.Text.All(char.IsLetter) && currentList.All(x => string.Compare(x.Label, token.Text, true) != 0 )) { diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 12258645..c62f3bec 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -1,5 +1,5 @@ // WARNING: -// This file was generated by the Microsoft DataWarehouse String Resource Tool 6.0.0.0 +// This file was generated by the Microsoft DataWarehouse String Resource Tool 7.0.0.0 // from information in sr.strings // DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN // diff --git a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj index a5114f2c..e53fda75 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj +++ b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj @@ -13,6 +13,8 @@ true true $(ToolsServiceTargetRuntimes) + + $(NoWarn);SYSLIB1045;CA1311;CA1854;CS8600;CS8603;CS8625 diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs index 292462b0..e2b008d4 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs @@ -63,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer public ObjectExplorerService() { sessionMap = new ConcurrentDictionary(); - applicableNodeChildFactories = new Lazy>>(() => PopulateFactories()); + applicableNodeChildFactories = new Lazy>>(PopulateFactories); NodePathGenerator.Initialize(); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs index 8933c88f..dc491bcc 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs @@ -118,7 +118,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return; } - IEnumerable queriers = context.ServiceProvider.GetServices(q => IsCompatibleQuerier(q)); + IEnumerable queriers = context.ServiceProvider.GetServices(IsCompatibleQuerier); var filters = this.Filters.ToList(); var smoProperties = this.SmoProperties.Where(p => ServerVersionHelper.IsValidFor(serverValidFor, p.ValidFor)).Select(x => x.Name); if (!string.IsNullOrEmpty(name)) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Program.cs b/src/Microsoft.SqlTools.ServiceLayer/Program.cs index 1148e5c9..f63bd63f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Program.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Program.cs @@ -11,6 +11,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.Utility; using Microsoft.SqlTools.Utility; using System.Diagnostics; +using System.Threading.Tasks; namespace Microsoft.SqlTools.ServiceLayer { @@ -22,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer /// /// Main entry point into the SQL Tools API Service Layer /// - internal static void Main(string[] args) + internal static async Task Main(string[] args) { SqlClientListener? sqlClientListener = null; try @@ -61,7 +62,7 @@ namespace Microsoft.SqlTools.ServiceLayer ProcessExitTimer.Start(commandOptions.ParentProcessId.Value); } - serviceHost.WaitForExit(); + await serviceHost.WaitForExitAsync(); } catch (Exception ex) { diff --git a/src/Microsoft.SqlTools.ServiceLayer/TaskServices/SqlTask.cs b/src/Microsoft.SqlTools.ServiceLayer/TaskServices/SqlTask.cs index 69a4ecee..1975e47b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TaskServices/SqlTask.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TaskServices/SqlTask.cs @@ -231,7 +231,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices //Run Task synchronously public void Run() { - Task.Run(() => RunAsync()); + Task.Run(RunAsync); } /// diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserMockEventHandler.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserMockEventHandler.cs index 08caff80..7e110ee0 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserMockEventHandler.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserMockEventHandler.cs @@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode; namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser { - internal class BatchParserMockEventHandler : IBatchEventsHandler + public class BatchParserMockEventHandler : IBatchEventsHandler { public SqlError Error { get; private set; } diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserTests.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserTests.cs index 1b351554..0ad1053f 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserTests.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/BatchParserTests.cs @@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser p.ThrowOnUnresolvedVariable = true; handler.SetParser(p); - Assert.Throws(() => p.Parse()); + Assert.Throws(p.Parse); } } @@ -77,7 +77,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser { p.ThrowOnUnresolvedVariable = true; handler.SetParser(p); - Assert.Throws(() => p.Parse()); + Assert.Throws(p.Parse); } } @@ -98,7 +98,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser { p.ThrowOnUnresolvedVariable = true; handler.SetParser(p); - Assert.Throws(() => p.Parse()); + Assert.Throws(p.Parse); } } @@ -119,7 +119,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser { p.ThrowOnUnresolvedVariable = true; handler.SetParser(p); - Assert.Throws(() => p.Parse()); + Assert.Throws(p.Parse); } } @@ -142,7 +142,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser handler.SetParser(p); // This test will fail because we are passing invalid number. // Exception will be raised from ParseGo() - Assert.Throws(() => p.Parse()); + Assert.Throws(p.Parse); } } @@ -248,7 +248,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser p.ThrowOnUnresolvedVariable = true; handler.SetParser(p); - var exception = Assert.Throws(() => p.Parse()); + var exception = Assert.Throws(p.Parse); // Verify the message should be "Command Execute is not supported." Assert.AreEqual("Command Execute is not supported.", exception.Message); } diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/TestCommandHandler.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/TestCommandHandler.cs index 946db504..49283834 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/TestCommandHandler.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/BatchParser/TestCommandHandler.cs @@ -13,7 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser; namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser { - internal class TestCommandHandler : ICommandHandler + public class TestCommandHandler : ICommandHandler { private Parser parser; private StringBuilder outputString; diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/BatchEventHandler.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/BatchEventHandler.cs index ba61526a..8ae85b2d 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/BatchEventHandler.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/BatchEventHandler.cs @@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode; namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine { - internal class BatchEventHandler : IBatchEventsHandler + public class BatchEventHandler : IBatchEventsHandler { private List resultCounts = new List(); private List sqlMessages = new List(); diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs index 6c0bd58c..d78b394d 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs @@ -14,7 +14,7 @@ using Microsoft.SqlTools.Utility; namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine { - internal class TestExecutor : IDisposable + public class TestExecutor : IDisposable { #region Private variables diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/FileUtilities.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/FileUtilities.cs index b30a27fd..602352fe 100644 --- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/FileUtilities.cs +++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/FileUtilities.cs @@ -9,7 +9,7 @@ using System.IO; namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility { - internal class FileUtilities + public class FileUtilities { /// /// Turns off the read-only attribute for this file diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj index e0333102..7eb7a671 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj @@ -6,6 +6,8 @@ Microsoft.SqlTools.ServiceLayer.IntegrationTests true $(DefineConstants);TRACE + + $(NoWarn);SYSLIB1045;IDE0200;IDE0230;CA1311;CA1852;CA1854 diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/ComparisonFailureException.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/ComparisonFailureException.cs index 3428b325..b36e4437 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/ComparisonFailureException.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/ComparisonFailureException.cs @@ -9,7 +9,7 @@ using System; namespace Microsoft.SqlTools.ServiceLayer.Test.Common { - internal class ComparisonFailureException : InvalidOperationException + internal sealed class ComparisonFailureException : InvalidOperationException { internal string FullMessageWithDiff { get; private set; } internal string EditAndCopyMessage { get; private set; } diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs index 47077d98..4b73c031 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs @@ -180,14 +180,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking Event } - private class ExpectedEvent + private sealed class ExpectedEvent { public EventTypes EventType { get; set; } public Type ParamType { get; set; } public Delegate Validator { get; set; } } - private class ReceivedEvent + private sealed class ReceivedEvent { public object EventObject { get; set; } public EventTypes EventType { get; set; } diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs index ade21caf..a64a6229 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs @@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver // Include a fallback value to for running tests within visual studio serviceHostExecutable = - @"..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Debug\net6.0\win-x64\MicrosoftSqlToolsServiceLayer.exe"; + @"..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Debug\net7.0\win-x64\MicrosoftSqlToolsServiceLayer.exe"; if (!File.Exists(serviceHostExecutable)) { serviceHostExecutable = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "MicrosoftSqlToolsServiceLayer.exe"); diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs b/test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs index 17afca78..cddf965b 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Program.cs @@ -13,7 +13,7 @@ using System.Collections.Generic; namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig { - class Program + sealed class Program { [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0210:Convert to top-level statements", Justification = "Structure retained for readability.")] static void Main(string[] args) diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj index fa6d2654..0f947ee0 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj @@ -5,7 +5,9 @@ $(DefineConstants);NETCOREAPP1_0;TRACE false - + + + $(NoWarn);SYSLIB1045;IDE0200;IDE0230;CA1311;CA1852;CA1854 diff --git a/test/ScriptGenerator/Program.cs b/test/ScriptGenerator/Program.cs index a506129e..ceb57856 100644 --- a/test/ScriptGenerator/Program.cs +++ b/test/ScriptGenerator/Program.cs @@ -11,21 +11,20 @@ using System.Text.RegularExpressions; namespace ScriptGenerator { - - class Program + public partial class Program { internal const string DefaultFileExtension = "Sql"; - static readonly Regex ExtractDbName = new Regex(@"CREATE\s+DATABASE\s+\[(?\w+)\]", RegexOptions.Compiled | RegexOptions.IgnoreCase); - static readonly Regex CreateTableRegex = new Regex(@"(?CREATE\s+TABLE\s+.*)(?\](?![\.])[\s\S]*?CONSTRAINT\s+\[\w+?)(?\](?![\.]))", RegexOptions.Compiled | RegexOptions.IgnoreCase); - static readonly Regex AlterTableConstraintRegex = new Regex(@"(?ALTER\s+TABLE\s+.*?)(?\](?![\.])\s*\b(?:ADD|WITH|CHECK)\b[\s\S]*?CONSTRAINT\s+\[\w+?)(?\](?![\.]))", RegexOptions.Compiled | RegexOptions.IgnoreCase); - static readonly Regex CreateViewRegex = new Regex(@"(?CREATE\s+VIEW\s+.*?)(?\](?![\.])[\s\S]*?\bAS\b)", RegexOptions.Compiled | RegexOptions.IgnoreCase ); - static readonly Regex CreateProcedureRegex = new Regex(@"(?CREATE\s+PROCEDURE\s+.*?)(?\](?![\.])[\s\S]*?(?:@|WITH|AS))", RegexOptions.Compiled | RegexOptions.IgnoreCase); + static readonly Regex ExtractDbName = CreateDbRegex(); + static readonly Regex CreateTableRegex = CreateTableSyntaxRegex(); + static readonly Regex AlterTableConstraintRegex = AlterTableSyntaxRegex(); + static readonly Regex CreateViewRegex = CreateViewSyntaxRegex(); + static readonly Regex CreateProcedureRegex = CreateProcedureSyntaxRegex(); static void Main(string[] args) { - CommandOptions options = new CommandOptions(args); + var options = new CommandOptions(args); for (int d = 1; d <= options.Databases; d++) { - using (StreamWriter writer = new StreamWriter(Path.ChangeExtension($@"{options.FilePathPrefix}{d}", DefaultFileExtension))) + using (var writer = new StreamWriter(Path.ChangeExtension($@"{options.FilePathPrefix}{d}", DefaultFileExtension))) { string oldDbName = ExtractDbName.Match(Resources.AdventureWorks).Groups["dbName"].Value; string newDbName = $@"{oldDbName}{d}"; @@ -59,5 +58,16 @@ namespace ScriptGenerator } } } + + [GeneratedRegex("CREATE\\s+DATABASE\\s+\\[(?\\w+)\\]", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")] + private static partial Regex CreateDbRegex(); + [GeneratedRegex("(?CREATE\\s+TABLE\\s+.*)(?\\](?![\\.])[\\s\\S]*?CONSTRAINT\\s+\\[\\w+?)(?\\](?![\\.]))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")] + private static partial Regex CreateTableSyntaxRegex(); + [GeneratedRegex("(?ALTER\\s+TABLE\\s+.*?)(?\\](?![\\.])\\s*\\b(?:ADD|WITH|CHECK)\\b[\\s\\S]*?CONSTRAINT\\s+\\[\\w+?)(?\\](?![\\.]))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")] + private static partial Regex AlterTableSyntaxRegex(); + [GeneratedRegex("(?CREATE\\s+VIEW\\s+.*?)(?\\](?![\\.])[\\s\\S]*?\\bAS\\b)", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")] + private static partial Regex CreateViewSyntaxRegex(); + [GeneratedRegex("(?CREATE\\s+PROCEDURE\\s+.*?)(?\\](?![\\.])[\\s\\S]*?(?:@|WITH|AS))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")] + private static partial Regex CreateProcedureSyntaxRegex(); } }