diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88405c2e..ad0258de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies shell: pwsh @@ -35,7 +35,7 @@ jobs: run: ./Build/build.ps1 -Mode "github" -GithubToken "${{ secrets.GITHUB_TOKEN }}" - name: Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: packages path: | diff --git a/.gitignore b/.gitignore index de2aa5c1..bb33e3d1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ bin/ build.out/ launchSettings.json +launchSettings.txt *.sln.DotSettings.user +*.csproj.user todo.txt \ No newline at end of file diff --git a/Build/README.md b/Build/README.md index 3aedcafc..eeea4807 100644 --- a/Build/README.md +++ b/Build/README.md @@ -5,8 +5,8 @@ build.ps1 is designed to run on windows - PowerShell Desktop 5.1 - PowerShell [7.3.0](https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0) for .net 7.0 and 8.0 tests - PowerShell [7.2.1](https://github.com/PowerShell/PowerShell/releases/tag/v7.2.1) for .net 6.0 tests -- Install-Module -Name [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild/5.10.4) -RequiredVersion 5.10.4 -- Install-Module -Name [ThirdPartyLibraries](https://www.powershellgallery.com/packages/ThirdPartyLibraries/3.4.1) -RequiredVersion 3.4.1 +- Install-Module -Name [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild/5.11.0) -RequiredVersion 5.11.0 +- Install-Module -Name [ThirdPartyLibraries](https://www.powershellgallery.com/packages/ThirdPartyLibraries/3.5.1) -RequiredVersion 3.5.1 - .net framework 4.7.2+ sdk - .net 8.0 sdk - docker, switched to linux containers diff --git a/Build/build.ps1 b/Build/build.ps1 index 7ce53c07..39b7471b 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -1,6 +1,6 @@ #Requires -Version "7.0" -#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.10.4" } -#Requires -Modules @{ ModuleName="ThirdPartyLibraries"; ModuleVersion="3.4.1" } +#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.11.0" } +#Requires -Modules @{ ModuleName="ThirdPartyLibraries"; ModuleVersion="3.5.1" } [CmdletBinding()] param ( diff --git a/Build/create-images.ps1 b/Build/create-images.ps1 index 5938045e..67e5750d 100644 --- a/Build/create-images.ps1 +++ b/Build/create-images.ps1 @@ -1,5 +1,5 @@ #Requires -Version "7.0" -#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.10.4" } +#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.11.0" } Set-StrictMode -Version Latest diff --git a/Build/install-dependencies.ps1 b/Build/install-dependencies.ps1 index 6a782c06..79bb5425 100644 --- a/Build/install-dependencies.ps1 +++ b/Build/install-dependencies.ps1 @@ -16,8 +16,8 @@ $ErrorActionPreference = "Stop" . (Join-Path $PSScriptRoot "scripts/Invoke-InstallModule.ps1") if (".net" -in $List) { - Invoke-InstallDotNet -Version "6.0.319" - Invoke-InstallDotNet -Version "7.0.100" + Invoke-InstallDotNet -Version "6.0.419" + Invoke-InstallDotNet -Version "7.0.406" $version = (Get-Content -Raw (Join-Path $PSScriptRoot "../Sources/global.json") | ConvertFrom-Json).sdk.version Invoke-InstallDotNet -Version $version diff --git a/Build/show-powershell-images.ps1 b/Build/show-powershell-images.ps1 index c475a5ed..7d9f580c 100644 --- a/Build/show-powershell-images.ps1 +++ b/Build/show-powershell-images.ps1 @@ -1,4 +1,4 @@ -$ErrorActionPreference = "Stop" +$ErrorActionPreference = 'Stop' function Get-ShortVersion { [CmdletBinding()] @@ -9,23 +9,27 @@ function Get-ShortVersion { ) process { - $parts = $FullVersion -split "-" - $result = $parts[0] + # preview-7.5-ubuntu-20.04 + # 7.4-ubuntu-22.04 + # 7.3.0-preview.1-ubuntu-20.04 + $parts = $FullVersion -split '-' + $version = $parts[0] + $tag = $parts[1] - if ($parts[1] -like "preview*") { - $result += "-" + $parts[1] + if ($version -like 'preview*') { + $version = $parts[1] + $tag = $parts[0] } - return $result + if ($tag -like 'preview*') { + $version += '-' + $tag + } + + return $version } } -(Invoke-RestMethod -Uri "https://mcr.microsoft.com/v2/powershell/tags/list").tags ` - | Where-Object {$_ -Like "[0-9]*"} ` - | Get-ShortVersion ` - | Sort-Object -Unique - -# (Invoke-RestMethod -Uri "https://mcr.microsoft.com/v2/powershell/tags/list").tags ` -# | Where-Object {$_ -Like "7.2.0*"} ` -# | Where-Object {($_ -Like "*ubuntu*") -or ($_ -Like "*alpine*")} ` -# | Sort-Object +(Invoke-RestMethod -Uri 'https://mcr.microsoft.com/v2/powershell/tags/list').tags ` +| Where-Object { ($_ -Like '[0-9]*') -or ($_ -Like 'preview-[0-9]*') } ` +| Get-ShortVersion ` +| Sort-Object -Unique \ No newline at end of file diff --git a/Build/tasks/build-tasks.ps1 b/Build/tasks/build-tasks.ps1 index f311e9ee..8b1e6c26 100644 --- a/Build/tasks/build-tasks.ps1 +++ b/Build/tasks/build-tasks.ps1 @@ -70,7 +70,7 @@ task PackGlobalTool { } task PackPoweShellModule { - $source = Join-Path $settings.bin "SqlDatabase.PowerShell\netstandard2.0\" + $source = Join-Path $settings.bin "SqlDatabase.PowerShell" $dest = $settings.artifactsPowerShell Copy-Item -Path $source -Destination $dest -Recurse @@ -204,14 +204,14 @@ task PsCoreTest { , "mcr.microsoft.com/powershell:7.2.0-ubuntu-20.04" , "mcr.microsoft.com/powershell:7.2.1-ubuntu-20.04" , "mcr.microsoft.com/powershell:7.2.2-ubuntu-20.04" - , "mcr.microsoft.com/powershell:7.3-ubuntu-20.04") - - foreach ($image in $images) { - exec { docker pull $image } - } + , "mcr.microsoft.com/powershell:7.3-ubuntu-20.04" + , "mcr.microsoft.com/powershell:7.4-ubuntu-20.04" + , "mcr.microsoft.com/powershell:preview-7.5-ubuntu-20.04") $builds = @() foreach ($image in $images) { + exec { docker pull -q $image } + foreach ($database in $databases) { $builds += @{ File = "build-tasks.it-ps-core.ps1" diff --git a/Build/tasks/create-images-tasks.ps1 b/Build/tasks/create-images-tasks.ps1 index bc718538..b6a91a5e 100644 --- a/Build/tasks/create-images-tasks.ps1 +++ b/Build/tasks/create-images-tasks.ps1 @@ -17,6 +17,7 @@ task BuildMsSqlDatabase { $dockerfile = Join-Path $context "image-mssql-2017.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/mssql:2017 ` $context @@ -27,6 +28,7 @@ task BuildPgSqlDatabase { $dockerfile = Join-Path $context "image-postgres-133.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/postgres:13.3 ` $context @@ -37,6 +39,7 @@ task BuildMySqlDatabase { $dockerfile = Join-Path $context "image-mysql-8025.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/mysql:8.0.25 ` $context @@ -47,6 +50,7 @@ task BuildDotnetSdk60 { $dockerfile = Join-Path $context "image-dotnet-sdk-6.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:6.0-sdk ` . @@ -57,6 +61,7 @@ task BuildDotnetRuntime60 { $dockerfile = Join-Path $context "image-dotnet-runtime-6.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:6.0-runtime ` . @@ -67,6 +72,7 @@ task BuildDotnetSdk70 { $dockerfile = Join-Path $context "image-dotnet-sdk-7.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:7.0-sdk ` . @@ -77,6 +83,7 @@ task BuildDotnetRuntime70 { $dockerfile = Join-Path $context "image-dotnet-runtime-7.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:7.0-runtime ` . @@ -87,6 +94,7 @@ task BuildDotnetSdk80 { $dockerfile = Join-Path $context "image-dotnet-sdk-8.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:8.0-sdk ` . @@ -97,6 +105,7 @@ task BuildDotnetRuntime80 { $dockerfile = Join-Path $context "image-dotnet-runtime-8.0.dockerfile" exec { docker build ` + --pull ` -f $dockerfile ` -t sqldatabase/dotnet_pwsh:8.0-runtime ` . diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/index.json b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/index.json similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/index.json rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/index.json diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/package.nuspec b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/package.nuspec similarity index 90% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/package.nuspec index 75ea09ac..7e3a1c4a 100644 --- a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/package.nuspec @@ -2,7 +2,7 @@ Dapper.StrongName - 2.1.15 + 2.1.35 Dapper (Strong Named) Sam Saffron,Marc Gravell,Nick Craver Sam Saffron,Marc Gravell,Nick Craver @@ -14,10 +14,11 @@ https://dapperlib.github.io/Dapper/ 2019 Stack Exchange, Inc. orm sql micro-orm - + + diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/project-License.txt b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/project-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/project-License.txt rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/project-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/readme.md b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/readme.md similarity index 88% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/readme.md rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/readme.md index ea8883fd..53ad0b14 100644 --- a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/readme.md @@ -1,4 +1,4 @@ -Dapper.StrongName [2.1.15](https://www.nuget.org/packages/Dapper.StrongName/2.1.15) +Dapper.StrongName [2.1.35](https://www.nuget.org/packages/Dapper.StrongName/2.1.35) -------------------- Used by: SqlDatabase internal diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/remarks.md b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/remarks.md rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/repository-License.txt b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/repository-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/repository-License.txt rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/repository-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.15/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.1.35/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package-LICENSE_NET.txt deleted file mode 100644 index 5b03e9dc..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package-LICENSE_NET.txt +++ /dev/null @@ -1,65 +0,0 @@ -MICROSOFT SOFTWARE LICENSE TERMS - -MICROSOFT .NET LIBRARY - -These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the software named above. The terms also apply to any Microsoft services or updates for the software, except to the extent those have different terms. - -IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. - -1. INSTALLATION AND USE RIGHTS. -You may install and use any number of copies of the software to develop and test your applications. - -2. THIRD PARTY COMPONENTS. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. -3. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. -a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in applications you develop if you comply with the terms below. -i. Right to Use and Distribute. -· You may copy and distribute the object code form of the software. - -· Third Party Distribution. You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications. - -ii. Distribution Requirements. For any Distributable Code you distribute, you must -· use the Distributable Code in your applications and not as a standalone distribution; - -· require distributors and external end users to agree to terms that protect it at least as much as this agreement; and - -· indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified Distributable Code. - -iii. Distribution Restrictions. You may not -· use Microsoft’s trademarks in your applications’ names or in a way that suggests your applications come from or are endorsed by Microsoft; or - -· modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An “Excluded License” is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it. - -4. DATA. -a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the software documentation. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and its use from the software documentation and our privacy statement. Your use of the software operates as your consent to these practices. -b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://docs.microsoft.com/en-us/legal/gdpr. -5. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not -· work around any technical limitations in the software; - -· reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; - -· remove, minimize, block or modify any notices of Microsoft or its suppliers in the software; - -· use the software in any way that is against the law; or - -· share, publish, rent or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. - -6. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit www.microsoft.com/exporting. -7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it. -8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. -9. APPLICABLE LAW. If you acquired the software in the United States, Washington law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the software in any other country, its laws apply. -10. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: -a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. -b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. -c) Germany and Austria. -(i) Warranty. The software will perform substantially as described in any Microsoft materials that accompany it. However, Microsoft gives no contractual guarantee in relation to the software. - -(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as in case of death or personal or physical injury, Microsoft is liable according to the statutory law. - -Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence -11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. - -It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state or country may not allow the exclusion or limitation of incidental, consequential or other damages. - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/index.json similarity index 76% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/index.json index d4d492c6..75b2ff21 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/index.json @@ -1,7 +1,7 @@ { "Source": "https://api.nuget.org/v3/index.json", "License": { - "Code": "ms-net-library", + "Code": "MIT", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -19,9 +19,9 @@ "Licenses": [ { "Subject": "package", - "Code": "ms-net-library", - "HRef": "LICENSE_NET.txt", - "Description": "The license file is identical to the file from version 17.4.0." + "Code": "MIT", + "HRef": "LICENSE_MIT.txt", + "Description": "The license file is identical to the repository license file." }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package-LICENSE_MIT.txt similarity index 86% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package-LICENSE_MIT.txt index b2f52a2b..62336476 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package-LICENSE_MIT.txt @@ -1,6 +1,8 @@ -Copyright (c) Microsoft Corporation. +The MIT License (MIT) -MIT License +Copyright (c) Microsoft Corporation + +All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -12,10 +14,11 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package.nuspec similarity index 88% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package.nuspec index 1a5d6895..8cd96d08 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package.nuspec @@ -2,10 +2,10 @@ Microsoft.CodeCoverage - 17.7.2 + 17.9.0 Microsoft true - LICENSE_NET.txt + LICENSE_MIT.txt https://aka.ms/deprecateLicenseUrl Icon.png https://github.com/microsoft/vstest @@ -13,7 +13,7 @@ © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing codecoverage code-coverage true - + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/readme.md similarity index 64% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/readme.md index 615d9061..279b3850 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/readme.md @@ -1,13 +1,13 @@ -Microsoft.CodeCoverage [17.7.2](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.7.2) +Microsoft.CodeCoverage [17.9.0](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.9.0) -------------------- Used by: SqlDatabase internal Target frameworks: net472, net6.0, net7.0, net8.0 -License: [ms-net-library](../../../../licenses/ms-net-library) +License: [MIT](../../../../licenses/mit) -- package license: [ms-net-library]() , The license file is identical to the file from version 17.4.0. +- package license: [MIT]() , The license file is identical to the repository license file. - repository license: [MIT](https://github.com/microsoft/vstest) - project license: [MIT](https://github.com/microsoft/vstest) diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package-LICENSE_NET.txt deleted file mode 100644 index 5b03e9dc..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package-LICENSE_NET.txt +++ /dev/null @@ -1,65 +0,0 @@ -MICROSOFT SOFTWARE LICENSE TERMS - -MICROSOFT .NET LIBRARY - -These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the software named above. The terms also apply to any Microsoft services or updates for the software, except to the extent those have different terms. - -IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. - -1. INSTALLATION AND USE RIGHTS. -You may install and use any number of copies of the software to develop and test your applications. - -2. THIRD PARTY COMPONENTS. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. -3. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. -a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in applications you develop if you comply with the terms below. -i. Right to Use and Distribute. -· You may copy and distribute the object code form of the software. - -· Third Party Distribution. You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications. - -ii. Distribution Requirements. For any Distributable Code you distribute, you must -· use the Distributable Code in your applications and not as a standalone distribution; - -· require distributors and external end users to agree to terms that protect it at least as much as this agreement; and - -· indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified Distributable Code. - -iii. Distribution Restrictions. You may not -· use Microsoft’s trademarks in your applications’ names or in a way that suggests your applications come from or are endorsed by Microsoft; or - -· modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An “Excluded License” is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it. - -4. DATA. -a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the software documentation. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and its use from the software documentation and our privacy statement. Your use of the software operates as your consent to these practices. -b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://docs.microsoft.com/en-us/legal/gdpr. -5. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not -· work around any technical limitations in the software; - -· reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; - -· remove, minimize, block or modify any notices of Microsoft or its suppliers in the software; - -· use the software in any way that is against the law; or - -· share, publish, rent or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. - -6. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit www.microsoft.com/exporting. -7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it. -8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. -9. APPLICABLE LAW. If you acquired the software in the United States, Washington law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the software in any other country, its laws apply. -10. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: -a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. -b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. -c) Germany and Austria. -(i) Warranty. The software will perform substantially as described in any Microsoft materials that accompany it. However, Microsoft gives no contractual guarantee in relation to the software. - -(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as in case of death or personal or physical injury, Microsoft is liable according to the statutory law. - -Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence -11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. - -It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state or country may not allow the exclusion or limitation of incidental, consequential or other damages. - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/index.json similarity index 76% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/index.json index 3f13abfb..53361955 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/index.json @@ -1,7 +1,7 @@ { "Source": "https://api.nuget.org/v3/index.json", "License": { - "Code": "ms-net-library", + "Code": "MIT", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -17,11 +17,11 @@ "Dependencies": [ { "Name": "Microsoft.CodeCoverage", - "Version": "17.7.2" + "Version": "17.9.0" }, { "Name": "Microsoft.TestPlatform.TestHost", - "Version": "17.7.2" + "Version": "17.9.0" } ] } @@ -29,9 +29,9 @@ "Licenses": [ { "Subject": "package", - "Code": "ms-net-library", - "HRef": "LICENSE_NET.txt", - "Description": "The license file is identical to the file from version 17.4.0." + "Code": "MIT", + "HRef": "LICENSE_MIT.txt", + "Description": "The license file is identical to the repository license file." }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package-LICENSE_MIT.txt similarity index 86% rename from Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/project-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package-LICENSE_MIT.txt index b2f52a2b..62336476 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/project-LICENSE.txt +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package-LICENSE_MIT.txt @@ -1,6 +1,8 @@ -Copyright (c) Microsoft Corporation. +The MIT License (MIT) -MIT License +Copyright (c) Microsoft Corporation + +All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -12,10 +14,11 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package.nuspec similarity index 78% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package.nuspec index b3e84fcf..dd9a11bf 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package.nuspec @@ -2,10 +2,10 @@ Microsoft.NET.Test.Sdk - 17.7.2 + 17.9.0 Microsoft true - LICENSE_NET.txt + LICENSE_MIT.txt https://aka.ms/deprecateLicenseUrl Icon.png https://github.com/microsoft/vstest @@ -13,14 +13,14 @@ © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing true - + - - + + - + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/readme.md similarity index 63% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/readme.md index 51309baf..8021840e 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/readme.md @@ -1,13 +1,13 @@ -Microsoft.NET.Test.Sdk [17.7.2](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.7.2) +Microsoft.NET.Test.Sdk [17.9.0](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.9.0) -------------------- Used by: SqlDatabase internal Target frameworks: net472, net6.0, net7.0, net8.0 -License: [ms-net-library](../../../../licenses/ms-net-library) +License: [MIT](../../../../licenses/mit) -- package license: [ms-net-library]() , The license file is identical to the file from version 17.4.0. +- package license: [MIT]() , The license file is identical to the repository license file. - repository license: [MIT](https://github.com/microsoft/vstest) - project license: [MIT](https://github.com/microsoft/vstest) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[Microsoft.CodeCoverage](../../../../packages/nuget.org/microsoft.codecoverage/17.7.2)|17.7.2| -|[Microsoft.TestPlatform.TestHost](../../../../packages/nuget.org/microsoft.testplatform.testhost/17.7.2)|17.7.2| +|[Microsoft.CodeCoverage](../../../../packages/nuget.org/microsoft.codecoverage/17.9.0)|17.9.0| +|[Microsoft.TestPlatform.TestHost](../../../../packages/nuget.org/microsoft.testplatform.testhost/17.9.0)|17.9.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package-LICENSE_NET.txt deleted file mode 100644 index 5b03e9dc..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package-LICENSE_NET.txt +++ /dev/null @@ -1,65 +0,0 @@ -MICROSOFT SOFTWARE LICENSE TERMS - -MICROSOFT .NET LIBRARY - -These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the software named above. The terms also apply to any Microsoft services or updates for the software, except to the extent those have different terms. - -IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. - -1. INSTALLATION AND USE RIGHTS. -You may install and use any number of copies of the software to develop and test your applications. - -2. THIRD PARTY COMPONENTS. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. -3. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. -a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in applications you develop if you comply with the terms below. -i. Right to Use and Distribute. -· You may copy and distribute the object code form of the software. - -· Third Party Distribution. You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications. - -ii. Distribution Requirements. For any Distributable Code you distribute, you must -· use the Distributable Code in your applications and not as a standalone distribution; - -· require distributors and external end users to agree to terms that protect it at least as much as this agreement; and - -· indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified Distributable Code. - -iii. Distribution Restrictions. You may not -· use Microsoft’s trademarks in your applications’ names or in a way that suggests your applications come from or are endorsed by Microsoft; or - -· modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An “Excluded License” is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it. - -4. DATA. -a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the software documentation. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and its use from the software documentation and our privacy statement. Your use of the software operates as your consent to these practices. -b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://docs.microsoft.com/en-us/legal/gdpr. -5. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not -· work around any technical limitations in the software; - -· reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; - -· remove, minimize, block or modify any notices of Microsoft or its suppliers in the software; - -· use the software in any way that is against the law; or - -· share, publish, rent or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. - -6. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit www.microsoft.com/exporting. -7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it. -8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. -9. APPLICABLE LAW. If you acquired the software in the United States, Washington law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the software in any other country, its laws apply. -10. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: -a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. -b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. -c) Germany and Austria. -(i) Warranty. The software will perform substantially as described in any Microsoft materials that accompany it. However, Microsoft gives no contractual guarantee in relation to the software. - -(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as in case of death or personal or physical injury, Microsoft is liable according to the statutory law. - -Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence -11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. - -It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state or country may not allow the exclusion or limitation of incidental, consequential or other damages. - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/index.json similarity index 73% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/index.json index f4be26eb..15e1245e 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/index.json @@ -1,7 +1,7 @@ { "Source": "https://api.nuget.org/v3/index.json", "License": { - "Code": "ms-net-library", + "Code": "MIT", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -15,10 +15,6 @@ "net8.0" ], "Dependencies": [ - { - "Name": "NuGet.Frameworks", - "Version": "6.5.0" - }, { "Name": "System.Reflection.Metadata", "Version": "1.6.0" @@ -29,9 +25,9 @@ "Licenses": [ { "Subject": "package", - "Code": "ms-net-library", - "HRef": "LICENSE_NET.txt", - "Description": "The license file is identical to the file from version 17.4.0." + "Code": "MIT", + "HRef": "LICENSE_MIT.txt", + "Description": "The license file is identical to the repository license file." }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package-LICENSE_MIT.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package-LICENSE_MIT.txt new file mode 100644 index 00000000..62336476 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package-LICENSE_MIT.txt @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package.nuspec similarity index 86% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package.nuspec index 3445be41..d4e46da9 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package.nuspec @@ -2,10 +2,10 @@ Microsoft.TestPlatform.ObjectModel - 17.7.2 + 17.9.0 Microsoft true - LICENSE_NET.txt + LICENSE_MIT.txt https://aka.ms/deprecateLicenseUrl Icon.png https://github.com/microsoft/vstest @@ -13,19 +13,16 @@ © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing true - + - - - diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/readme.md similarity index 57% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/readme.md index 3e833b6e..461a7581 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/readme.md @@ -1,13 +1,13 @@ -Microsoft.TestPlatform.ObjectModel [17.7.2](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.7.2) +Microsoft.TestPlatform.ObjectModel [17.9.0](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.9.0) -------------------- Used by: SqlDatabase internal Target frameworks: net472, net6.0, net7.0, net8.0 -License: [ms-net-library](../../../../licenses/ms-net-library) +License: [MIT](../../../../licenses/mit) -- package license: [ms-net-library]() , The license file is identical to the file from version 17.4.0. +- package license: [MIT]() , The license file is identical to the repository license file. - repository license: [MIT](https://github.com/microsoft/vstest) - project license: [MIT](https://github.com/microsoft/vstest) @@ -20,12 +20,11 @@ Remarks no remarks -Dependencies 2 +Dependencies 1 ----------- |Name|Version| |----------|:----| -|[NuGet.Frameworks](../../../../packages/nuget.org/nuget.frameworks/6.5.0)|6.5.0| |[System.Reflection.Metadata](../../../../packages/nuget.org/system.reflection.metadata/1.6.0)|1.6.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package-LICENSE_NET.txt deleted file mode 100644 index 5b03e9dc..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package-LICENSE_NET.txt +++ /dev/null @@ -1,65 +0,0 @@ -MICROSOFT SOFTWARE LICENSE TERMS - -MICROSOFT .NET LIBRARY - -These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the software named above. The terms also apply to any Microsoft services or updates for the software, except to the extent those have different terms. - -IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. - -1. INSTALLATION AND USE RIGHTS. -You may install and use any number of copies of the software to develop and test your applications. - -2. THIRD PARTY COMPONENTS. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. -3. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. -a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in applications you develop if you comply with the terms below. -i. Right to Use and Distribute. -· You may copy and distribute the object code form of the software. - -· Third Party Distribution. You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications. - -ii. Distribution Requirements. For any Distributable Code you distribute, you must -· use the Distributable Code in your applications and not as a standalone distribution; - -· require distributors and external end users to agree to terms that protect it at least as much as this agreement; and - -· indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified Distributable Code. - -iii. Distribution Restrictions. You may not -· use Microsoft’s trademarks in your applications’ names or in a way that suggests your applications come from or are endorsed by Microsoft; or - -· modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An “Excluded License” is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it. - -4. DATA. -a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the software documentation. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and its use from the software documentation and our privacy statement. Your use of the software operates as your consent to these practices. -b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://docs.microsoft.com/en-us/legal/gdpr. -5. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not -· work around any technical limitations in the software; - -· reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; - -· remove, minimize, block or modify any notices of Microsoft or its suppliers in the software; - -· use the software in any way that is against the law; or - -· share, publish, rent or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. - -6. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit www.microsoft.com/exporting. -7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it. -8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. -9. APPLICABLE LAW. If you acquired the software in the United States, Washington law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the software in any other country, its laws apply. -10. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: -a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. -b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. -c) Germany and Austria. -(i) Warranty. The software will perform substantially as described in any Microsoft materials that accompany it. However, Microsoft gives no contractual guarantee in relation to the software. - -(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as in case of death or personal or physical injury, Microsoft is liable according to the statutory law. - -Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence -11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. - -It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state or country may not allow the exclusion or limitation of incidental, consequential or other damages. - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/index.json similarity index 79% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/index.json index 63502005..19667cfc 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/index.json @@ -1,7 +1,7 @@ { "Source": "https://api.nuget.org/v3/index.json", "License": { - "Code": "ms-net-library", + "Code": "MIT", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -17,7 +17,7 @@ "Dependencies": [ { "Name": "Microsoft.TestPlatform.ObjectModel", - "Version": "17.7.2" + "Version": "17.9.0" }, { "Name": "Newtonsoft.Json", @@ -29,9 +29,9 @@ "Licenses": [ { "Subject": "package", - "Code": "ms-net-library", - "HRef": "LICENSE_NET.txt", - "Description": "The license file is identical to the file from version 17.4.0." + "Code": "MIT", + "HRef": "LICENSE_MIT.txt", + "Description": "The license file is identical to the repository license file." }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package-LICENSE_MIT.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package-LICENSE_MIT.txt new file mode 100644 index 00000000..62336476 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package-LICENSE_MIT.txt @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package.nuspec similarity index 87% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package.nuspec index da29550b..aaf49531 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package.nuspec @@ -2,10 +2,10 @@ Microsoft.TestPlatform.TestHost - 17.7.2 + 17.9.0 Microsoft true - LICENSE_NET.txt + LICENSE_MIT.txt https://aka.ms/deprecateLicenseUrl Icon.png https://github.com/microsoft/vstest @@ -13,10 +13,10 @@ © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing true - + - + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/readme.md similarity index 64% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/readme.md index fbb4fa11..91ffcadf 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/readme.md @@ -1,13 +1,13 @@ -Microsoft.TestPlatform.TestHost [17.7.2](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.7.2) +Microsoft.TestPlatform.TestHost [17.9.0](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.9.0) -------------------- Used by: SqlDatabase internal Target frameworks: net472, net6.0, net7.0, net8.0 -License: [ms-net-library](../../../../licenses/ms-net-library) +License: [MIT](../../../../licenses/mit) -- package license: [ms-net-library]() , The license file is identical to the file from version 17.4.0. +- package license: [MIT]() , The license file is identical to the repository license file. - repository license: [MIT](https://github.com/microsoft/vstest) - project license: [MIT](https://github.com/microsoft/vstest) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[Microsoft.TestPlatform.ObjectModel](../../../../packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2)|17.7.2| +|[Microsoft.TestPlatform.ObjectModel](../../../../packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0)|17.9.0| |[Newtonsoft.Json](../../../../packages/nuget.org/newtonsoft.json/13.0.1)|13.0.1| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json deleted file mode 100644 index 24450662..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "Source": "https://api.nuget.org/v3/index.json", - "License": { - "Code": "MIT", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": false, - "TargetFrameworks": [ - "net472", - "net6.0", - "net7.0", - "net8.0", - "netstandard2.0" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "MIT", - "HRef": "https://licenses.nuget.org/MIT" - }, - { - "Subject": "project", - "Code": "MIT", - "HRef": "https://github.com/PowerShell/PowerShell" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/package.nuspec deleted file mode 100644 index 74d0a9f8..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/package.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - Microsoft.WSMan.Runtime - 7.2.0 - Microsoft - Microsoft,PowerShell - false - MIT - https://licenses.nuget.org/MIT - Powershell_black_64.png - https://github.com/PowerShell/PowerShell - Runtime for hosting PowerShell - © Microsoft Corporation. All rights reserved. - en-US - PowerShell - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md deleted file mode 100644 index 17289c6e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md +++ /dev/null @@ -1,26 +0,0 @@ -Microsoft.WSMan.Runtime [7.2.0](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.2.0) --------------------- - -Used by: SqlDatabase - -Target frameworks: net472, net6.0, net7.0, net8.0, netstandard2.0 - -License: [MIT](../../../../licenses/mit) - -- package license: [MIT](https://licenses.nuget.org/MIT) -- project license: [MIT](https://github.com/PowerShell/PowerShell) - -Description ------------ -Runtime for hosting PowerShell - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json deleted file mode 100644 index 24450662..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "Source": "https://api.nuget.org/v3/index.json", - "License": { - "Code": "MIT", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": false, - "TargetFrameworks": [ - "net472", - "net6.0", - "net7.0", - "net8.0", - "netstandard2.0" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "MIT", - "HRef": "https://licenses.nuget.org/MIT" - }, - { - "Subject": "project", - "Code": "MIT", - "HRef": "https://github.com/PowerShell/PowerShell" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec deleted file mode 100644 index a9602f65..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - Microsoft.WSMan.Runtime - 7.3.0 - Microsoft - Microsoft,PowerShell - false - MIT - https://licenses.nuget.org/MIT - Powershell_black_64.png - https://github.com/PowerShell/PowerShell - Runtime for hosting PowerShell - © Microsoft Corporation. All rights reserved. - en-US - PowerShell - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md deleted file mode 100644 index f1e29f3f..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md +++ /dev/null @@ -1,26 +0,0 @@ -Microsoft.WSMan.Runtime [7.3.0](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.3.0) --------------------- - -Used by: SqlDatabase - -Target frameworks: net472, net6.0, net7.0, net8.0, netstandard2.0 - -License: [MIT](../../../../licenses/mit) - -- package license: [MIT](https://licenses.nuget.org/MIT) -- project license: [MIT](https://github.com/PowerShell/PowerShell) - -Description ------------ -Runtime for hosting PowerShell - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/index.json b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/index.json similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/index.json rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/index.json diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/package.nuspec b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/package.nuspec similarity index 94% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/package.nuspec index 78b02cae..4d5b0ba1 100644 --- a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/package.nuspec @@ -2,7 +2,7 @@ Moq - 4.20.69 + 4.20.70 Moq: an enjoyable mocking library Daniel Cazzulino, kzu false @@ -15,7 +15,7 @@ https://github.com/moq/moq/blob/main/changelog.md Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD, and Contributors. All rights reserved. moq;tdd;mocking;mocks;unittesting;agile;unittest - + diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/project-License.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/project-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/project-License.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/project-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/readme.md b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/readme.md similarity index 93% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/readme.md rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/readme.md index 0e4df030..76a6d854 100644 --- a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/readme.md @@ -1,4 +1,4 @@ -Moq [4.20.69](https://www.nuget.org/packages/Moq/4.20.69) +Moq [4.20.70](https://www.nuget.org/packages/Moq/4.20.70) -------------------- Used by: SqlDatabase internal diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/repository-License.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/repository-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/repository-License.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/repository-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.20.70/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.20.70/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/index.json deleted file mode 100644 index 2809b998..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/index.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "Source": "https://api.nuget.org/v3/index.json", - "License": { - "Code": "Apache-2.0", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "net472", - "net6.0", - "net7.0", - "net8.0" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "Apache-2.0", - "HRef": "https://licenses.nuget.org/Apache-2.0" - }, - { - "Subject": "repository", - "Code": null, - "HRef": "https://github.com/NuGet/NuGet.Client", - "Description": "License code NOASSERTION" - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://aka.ms/nugetprj" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/package.nuspec deleted file mode 100644 index 811d1c0d..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/package.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - NuGet.Frameworks - 6.5.0 - Microsoft - true - Apache-2.0 - https://licenses.nuget.org/Apache-2.0 - icon.png - README.md - https://aka.ms/nugetprj - NuGet's understanding of target frameworks. - © Microsoft Corporation. All rights reserved. - nuget - true - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/readme.md deleted file mode 100644 index 6d535493..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/readme.md +++ /dev/null @@ -1,27 +0,0 @@ -NuGet.Frameworks [6.5.0](https://www.nuget.org/packages/NuGet.Frameworks/6.5.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net6.0, net7.0, net8.0 - -License: [Apache-2.0](../../../../licenses/apache-2.0) - -- package license: [Apache-2.0](https://licenses.nuget.org/Apache-2.0) -- repository license: [Unknown](https://github.com/NuGet/NuGet.Client) , License code NOASSERTION -- project license: [Unknown](https://aka.ms/nugetprj) - -Description ------------ -NuGet's understanding of target frameworks. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/repository-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/repository-LICENSE.txt deleted file mode 100644 index 86930deb..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/repository-LICENSE.txt +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) .NET Foundation and Contributors. - -All rights reserved. - - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the -License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package.nuspec deleted file mode 100644 index 13489c22..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package.nuspec +++ /dev/null @@ -1,38 +0,0 @@ - - - - NUnit - 3.14.0 - NUnit - Charlie Poole, Rob Prouse - Charlie Poole, Rob Prouse - false - LICENSE.txt - https://aka.ms/deprecateLicenseUrl - icon.png - README.md - https://nunit.org/ - https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png - NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. - -This package includes the NUnit 3 framework assembly, which is referenced by your tests. You will need to install version 3 of the nunit3-console program or a third-party runner that supports NUnit 3 in order to execute tests. Runners intended for use with NUnit 2.x will not run NUnit 3 tests correctly. - -Supported platforms: -- .NET Framework 3.5+ -- .NET Standard 2.0+ - NUnit is a unit-testing framework for all .NET languages with a strong TDD focus. - This package includes the NUnit 3 framework assembly, which is referenced by your tests. You will need to install version 3 of the nunit3-console program or a third-party runner that supports NUnit 3 in order to execute tests. Runners intended for use with NUnit 2.x will not run NUnit 3 tests correctly. - Copyright (c) 2023 Charlie Poole, Rob Prouse - en-US - nunit test testing tdd framework fluent assert theory plugin addin - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/readme.md b/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/readme.md deleted file mode 100644 index 0e505383..00000000 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -NUnit [3.14.0](https://www.nuget.org/packages/NUnit/3.14.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net6.0, net7.0, net8.0 - -License: [MIT](../../../../licenses/mit) - -- package license: [MIT]() , The license file is identical to the repository license file. -- repository license: [MIT](https://github.com/nunit/nunit) -- project license: [Unknown](https://nunit.org/) - -Description ------------ -NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. - -This package includes the NUnit 3 framework assembly, which is referenced by your tests. You will need to install version 3 of the nunit3-console program or a third-party runner that supports NUnit 3 in order to execute tests. Runners intended for use with NUnit 2.x will not run NUnit 3 tests correctly. - -Supported platforms: -- .NET Framework 3.5+ -- .NET Standard 2.0+ - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/index.json b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/index.json similarity index 84% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/index.json rename to Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/index.json index 27b50717..aee9b6b1 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/index.json @@ -20,8 +20,7 @@ { "Subject": "package", "Code": "MIT", - "HRef": "LICENSE.txt", - "Description": "The license file is identical to the repository license file." + "HRef": "https://licenses.nuget.org/MIT" }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package-LICENSE.txt similarity index 95% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package-LICENSE.txt index 7eb103cf..365de41e 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package-LICENSE.txt +++ b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package-LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2023 Charlie Poole, Rob Prouse +Copyright (c) 2024 Charlie Poole, Rob Prouse Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package.nuspec new file mode 100644 index 00000000..07952526 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package.nuspec @@ -0,0 +1,40 @@ + + + + NUnit + 4.1.0 + NUnit + Charlie Poole, Rob Prouse + Charlie Poole, Rob Prouse + false + MIT + https://licenses.nuget.org/MIT + icon.png + README.md + https://nunit.org/ + NUnit is a unit-testing framework for all .NET languages. + It can run on macOS, Linux and Windows operating systems. + NUnit can be used for a wide range of testing, from unit testing with TDD to full-fledged system and integration testing. + It is a non-opinionated, broad and deep framework with multiple different ways to assert that your code behaves as expected. Many aspects of NUnit can be extended to suit your specific purposes. + + The latest version, version 4, is an upgrade from the groundbreaking NUnit 3 framework. It is a modernized version, aimed at taking advantage of the latest .NET features and C# language constructs. + + If you are upgrading from NUnit 3, be aware of the breaking changes (https://docs.nunit.org/articles/nunit/release-notes/breaking-changes.html#nunit-40). Please see the NUnit 4 Migration Guide (https://docs.nunit.org/articles/nunit/release-notes/Nunit4.0-MigrationGuide.html) and take care to prepare your NUnit 3 code before you do the upgrade. + + Supported platforms: + - .NET Framework 4.6.2+ + - .NET 6.0+ + NUnit is a unit-testing framework for all .NET languages with a strong TDD focus. + See release notes at https://docs.nunit.org/articles/nunit/release-notes/framework.html#nunit-400---november-26-2023 + Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License. + en-US + nunit test testing tdd framework fluent assert theory plugin addin + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/readme.md b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/readme.md new file mode 100644 index 00000000..b52d1c7e --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/readme.md @@ -0,0 +1,38 @@ +NUnit [4.1.0](https://www.nuget.org/packages/NUnit/4.1.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net6.0, net7.0, net8.0 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](https://github.com/nunit/nunit) +- project license: [Unknown](https://nunit.org/) + +Description +----------- +NUnit is a unit-testing framework for all .NET languages. + It can run on macOS, Linux and Windows operating systems. + NUnit can be used for a wide range of testing, from unit testing with TDD to full-fledged system and integration testing. + It is a non-opinionated, broad and deep framework with multiple different ways to assert that your code behaves as expected. Many aspects of NUnit can be extended to suit your specific purposes. + + The latest version, version 4, is an upgrade from the groundbreaking NUnit 3 framework. It is a modernized version, aimed at taking advantage of the latest .NET features and C# language constructs. + + If you are upgrading from NUnit 3, be aware of the breaking changes (https://docs.nunit.org/articles/nunit/release-notes/breaking-changes.html#nunit-40). Please see the NUnit 4 Migration Guide (https://docs.nunit.org/articles/nunit/release-notes/Nunit4.0-MigrationGuide.html) and take care to prepare your NUnit 3 code before you do the upgrade. + + Supported platforms: + - .NET Framework 4.6.2+ + - .NET 6.0+ + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/repository-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/repository-LICENSE.txt similarity index 95% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/repository-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/repository-LICENSE.txt index 7eb103cf..365de41e 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/repository-LICENSE.txt +++ b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/repository-LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2023 Charlie Poole, Rob Prouse +Copyright (c) 2024 Charlie Poole, Rob Prouse Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/index.json similarity index 91% rename from Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/index.json index 7ea9e2d3..1dbc4598 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/index.json @@ -10,9 +10,6 @@ "InternalOnly": false, "TargetFrameworks": [ "net472", - "net6.0", - "net7.0", - "net8.0", "netstandard2.0" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/package-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/package-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/package.nuspec similarity index 85% rename from Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/package.nuspec index 095a9895..35c9a2df 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/package.nuspec @@ -2,7 +2,8 @@ PowerShellStandard.Library - 5.1.0 + 5.1.1 + PowerShellStandard.Library Microsoft Microsoft,PowerShellTeam false @@ -11,7 +12,7 @@ https://github.com/PowerShell/PowerShell/blob/master/assets/Powershell_64.png Contains the reference assemblies for PowerShell Standard 5 © Microsoft Corporation. All rights reserved. - PowerShell, reference, netstandard2, netstandard2.0 + PowerShell, reference, net452, netstandard2, netstandard2.0 diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/project-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/project-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/project-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md similarity index 72% rename from Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md index 3c701fff..9456ed96 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md @@ -1,9 +1,9 @@ -PowerShellStandard.Library [5.1.0](https://www.nuget.org/packages/PowerShellStandard.Library/5.1.0) +PowerShellStandard.Library [5.1.1](https://www.nuget.org/packages/PowerShellStandard.Library/5.1.1) -------------------- Used by: SqlDatabase -Target frameworks: net472, net6.0, net7.0, net8.0, netstandard2.0 +Target frameworks: net472, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/remarks.md b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/remarks.md rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.20.69/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.20.69/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/remarks.md b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/index.json b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/index.json similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/index.json rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/index.json diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/package-LICENSE b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/package-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/package-LICENSE rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/package-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/package.nuspec b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/package.nuspec similarity index 92% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/package.nuspec index 9fd61111..675c9db9 100644 --- a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/package.nuspec @@ -2,7 +2,7 @@ StyleCop.Analyzers.Unstable - 1.2.0.507 + 1.2.0.556 StyleCop.Analyzers.Unstable Sam Harwell et. al. Sam Harwell @@ -12,7 +12,7 @@ https://licenses.nuget.org/MIT https://github.com/DotNetAnalyzers/StyleCopAnalyzers An implementation of StyleCop's rules using Roslyn analyzers and code fixes - https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases/1.2.0-beta.507 + https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases/1.2.0-beta.556 Copyright 2015 Tunnel Vision Laboratories, LLC StyleCop DotNetAnalyzers Roslyn Diagnostic Analyzer diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/readme.md b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/readme.md similarity index 81% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/readme.md rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/readme.md index bc613e4a..44fedfa8 100644 --- a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/readme.md @@ -1,4 +1,4 @@ -StyleCop.Analyzers.Unstable [1.2.0.507](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.507) +StyleCop.Analyzers.Unstable [1.2.0.556](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.556) -------------------- Used by: SqlDatabase internal diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json index 32f97a40..082ffec6 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md index 710959a7..d7dee260 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md @@ -3,7 +3,7 @@ System.Buffers [4.5.1](https://www.nuget.org/packages/System.Buffers/4.5.1) Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/index.json b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/index.json similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/index.json rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/index.json diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/package-LICENSE.TXT similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/package-LICENSE.TXT diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/package.nuspec similarity index 99% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/package.nuspec index 74d98029..10416eab 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/package.nuspec @@ -2,7 +2,7 @@ System.Data.SqlClient - 4.8.5 + 4.8.6 System.Data.SqlClient Microsoft microsoft,dotnetframework diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/readme.md similarity index 94% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/readme.md index f3bdcc99..a8f05880 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/readme.md @@ -1,4 +1,4 @@ -System.Data.SqlClient [4.8.5](https://www.nuget.org/packages/System.Data.SqlClient/4.8.5) +System.Data.SqlClient [4.8.6](https://www.nuget.org/packages/System.Data.SqlClient/4.8.6) -------------------- Used by: SqlDatabase diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.6/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json index 4d4b6b37..844fbef3 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ], "Dependencies": [ diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md index 968c953e..cbb66ab6 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md @@ -3,7 +3,7 @@ System.Diagnostics.DiagnosticSource [4.7.0](https://www.nuget.org/packages/Syste Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json index a1e7bf15..ba06c1b3 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ], "Dependencies": [ diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md index ba47fe32..23e24765 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md @@ -3,7 +3,7 @@ System.Memory [4.5.4](https://www.nuget.org/packages/System.Memory/4.5.4) Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json index 32f97a40..082ffec6 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md index 77fe24e5..f6183629 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md @@ -3,7 +3,7 @@ System.Numerics.Vectors [4.4.0](https://www.nuget.org/packages/System.Numerics.V Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json index 581a7123..c3e488ad 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json @@ -9,6 +9,10 @@ "Name": "SqlDatabase", "InternalOnly": true, "TargetFrameworks": [ + "net472", + "net6.0", + "net7.0", + "net8.0", "netstandard2.0" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md index 67fdfc27..f1c665b0 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md @@ -3,7 +3,7 @@ System.Runtime.CompilerServices.Unsafe [4.5.3](https://www.nuget.org/packages/Sy Used by: SqlDatabase internal -Target frameworks: netstandard2.0 +Target frameworks: net472, net6.0, net7.0, net8.0, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json index 5b097663..dbd3f587 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md index ce59f306..22bc6760 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md @@ -3,7 +3,7 @@ System.Runtime.CompilerServices.Unsafe [4.7.0](https://www.nuget.org/packages/Sy Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json index 6cc05047..a85521b4 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json @@ -9,7 +9,6 @@ "Name": "SqlDatabase", "InternalOnly": false, "TargetFrameworks": [ - "net472", "netstandard2.0" ], "Dependencies": [ diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md index ae05e7a9..2f3d5803 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md @@ -3,7 +3,7 @@ System.Text.Encoding.CodePages [4.7.0](https://www.nuget.org/packages/System.Tex Used by: SqlDatabase -Target frameworks: net472, netstandard2.0 +Target frameworks: netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json index 9c30edc5..22fa47de 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json @@ -9,6 +9,10 @@ "Name": "SqlDatabase", "InternalOnly": true, "TargetFrameworks": [ + "net472", + "net6.0", + "net7.0", + "net8.0", "netstandard2.0" ], "Dependencies": [ diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md index 2c92941d..b1da2eef 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md @@ -3,7 +3,7 @@ System.Threading.Tasks.Extensions [4.5.4](https://www.nuget.org/packages/System. Used by: SqlDatabase internal -Target frameworks: netstandard2.0 +Target frameworks: net472, net6.0, net7.0, net8.0, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/readme.md b/Build/third-party-libraries/readme.md index 2d4b39cd..8e5dc548 100644 --- a/Build/third-party-libraries/readme.md +++ b/Build/third-party-libraries/readme.md @@ -3,48 +3,45 @@ Licenses |Code|Requires approval|Requires third party notices|Packages count| |----------|:----|:----|:----| -|[Apache-2.0](licenses/apache-2.0)|no|no|3| +|[Apache-2.0](licenses/apache-2.0)|no|no|2| |[BSD-2-Clause](licenses/bsd-2-clause)|no|no|1| |[BSD-3-Clause](licenses/bsd-3-clause)|no|no|1| -|[MIT](licenses/mit)|no|no|38| -|[ms-net-library](licenses/ms-net-library)|no|no|6| +|[MIT](licenses/mit)|no|no|40| +|[ms-net-library](licenses/ms-net-library)|no|no|2| |[PostgreSQL](licenses/postgresql)|no|no|1| -Packages 50 +Packages 47 -------- |Name|Version|Source|License|Used by| |----------|:----|:----|:----|:----| |[Castle.Core](packages/nuget.org/castle.core/5.1.1)|5.1.1|[nuget.org](https://www.nuget.org/packages/Castle.Core/5.1.1)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| -|[Dapper.StrongName](packages/nuget.org/dapper.strongname/2.1.15)|2.1.15|[nuget.org](https://www.nuget.org/packages/Dapper.StrongName/2.1.15)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| +|[Dapper.StrongName](packages/nuget.org/dapper.strongname/2.1.35)|2.1.35|[nuget.org](https://www.nuget.org/packages/Dapper.StrongName/2.1.35)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| |[DiffEngine](packages/nuget.org/diffengine/11.3.0)|11.3.0|[nuget.org](https://www.nuget.org/packages/DiffEngine/11.3.0)|[MIT](licenses/mit)|SqlDatabase internal| |[EmptyFiles](packages/nuget.org/emptyfiles/4.4.0)|4.4.0|[nuget.org](https://www.nuget.org/packages/EmptyFiles/4.4.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.CodeCoverage](packages/nuget.org/microsoft.codecoverage/17.7.2)|17.7.2|[nuget.org](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.7.2)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.CodeCoverage](packages/nuget.org/microsoft.codecoverage/17.9.0)|17.9.0|[nuget.org](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.9.0)|[MIT](licenses/mit)|SqlDatabase internal| |[Microsoft.CSharp](packages/nuget.org/microsoft.csharp/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/Microsoft.CSharp/4.7.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.NET.Test.Sdk](packages/nuget.org/microsoft.net.test.sdk/17.7.2)|17.7.2|[nuget.org](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.7.2)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[Microsoft.TestPlatform.ObjectModel](packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2)|17.7.2|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.7.2)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[Microsoft.TestPlatform.TestHost](packages/nuget.org/microsoft.testplatform.testhost/17.7.2)|17.7.2|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.7.2)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.NET.Test.Sdk](packages/nuget.org/microsoft.net.test.sdk/17.9.0)|17.9.0|[nuget.org](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.9.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[Microsoft.TestPlatform.ObjectModel](packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0)|17.9.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.9.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[Microsoft.TestPlatform.TestHost](packages/nuget.org/microsoft.testplatform.testhost/17.9.0)|17.9.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.9.0)|[MIT](licenses/mit)|SqlDatabase internal| |[Microsoft.Win32.Registry](packages/nuget.org/microsoft.win32.registry/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/Microsoft.Win32.Registry/4.7.0)|[MIT](licenses/mit)|SqlDatabase| -|[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.2.0)|7.2.0|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.2.0)|[MIT](licenses/mit)|SqlDatabase| -|[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.3.0)|7.3.0|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.3.0)|[MIT](licenses/mit)|SqlDatabase| -|[Moq](packages/nuget.org/moq/4.20.69)|4.20.69|[nuget.org](https://www.nuget.org/packages/Moq/4.20.69)|[BSD-3-Clause](licenses/bsd-3-clause)|SqlDatabase internal| +|[Moq](packages/nuget.org/moq/4.20.70)|4.20.70|[nuget.org](https://www.nuget.org/packages/Moq/4.20.70)|[BSD-3-Clause](licenses/bsd-3-clause)|SqlDatabase internal| |[MySqlConnector](packages/nuget.org/mysqlconnector/1.3.10)|1.3.10|[nuget.org](https://www.nuget.org/packages/MySqlConnector/1.3.10)|[MIT](licenses/mit)|SqlDatabase| |[NETStandard.Library](packages/nuget.org/netstandard.library/2.0.3)|2.0.3|[nuget.org](https://www.nuget.org/packages/NETStandard.Library/2.0.3)|[MIT](licenses/mit)|SqlDatabase| |[Newtonsoft.Json](packages/nuget.org/newtonsoft.json/13.0.1)|13.0.1|[nuget.org](https://www.nuget.org/packages/Newtonsoft.Json/13.0.1)|[MIT](licenses/mit)|SqlDatabase internal| |[Newtonsoft.Json](packages/nuget.org/newtonsoft.json/13.0.3)|13.0.3|[nuget.org](https://www.nuget.org/packages/Newtonsoft.Json/13.0.3)|[MIT](licenses/mit)|SqlDatabase internal| |[Npgsql](packages/nuget.org/npgsql/4.0.11)|4.0.11|[nuget.org](https://www.nuget.org/packages/Npgsql/4.0.11)|[PostgreSQL](licenses/postgresql)|SqlDatabase| -|[NuGet.Frameworks](packages/nuget.org/nuget.frameworks/6.5.0)|6.5.0|[nuget.org](https://www.nuget.org/packages/NuGet.Frameworks/6.5.0)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| -|[NUnit](packages/nuget.org/nunit/3.14.0)|3.14.0|[nuget.org](https://www.nuget.org/packages/NUnit/3.14.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[NUnit](packages/nuget.org/nunit/4.1.0)|4.1.0|[nuget.org](https://www.nuget.org/packages/NUnit/4.1.0)|[MIT](licenses/mit)|SqlDatabase internal| |[NUnit3TestAdapter](packages/nuget.org/nunit3testadapter/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/NUnit3TestAdapter/4.5.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[PowerShellStandard.Library](packages/nuget.org/powershellstandard.library/5.1.0)|5.1.0|[nuget.org](https://www.nuget.org/packages/PowerShellStandard.Library/5.1.0)|[MIT](licenses/mit)|SqlDatabase| +|[PowerShellStandard.Library](packages/nuget.org/powershellstandard.library/5.1.1)|5.1.1|[nuget.org](https://www.nuget.org/packages/PowerShellStandard.Library/5.1.1)|[MIT](licenses/mit)|SqlDatabase| |[Shouldly](packages/nuget.org/shouldly/4.2.1)|4.2.1|[nuget.org](https://www.nuget.org/packages/Shouldly/4.2.1)|[BSD-2-Clause](licenses/bsd-2-clause)|SqlDatabase internal| -|[StyleCop.Analyzers.Unstable](packages/nuget.org/stylecop.analyzers.unstable/1.2.0.507)|1.2.0.507|[nuget.org](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.507)|[MIT](licenses/mit)|SqlDatabase internal| +|[StyleCop.Analyzers.Unstable](packages/nuget.org/stylecop.analyzers.unstable/1.2.0.556)|1.2.0.556|[nuget.org](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.556)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Buffers](packages/nuget.org/system.buffers/4.4.0)|4.4.0|[nuget.org](https://www.nuget.org/packages/System.Buffers/4.4.0)|[MIT](licenses/mit)|SqlDatabase| |[System.Buffers](packages/nuget.org/system.buffers/4.5.1)|4.5.1|[nuget.org](https://www.nuget.org/packages/System.Buffers/4.5.1)|[MIT](licenses/mit)|SqlDatabase| |[System.CodeDom](packages/nuget.org/system.codedom/6.0.0)|6.0.0|[nuget.org](https://www.nuget.org/packages/System.CodeDom/6.0.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[System.Data.SqlClient](packages/nuget.org/system.data.sqlclient/4.8.5)|4.8.5|[nuget.org](https://www.nuget.org/packages/System.Data.SqlClient/4.8.5)|[MIT](licenses/mit)|SqlDatabase| +|[System.Data.SqlClient](packages/nuget.org/system.data.sqlclient/4.8.6)|4.8.6|[nuget.org](https://www.nuget.org/packages/System.Data.SqlClient/4.8.6)|[MIT](licenses/mit)|SqlDatabase| |[System.Diagnostics.DiagnosticSource](packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/4.7.0)|[MIT](licenses/mit)|SqlDatabase| |[System.Diagnostics.EventLog](packages/nuget.org/system.diagnostics.eventlog/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.EventLog/4.7.0)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Management](packages/nuget.org/system.management/6.0.1)|6.0.1|[nuget.org](https://www.nuget.org/packages/System.Management/6.0.1)|[MIT](licenses/mit)|SqlDatabase internal| diff --git a/Examples/PowerShellScript/readme.md b/Examples/PowerShellScript/readme.md index 44a06a19..65c29b27 100644 --- a/Examples/PowerShellScript/readme.md +++ b/Examples/PowerShellScript/readme.md @@ -73,9 +73,12 @@ Installed Powershell Desktop version. Pre-installed Powershell Core is required, will be used by SqlDatabase as external component. Due to the Powershell Core design: -* SqlDatabase .net 8.0 and 7.0 can host Powershell Core versions below 7.4 +* SqlDatabase .net 8.0 can host Powershell Core versions below 7.5 +* SqlDatabase .net 7.0 can host Powershell Core versions below 7.4 * SqlDatabase .net 6.0 can host Powershell Core versions below 7.3 +see [PowerShell release history](https://learn.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.2#release-history). + PowerShell location can be passed via command line: ```bash diff --git a/LICENSE.md b/LICENSE.md index f6d2bfe7..0c2c8abc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2023 max-ieremenko +Copyright (c) 2018-2024 max-ieremenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index 72014747..a16a7677 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -9,6 +9,7 @@ ..\SqlDatabase.snk latest enable + enable false en @@ -17,20 +18,20 @@ - 4.2.0 + 4.2.1 $(SqlDatabaseVersion) $(SqlDatabaseVersion).0 $(SqlDatabaseVersion).0 SqlDatabase Max Ieremenko SqlDatabase is a tool for MSSQL Server, PostgreSQL and MySQL, allows executing scripts, database migrations and data export. - https://github.com/max-ieremenko/SqlDatabase/releases + https://github.com/max-ieremenko/SqlDatabase/releases/tag/$(SqlDatabaseVersion) https://github.com/max-ieremenko/SqlDatabase https://github.com/max-ieremenko/SqlDatabase https://github.com/max-ieremenko/SqlDatabase/raw/master/icon-32.png icon-32.png MIT - (C) 2018-2023 Max Ieremenko. + (C) 2018-2024 Max Ieremenko. git sqlserver database postgresql mysql mysql-database sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data false @@ -39,4 +40,11 @@ + + + + + + + \ No newline at end of file diff --git a/Sources/Directory.Packages.props b/Sources/Directory.Packages.props index 7f87a2a5..50ca7700 100644 --- a/Sources/Directory.Packages.props +++ b/Sources/Directory.Packages.props @@ -8,20 +8,20 @@ - + - + - - - + + + - + - + \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs index cacb2657..e4b62caa 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.FileSystem; @@ -15,7 +14,7 @@ public class AssemblyScriptFactoryTest [SetUp] public void BeforeEachTest() { - _sut = new AssemblyScriptFactory("class-name", "method-name"); + _sut = new AssemblyScriptFactory(FrameworkVersion.Net472, "class-name", "method-name"); } [Test] @@ -38,7 +37,7 @@ public void FromFile() { var file = FileFactory.File( "11.dll", - new byte[] { 1, 2, 3 }, + [1, 2, 3], FileFactory.Folder("name", FileFactory.File("11.txt", "3, 2, 1"))); var script = _sut.FromFile(file).ShouldBeOfType(); @@ -46,7 +45,7 @@ public void FromFile() script.DisplayName.ShouldBe("11.dll"); script.ClassName.ShouldBe("class-name"); script.MethodName.ShouldBe("method-name"); - script.ReadAssemblyContent().ShouldBe(new byte[] { 1, 2, 3 }); + script.ReadAssemblyContent().ShouldBe([1, 2, 3]); new StreamReader(script.ReadDescriptionContent()!).ReadToEnd().ShouldBe("3, 2, 1"); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs index 0a1a2862..9e4f84b2 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Text; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; @@ -39,7 +34,18 @@ public void BeforeEachTest() .Callback(() => _executedScripts.Add(_command.Object.CommandText)) .Returns(0); - _sut = new AssemblyScript("dummy", null, null, null!, null!); +#if NET472 + var frameworkVersion = FrameworkVersion.Net472; +#else + var frameworkVersion = FrameworkVersion.Net6; +#endif + _sut = new AssemblyScript( + frameworkVersion, + "dummy", + null, + null, + null!, + null!); } [Test] @@ -60,9 +66,7 @@ public void ExecuteExampleMsSql() _sut.DisplayName = "2.1_2.2.dll"; _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); -#if !NET472 using (new ConsoleListener(_log.Object)) -#endif { _sut.Execute(new DbCommandStub(_command.Object), _variables.Object, _log.Object); } @@ -96,9 +100,7 @@ public void ExecuteExamplePgSql() _sut.DisplayName = "2.1_2.2.dll"; _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); -#if !NET472 using (new ConsoleListener(_log.Object)) -#endif { _sut.Execute(new DbCommandStub(_command.Object), _variables.Object, _log.Object); } diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DbCommandStub.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DbCommandStub.cs index bf46fbc9..4ec4232a 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DbCommandStub.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DbCommandStub.cs @@ -1,6 +1,4 @@ -using System; -using System.Data; -using System.Data.Common; +using System.Data.Common; #pragma warning disable CS8765 // Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes). diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs index 2b9e41b4..ad11012d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Data; -using Moq; +using Moq; using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -49,16 +47,16 @@ public void Execute() _sut.Method = (c, v) => { - Assert.AreEqual(_command.Object, c); - Assert.AreEqual(_variables.Object, v); + _command.Object.ShouldBe(c); + _variables.Object.ShouldBe(v); executeCounter++; }; - Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); + _sut.Execute(_command.Object, _variables.Object).ShouldBeTrue(); - Assert.AreEqual(1, executeCounter); - Assert.AreEqual(0, _logOutput.Count); + executeCounter.ShouldBe(1); + _logOutput.ShouldBeEmpty(); } [Test] @@ -68,11 +66,11 @@ public void DisposeInstanceOnExecute() instance.Setup(i => i.Dispose()); _sut.ScriptInstance = instance.Object; - _sut.Method = (c, v) => + _sut.Method = (_, _) => { }; - Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); + _sut.Execute(_command.Object, _variables.Object).ShouldBeTrue(); instance.VerifyAll(); } @@ -80,10 +78,10 @@ public void DisposeInstanceOnExecute() [Test] public void ExceptionOnExecute() { - _sut.Method = (c, v) => throw new InvalidOperationException(); + _sut.Method = (_, _) => throw new InvalidOperationException(); - Assert.IsFalse(_sut.Execute(_command.Object, _variables.Object)); + _sut.Execute(_command.Object, _variables.Object).ShouldBeFalse(); - Assert.Greater(_logOutput.Count, 0); + _logOutput.ShouldNotBeEmpty(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.Stubs.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.Stubs.cs index 399a8a9d..9dc72d8f 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.Stubs.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.Stubs.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; +using System.Data.SqlClient; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.cs index 50f5c53b..71ec4a31 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/EntryPointResolverTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs index a8d70899..b25de909 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -23,28 +22,31 @@ public void BeforeEachTest() public void IsMatch() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method!)); + method.ShouldNotBeNull(); + _sut.IsMatch(method).ShouldBeTrue(); } [Test] public void CreateDelegate() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method!); - Assert.IsNotNull(actual); + method.ShouldNotBeNull(); + + var actual = _sut.CreateDelegate(this, method); + actual.ShouldNotBeNull(); var command = new Mock(MockBehavior.Strict); var variables = new Mock>(MockBehavior.Strict); actual(command.Object, variables.Object); - Assert.AreEqual(_executeCommand, command.Object); - Assert.AreEqual(_executeVariables, variables.Object); + command.Object.ShouldBe(_executeCommand); + variables.Object.ShouldBe(_executeVariables); } private void Execute(IDbCommand command, IReadOnlyDictionary variables) { - Assert.IsNull(_executeCommand); + _executeCommand.ShouldBeNull(); _executeCommand = command; _executeVariables = variables; } diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs index 81335baf..74a57d71 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs @@ -1,7 +1,7 @@ -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -21,24 +21,28 @@ public void BeforeEachTest() public void IsMatch() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method!)); + + method.ShouldNotBeNull(); + _sut.IsMatch(method).ShouldBeTrue(); } [Test] public void CreateDelegate() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method!); - Assert.IsNotNull(actual); + method.ShouldNotBeNull(); + + var actual = _sut.CreateDelegate(this, method); + actual.ShouldNotBeNull(); var command = new Mock(MockBehavior.Strict); actual(command.Object, null!); - Assert.AreEqual(_executeCommand, command.Object); + command.Object.ShouldBe(_executeCommand); } private void Execute(IDbCommand command) { - Assert.IsNull(_executeCommand); + _executeCommand.ShouldBeNull(); _executeCommand = command; } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs index ace9f95d..aa653ed4 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs @@ -1,7 +1,7 @@ -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -21,15 +21,18 @@ public void BeforeEachTest() public void IsMatch() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method!)); + method.ShouldNotBeNull(); + _sut.IsMatch(method).ShouldBeTrue(); } [Test] public void CreateDelegate() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method!); - Assert.IsNotNull(actual); + method.ShouldNotBeNull(); + + var actual = _sut.CreateDelegate(this, method); + actual.ShouldNotBeNull(); var connection = new Mock(MockBehavior.Strict); @@ -39,12 +42,12 @@ public void CreateDelegate() .Returns(connection.Object); actual(command.Object, null!); - Assert.AreEqual(_executeConnection, connection.Object); + connection.Object.ShouldBe(_executeConnection); } private void Execute(IDbConnection connection) { - Assert.IsNull(_executeConnection); + _executeConnection.ShouldBeNull(); _executeConnection = connection; } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs index 87ea00f0..5021fa2d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -23,28 +22,31 @@ public void BeforeEachTest() public void IsMatch() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method!)); + method.ShouldNotBeNull(); + _sut.IsMatch(method).ShouldBeTrue(); } [Test] public void CreateDelegate() { var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method!); - Assert.IsNotNull(actual); + method.ShouldNotBeNull(); + + var actual = _sut.CreateDelegate(this, method); + actual.ShouldNotBeNull(); var command = new Mock(MockBehavior.Strict); var variables = new Mock>(MockBehavior.Strict); actual(command.Object, variables.Object); - Assert.AreEqual(_executeCommand, command.Object); - Assert.AreEqual(_executeVariables, variables.Object); + command.Object.ShouldBe(_executeCommand); + variables.Object.ShouldBe(_executeVariables); } private void Execute(IReadOnlyDictionary variables, IDbCommand command) { - Assert.IsNull(_executeCommand); + _executeCommand.ShouldBeNull(); _executeCommand = command; _executeVariables = variables; } diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverSqlConnectionTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverSqlConnectionTest.cs index b7995697..d8245db5 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverSqlConnectionTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverSqlConnectionTest.cs @@ -1,5 +1,4 @@ -using System.Data; -using System.Data.SqlClient; +using System.Data.SqlClient; using System.Reflection; using Moq; using NUnit.Framework; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs index 93f7e122..ce7c23e4 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs @@ -1,8 +1,4 @@ #if NET472 -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; using Moq; using NUnit.Framework; using Shouldly; @@ -41,9 +37,10 @@ public void BeforeEachTest() .Returns(0); _sut = SubDomainFactory.Create( - log.Object, - GetType().Assembly.Location, - () => File.ReadAllBytes(GetType().Assembly.Location)) + FrameworkVersion.Net472, + log.Object, + GetType().Assembly.Location, + () => File.ReadAllBytes(GetType().Assembly.Location)) .ShouldBeOfType(); _sut.Initialize(); @@ -52,8 +49,8 @@ public void BeforeEachTest() [TearDown] public void AfterEachTest() { - _sut?.Unload(); - _sut?.Dispose(); + _sut.Unload(); + _sut.Dispose(); } [Test] @@ -67,11 +64,11 @@ public void ValidateScriptDomainAppBase() _executedScripts.Count.ShouldBe(2); var assemblyFileName = _executedScripts[0]; - FileAssert.DoesNotExist(assemblyFileName); + Assert.That(assemblyFileName, Does.Not.Exist); Path.GetFileName(GetType().Assembly.Location).ShouldBe(Path.GetFileName(assemblyFileName)); var appBase = _executedScripts[1]; - DirectoryAssert.DoesNotExist(appBase); + Assert.That(appBase, Does.Not.Exist); Path.GetDirectoryName(assemblyFileName).ShouldBe(appBase); } diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.StepWithSubDomain.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.StepWithSubDomain.cs index 6d3c7d8c..b4feaddb 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.StepWithSubDomain.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.StepWithSubDomain.cs @@ -1,7 +1,4 @@ -using System; -using System.Data; - -namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; +namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; public partial class NetCoreSubDomainTest { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.cs index 52550ee0..3fbe3f8e 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/NetCore/NetCoreSubDomainTest.cs @@ -1,8 +1,4 @@ #if !NET472 -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; using Moq; using NUnit.Framework; using Shouldly; @@ -41,6 +37,7 @@ public void BeforeEachTest() .Returns(0); _sut = SubDomainFactory.Create( + FrameworkVersion.Net6, log.Object, GetType().Assembly.Location, () => File.ReadAllBytes(GetType().Assembly.Location)) diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/SqlDatabase.Adapter.AssemblyScripts.Test.csproj.user b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/SqlDatabase.Adapter.AssemblyScripts.Test.csproj.user deleted file mode 100644 index 5cb47e2f..00000000 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/SqlDatabase.Adapter.AssemblyScripts.Test.csproj.user +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - Component - - - \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs index ab3360f4..99d86941 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs @@ -1,22 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter.AssemblyScripts; +namespace SqlDatabase.Adapter.AssemblyScripts; internal sealed class AssemblyScript : IScript { private const string DefaultClassName = "SqlDatabaseScript"; private const string DefaultMethodName = "Execute"; + private readonly FrameworkVersion _version; + public AssemblyScript( + FrameworkVersion version, string displayName, string? className, string? methodName, Func readAssemblyContent, Func readDescriptionContent) { + _version = version; DisplayName = displayName; ClassName = string.IsNullOrWhiteSpace(className) ? DefaultClassName : className!; MethodName = string.IsNullOrWhiteSpace(methodName) ? DefaultMethodName : methodName!; @@ -36,7 +35,7 @@ public AssemblyScript( public void Execute(IDbCommand? command, IVariables variables, ILogger logger) { - var domain = SubDomainFactory.Create(logger, DisplayName, ReadAssemblyContent); + var domain = SubDomainFactory.Create(_version, logger, DisplayName, ReadAssemblyContent); using (domain) { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs index 2b67dd46..de4c43ac 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs @@ -1,45 +1,37 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Adapter.AssemblyScripts; public sealed class AssemblyScriptFactory : IScriptFactory, IScriptEnvironment { + private readonly FrameworkVersion _version; private readonly string? _configurationClassName; private readonly string? _configurationMethodName; - public AssemblyScriptFactory(string? configurationClassName, string? configurationMethodName) + public AssemblyScriptFactory(FrameworkVersion version, string? configurationClassName, string? configurationMethodName) { + _version = version; _configurationClassName = configurationClassName; _configurationMethodName = configurationMethodName; } - public bool IsSupported(IFile file) - { - return ".exe".Equals(file.Extension, StringComparison.OrdinalIgnoreCase) - || ".dll".Equals(file.Extension, StringComparison.OrdinalIgnoreCase); - } + public bool IsSupported(IFile file) => + ".exe".Equals(file.Extension, StringComparison.OrdinalIgnoreCase) + || ".dll".Equals(file.Extension, StringComparison.OrdinalIgnoreCase); - public IScript FromFile(IFile file) - { - return new AssemblyScript( - file.Name, - _configurationClassName, - _configurationMethodName, - CreateBinaryReader(file), - CreateScriptDescriptionReader(file)); - } + public IScript FromFile(IFile file) => new AssemblyScript( + _version, + file.Name, + _configurationClassName, + _configurationMethodName, + CreateBinaryReader(file), + CreateScriptDescriptionReader(file)); public bool IsSupported(IScript script) => script is AssemblyScript; - public void Initialize(ILogger logger) => SubDomainFactory.Test(); + public void Initialize(ILogger logger) => SubDomainFactory.Test(_version); - private static Func CreateBinaryReader(IFile file) - { - return () => BinaryRead(file); - } + private static Func CreateBinaryReader(IFile file) => () => BinaryRead(file); private static byte[] BinaryRead(IFile file) { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/AllowNullAttribute.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/AllowNullAttribute.cs index 39be8db8..5226e104 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/AllowNullAttribute.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/AllowNullAttribute.cs @@ -1,8 +1,4 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] -internal sealed class AllowNullAttribute : Attribute -{ -} -#endif \ No newline at end of file +internal sealed class AllowNullAttribute : Attribute; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/NotNullWhenAttribute.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/NotNullWhenAttribute.cs index e3d56cf7..eec257bb 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/NotNullWhenAttribute.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/CodeAnalysis/NotNullWhenAttribute.cs @@ -1,10 +1,8 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; internal sealed class NotNullWhenAttribute : Attribute { public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; public bool ReturnValue { get; } -} -#endif +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ConsoleListener.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ConsoleListener.cs index 1909d299..da5fa9f0 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ConsoleListener.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ConsoleListener.cs @@ -1,9 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Text; - -namespace SqlDatabase.Adapter.AssemblyScripts; +namespace SqlDatabase.Adapter.AssemblyScripts; internal sealed class ConsoleListener : TextWriter { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/DefaultEntryPoint.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/DefaultEntryPoint.cs index 5870beae..2ce2c842 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/DefaultEntryPoint.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/DefaultEntryPoint.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; - -namespace SqlDatabase.Adapter.AssemblyScripts; +namespace SqlDatabase.Adapter.AssemblyScripts; internal sealed class DefaultEntryPoint : IEntryPoint { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/EntryPointResolver.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/EntryPointResolver.cs index d7d0208a..8fd2b56d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/EntryPointResolver.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/EntryPointResolver.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Text; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverBase.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverBase.cs index 9495dfc9..da1ad864 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverBase.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverBase.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommand.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommand.cs index 8c80f335..62f3c756 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommand.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommand.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommandDictionary.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommandDictionary.cs index 37881270..e0353f0f 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommandDictionary.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverCommandDictionary.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDbConnection.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDbConnection.cs index e5d156ef..6fc8d348 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDbConnection.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDbConnection.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDictionaryCommand.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDictionaryCommand.cs index 891c7d5c..14bc0025 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDictionaryCommand.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverDictionaryCommand.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverSqlConnection.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverSqlConnection.cs index a4ed5e68..651422ad 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverSqlConnection.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ExecuteMethodResolverSqlConnection.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq.Expressions; +using System.Linq.Expressions; using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/IEntryPoint.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/IEntryPoint.cs index 3e2dcde7..6ab6412d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/IEntryPoint.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/IEntryPoint.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Data; - -namespace SqlDatabase.Adapter.AssemblyScripts; +namespace SqlDatabase.Adapter.AssemblyScripts; internal interface IEntryPoint { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/ISubDomain.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/ISubDomain.cs index 54bc68ae..9f4d9b18 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/ISubDomain.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/ISubDomain.cs @@ -1,7 +1,4 @@ -using System; -using System.Data; - -namespace SqlDatabase.Adapter.AssemblyScripts; +namespace SqlDatabase.Adapter.AssemblyScripts; internal interface ISubDomain : IDisposable { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/AppDomainAdapter.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/AppDomainAdapter.cs index 47aa6411..ed3c332e 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/AppDomainAdapter.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/AppDomainAdapter.cs @@ -1,6 +1,4 @@ -using System; -using System.Linq; -using System.Linq.Expressions; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.InteropServices; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainAgent.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainAgent.cs index cc530ae1..e5734df1 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainAgent.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainAgent.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.IO; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.AssemblyScripts.Net472; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainDirectory.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainDirectory.cs index fb6a52ad..1c4c32f6 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainDirectory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/DomainDirectory.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; - -namespace SqlDatabase.Adapter.AssemblyScripts.Net472; +namespace SqlDatabase.Adapter.AssemblyScripts.Net472; internal sealed class DomainDirectory : IDisposable { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/LoggerProxy.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/LoggerProxy.cs index 824ccf2e..07302cc9 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/LoggerProxy.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/LoggerProxy.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; - -namespace SqlDatabase.Adapter.AssemblyScripts.Net472; +namespace SqlDatabase.Adapter.AssemblyScripts.Net472; internal sealed class LoggerProxy : TraceListener, ILogger { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/Net472SubDomain.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/Net472SubDomain.cs index 81909fff..3f289bd5 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/Net472SubDomain.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/Net472/Net472SubDomain.cs @@ -1,8 +1,4 @@ -using System; -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter.AssemblyScripts.Net472; +namespace SqlDatabase.Adapter.AssemblyScripts.Net472; internal sealed class Net472SubDomain : ISubDomain { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs index 01d47ab0..bbdb023f 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs @@ -1,7 +1,4 @@ -#if !NET472 -using System; -using System.IO; -using System.Reflection; +using System.Reflection; using System.Runtime.Loader; namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; @@ -29,5 +26,4 @@ public void UnloadAll() && assemblyName.Name.Equals(ScriptAssembly?.GetName().Name, StringComparison.OrdinalIgnoreCase); return isScriptAssembly ? ScriptAssembly : null; } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/NetCoreSubDomain.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/NetCoreSubDomain.cs index b1731894..576672ec 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/NetCoreSubDomain.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/NetCoreSubDomain.cs @@ -1,7 +1,4 @@ -using System; -using System.Data; - -namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; +namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; internal sealed class NetCoreSubDomain : ISubDomain { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs index eac53a2f..69ba3219 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs @@ -1,14 +1,12 @@ -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; namespace SqlDatabase.Adapter.AssemblyScripts; internal static class SubDomainFactory { - public static void Test() + public static void Test(FrameworkVersion version) { - if (IsNetFrameworkRuntime()) + if (version == FrameworkVersion.Net472) { Test472SubDomain(); } @@ -18,9 +16,9 @@ public static void Test() } } - public static ISubDomain Create(ILogger logger, string assemblyFileName, Func readAssemblyContent) + public static ISubDomain Create(FrameworkVersion version, ILogger logger, string assemblyFileName, Func readAssemblyContent) { - if (IsNetFrameworkRuntime()) + if (version == FrameworkVersion.Net472) { return Create472SubDomain(logger, assemblyFileName, readAssemblyContent); } @@ -28,13 +26,6 @@ public static ISubDomain Create(ILogger logger, string assemblyFileName, Func 0; - } - [MethodImpl(MethodImplOptions.NoInlining)] private static ISubDomain Create472SubDomain(ILogger logger, string assemblyFileName, Func readAssemblyContent) { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/VariablesProxy.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/VariablesProxy.cs index de7598a2..e14c3d66 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/VariablesProxy.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/VariablesProxy.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using System.Collections; namespace SqlDatabase.Adapter.AssemblyScripts; diff --git a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDataExporterTest.cs b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDataExporterTest.cs index ce522bdf..7f1cf61b 100644 --- a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDataExporterTest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.IO; -using System.Text; +using System.Data.SqlClient; using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDatabaseAdapterTest.cs index d3b86445..369cdaec 100644 --- a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlDatabaseAdapterTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlTextReaderTest.cs b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlTextReaderTest.cs index 5a10012c..75dcceaf 100644 --- a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlTextReaderTest.cs +++ b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlTextReaderTest.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlWriterTest.cs b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlWriterTest.cs index ba1579e6..25acd4cc 100644 --- a/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlWriterTest.cs +++ b/Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlWriterTest.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.MsSql.Test/TextScriptOutputMsSqlTest.cs b/Sources/SqlDatabase.Adapter.MsSql.Test/TextScriptOutputMsSqlTest.cs index 4fd8f8dd..a1bee63d 100644 --- a/Sources/SqlDatabase.Adapter.MsSql.Test/TextScriptOutputMsSqlTest.cs +++ b/Sources/SqlDatabase.Adapter.MsSql.Test/TextScriptOutputMsSqlTest.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data.SqlClient; +using System.Data.SqlClient; using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapter.cs b/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapter.cs index 7b3f9899..7f0cfb1c 100644 --- a/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapter.cs @@ -1,6 +1,4 @@ -using System.Data; -using System.Data.SqlClient; -using System.IO; +using System.Data.SqlClient; namespace SqlDatabase.Adapter.MsSql; diff --git a/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapterFactory.cs b/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapterFactory.cs index dc499f62..891524a1 100644 --- a/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapterFactory.cs +++ b/Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapterFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Data.Common; +using System.Data.Common; using System.Data.SqlClient; namespace SqlDatabase.Adapter.MsSql; diff --git a/Sources/SqlDatabase.Adapter.MsSql/MsSqlTextReader.cs b/Sources/SqlDatabase.Adapter.MsSql/MsSqlTextReader.cs index 8c3be1e9..3a7c9bc2 100644 --- a/Sources/SqlDatabase.Adapter.MsSql/MsSqlTextReader.cs +++ b/Sources/SqlDatabase.Adapter.MsSql/MsSqlTextReader.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace SqlDatabase.Adapter.MsSql; diff --git a/Sources/SqlDatabase.Adapter.MsSql/MsSqlWriter.cs b/Sources/SqlDatabase.Adapter.MsSql/MsSqlWriter.cs index 2b873c97..5e5b9983 100644 --- a/Sources/SqlDatabase.Adapter.MsSql/MsSqlWriter.cs +++ b/Sources/SqlDatabase.Adapter.MsSql/MsSqlWriter.cs @@ -1,9 +1,4 @@ -using System; -using System.Data; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; +using System.Globalization; namespace SqlDatabase.Adapter.MsSql; diff --git a/Sources/SqlDatabase.Adapter.MsSql/SqlDatabase.Adapter.MsSql.csproj b/Sources/SqlDatabase.Adapter.MsSql/SqlDatabase.Adapter.MsSql.csproj index 80a96461..21b5619a 100644 --- a/Sources/SqlDatabase.Adapter.MsSql/SqlDatabase.Adapter.MsSql.csproj +++ b/Sources/SqlDatabase.Adapter.MsSql/SqlDatabase.Adapter.MsSql.csproj @@ -1,15 +1,11 @@  - net472;netstandard2.0 + netstandard2.0 bin\ - - + diff --git a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDataExporterTest.cs b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDataExporterTest.cs index 4e1d9781..f4006461 100644 --- a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDataExporterTest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter.Sql.Export; diff --git a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDatabaseAdapterTest.cs index 0a0528c7..4c777f4c 100644 --- a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlDatabaseAdapterTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlWriterTest.cs b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlWriterTest.cs index c5bddbd1..2177a9be 100644 --- a/Sources/SqlDatabase.Adapter.MySql.Test/MySqlWriterTest.cs +++ b/Sources/SqlDatabase.Adapter.MySql.Test/MySqlWriterTest.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.MySql.Test/TextScriptOutputMySqlTest.cs b/Sources/SqlDatabase.Adapter.MySql.Test/TextScriptOutputMySqlTest.cs index 7c2bbf2b..0b73aa24 100644 --- a/Sources/SqlDatabase.Adapter.MySql.Test/TextScriptOutputMySqlTest.cs +++ b/Sources/SqlDatabase.Adapter.MySql.Test/TextScriptOutputMySqlTest.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Moq; +using Moq; using MySqlConnector; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapter.cs b/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapter.cs index 08772aae..18a206cc 100644 --- a/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapter.cs @@ -1,6 +1,4 @@ -using System.Data; -using System.IO; -using MySqlConnector; +using MySqlConnector; namespace SqlDatabase.Adapter.MySql; diff --git a/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapterFactory.cs b/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapterFactory.cs index 9645b99c..787e9330 100644 --- a/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapterFactory.cs +++ b/Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapterFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Data.Common; +using System.Data.Common; using MySqlConnector; namespace SqlDatabase.Adapter.MySql; diff --git a/Sources/SqlDatabase.Adapter.MySql/MySqlTextReader.cs b/Sources/SqlDatabase.Adapter.MySql/MySqlTextReader.cs index d8de984d..d39240a9 100644 --- a/Sources/SqlDatabase.Adapter.MySql/MySqlTextReader.cs +++ b/Sources/SqlDatabase.Adapter.MySql/MySqlTextReader.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace SqlDatabase.Adapter.MySql; diff --git a/Sources/SqlDatabase.Adapter.MySql/MySqlWriter.cs b/Sources/SqlDatabase.Adapter.MySql/MySqlWriter.cs index 9ce1136b..67742b88 100644 --- a/Sources/SqlDatabase.Adapter.MySql/MySqlWriter.cs +++ b/Sources/SqlDatabase.Adapter.MySql/MySqlWriter.cs @@ -1,9 +1,4 @@ -using System; -using System.Data; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; +using System.Globalization; namespace SqlDatabase.Adapter.MySql; diff --git a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDataExporterTest.cs b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDataExporterTest.cs index 45e2909b..2de58af2 100644 --- a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDataExporterTest.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; using System.Dynamic; -using System.IO; -using System.Text; using Moq; using Npgsql; using NpgsqlTypes; diff --git a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDatabaseAdapterTest.cs index 7f9e5895..f99034b5 100644 --- a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlDatabaseAdapterTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlWriterTest.cs b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlWriterTest.cs index 7e4bacfa..02a1f774 100644 --- a/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlWriterTest.cs +++ b/Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlWriterTest.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; using System.Dynamic; -using System.IO; -using System.Text; using NpgsqlTypes; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.PgSql.Test/TextScriptOutputPgSqlTest.cs b/Sources/SqlDatabase.Adapter.PgSql.Test/TextScriptOutputPgSqlTest.cs index 051bb098..407d095b 100644 --- a/Sources/SqlDatabase.Adapter.PgSql.Test/TextScriptOutputPgSqlTest.cs +++ b/Sources/SqlDatabase.Adapter.PgSql.Test/TextScriptOutputPgSqlTest.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Moq; +using Moq; using Npgsql; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapter.cs b/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapter.cs index a82d4ca8..3892b245 100644 --- a/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapter.cs @@ -1,6 +1,4 @@ -using System.Data; -using System.IO; -using Npgsql; +using Npgsql; namespace SqlDatabase.Adapter.PgSql; diff --git a/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapterFactory.cs b/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapterFactory.cs index 15d85c2b..7dc3d357 100644 --- a/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapterFactory.cs +++ b/Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapterFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Data.Common; +using System.Data.Common; using Npgsql; namespace SqlDatabase.Adapter.PgSql; diff --git a/Sources/SqlDatabase.Adapter.PgSql/PgSqlTextReader.cs b/Sources/SqlDatabase.Adapter.PgSql/PgSqlTextReader.cs index ffd84fee..5cac7d50 100644 --- a/Sources/SqlDatabase.Adapter.PgSql/PgSqlTextReader.cs +++ b/Sources/SqlDatabase.Adapter.PgSql/PgSqlTextReader.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace SqlDatabase.Adapter.PgSql; diff --git a/Sources/SqlDatabase.Adapter.PgSql/PgSqlWriter.cs b/Sources/SqlDatabase.Adapter.PgSql/PgSqlWriter.cs index 43c4e283..124f34d1 100644 --- a/Sources/SqlDatabase.Adapter.PgSql/PgSqlWriter.cs +++ b/Sources/SqlDatabase.Adapter.PgSql/PgSqlWriter.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Data; +using System.Collections; using System.Dynamic; using System.Globalization; -using System.IO; -using System.Linq; using System.Reflection; -using System.Text; using NpgsqlTypes; namespace SqlDatabase.Adapter.PgSql; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationInfoTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationInfoTest.cs new file mode 100644 index 00000000..b918e7cb --- /dev/null +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationInfoTest.cs @@ -0,0 +1,62 @@ +using NUnit.Framework; +using Shouldly; + +namespace SqlDatabase.Adapter.PowerShellScripts; + +[TestFixture] +public class InstallationInfoTest +{ + [Test] + [TestCaseSource(nameof(GetSortCases))] + public void Sort(object item1, object item2) + { + var info1 = (InstallationInfo)item1; + var info2 = (InstallationInfo)item2; + + List list = [info1, info2]; + list.Sort(); + list.ShouldBe([info1, info2]); + + list = [info2, info1]; + list.Sort(); + list.ShouldBe([info1, info2]); + } + + private static IEnumerable GetSortCases() + { + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0"), + new InstallationInfo("path", new Version(2, 0), "2.0")) + { + TestName = "1.0 vs 2.0" + }; + + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview"), + new InstallationInfo("path", new Version(1, 0), "1.0")) + { + TestName = "1.0-preview vs 1.0" + }; + + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1")) + { + TestName = "1.0-preview.1 vs 1.0-preview.2" + }; + + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path", new Version(1, 0), "1.0-preview.2")) + { + TestName = "1.0-preview.1 vs 1.0-preview.2" + }; + + yield return new TestCaseData( + new InstallationInfo("path 1", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path 2", new Version(1, 0), "1.0-preview.1")) + { + TestName = "1.0-preview.1 vs 1.0-preview.1" + }; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs index 99329240..09182755 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using Moq; +using System.Reflection; +using System.Runtime.InteropServices; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; @@ -12,10 +9,28 @@ namespace SqlDatabase.Adapter.PowerShellScripts; [TestFixture] public class InstallationSeekerTest { + private HostedRuntime _runtime; + + [OneTimeSetUp] + public void BeforeAllTests() + { +#if NET472 + var version = FrameworkVersion.Net472; +#elif NET6_0 + var version = FrameworkVersion.Net6; +#elif NET7_0 + var version = FrameworkVersion.Net7; +#else + var version = FrameworkVersion.Net8; +#endif + + _runtime = new HostedRuntime(false, RuntimeInformation.IsOSPlatform(OSPlatform.Windows), version); + } + [Test] public void TryFindByParentProcess() { - var actual = InstallationSeeker.TryFindByParentProcess(out var path); + var actual = InstallationSeeker.TryFindByParentProcess(_runtime, out var path); if (actual) { TestOutput.WriteLine(path); @@ -25,11 +40,7 @@ public void TryFindByParentProcess() [Test] public void TryFindOnDisk() { -#if NET472 - Assert.Ignore(); -#endif - - InstallationSeeker.TryFindOnDisk(out var path).ShouldBeTrue(); + InstallationSeeker.TryFindOnDisk(_runtime, out var path).ShouldBe(_runtime.Version != FrameworkVersion.Net472); TestOutput.WriteLine(path); } @@ -43,7 +54,7 @@ public void TryGetInfo() InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); - File.WriteAllText(Path.Combine(dir.Location, "pwsh.dll"), "dummy"); + File.WriteAllText(Path.Combine(dir.Location, InstallationSeeker.PowershellFileName), "dummy"); File.WriteAllText(root, "dummy"); InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); @@ -58,68 +69,4 @@ public void TryGetInfo() actual.ProductVersion.ShouldBe(GetType().Assembly.GetCustomAttribute()!.InformationalVersion); } } - - [Test] - [TestCaseSource(nameof(GetSortInstallationInfoCases))] - public void SortInstallationInfo(object item1, object item2) - { - var info1 = (InstallationInfo)item1; - var info2 = (InstallationInfo)item2; - - var comparer = new Mock>(MockBehavior.Strict); - comparer - .Setup(c => c.Equals(It.IsAny(), It.IsAny())) - .Returns((x, y) => - { - return x.Location.Equals(y.Location, StringComparison.OrdinalIgnoreCase) - && x.Version == y.Version - && x.ProductVersion.Equals(y.ProductVersion, StringComparison.OrdinalIgnoreCase); - }); - - var list = new List { info1, info2 }; - list.Sort(); - list[1].ShouldBe(info2, comparer.Object); - - list = new List { info2, info1 }; - list.Sort(); - list[1].ShouldBe(info2, comparer.Object); - } - - private static IEnumerable GetSortInstallationInfoCases() - { - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0"), - new InstallationInfo("path", new Version(2, 0), "2.0")) - { - TestName = "1.0 vs 2.0" - }; - - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview"), - new InstallationInfo("path", new Version(1, 0), "1.0")) - { - TestName = "1.0-preview vs 1.0" - }; - - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1")) - { - TestName = "1.0-preview.1 vs 1.0-preview.2" - }; - - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path", new Version(1, 0), "1.0-preview.2")) - { - TestName = "1.0-preview.1 vs 1.0-preview.2" - }; - - yield return new TestCaseData( - new InstallationInfo("path 1", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path 2", new Version(1, 0), "1.0-preview.1")) - { - TestName = "1.0-preview.1 vs 1.0-preview.1" - }; - } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellLinuxTest.cs similarity index 58% rename from Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs rename to Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellLinuxTest.cs index bc4bbf79..d2dec536 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellLinuxTest.cs @@ -1,31 +1,21 @@ -using System.Diagnostics; -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.Adapter.PowerShellScripts; [TestFixture] -public class DiagnosticsToolsTest +public class PowerShellLinuxTest { [Test] - public void ParseParentProcessIdLinux() + public void ParseParentProcessId() { const string Content = "43 (dotnet) R 123 43 1 34816 43 4210688 1660 0 1 0 4 1 0 0 20 0 7 0 11192599 2821132288 5836 18446744073709551615 4194304 4261060 140729390742432 0 0 0 0 4096 17630 0 0 0 17 2 0 0 0 0 0 6360360 6362127 11538432 140729390743290 140729390743313 140729390743313 140729390743528 0"; using (var file = new TempFile(".txt")) { File.WriteAllText(file.Location, Content); - DiagnosticsTools.ParseParentProcessIdLinux(file.Location).ShouldBe(123); + PowerShellLinux.ParseParentProcessId(file.Location).ShouldBe(123); } } - -#if !NET472 - [Test] - public void GetParentProcessId() - { - DiagnosticsTools.GetParentProcessId(Process.GetCurrentProcess().Id).ShouldNotBeNull(); - } -#endif } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptFactoryTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptFactoryTest.cs index aae7b12b..3c2dcd73 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptFactoryTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptFactoryTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptTest.cs index f69fa0b8..14fef127 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellScriptTest.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Text; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs index f81d5e89..2bf5aca2 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; +using System.Runtime.InteropServices; using Moq; using NUnit.Framework; using Shouldly; @@ -35,7 +32,19 @@ public void BeforeAllTests() .Setup(l => l.Indent()) .Returns((IDisposable)null!); - _factory = PowerShellFactory.Create(null); +#if NET472 + var version = FrameworkVersion.Net472; +#elif NET6_0 + var version = FrameworkVersion.Net6; +#elif NET7_0 + var version = FrameworkVersion.Net7; +#else + var version = FrameworkVersion.Net8; +#endif + + var runtime = new HostedRuntime(false, RuntimeInformation.IsOSPlatform(OSPlatform.Windows), version); + + _factory = new PowerShellFactory(runtime, null); _factory.Initialize(_logger.Object); } diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellWindowsTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellWindowsTest.cs new file mode 100644 index 00000000..e219a8bf --- /dev/null +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellWindowsTest.cs @@ -0,0 +1,16 @@ +using NUnit.Framework; +using Shouldly; + +namespace SqlDatabase.Adapter.PowerShellScripts; + +[TestFixture] +public class PowerShellWindowsTest +{ + [Test] + public void GetParentProcessId() + { + var processId = Process.GetCurrentProcess().Id; + + PowerShellWindows.GetParentProcessId(processId).ShouldNotBeNull(); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/AllowNullAttribute.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/AllowNullAttribute.cs index 39be8db8..748f77b7 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/AllowNullAttribute.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/AllowNullAttribute.cs @@ -1,8 +1,4 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] -internal sealed class AllowNullAttribute : Attribute -{ -} -#endif \ No newline at end of file +internal sealed class AllowNullAttribute : Attribute; \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/NotNullWhenAttribute.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/NotNullWhenAttribute.cs index e3d56cf7..eec257bb 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/NotNullWhenAttribute.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/CodeAnalysis/NotNullWhenAttribute.cs @@ -1,10 +1,8 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; internal sealed class NotNullWhenAttribute : Attribute { public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; public bool ReturnValue { get; } -} -#endif +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs index 269719e7..24ab9875 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs @@ -1,135 +1,60 @@ -using System; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; internal static class DiagnosticsTools { - public static bool IsOSPlatformWindows() - { -#if NET472 - return true; -#else - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -#endif - } - - public static int? GetParentProcessId(int processId) - { -#if NET472 - return null; -#else - return IsOSPlatformWindows() ? GetParentProcessIdWindows(processId) : GetParentProcessIdLinux(processId); -#endif - } - - internal static int? ParseParentProcessIdLinux(string fileName) + public static string? FindPowerShellProcess(HostedRuntime runtime) { - string? line = null; - - try - { - using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) - using (var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true)) - { - line = reader.ReadLine(); - } - } - catch - { - } - - if (string.IsNullOrWhiteSpace(line)) + if (runtime.Version == FrameworkVersion.Net472) { return null; } - // (2) comm %s: The filename of the executable, in parentheses. - var startIndex = line!.LastIndexOf(')'); - if (startIndex <= 0 || startIndex >= line.Length) + int processId; + DateTime processStartTime; + using (var current = Process.GetCurrentProcess()) { - return null; + processId = current.Id; + processStartTime = current.StartTime; } - // (3) state %c - startIndex = line.IndexOf(' ', startIndex + 1); - if (startIndex <= 0 || startIndex >= line.Length) + return TryParentProcess(runtime, processId, processStartTime); + } + + private static string? TryParentProcess(HostedRuntime runtime, int childId, DateTime processStartTime) + { + var parentId = runtime.IsWindows ? PowerShellWindows.GetParentProcessId(childId) : PowerShellLinux.GetParentProcessId(childId); + if (!parentId.HasValue || parentId == childId) { return null; } - // (4) ppid %d: The PID of the parent of this process. - startIndex = line.IndexOf(' ', startIndex + 1); - if (startIndex <= 0 || startIndex >= line.Length) + string? parentLocation = null; + try { - return null; + using (var parent = Process.GetProcessById(parentId.Value)) + { + if (parent.StartTime < processStartTime) + { + parentLocation = parent.MainModule?.FileName; + } + } } - - var endIndex = line.IndexOf(' ', startIndex + 1); - if (endIndex <= startIndex) + catch { - return null; } - var ppid = line.Substring(startIndex + 1, endIndex - startIndex - 1); - if (int.TryParse(ppid, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) + if (string.IsNullOrWhiteSpace(parentLocation) || !File.Exists(parentLocation)) { - return result; + return null; } - return null; - } - -#if !NET472 - private static int? GetParentProcessIdLinux(int processId) - { - // /proc/[pid]/stat https://man7.org/linux/man-pages/man5/procfs.5.html - var fileName = "/proc/" + processId.ToString(CultureInfo.InvariantCulture) + "/stat"; - - return ParseParentProcessIdLinux(fileName); - } - - private static int? GetParentProcessIdWindows(int processId) - { - const int DesiredAccess = 0x0400; // PROCESS_QUERY_INFORMATION - const int ProcessInfoClass = 0; // ProcessBasicInformation - - int? result = null; - using (var hProcess = OpenProcess(DesiredAccess, false, processId)) + var fileName = Path.GetFileName(parentLocation); + if (!PowerShellWindows.IsExecutable(fileName) && PowerShellLinux.IsExecutable(fileName)) { - if (!hProcess.IsInvalid) - { - var basicInformation = default(ProcessBasicInformation); - var pSize = 0; - var pbiSize = (uint)Marshal.SizeOf(); - - if (NtQueryInformationProcess(hProcess, ProcessInfoClass, ref basicInformation, pbiSize, ref pSize) == 0) - { - result = (int)basicInformation.InheritedFromUniqueProcessId; - } - } + // try parent + return TryParentProcess(runtime, parentId.Value, processStartTime); } - return result; - } - - [DllImport("kernel32.dll", SetLastError = true)] - private static extern Microsoft.Win32.SafeHandles.SafeProcessHandle OpenProcess(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); - - [DllImport("ntdll.dll")] - private static extern int NtQueryInformationProcess(Microsoft.Win32.SafeHandles.SafeProcessHandle hProcess, int pic, ref ProcessBasicInformation pbi, uint cb, ref int pSize); - - [StructLayout(LayoutKind.Sequential)] - private struct ProcessBasicInformation - { - public uint ExitStatus; - public IntPtr PebBaseAddress; - public UIntPtr AffinityMask; - public int BasePriority; - public UIntPtr UniqueProcessId; - public UIntPtr InheritedFromUniqueProcessId; + return Path.GetDirectoryName(parentLocation); } -#endif } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/IPowerShell.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/IPowerShell.cs index 0f3bd82a..46874473 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/IPowerShell.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/IPowerShell.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; internal interface IPowerShell { diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs index b81c8cc0..f629f45f 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs @@ -1,12 +1,9 @@ -using System; -using System.Diagnostics; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; [DebuggerDisplay("{Version}")] -internal readonly struct InstallationInfo : IComparable +internal readonly struct InstallationInfo : IEquatable, IComparable { - public InstallationInfo(string location, Version version, string productVersion) + public InstallationInfo(string location, Version version, string? productVersion) { Location = location; Version = version; @@ -48,8 +45,20 @@ public int CompareTo(InstallationInfo other) return result; } - private bool IsPreview() + public bool Equals(InstallationInfo other) => + StringComparer.InvariantCultureIgnoreCase.Equals(Location, other.Location) + && Version == other.Version + && StringComparer.InvariantCultureIgnoreCase.Equals(ProductVersion, other.ProductVersion); + + public override bool Equals(object? obj) => obj is InstallationInfo other && Equals(other); + + public override int GetHashCode() { - return ProductVersion.IndexOf("preview", StringComparison.OrdinalIgnoreCase) > 0; + var h1 = StringComparer.InvariantCultureIgnoreCase.GetHashCode(Location); + var h2 = StringComparer.InvariantCultureIgnoreCase.GetHashCode(ProductVersion); + var h3 = Version.GetHashCode(); + return h1 + h2 + h3; } + + private bool IsPreview() => ProductVersion.IndexOf("preview", StringComparison.OrdinalIgnoreCase) > 0; } diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs index 989409f3..42194bca 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs @@ -1,36 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.IO; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; internal static class InstallationSeeker { + public const string PowershellFileName = "pwsh.dll"; public const string RootAssemblyName = "System.Management.Automation"; public const string RootAssemblyFileName = RootAssemblyName + ".dll"; - public static bool TryFindByParentProcess([NotNullWhen(true)] out string? installationPath) + public static bool TryFindByParentProcess(HostedRuntime runtime, [NotNullWhen(true)] out string? installationPath) { - int processId; - DateTime processStartTime; - using (var current = Process.GetCurrentProcess()) - { - processId = current.Id; - processStartTime = current.StartTime; - } + installationPath = DiagnosticsTools.FindPowerShellProcess(runtime); - installationPath = FindPowerShellProcess(processId, processStartTime); return !string.IsNullOrEmpty(installationPath) && TryGetInfo(installationPath!, out var info) - && IsCompatibleVersion(info.Version); + && IsCompatibleVersion(runtime.Version, info.Version); } - public static bool TryFindOnDisk([NotNullWhen(true)] out string? installationPath) + public static bool TryFindOnDisk(HostedRuntime runtime, [NotNullWhen(true)] out string? installationPath) { installationPath = null; - var root = GetDefaultInstallationRoot(); + + var root = runtime.IsWindows ? PowerShellWindows.GetInstallationPath() : PowerShellLinux.GetInstallationPath(); if (!Directory.Exists(root)) { return false; @@ -42,7 +31,7 @@ public static bool TryFindOnDisk([NotNullWhen(true)] out string? installationPat for (var i = 0; i < directories.Length; i++) { if (TryGetInfo(directories[i], out var info) - && IsCompatibleVersion(info.Version)) + && IsCompatibleVersion(runtime.Version, info.Version)) { candidates.Add(info); } @@ -63,7 +52,7 @@ public static bool TryGetInfo(string installationPath, out InstallationInfo info info = default; var root = Path.Combine(installationPath, RootAssemblyFileName); - if (!File.Exists(Path.Combine(installationPath, "pwsh.dll")) + if (!File.Exists(Path.Combine(installationPath, PowershellFileName)) || !File.Exists(root)) { return false; @@ -81,68 +70,23 @@ public static bool TryGetInfo(string installationPath, out InstallationInfo info return true; } - private static string? FindPowerShellProcess(int processId, DateTime processStartTime) + private static bool IsCompatibleVersion(FrameworkVersion runtimeVersion, Version version) { - var parentId = DiagnosticsTools.GetParentProcessId(processId); - if (!parentId.HasValue || parentId == processId) - { - return null; - } - - string? parentLocation = null; - try - { - using (var parent = Process.GetProcessById(parentId.Value)) - { - if (parent.StartTime < processStartTime) - { - parentLocation = parent.MainModule?.FileName; - } - } - } - catch + if (runtimeVersion == FrameworkVersion.Net8) { + return version < new Version("7.5"); } - if (string.IsNullOrWhiteSpace(parentLocation) || !File.Exists(parentLocation)) + if (runtimeVersion == FrameworkVersion.Net7) { - return null; + return version < new Version("7.4"); } - var fileName = Path.GetFileName(parentLocation); - if (!"pwsh.exe".Equals(fileName, StringComparison.OrdinalIgnoreCase) && !"pwsh".Equals(fileName, StringComparison.OrdinalIgnoreCase)) - { - // try parent - return FindPowerShellProcess(parentId.Value, processStartTime); - } - - return Path.GetDirectoryName(parentLocation); - } - - private static string GetDefaultInstallationRoot() - { - if (DiagnosticsTools.IsOSPlatformWindows()) + if (runtimeVersion == FrameworkVersion.Net6) { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell"); + return version < new Version("7.3"); } - return "/opt/microsoft/powershell"; - } - - private static bool IsCompatibleVersion(Version version) - { -#if NET8_0 - return version < new Version("7.5"); -#elif NET7_0 - return version < new Version("7.4"); -#elif NET6_0 - return version < new Version("7.3"); -#elif NET5_0 - return version < new Version("7.2"); -#elif NETCOREAPP3_1_OR_GREATER - return version < new Version("7.1"); -#else return false; -#endif } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs index f7885734..2700f42c 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs @@ -1,12 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Management.Automation; +using System.Management.Automation; using System.Management.Automation.Runspaces; namespace SqlDatabase.Adapter.PowerShellScripts; internal sealed class PowerShell : IPowerShell { + private readonly FrameworkVersion _version; + + public PowerShell(FrameworkVersion version) + { + _version = version; + } + public bool SupportsShouldProcess(string script) { var attributes = ScriptBlock.Create(script).Attributes; @@ -30,7 +35,7 @@ public void Invoke(string script, ILogger logger, params KeyValuePair>(); + + method(installationPath); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs index 3d9761ce..c7b8f7c1 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs @@ -1,22 +1,24 @@ -using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Loader; namespace SqlDatabase.Adapter.PowerShellScripts; -internal sealed partial class PowerShellFactory : IPowerShellFactory +// https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell +internal sealed class PowerShellFactory : IPowerShellFactory { + private static string? _initializedInstallationPath; private bool _initialized; - private PowerShellFactory(string? installationPath) + public PowerShellFactory(HostedRuntime runtime, string? installationPath) { + Runtime = runtime; InstallationPath = installationPath; } - public string? InstallationPath { get; private set; } + public HostedRuntime Runtime { get; } - public static IPowerShellFactory Create(string? installationPath) - { - return new PowerShellFactory(installationPath); - } + public string? InstallationPath { get; private set; } public void Initialize(ILogger logger) { @@ -26,7 +28,11 @@ public void Initialize(ILogger logger) } _initialized = true; - DoInitialize(logger); + + if (!Runtime.IsPowershell && Runtime.Version != FrameworkVersion.Net472) + { + InitializePowerShellAssemblyLoadContext(logger); + } } public IPowerShell Create() @@ -36,8 +42,98 @@ public IPowerShell Create() throw new InvalidOperationException("PowerShell host is not initialized."); } - return new PowerShell(); + return new PowerShell(Runtime.Version); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private void InitializePowerShellAssemblyLoadContext(ILogger logger) + { + if (string.IsNullOrEmpty(InstallationPath)) + { + if (InstallationSeeker.TryFindByParentProcess(Runtime, out var test)) + { + InstallationPath = test; + } + else if (InstallationSeeker.TryFindOnDisk(Runtime, out test)) + { + InstallationPath = test; + } + } + + if (string.IsNullOrEmpty(InstallationPath)) + { + throw new InvalidOperationException("PowerShell Core installation not found, please provide installation path via command line options -usePowerShell."); + } + + if (!InstallationSeeker.TryGetInfo(InstallationPath!, out var info)) + { + throw new InvalidOperationException($"PowerShell Core installation not found in {InstallationPath}."); + } + + logger.Info($"host PowerShell from {InstallationPath}, version {info.ProductVersion}"); + + Func assemblyResolver = AssemblyResolving; + AssemblyLoadContext.Default.Resolving += assemblyResolver; + try + { + Test(logger); + } + catch (Exception ex) + { + throw new InvalidOperationException($"PowerShell host {InstallationPath} initialization failed. Try to use another PowerShell Core installation.", ex); + } + finally + { + AssemblyLoadContext.Default.Resolving -= assemblyResolver; + } + } + + private void Test(ILogger logger) + { + SetPowerShellAssemblyLoadContext(); + + using (logger.Indent()) + { + const string Script = @" +Write-Host ""PSVersion:"" $PSVersionTable.PSVersion +Write-Host ""PSEdition:"" $PSVersionTable.PSEdition +Write-Host ""OS:"" $PSVersionTable.OS"; + + Create().Invoke(Script, logger); + } } - partial void DoInitialize(ILogger logger); + private Assembly? AssemblyResolving(AssemblyLoadContext context, AssemblyName assemblyName) + { + if (InstallationSeeker.RootAssemblyName.Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase)) + { + var fileName = Path.Combine(InstallationPath!, InstallationSeeker.RootAssemblyFileName); + return context.LoadFromAssemblyPath(fileName); + } + + // https://github.com/PowerShell/PowerShell/releases/download/v7.0.5/powershell_7.0.5-1.debian.10_amd64.deb + // Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. + // package contains Microsoft.Management.Infrastructure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null + if ("Microsoft.Management.Infrastructure".Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase)) + { + var fileName = Path.Combine(InstallationPath!, assemblyName.Name + ".dll"); + if (File.Exists(fileName)) + { + return context.LoadFromAssemblyPath(fileName); + } + } + + return null; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private void SetPowerShellAssemblyLoadContext() + { + // The singleton of PowerShellAssemblyLoadContext has already been initialized + if (_initializedInstallationPath == null || !_initializedInstallationPath.Equals(InstallationPath, StringComparison.OrdinalIgnoreCase)) + { + PowerShellAssemblyLoadContextInitializerAdapter.SetPowerShellAssemblyLoadContext(InstallationPath!); + _initializedInstallationPath = InstallationPath; + } + } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs deleted file mode 100644 index ef3d7c27..00000000 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs +++ /dev/null @@ -1,106 +0,0 @@ -#if NET5_0_OR_GREATER -using System; -using System.IO; -using System.Management.Automation; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Loader; - -namespace SqlDatabase.Adapter.PowerShellScripts; - -// https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell -internal partial class PowerShellFactory -{ - private static string? _initializedInstallationPath; - - partial void DoInitialize(ILogger logger) - { - if (string.IsNullOrEmpty(InstallationPath)) - { - if (InstallationSeeker.TryFindByParentProcess(out var test)) - { - InstallationPath = test; - } - else if (InstallationSeeker.TryFindOnDisk(out test)) - { - InstallationPath = test; - } - } - - if (string.IsNullOrEmpty(InstallationPath)) - { - throw new InvalidOperationException("PowerShell Core installation not found, please provide installation path via command line options -usePowerShell."); - } - - if (!InstallationSeeker.TryGetInfo(InstallationPath, out var info)) - { - throw new InvalidOperationException($"PowerShell Core installation not found in {InstallationPath}."); - } - - logger.Info($"host PowerShell from {InstallationPath}, version {info.ProductVersion}"); - - AssemblyLoadContext.Default.Resolving += AssemblyResolving; - try - { - Test(logger); - } - catch (Exception ex) - { - throw new InvalidOperationException("PowerShell host initialization failed. Try to use another PowerShell Core installation.", ex); - } - finally - { - AssemblyLoadContext.Default.Resolving -= AssemblyResolving; - } - } - - private void Test(ILogger logger) - { - SetPowerShellAssemblyLoadContext(); - - using (logger.Indent()) - { - const string Script = @" -Write-Host ""PSVersion:"" $PSVersionTable.PSVersion -Write-Host ""PSEdition:"" $PSVersionTable.PSEdition -Write-Host ""OS:"" $PSVersionTable.OS"; - - Create().Invoke(Script, logger); - } - } - - private Assembly? AssemblyResolving(AssemblyLoadContext context, AssemblyName assemblyName) - { - if (InstallationSeeker.RootAssemblyName.Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase)) - { - var fileName = Path.Combine(InstallationPath!, InstallationSeeker.RootAssemblyFileName); - return context.LoadFromAssemblyPath(fileName); - } - - // https://github.com/PowerShell/PowerShell/releases/download/v7.0.5/powershell_7.0.5-1.debian.10_amd64.deb - // Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. - // package contains Microsoft.Management.Infrastructure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null - if ("Microsoft.Management.Infrastructure".Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase)) - { - var fileName = Path.Combine(InstallationPath!, assemblyName.Name + ".dll"); - if (File.Exists(fileName)) - { - return context.LoadFromAssemblyPath(fileName); - } - } - - return null; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private void SetPowerShellAssemblyLoadContext() - { - // The singleton of PowerShellAssemblyLoadContext has already been initialized - if (_initializedInstallationPath == null || !_initializedInstallationPath.Equals(InstallationPath, StringComparison.OrdinalIgnoreCase)) - { - PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(InstallationPath); - _initializedInstallationPath = InstallationPath; - } - } -} -#endif \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.native.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.native.cs deleted file mode 100644 index 8f2bb9fe..00000000 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.native.cs +++ /dev/null @@ -1,7 +0,0 @@ -#if NET472 || NETSTANDARD -namespace SqlDatabase.Adapter.PowerShellScripts; - -internal partial class PowerShellFactory -{ -} -#endif \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellLinux.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellLinux.cs new file mode 100644 index 00000000..7d599248 --- /dev/null +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellLinux.cs @@ -0,0 +1,75 @@ +using System.Globalization; + +namespace SqlDatabase.Adapter.PowerShellScripts; + +internal static class PowerShellLinux +{ + public static string GetInstallationPath() => "/opt/microsoft/powershell"; + + public static bool IsExecutable(string fileName) => "pwsh".Equals(fileName, StringComparison.OrdinalIgnoreCase); + + public static int? GetParentProcessId(int processId) + { + // /proc/[pid]/stat https://man7.org/linux/man-pages/man5/procfs.5.html + var fileName = "/proc/" + processId.ToString(CultureInfo.InvariantCulture) + "/stat"; + + return ParseParentProcessId(fileName); + } + + internal static int? ParseParentProcessId(string fileName) + { + string? line = null; + + try + { + using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) + using (var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true)) + { + line = reader.ReadLine(); + } + } + catch + { + } + + if (string.IsNullOrWhiteSpace(line)) + { + return null; + } + + // (2) comm %s: The filename of the executable, in parentheses. + var startIndex = line!.LastIndexOf(')'); + if (startIndex <= 0 || startIndex >= line.Length) + { + return null; + } + + // (3) state %c + startIndex = line.IndexOf(' ', startIndex + 1); + if (startIndex <= 0 || startIndex >= line.Length) + { + return null; + } + + // (4) ppid %d: The PID of the parent of this process. + startIndex = line.IndexOf(' ', startIndex + 1); + if (startIndex <= 0 || startIndex >= line.Length) + { + return null; + } + + var endIndex = line.IndexOf(' ', startIndex + 1); + if (endIndex <= startIndex) + { + return null; + } + + var ppid = line.Substring(startIndex + 1, endIndex - startIndex - 1); + if (int.TryParse(ppid, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) + { + return result; + } + + return null; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScript.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScript.cs index b42800ec..0cf77f02 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScript.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScript.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; internal sealed class PowerShellScript : IScript { diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs index 1f9cae8c..63e5055e 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Adapter.PowerShellScripts; @@ -9,8 +6,8 @@ public sealed class PowerShellScriptFactory : IScriptFactory, IScriptEnvironment { private readonly IPowerShellFactory _powerShell; - public PowerShellScriptFactory(string? installationPath) - : this(PowerShellFactory.Create(installationPath)) + public PowerShellScriptFactory(HostedRuntime runtime, string? installationPath) + : this(new PowerShellFactory(runtime, installationPath)) { } @@ -19,38 +16,29 @@ internal PowerShellScriptFactory(IPowerShellFactory powerShell) _powerShell = powerShell; } - public bool IsSupported(IFile file) - { - return ".ps1".Equals(file.Extension, StringComparison.OrdinalIgnoreCase); - } + public bool IsSupported(IFile file) => ".ps1".Equals(file.Extension, StringComparison.OrdinalIgnoreCase); - public IScript FromFile(IFile file) - { - return new PowerShellScript( - file.Name, - file.OpenRead, - CreateScriptDescriptionReader(file), - _powerShell); - } + public IScript FromFile(IFile file) => new PowerShellScript( + file.Name, + file.OpenRead, + CreateScriptDescriptionReader(file), + _powerShell); public bool IsSupported(IScript script) => script is PowerShellScript; public void Initialize(ILogger logger) => _powerShell.Initialize(logger); - private static Func CreateScriptDescriptionReader(IFile file) + private static Func CreateScriptDescriptionReader(IFile file) => () => { - return () => + var parent = file.GetParent(); + if (parent == null) { - var parent = file.GetParent(); - if (parent == null) - { - return null; - } + return null; + } - var descriptionName = Path.GetFileNameWithoutExtension(file.Name) + ".txt"; - var description = parent.GetFiles().FirstOrDefault(i => string.Equals(descriptionName, i.Name, StringComparison.OrdinalIgnoreCase)); + var descriptionName = Path.GetFileNameWithoutExtension(file.Name) + ".txt"; + var description = parent.GetFiles().FirstOrDefault(i => string.Equals(descriptionName, i.Name, StringComparison.OrdinalIgnoreCase)); - return description?.OpenRead(); - }; - } + return description?.OpenRead(); + }; } \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs index 86b1164c..969d754e 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; using System.Management.Automation; namespace SqlDatabase.Adapter.PowerShellScripts; @@ -10,12 +9,12 @@ internal sealed class PowerShellStreamsListener : IDisposable private readonly ILogger _logger; private readonly IList _information; - public PowerShellStreamsListener(PSDataStreams streams, ILogger logger) + public PowerShellStreamsListener(PSDataStreams streams, FrameworkVersion version, ILogger logger) { _streams = streams; _logger = logger; - _information = GetInformation(streams); + _information = version == FrameworkVersion.Net472 ? ReflectionGetInformation(streams) : streams.Information; InvokeDataAdded(_information, OnInformation, true); streams.Verbose.DataAdded += OnVerbose; @@ -33,15 +32,6 @@ public void Dispose() InvokeDataAdded(_information, OnInformation, false); } - private static IList GetInformation(PSDataStreams streams) - { -#if !NET472 - return streams.Information; -#else - return ReflectionGetInformation(streams); -#endif - } - private static IList ReflectionGetInformation(PSDataStreams streams) { return (IList)streams @@ -58,11 +48,11 @@ private static void InvokeDataAdded(object dataCollection, EventHandler Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell"); + + public static bool IsExecutable(string fileName) => "pwsh.exe".Equals(fileName, StringComparison.OrdinalIgnoreCase); + + public static int? GetParentProcessId(int processId) + { + const int DesiredAccess = 0x0400; // PROCESS_QUERY_INFORMATION + const int ProcessInfoClass = 0; // ProcessBasicInformation + + int? result = null; + using (var hProcess = OpenProcess(DesiredAccess, false, processId)) + { + if (!hProcess.IsInvalid) + { + var basicInformation = default(ProcessBasicInformation); + var pSize = 0; + var pbiSize = (uint)Marshal.SizeOf(); + + if (NtQueryInformationProcess(hProcess, ProcessInfoClass, ref basicInformation, pbiSize, ref pSize) == 0) + { + result = (int)basicInformation.InheritedFromUniqueProcessId; + } + } + } + + return result; + } + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern Microsoft.Win32.SafeHandles.SafeProcessHandle OpenProcess(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); + + [DllImport("ntdll.dll")] + private static extern int NtQueryInformationProcess(Microsoft.Win32.SafeHandles.SafeProcessHandle hProcess, int pic, ref ProcessBasicInformation pbi, uint cb, ref int pSize); + + [StructLayout(LayoutKind.Sequential)] + private struct ProcessBasicInformation + { + public uint ExitStatus; + public IntPtr PebBaseAddress; + public UIntPtr AffinityMask; + public int BasePriority; + public UIntPtr UniqueProcessId; + public UIntPtr InheritedFromUniqueProcessId; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs index de42ed57..786b000b 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.Adapter.PowerShellScripts; @@ -16,6 +15,42 @@ public static PropertyInfo FindProperty(this Type type, string name) return result; } + public static MethodInfo FindStaticMethod(this Type type, string name, params Type[] parameters) + { + var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); + for (var i = 0; i < methods.Length; i++) + { + var method = methods[i]; + if (!name.Equals(method.Name, StringComparison.Ordinal)) + { + continue; + } + + var input = method.GetParameters(); + if (input.Length != parameters.Length) + { + continue; + } + + var inputMatch = true; + for (var j = 0; j < parameters.Length; j++) + { + if (parameters[i] != input[i].ParameterType) + { + inputMatch = false; + break; + } + } + + if (inputMatch) + { + return method; + } + } + + throw new InvalidOperationException($"public static {name} not found in {type.FullName}."); + } + public static EventInfo FindEvent(this Type type, string name) { var result = type.GetEvent(name, BindingFlags.Public | BindingFlags.Instance); diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj b/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj index d7b2f9c1..8ce5fa20 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj @@ -1,19 +1,12 @@  - net472;net6.0;net7.0;net8.0;netstandard2.0 + netstandard2.0 - - - - - - - - - - + + + diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/VariablesProxy.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/VariablesProxy.cs index 126d2d53..282dffb8 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/VariablesProxy.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/VariablesProxy.cs @@ -1,5 +1,4 @@ -using System.Diagnostics.CodeAnalysis; -using System.Dynamic; +using System.Dynamic; namespace SqlDatabase.Adapter.PowerShellScripts; diff --git a/Sources/SqlDatabase.Adapter.Sql.Test/Export/DataExportLoggerTest.cs b/Sources/SqlDatabase.Adapter.Sql.Test/Export/DataExportLoggerTest.cs index 9879b9fd..f0bcfe09 100644 --- a/Sources/SqlDatabase.Adapter.Sql.Test/Export/DataExportLoggerTest.cs +++ b/Sources/SqlDatabase.Adapter.Sql.Test/Export/DataExportLoggerTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.Sql.Test/SqlScriptVariableParserTest.cs b/Sources/SqlDatabase.Adapter.Sql.Test/SqlScriptVariableParserTest.cs index 460f74b1..97912f3e 100644 --- a/Sources/SqlDatabase.Adapter.Sql.Test/SqlScriptVariableParserTest.cs +++ b/Sources/SqlDatabase.Adapter.Sql.Test/SqlScriptVariableParserTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.Sql.Test/TextScriptTest.cs b/Sources/SqlDatabase.Adapter.Sql.Test/TextScriptTest.cs index 60c0e49e..2ef5c17d 100644 --- a/Sources/SqlDatabase.Adapter.Sql.Test/TextScriptTest.cs +++ b/Sources/SqlDatabase.Adapter.Sql.Test/TextScriptTest.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Linq; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.Sql/Export/DataExportLogger.cs b/Sources/SqlDatabase.Adapter.Sql/Export/DataExportLogger.cs index 6869d2fa..225845b7 100644 --- a/Sources/SqlDatabase.Adapter.Sql/Export/DataExportLogger.cs +++ b/Sources/SqlDatabase.Adapter.Sql/Export/DataExportLogger.cs @@ -1,8 +1,4 @@ -using System; -using System.IO; -using System.Text; - -namespace SqlDatabase.Adapter.Sql.Export; +namespace SqlDatabase.Adapter.Sql.Export; public sealed class DataExportLogger : ILogger { diff --git a/Sources/SqlDatabase.Adapter.Sql/Export/DataExporter.cs b/Sources/SqlDatabase.Adapter.Sql/Export/DataExporter.cs index d5e78033..83aef727 100644 --- a/Sources/SqlDatabase.Adapter.Sql/Export/DataExporter.cs +++ b/Sources/SqlDatabase.Adapter.Sql/Export/DataExporter.cs @@ -1,6 +1,4 @@ -using System.Data; - -namespace SqlDatabase.Adapter.Sql.Export; +namespace SqlDatabase.Adapter.Sql.Export; public sealed class DataExporter : IDataExporter { diff --git a/Sources/SqlDatabase.Adapter.Sql/Export/IDataExporter.cs b/Sources/SqlDatabase.Adapter.Sql/Export/IDataExporter.cs index dce30582..88d0bd8d 100644 --- a/Sources/SqlDatabase.Adapter.Sql/Export/IDataExporter.cs +++ b/Sources/SqlDatabase.Adapter.Sql/Export/IDataExporter.cs @@ -1,6 +1,4 @@ -using System.Data; - -namespace SqlDatabase.Adapter.Sql.Export; +namespace SqlDatabase.Adapter.Sql.Export; public interface IDataExporter { diff --git a/Sources/SqlDatabase.Adapter.Sql/SqlScriptVariableParser.cs b/Sources/SqlDatabase.Adapter.Sql/SqlScriptVariableParser.cs index 1c491d63..c7dba0e7 100644 --- a/Sources/SqlDatabase.Adapter.Sql/SqlScriptVariableParser.cs +++ b/Sources/SqlDatabase.Adapter.Sql/SqlScriptVariableParser.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace SqlDatabase.Adapter.Sql; diff --git a/Sources/SqlDatabase.Adapter.Sql/TextScript.cs b/Sources/SqlDatabase.Adapter.Sql/TextScript.cs index e0c96e6f..c5197921 100644 --- a/Sources/SqlDatabase.Adapter.Sql/TextScript.cs +++ b/Sources/SqlDatabase.Adapter.Sql/TextScript.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Globalization; -using System.IO; -using System.Linq; +using System.Globalization; namespace SqlDatabase.Adapter.Sql; diff --git a/Sources/SqlDatabase.Adapter.Sql/TextScriptFactory.cs b/Sources/SqlDatabase.Adapter.Sql/TextScriptFactory.cs index dd02563b..e54dc01b 100644 --- a/Sources/SqlDatabase.Adapter.Sql/TextScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.Sql/TextScriptFactory.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Adapter.Sql; diff --git a/Sources/SqlDatabase.Adapter/DataReaderTools.cs b/Sources/SqlDatabase.Adapter/DataReaderTools.cs index 6a5c845c..f64e4d10 100644 --- a/Sources/SqlDatabase.Adapter/DataReaderTools.cs +++ b/Sources/SqlDatabase.Adapter/DataReaderTools.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public static class DataReaderTools { diff --git a/Sources/SqlDatabase.Adapter/ExportTable.cs b/Sources/SqlDatabase.Adapter/ExportTable.cs index e80e4323..8716b6ce 100644 --- a/Sources/SqlDatabase.Adapter/ExportTable.cs +++ b/Sources/SqlDatabase.Adapter/ExportTable.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public sealed class ExportTable { diff --git a/Sources/SqlDatabase.Adapter/HostedRuntime.cs b/Sources/SqlDatabase.Adapter/HostedRuntime.cs new file mode 100644 index 00000000..6c21b75e --- /dev/null +++ b/Sources/SqlDatabase.Adapter/HostedRuntime.cs @@ -0,0 +1,25 @@ +namespace SqlDatabase.Adapter; + +public enum FrameworkVersion +{ + Net472, + Net6, + Net7, + Net8 +} + +public readonly struct HostedRuntime +{ + public HostedRuntime(bool isPowershell, bool isWindows, FrameworkVersion version) + { + IsPowershell = isPowershell; + IsWindows = isWindows; + Version = version; + } + + public bool IsPowershell { get; } + + public bool IsWindows { get; } + + public FrameworkVersion Version { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Adapter/IDatabaseAdapter.cs b/Sources/SqlDatabase.Adapter/IDatabaseAdapter.cs index 4d45dfab..b06ec19e 100644 --- a/Sources/SqlDatabase.Adapter/IDatabaseAdapter.cs +++ b/Sources/SqlDatabase.Adapter/IDatabaseAdapter.cs @@ -1,7 +1,4 @@ -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public interface IDatabaseAdapter { diff --git a/Sources/SqlDatabase.Adapter/ILogger.cs b/Sources/SqlDatabase.Adapter/ILogger.cs index bbc101a6..d23023f8 100644 --- a/Sources/SqlDatabase.Adapter/ILogger.cs +++ b/Sources/SqlDatabase.Adapter/ILogger.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public interface ILogger { diff --git a/Sources/SqlDatabase.Adapter/IScript.cs b/Sources/SqlDatabase.Adapter/IScript.cs index e842c882..aaadbef0 100644 --- a/Sources/SqlDatabase.Adapter/IScript.cs +++ b/Sources/SqlDatabase.Adapter/IScript.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public interface IScript { diff --git a/Sources/SqlDatabase.Adapter/ISqlTextReader.cs b/Sources/SqlDatabase.Adapter/ISqlTextReader.cs index a4e6aa77..18ef91f5 100644 --- a/Sources/SqlDatabase.Adapter/ISqlTextReader.cs +++ b/Sources/SqlDatabase.Adapter/ISqlTextReader.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.IO; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public interface ISqlTextReader { diff --git a/Sources/SqlDatabase.Adapter/LoggerExtensions.cs b/Sources/SqlDatabase.Adapter/LoggerExtensions.cs index a126501a..a0b6bbda 100644 --- a/Sources/SqlDatabase.Adapter/LoggerExtensions.cs +++ b/Sources/SqlDatabase.Adapter/LoggerExtensions.cs @@ -1,7 +1,4 @@ -using System; -using System.Text; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public static class LoggerExtensions { diff --git a/Sources/SqlDatabase.Adapter/SqlWriterBase.cs b/Sources/SqlDatabase.Adapter/SqlWriterBase.cs index f0f911e2..b04b4ac5 100644 --- a/Sources/SqlDatabase.Adapter/SqlWriterBase.cs +++ b/Sources/SqlDatabase.Adapter/SqlWriterBase.cs @@ -1,8 +1,4 @@ -using System; -using System.Data; -using System.IO; - -namespace SqlDatabase.Adapter; +namespace SqlDatabase.Adapter; public abstract class SqlWriterBase : IDisposable { diff --git a/Sources/SqlDatabase/Configuration/TransactionMode.cs b/Sources/SqlDatabase.Adapter/TransactionMode.cs similarity index 57% rename from Sources/SqlDatabase/Configuration/TransactionMode.cs rename to Sources/SqlDatabase.Adapter/TransactionMode.cs index c816290f..a0f7a1ab 100644 --- a/Sources/SqlDatabase/Configuration/TransactionMode.cs +++ b/Sources/SqlDatabase.Adapter/TransactionMode.cs @@ -1,4 +1,4 @@ -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Adapter; public enum TransactionMode { diff --git a/Sources/SqlDatabase.CommandLine.Test/CommandLineParserTest.cs b/Sources/SqlDatabase.CommandLine.Test/CommandLineParserTest.cs new file mode 100644 index 00000000..59ed5b75 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine.Test/CommandLineParserTest.cs @@ -0,0 +1,149 @@ +using NUnit.Framework; +using Shouldly; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine.Internal; + +namespace SqlDatabase.CommandLine; + +[TestFixture] +public class CommandLineParserTest +{ + private readonly HostedRuntime _testRuntime = new(false, false, FrameworkVersion.Net8); + + [Test] + [TestCase("", null, true)] + [TestCase("-help", null, true)] + [TestCase("create", "create", true)] + [TestCase("export -h", "export", true)] + [TestCase("execute -help", "execute", true)] + [TestCase("Upgrade -arg1 -arg2", "Upgrade", false)] + [TestCase("Upgrade -help -arg1 -arg2", "Upgrade", false)] + public void HelpRequested(string args, string? expectedCommand, bool expectedHelp) + { + CommandLineParser.HelpRequested(args.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), out var actualCommand).ShouldBe(expectedHelp); + + actualCommand.ShouldBe(expectedCommand); + } + + [Test] + public void ParseCreateCommand() + { + var args = ToArgs( + "create", + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), + new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("whatIf", null)); + + var actual = CommandLineParser.Parse(_testRuntime, args).ShouldBeOfType(); + + actual.From.ShouldBe([new(false, @"c:\folder")]); + + actual.Database.ShouldBe("Data Source=.;Initial Catalog=test"); + + actual.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + actual.Variables["x"].ShouldBe("1 2 3"); + actual.Variables["y"].ShouldBe("value"); + + actual.Configuration.ShouldBe("app.config"); + actual.UsePowerShell.ShouldBe(@"c:\PowerShell"); + actual.WhatIf.ShouldBeTrue(); + } + + [Test] + public void ParseExecuteCommand() + { + var args = ToArgs( + "execute", + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("fromSql", "drop 1"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), + new Arg("transaction", "perStep"), + new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("whatIf", null)); + + var actual = CommandLineParser.Parse(_testRuntime, args).ShouldBeOfType(); + + actual.From.Count.ShouldBe(2); + actual.From[0].ShouldBe(new(false, @"c:\folder")); + actual.From[1].ShouldBe(new(true, "drop 1")); + + actual.Database.ShouldBe("Data Source=.;Initial Catalog=test"); + + actual.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + actual.Variables["x"].ShouldBe("1 2 3"); + actual.Variables["y"].ShouldBe("value"); + + actual.Configuration.ShouldBe("app.config"); + actual.Transaction.ShouldBe(TransactionMode.PerStep); + actual.UsePowerShell.ShouldBe(@"c:\PowerShell"); + actual.WhatIf.ShouldBeTrue(); + } + + [Test] + public void ParseUpgradeCommand() + { + var args = ToArgs( + "upgrade", + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), + new Arg("transaction", "perStep"), + new Arg("folderAsModuleName", null), + new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("whatIf", null)); + + var actual = CommandLineParser.Parse(_testRuntime, args).ShouldBeOfType(); + + actual.From.ShouldBe([new(false, @"c:\folder")]); + + actual.Database.ShouldBe("Data Source=.;Initial Catalog=test"); + + actual.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + actual.Variables["x"].ShouldBe("1 2 3"); + actual.Variables["y"].ShouldBe("value"); + + actual.Configuration.ShouldBe("app.config"); + actual.Transaction.ShouldBe(TransactionMode.PerStep); + actual.UsePowerShell.ShouldBe(@"c:\PowerShell"); + actual.WhatIf.ShouldBeTrue(); + actual.FolderAsModuleName.ShouldBeTrue(); + } + + [Test] + public void ParseExportCommand() + { + var args = ToArgs( + "export", + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("fromSql", "select 1"), + new Arg("from", @"c:\folder"), + new Arg("toTable", "dbo.ExportedData"), + new Arg("toFile", "file path")); + + var actual = CommandLineParser.Parse(_testRuntime, args).ShouldBeOfType(); + + actual.From.Count.ShouldBe(2); + actual.From[0].ShouldBe(new(true, "select 1")); + actual.From[1].ShouldBe(new(false, @"c:\folder")); + + actual.Database.ShouldBe("Data Source=.;Initial Catalog=test"); + actual.DestinationTableName.ShouldBe("dbo.ExportedData"); + actual.DestinationFileName.ShouldBe("file path"); + } + + private static string[] ToArgs(string command, params Arg[] args) + { + var result = new List(args.Length + 1) { command }; + result.AddRange(args.Select(i => '-' + i.ToString())); + return result.ToArray(); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine.Test/Internal/ArgTest.cs b/Sources/SqlDatabase.CommandLine.Test/Internal/ArgTest.cs new file mode 100644 index 00000000..a1f8b4e5 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine.Test/Internal/ArgTest.cs @@ -0,0 +1,27 @@ +using NUnit.Framework; +using Shouldly; + +namespace SqlDatabase.CommandLine.Internal; + +[TestFixture] +public class ArgTest +{ + [Test] + [TestCase("command", null, null)] + [TestCase("-", null, null)] + [TestCase("-=", null, null)] + [TestCase("-arg", "arg", null)] + [TestCase("-arg =", "arg", null)] + [TestCase("-arg = ", "arg", null)] + [TestCase("-arg= value", "arg", "value")] + public void TryParse(string value, string? expectedKey, string? expectedValue) + { + Arg.TryParse(value, out var actual).ShouldBe(expectedKey != null); + + if (expectedKey != null) + { + actual.Key.ShouldBe(expectedKey); + actual.Value.ShouldBe(expectedValue); + } + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine.Test/SqlDatabase.CommandLine.Test.csproj b/Sources/SqlDatabase.CommandLine.Test/SqlDatabase.CommandLine.Test.csproj new file mode 100644 index 00000000..b05987bf --- /dev/null +++ b/Sources/SqlDatabase.CommandLine.Test/SqlDatabase.CommandLine.Test.csproj @@ -0,0 +1,19 @@ + + + + net472;net6.0;net7.0;net8.0 + SqlDatabase.CommandLine + + + + + + + + + + + + + + diff --git a/Sources/SqlDatabase.CommandLine/CodeAnalysis/AllowNullAttribute.cs b/Sources/SqlDatabase.CommandLine/CodeAnalysis/AllowNullAttribute.cs new file mode 100644 index 00000000..748f77b7 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/CodeAnalysis/AllowNullAttribute.cs @@ -0,0 +1,4 @@ +namespace System.Diagnostics.CodeAnalysis; + +[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] +internal sealed class AllowNullAttribute : Attribute; \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/CodeAnalysis/NotNullWhenAttribute.cs b/Sources/SqlDatabase.CommandLine/CodeAnalysis/NotNullWhenAttribute.cs new file mode 100644 index 00000000..eec257bb --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/CodeAnalysis/NotNullWhenAttribute.cs @@ -0,0 +1,8 @@ +namespace System.Diagnostics.CodeAnalysis; + +internal sealed class NotNullWhenAttribute : Attribute +{ + public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; + + public bool ReturnValue { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/CommandLineParser.cs b/Sources/SqlDatabase.CommandLine/CommandLineParser.cs new file mode 100644 index 00000000..403b63e3 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/CommandLineParser.cs @@ -0,0 +1,157 @@ +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine.Internal; + +namespace SqlDatabase.CommandLine; + +public static class CommandLineParser +{ + private const string CommandUpgrade = "Upgrade"; + private const string CommandCreate = "Create"; + private const string CommandExecute = "Execute"; + private const string CommandExport = "Export"; + + public static bool HelpRequested(string[] args, out string? command) + { + command = null; + + if (args.Length == 0) + { + return true; + } + + // -h + // execute + // execute -h + if (args.Length == 1) + { + if (IsHelpArg(args[0])) + { + return true; + } + + return IsCommand(args[0], out command); + } + + if (!IsCommand(args[0], out command)) + { + return false; + } + + return IsHelpArg(args[1]) && args.Length == 2; + } + + public static ICommandLine Parse(HostedRuntime runtime, string[] args) + { + if (Arg.TryParse(args[0], out _)) + { + throw new InvalidCommandLineException(" not found."); + } + + var command = args[0]; + var commandArgs = args.Skip(1); + + if (CommandCreate.Equals(command, StringComparison.OrdinalIgnoreCase)) + { + return ParseCreate(runtime, commandArgs); + } + + if (CommandExecute.Equals(command, StringComparison.OrdinalIgnoreCase)) + { + return ParseExecute(runtime, commandArgs); + } + + if (CommandUpgrade.Equals(command, StringComparison.OrdinalIgnoreCase)) + { + return ParseUpgrade(runtime, commandArgs); + } + + if (CommandExport.Equals(command, StringComparison.OrdinalIgnoreCase)) + { + return ParseExport(commandArgs); + } + + throw new InvalidCommandLineException($"Unknown command [{args[0]}]."); + } + + public static void AddVariable(Dictionary target, string nameValue) + { + if (!Arg.TryParse(ArgNames.Sign + nameValue, out var arg)) + { + throw new InvalidCommandLineException($"Invalid variable value definition [{nameValue}]."); + } + + if (target.ContainsKey(arg.Key)) + { + throw new InvalidCommandLineException($"Variable [{arg.Key}] is duplicated."); + } + + target.Add(arg.Key, arg.Value ?? string.Empty); + } + + private static bool IsCommand(string value, out string? command) + { + if (CommandUpgrade.Equals(value, StringComparison.OrdinalIgnoreCase) + || CommandCreate.Equals(value, StringComparison.OrdinalIgnoreCase) + || CommandExecute.Equals(value, StringComparison.OrdinalIgnoreCase) + || CommandExport.Equals(value, StringComparison.OrdinalIgnoreCase)) + { + command = value; + return true; + } + + command = null; + return false; + } + + private static bool IsHelpArg(string value) => + Arg.TryParse(value, out var arg) + && arg.Value == null + && (arg.Is(ArgNames.Help) || arg.Is(ArgNames.HelpShort)); + + private static CreateCommandLine ParseCreate(HostedRuntime runtime, IEnumerable args) => + new CommandLineBinder(new()) + .BindDatabase((i, value) => i.Database = value) + .BindScripts(i => i.From) + .BindVariables(i => i.Variables) + .BindConfiguration((i, value) => i.Configuration = value) + .BindLog((i, value) => i.Log = value) + .BindUsePowerShell(runtime, (i, value) => i.UsePowerShell = value) + .BindWhatIf((i, value) => i.WhatIf = value) + .Build(args); + + private static ExecuteCommandLine ParseExecute(HostedRuntime runtime, IEnumerable args) => + new CommandLineBinder(new()) + .BindDatabase((i, value) => i.Database = value) + .BindScripts(i => i.From) + .BindTransaction((i, value) => i.Transaction = value) + .BindVariables(i => i.Variables) + .BindConfiguration((i, value) => i.Configuration = value) + .BindLog((i, value) => i.Log = value) + .BindUsePowerShell(runtime, (i, value) => i.UsePowerShell = value) + .BindWhatIf((i, value) => i.WhatIf = value) + .Build(args); + + private static UpgradeCommandLine ParseUpgrade(HostedRuntime runtime, IEnumerable args) => + new CommandLineBinder(new()) + .BindDatabase((i, value) => i.Database = value) + .BindScripts(i => i.From) + .BindTransaction((i, value) => i.Transaction = value) + .BindVariables(i => i.Variables) + .BindConfiguration((i, value) => i.Configuration = value) + .BindLog((i, value) => i.Log = value) + .BindUsePowerShell(runtime, (i, value) => i.UsePowerShell = value) + .BindWhatIf((i, value) => i.WhatIf = value) + .BindFolderAsModuleName((i, value) => i.FolderAsModuleName = value) + .Build(args); + + private static ExportCommandLine ParseExport(IEnumerable args) => + new CommandLineBinder(new()) + .BindDatabase((i, value) => i.Database = value) + .BindScripts(i => i.From) + .BindExportToTable((i, value) => i.DestinationTableName = value) + .BindExportToFile((i, value) => i.DestinationFileName = value) + .BindVariables(i => i.Variables) + .BindConfiguration((i, value) => i.Configuration = value) + .BindLog((i, value) => i.Log = value) + .Build(args); +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/CreateCommandLine.cs b/Sources/SqlDatabase.CommandLine/CreateCommandLine.cs new file mode 100644 index 00000000..69f9da65 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/CreateCommandLine.cs @@ -0,0 +1,18 @@ +namespace SqlDatabase.CommandLine; + +public sealed class CreateCommandLine : ICommandLine +{ + public string Database { get; set; } = string.Empty; + + public List From { get; } = new(); + + public Dictionary Variables { get; } = new(StringComparer.OrdinalIgnoreCase); + + public string? Configuration { get; set; } + + public string? Log { get; set; } + + public string? UsePowerShell { get; set; } + + public bool WhatIf { get; set; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/ExecuteCommandLine.cs b/Sources/SqlDatabase.CommandLine/ExecuteCommandLine.cs new file mode 100644 index 00000000..67e003fd --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/ExecuteCommandLine.cs @@ -0,0 +1,22 @@ +using SqlDatabase.Adapter; + +namespace SqlDatabase.CommandLine; + +public sealed class ExecuteCommandLine : ICommandLine +{ + public string Database { get; set; } = string.Empty; + + public List From { get; } = new(); + + public TransactionMode Transaction { get; set; } + + public Dictionary Variables { get; } = new(StringComparer.OrdinalIgnoreCase); + + public string? Configuration { get; set; } + + public string? Log { get; set; } + + public string? UsePowerShell { get; set; } + + public bool WhatIf { get; set; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/ExportCommandLine.cs b/Sources/SqlDatabase.CommandLine/ExportCommandLine.cs new file mode 100644 index 00000000..c192d0d0 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/ExportCommandLine.cs @@ -0,0 +1,18 @@ +namespace SqlDatabase.CommandLine; + +public sealed class ExportCommandLine : ICommandLine +{ + public string Database { get; set; } = string.Empty; + + public List From { get; } = new(); + + public string? DestinationTableName { get; set; } + + public string? DestinationFileName { get; set; } + + public Dictionary Variables { get; } = new(StringComparer.OrdinalIgnoreCase); + + public string? Configuration { get; set; } + + public string? Log { get; set; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/ICommandLine.cs b/Sources/SqlDatabase.CommandLine/ICommandLine.cs new file mode 100644 index 00000000..6b21bab9 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/ICommandLine.cs @@ -0,0 +1,6 @@ +namespace SqlDatabase.CommandLine; + +public interface ICommandLine +{ + string? Log { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/Arg.cs b/Sources/SqlDatabase.CommandLine/Internal/Arg.cs new file mode 100644 index 00000000..70f86231 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/Arg.cs @@ -0,0 +1,56 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal readonly struct Arg +{ + public Arg(string key, string? value) + { + Key = key; + Value = value; + } + + public string Key { get; } + + public string? Value { get; } + + public static bool TryParse(string? value, out Arg result) + { + value = value?.Trim(); + result = default; + + if (value == null || value.Length < 2 || value[0] != ArgNames.Sign) + { + return false; + } + + value = value.Substring(1); + + var index = value.IndexOf(ArgNames.Separator); + if (index < 0) + { + result = new Arg(value, null); + return true; + } + + if (index == 0) + { + return false; + } + + var key = value.Substring(0, index).Trim(); + value = index == value.Length - 1 ? null : value.Substring(index + 1).Trim(); + result = new Arg(key, string.IsNullOrEmpty(value) ? null : value); + return true; + } + + public bool Is(string key) => Key.Equals(key, StringComparison.OrdinalIgnoreCase); + + public override string ToString() + { + if (Value != null) + { + return $"{Key}={Value}"; + } + + return Key; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/Arg.cs b/Sources/SqlDatabase.CommandLine/Internal/ArgNames.cs similarity index 51% rename from Sources/SqlDatabase/Configuration/Arg.cs rename to Sources/SqlDatabase.CommandLine/Internal/ArgNames.cs index 8be89428..34d7097b 100644 --- a/Sources/SqlDatabase/Configuration/Arg.cs +++ b/Sources/SqlDatabase.CommandLine/Internal/ArgNames.cs @@ -1,11 +1,15 @@ -namespace SqlDatabase.Configuration; +namespace SqlDatabase.CommandLine.Internal; -internal readonly struct Arg +internal static class ArgNames { - internal const string Sign = "-"; + internal const char Sign = '-'; + internal const char Separator = '='; + + internal const string Help = "help"; + internal const string HelpShort = "h"; internal const string Database = "database"; - internal const string Scripts = "from"; + internal const string Script = "from"; internal const string InLineScript = "fromSql"; internal const string Variable = "var"; internal const string Configuration = "configuration"; @@ -17,38 +21,5 @@ internal readonly struct Arg internal const string ExportToTable = "toTable"; internal const string ExportToFile = "toFile"; - internal const string Help = "help"; - internal const string HelpShort = "h"; - internal const string Log = "log"; - - public Arg(string key, string? value) - { - IsPair = true; - Key = key; - Value = value; - } - - public Arg(string value) - { - IsPair = false; - Key = null; - Value = value; - } - - public bool IsPair { get; } - - public string? Key { get; } - - public string? Value { get; } - - public override string? ToString() - { - if (IsPair) - { - return $"{Key}={Value}"; - } - - return Value; - } } \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinder.cs new file mode 100644 index 00000000..cb95ef84 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinder.cs @@ -0,0 +1,67 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class CommandLineBinder +{ + private readonly List> _binders; + private readonly TCommand _command; + + public CommandLineBinder(TCommand command) + { + _command = command; + _binders = new(); + } + + public void AddBinder(IArgBinder binder) => _binders.Add(binder); + + public TCommand Build(IEnumerable args) + { + foreach (var value in args) + { + if (!Arg.TryParse(value, out var arg)) + { + throw new InvalidCommandLineException($"Invalid option [{value}]."); + } + + if (!TryFindBinder(arg, out var binder)) + { + throw new InvalidCommandLineException($"Unknown option [{arg.Key}]."); + } + + if (binder.IsDuplicated(_command, arg)) + { + throw new InvalidCommandLineException($"Option [{arg.Key}] is duplicated."); + } + + if (!binder.TryBind(_command, arg)) + { + throw new InvalidCommandLineException($"Fail to parse option [{value}]."); + } + } + + for (var i = 0; i < _binders.Count; i++) + { + var binder = _binders[i]; + if (!binder.IsAssigned(_command, out var key)) + { + throw new InvalidOperationException($"Option {key} is not specified."); + } + } + + return _command; + } + + private bool TryFindBinder(Arg arg, [NotNullWhen(true)] out IArgBinder? binder) + { + for (var i = 0; i < _binders.Count; i++) + { + binder = _binders[i]; + if (binder.Match(arg)) + { + return true; + } + } + + binder = null; + return false; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinderExtensions.cs b/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinderExtensions.cs new file mode 100644 index 00000000..dd4cea16 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/CommandLineBinderExtensions.cs @@ -0,0 +1,76 @@ +using SqlDatabase.Adapter; + +namespace SqlDatabase.CommandLine.Internal; + +internal static class CommandLineBinderExtensions +{ + public static CommandLineBinder BindDatabase(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new StringArgBinder(ArgNames.Database, setter, true)); + return binder; + } + + public static CommandLineBinder BindScripts(this CommandLineBinder binder, Func> getter) + { + binder.AddBinder(new ScriptSourceArgBinder(getter)); + return binder; + } + + public static CommandLineBinder BindVariables(this CommandLineBinder binder, Func> getter) + { + binder.AddBinder(new VariableArgBinder(getter)); + return binder; + } + + public static CommandLineBinder BindConfiguration(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new StringArgBinder(ArgNames.Configuration, setter, false)); + return binder; + } + + public static CommandLineBinder BindLog(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new StringArgBinder(ArgNames.Log, setter, false)); + return binder; + } + + public static CommandLineBinder BindUsePowerShell(this CommandLineBinder binder, HostedRuntime runtime, Action setter) + { + if (!runtime.IsPowershell && runtime.Version != FrameworkVersion.Net472) + { + binder.AddBinder(new StringArgBinder(ArgNames.UsePowerShell, setter, false)); + } + + return binder; + } + + public static CommandLineBinder BindWhatIf(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new SwitchArgBinder(ArgNames.WhatIf, setter)); + return binder; + } + + public static CommandLineBinder BindTransaction(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new EnumArgBinder(ArgNames.Transaction, setter)); + return binder; + } + + public static CommandLineBinder BindFolderAsModuleName(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new SwitchArgBinder(ArgNames.FolderAsModuleName, setter)); + return binder; + } + + public static CommandLineBinder BindExportToTable(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new StringArgBinder(ArgNames.ExportToTable, setter, false)); + return binder; + } + + public static CommandLineBinder BindExportToFile(this CommandLineBinder binder, Action setter) + { + binder.AddBinder(new StringArgBinder(ArgNames.ExportToFile, setter, false)); + return binder; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/EnumArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/EnumArgBinder.cs new file mode 100644 index 00000000..db2c54ad --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/EnumArgBinder.cs @@ -0,0 +1,37 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class EnumArgBinder : IArgBinder + where TEnum : struct +{ + private readonly string _key; + private readonly Action _setter; + private bool _isAssigned; + + public EnumArgBinder(string key, Action setter) + { + _key = key; + _setter = setter; + } + + public bool Match(Arg arg) => arg.Is(_key); + + public bool IsDuplicated(TCommand command, Arg arg) => _isAssigned; + + public bool TryBind(TCommand command, Arg arg) + { + if (string.IsNullOrEmpty(arg.Value) || !Enum.TryParse(arg.Value, true, out var value)) + { + return false; + } + + _isAssigned = true; + _setter(command, value); + return true; + } + + public bool IsAssigned(TCommand command, out string key) + { + key = _key; + return true; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/IArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/IArgBinder.cs new file mode 100644 index 00000000..bd8242cf --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/IArgBinder.cs @@ -0,0 +1,12 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal interface IArgBinder +{ + bool Match(Arg arg); + + bool IsDuplicated(TCommand command, Arg arg); + + bool TryBind(TCommand command, Arg arg); + + bool IsAssigned(TCommand command, [NotNullWhen(false)] out string? key); +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/ScriptSourceArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/ScriptSourceArgBinder.cs new file mode 100644 index 00000000..86e0a47e --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/ScriptSourceArgBinder.cs @@ -0,0 +1,31 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class ScriptSourceArgBinder : IArgBinder +{ + private readonly Func> _getter; + + public ScriptSourceArgBinder(Func> getter) + { + _getter = getter; + } + + public bool Match(Arg arg) => arg.Is(ArgNames.Script) || arg.Is(ArgNames.InLineScript); + + public bool IsDuplicated(TCommand command, Arg arg) => false; + + public bool TryBind(TCommand command, Arg arg) + { + if (!string.IsNullOrEmpty(arg.Value)) + { + _getter(command).Add(new ScriptSource(arg.Is(ArgNames.InLineScript), arg.Value!)); + } + + return true; + } + + public bool IsAssigned(TCommand command, out string key) + { + key = ArgNames.Script; + return _getter(command).Count > 0; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/StringArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/StringArgBinder.cs new file mode 100644 index 00000000..6b373892 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/StringArgBinder.cs @@ -0,0 +1,38 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class StringArgBinder : IArgBinder +{ + private readonly string _key; + private readonly Action _setter; + private readonly bool _required; + private bool _isAssigned; + + public StringArgBinder(string key, Action setter, bool required) + { + _key = key; + _setter = setter; + _required = required; + } + + public bool Match(Arg arg) => arg.Is(_key); + + public bool IsDuplicated(TCommand command, Arg arg) => _isAssigned; + + public bool TryBind(TCommand command, Arg arg) + { + if (string.IsNullOrEmpty(arg.Value)) + { + return false; + } + + _isAssigned = true; + _setter(command, arg.Value!); + return true; + } + + public bool IsAssigned(TCommand command, out string key) + { + key = _key; + return !_required || _isAssigned; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/SwitchArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/SwitchArgBinder.cs new file mode 100644 index 00000000..56d4cfee --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/SwitchArgBinder.cs @@ -0,0 +1,37 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class SwitchArgBinder : IArgBinder +{ + private readonly string _key; + private readonly Action _setter; + private bool _isAssigned; + + public SwitchArgBinder(string key, Action setter) + { + _key = key; + _setter = setter; + } + + public bool Match(Arg arg) => arg.Is(_key); + + public bool IsDuplicated(TCommand command, Arg arg) => _isAssigned; + + public bool TryBind(TCommand command, Arg arg) + { + var value = true; + if (!string.IsNullOrEmpty(arg.Value) && !bool.TryParse(arg.Value, out value)) + { + return false; + } + + _isAssigned = true; + _setter(command, value); + return true; + } + + public bool IsAssigned(TCommand command, out string key) + { + key = _key; + return true; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Internal/VariableArgBinder.cs b/Sources/SqlDatabase.CommandLine/Internal/VariableArgBinder.cs new file mode 100644 index 00000000..9cf6090d --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Internal/VariableArgBinder.cs @@ -0,0 +1,31 @@ +namespace SqlDatabase.CommandLine.Internal; + +internal sealed class VariableArgBinder : IArgBinder +{ + private readonly Func> _getter; + + public VariableArgBinder(Func> getter) + { + _getter = getter; + } + + public bool Match(Arg arg) => + arg.Key.StartsWith(ArgNames.Variable, StringComparison.OrdinalIgnoreCase) && arg.Key.Length > ArgNames.Variable.Length; + + public bool IsDuplicated(TCommand command, Arg arg) => + _getter(command).ContainsKey(GetVarName(arg.Key)); + + public bool TryBind(TCommand command, Arg arg) + { + _getter(command).Add(GetVarName(arg.Key), arg.Value ?? string.Empty); + return true; + } + + public bool IsAssigned(TCommand command, out string key) + { + key = string.Empty; + return true; + } + + private static string GetVarName(string key) => key.Substring(ArgNames.Variable.Length); +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/InvalidCommandLineException.cs b/Sources/SqlDatabase.CommandLine/InvalidCommandLineException.cs new file mode 100644 index 00000000..49ee567f --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/InvalidCommandLineException.cs @@ -0,0 +1,18 @@ +namespace SqlDatabase.CommandLine; + +public sealed class InvalidCommandLineException : SystemException +{ + public InvalidCommandLineException() + { + } + + public InvalidCommandLineException(string message) + : base(message) + { + } + + public InvalidCommandLineException(string message, Exception inner) + : base(message, inner) + { + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/Properties/AssemblyInfo.cs b/Sources/SqlDatabase.CommandLine/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..79c2eb54 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("SqlDatabase.CommandLine.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010055AB0DC1F8A24FB41E7358B65A606EC92141F1ABAFBFF062635AB5FAEB22308CFFBC8B54F3436694F14F6FD6C145D4F16C13A3E739FFCA837902BB78E2D51B890D964CC7384C2CC6B844AE37323F501F29E3EDC2DFADA82C99F5FBB5197ED757D795C2E5408DCB3FBAF9DDDF39E60B137ED0A23603A361EA811E6ADB605DFECC")] \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/ScriptSource.cs b/Sources/SqlDatabase.CommandLine/ScriptSource.cs new file mode 100644 index 00000000..be5c3d78 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/ScriptSource.cs @@ -0,0 +1,23 @@ +namespace SqlDatabase.CommandLine; + +public readonly struct ScriptSource : IEquatable +{ + public ScriptSource(bool isInline, string value) + { + IsInline = isInline; + Value = value; + } + + public bool IsInline { get; } + + public string Value { get; } + + public bool Equals(ScriptSource other) => + IsInline == other.IsInline && string.Equals(Value, other.Value, StringComparison.Ordinal); + + public override bool Equals(object? obj) => obj is ScriptSource other && Equals(other); + + public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(Value); + + public override string ToString() => Value; +} \ No newline at end of file diff --git a/Sources/SqlDatabase.CommandLine/SqlDatabase.CommandLine.csproj b/Sources/SqlDatabase.CommandLine/SqlDatabase.CommandLine.csproj new file mode 100644 index 00000000..dfc4d620 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/SqlDatabase.CommandLine.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/Sources/SqlDatabase.CommandLine/UpgradeCommandLine.cs b/Sources/SqlDatabase.CommandLine/UpgradeCommandLine.cs new file mode 100644 index 00000000..c4faa936 --- /dev/null +++ b/Sources/SqlDatabase.CommandLine/UpgradeCommandLine.cs @@ -0,0 +1,24 @@ +using SqlDatabase.Adapter; + +namespace SqlDatabase.CommandLine; + +public sealed class UpgradeCommandLine : ICommandLine +{ + public string Database { get; set; } = string.Empty; + + public List From { get; } = new(); + + public TransactionMode Transaction { get; set; } + + public Dictionary Variables { get; } = new(StringComparer.OrdinalIgnoreCase); + + public string? Configuration { get; set; } + + public string? Log { get; set; } + + public string? UsePowerShell { get; set; } + + public bool WhatIf { get; set; } + + public bool FolderAsModuleName { get; set; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs index 7098185d..4763cc84 100644 --- a/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs +++ b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs @@ -1,6 +1,7 @@ -using System.IO; +using Moq; using NUnit.Framework; using Shouldly; +using SqlDatabase.FileSystem; using SqlDatabase.TestApi; namespace SqlDatabase.Configuration; @@ -14,53 +15,51 @@ public class ConfigurationManagerTest "; - private TempDirectory _temp = null!; + private Mock _fileSystem = null!; private ConfigurationManager _sut = null!; [SetUp] public void BeforeEachTest() { - _temp = new TempDirectory(); - _sut = new ConfigurationManager(); - } - - [TearDown] - public void AfterEachTest() - { - _temp.Dispose(); + _fileSystem = new Mock(MockBehavior.Strict); + _sut = new ConfigurationManager(_fileSystem.Object); } [Test] - public void LoadFromCurrentConfiguration() + public void LoadFromDefaultConfiguration() { - _sut.LoadFrom((string?)null); + var actual = _sut.LoadFrom(null); - _sut.SqlDatabase.ShouldNotBeNull(); - _sut.SqlDatabase.Variables.Keys.ShouldBe(new[] { nameof(ConfigurationManagerTest) }); - _sut.SqlDatabase.Variables[nameof(ConfigurationManagerTest)].ShouldBe(nameof(LoadFromCurrentConfiguration)); + actual.Variables.Keys.ShouldBe(new[] { nameof(ConfigurationManagerTest) }); + actual.Variables[nameof(ConfigurationManagerTest)].ShouldBe("LoadFromCurrentConfiguration"); } [Test] public void LoadFromEmptyFile() { - var fileName = Path.Combine(_temp.Location, "app.config"); - File.WriteAllText(fileName, ""); + const string FileName = "app.config"; - _sut.LoadFrom(fileName); + _fileSystem + .Setup(f => f.FileSystemInfoFromPath(FileName)) + .Returns(FileFactory.File(FileName, "")); - _sut.SqlDatabase.ShouldNotBeNull(); + var actual = _sut.LoadFrom(FileName); + + actual.ShouldNotBeNull(); } [Test] public void LoadFromFile() { - var fileName = Path.Combine(_temp.Location, "app.config"); - File.WriteAllText(fileName, SomeConfiguration); + const string FileName = "app.config"; + + _fileSystem + .Setup(f => f.FileSystemInfoFromPath(FileName)) + .Returns(FileFactory.File(FileName, SomeConfiguration)); - _sut.LoadFrom(fileName); + var actual = _sut.LoadFrom(FileName); - _sut.SqlDatabase.ShouldNotBeNull(); - _sut.SqlDatabase.GetCurrentVersionScript.ShouldBe("expected"); + actual.GetCurrentVersionScript.ShouldBe("expected"); } [Test] @@ -68,34 +67,40 @@ public void LoadFromFile() [TestCase(ConfigurationManager.Name2)] public void LoadFromDirectory(string fileName) { - File.WriteAllText(Path.Combine(_temp.Location, fileName), SomeConfiguration); + const string DirectoryName = "some/path"; - _sut.LoadFrom(_temp.Location); + _fileSystem + .Setup(f => f.FileSystemInfoFromPath(DirectoryName)) + .Returns(FileFactory.Folder( + "path", + FileFactory.File(fileName, SomeConfiguration))); - _sut.SqlDatabase.ShouldNotBeNull(); - _sut.SqlDatabase.GetCurrentVersionScript.ShouldBe("expected"); + var actual = _sut.LoadFrom(DirectoryName); + + actual.GetCurrentVersionScript.ShouldBe("expected"); } [Test] public void NotFoundInDirectory() { - Assert.Throws(() => _sut.LoadFrom(_temp.Location)); - } + const string DirectoryName = "some/path"; - [Test] - public void FileNotFound() - { - var fileName = Path.Combine(_temp.Location, "app.config"); + _fileSystem + .Setup(f => f.FileSystemInfoFromPath(DirectoryName)) + .Returns(FileFactory.Folder("path")); - Assert.Throws(() => _sut.LoadFrom(fileName)); + Assert.Throws(() => _sut.LoadFrom(DirectoryName)); } [Test] public void LoadInvalidConfiguration() { - var fileName = Path.Combine(_temp.Location, "app.config"); - File.WriteAllText(fileName, ""); + const string FileName = "app.config"; + + _fileSystem + .Setup(f => f.FileSystemInfoFromPath(FileName)) + .Returns(FileFactory.File(FileName, "")); - Assert.Throws(() => _sut.LoadFrom(fileName)); + Assert.Throws(() => _sut.LoadFrom(FileName)); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Configuration/AppConfiguration.cs b/Sources/SqlDatabase.Configuration/AppConfiguration.cs index 30a37c5f..124bdf7a 100644 --- a/Sources/SqlDatabase.Configuration/AppConfiguration.cs +++ b/Sources/SqlDatabase.Configuration/AppConfiguration.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; public sealed class AppConfiguration { diff --git a/Sources/SqlDatabase.Configuration/ConfigurationErrorsException.cs b/Sources/SqlDatabase.Configuration/ConfigurationErrorsException.cs index bdc00ae7..f63813b0 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationErrorsException.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationErrorsException.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; public sealed class ConfigurationErrorsException : ApplicationException { diff --git a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs index f687c454..ff63d160 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs @@ -1,73 +1,66 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Configuration; -public sealed class ConfigurationManager : IConfigurationManager +public sealed class ConfigurationManager { internal const string Name1 = "SqlDatabase.exe.config"; internal const string Name2 = "SqlDatabase.dll.config"; - public AppConfiguration SqlDatabase { get; private set; } = null!; + private readonly IFileSystemFactory _fileSystem; - public static string ResolveDefaultConfigurationFile(string probingPath) + public ConfigurationManager(IFileSystemFactory fileSystem) { - var fileName = ResolveConfigurationFile(probingPath).Name; - return Path.Combine(probingPath, fileName); + _fileSystem = fileSystem; } - public void LoadFrom(string? configurationFile) + public static string GetDefaultConfigurationFile() => GetDefaultFile().GetFullName(); + + public AppConfiguration LoadFrom(string? configurationFile) { - IFile source; - if (string.IsNullOrWhiteSpace(configurationFile)) - { - source = ResolveConfigurationFile(Path.GetDirectoryName(GetType().Assembly.Location)); - } - else - { - source = ResolveConfigurationFile(configurationFile!); - } + var source = string.IsNullOrWhiteSpace(configurationFile) ? GetDefaultFile() : GetFile(_fileSystem, configurationFile); try { using (var stream = source.OpenRead()) { - SqlDatabase = ConfigurationReader.Read(stream); + return ConfigurationReader.Read(stream); } } - catch (Exception ex) when ((ex as IOException) == null) + catch (Exception ex) when (ex is not IOException) { throw new ConfigurationErrorsException($"Fail to load configuration from [{configurationFile}].", ex); } } - private static IFile ResolveConfigurationFile(string probingPath) + private static IFile GetDefaultFile() { - var info = FileSystemFactory.FileSystemInfoFromPath(probingPath); - return ResolveFile(info); + var fileSystem = new FileSystemFactory(Path.GetDirectoryName(typeof(ConfigurationManager).Assembly.Location)!); + return GetFile(fileSystem, null); } - private static IFile ResolveFile(IFileSystemInfo info) + private static IFile GetFile(IFileSystemFactory fileSystem, string? configurationFile) { - IFile? file; - if (info is IFolder folder) + var location = fileSystem.FileSystemInfoFromPath(configurationFile); + if (location is IFile file) { - file = folder - .GetFiles() - .Where(i => Name1.Equals(i.Name, StringComparison.OrdinalIgnoreCase) || Name2.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) - .OrderByDescending(i => i.Name, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - - if (file == null) - { - throw new FileNotFoundException($"Configuration file {Name2} not found in {info.Name}."); - } + return file; } - else + + return FindFile((IFolder)location); + } + + private static IFile FindFile(IFolder folder) + { + var file = folder + .GetFiles() + .Where(i => Name1.Equals(i.Name, StringComparison.OrdinalIgnoreCase) || Name2.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) + .OrderByDescending(i => i.Name, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + + if (file == null) { - file = (IFile)info; + throw new FileNotFoundException($"Configuration file {Name2} not found in {folder.GetFullName()}."); } return file; diff --git a/Sources/SqlDatabase.Configuration/ConfigurationReader.cs b/Sources/SqlDatabase.Configuration/ConfigurationReader.cs index b728ee18..4350c76f 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationReader.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationReader.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Xml; +using System.Xml; namespace SqlDatabase.Configuration; diff --git a/Sources/SqlDatabase.Configuration/DatabaseConfiguration.cs b/Sources/SqlDatabase.Configuration/DatabaseConfiguration.cs index 33891f8b..7982a46e 100644 --- a/Sources/SqlDatabase.Configuration/DatabaseConfiguration.cs +++ b/Sources/SqlDatabase.Configuration/DatabaseConfiguration.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; public sealed class DatabaseConfiguration { diff --git a/Sources/SqlDatabase.Configuration/IConfigurationManager.cs b/Sources/SqlDatabase.Configuration/IConfigurationManager.cs deleted file mode 100644 index 2bd67569..00000000 --- a/Sources/SqlDatabase.Configuration/IConfigurationManager.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SqlDatabase.Configuration; - -public interface IConfigurationManager -{ - AppConfiguration SqlDatabase { get; } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs index c15a81c8..70c7b2c1 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs @@ -1,6 +1,5 @@ -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.FileSystem; @@ -8,14 +7,44 @@ namespace SqlDatabase.FileSystem; [TestFixture] public class FileSystemFactoryTest { + private TempDirectory _location = null!; + private FileSystemFactory _sut = null!; + + [SetUp] + public void BeforeEachTest() + { + _location = new TempDirectory(); + _sut = new FileSystemFactory(_location.Location); + } + + [TearDown] + public void AfterEachTest() + { + _location.Dispose(); + } + [Test] - public void NewFileSystemFolder() + public void FileSystemFolderFromFullPath() { - using (var dir = new TempDirectory("Content.zip")) - { - var folder = FileSystemFactory.FileSystemInfoFromPath(dir.Location); - Assert.IsInstanceOf(folder); - } + var actual = _sut.FileSystemInfoFromPath(_location.Location).ShouldBeOfType(); + actual.GetFullName().ShouldBe(_location.Location); + } + + [Test] + public void FileSystemFolderFromCurrentDirectory() + { + var actual = _sut.FileSystemInfoFromPath(null).ShouldBeOfType(); + actual.GetFullName().ShouldBe(_location.Location); + } + + [Test] + public void FileSystemFolderFromChildDirectory() + { + var path = Path.Combine(_location.Location, "child.zip"); + Directory.CreateDirectory(path); + + var actual = _sut.FileSystemInfoFromPath("child.zip").ShouldBeOfType(); + actual.GetFullName().ShouldBe(path); } [Test] @@ -24,21 +53,20 @@ public void NewFileSystemFolder() [TestCase(@"Content.zip\2\2.2", "2.2.txt")] [TestCase(@"Content.zip\inner.zip", "11.txt")] [TestCase(@"Content.zip\inner.zip\2", "22.txt")] - public void NewZipFolder(string path, string fileName) + public void ZipFolderFromFullPath(string path, string? fileName) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + _location.CopyFileFromResources("Content.zip"); - var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); - Assert.IsNotNull(folder); + var folder = _sut + .FileSystemInfoFromPath(Path.Combine(_location.Location, path)) + .ShouldBeAssignableTo() + .ShouldNotBeNull(); - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - Assert.AreEqual(1, files.Count); - Assert.AreEqual(fileName, files[0].Name); - } + var files = folder.GetFiles().ToList(); + if (fileName != null) + { + files.Count.ShouldBe(1); + files[0].Name.ShouldBe(fileName); } } @@ -46,22 +74,21 @@ public void NewZipFolder(string path, string fileName) [TestCase("Content.nupkg", null)] [TestCase(@"Content.nupkg\2", "22.txt")] [TestCase(@"Content.nupkg\inner.zip", "11.txt")] - public void NewNuGetFolder(string path, string fileName) + public void NuGetFolderFromChildPath(string path, string? fileName) { - using (var dir = new TempDirectory()) + _location.CopyFileFromResources("Content.zip"); + File.Move(Path.Combine(_location.Location, "Content.zip"), Path.Combine(_location.Location, "Content.nupkg")); + + var folder = _sut + .FileSystemInfoFromPath(path) + .ShouldBeAssignableTo() + .ShouldNotBeNull(); + + var files = folder.GetFiles().ToList(); + if (fileName != null) { - dir.CopyFileFromResources("Content.zip"); - File.Move(Path.Combine(dir.Location, "Content.zip"), Path.Combine(dir.Location, "Content.nupkg")); - - var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); - Assert.IsNotNull(folder); - - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - Assert.AreEqual(1, files.Count); - Assert.AreEqual(fileName, files[0].Name); - } + files.Count.ShouldBe(1); + files[0].Name.ShouldBe(fileName); } } @@ -71,7 +98,7 @@ public void NewNuGetFolder(string path, string fileName) [TestCase(@"c:\{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}\11")] public void NotFound(string path) { - Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(path)); + Assert.Throws(() => _sut.FileSystemInfoFromPath(path)); } [Test] @@ -81,42 +108,74 @@ public void NotFound(string path) [TestCase(@"Content.zip\inner.zip\xxx")] public void ZipNotFound(string path) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + _location.CopyFileFromResources("Content.zip"); - var fullPath = Path.Combine(dir.Location, path); - Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); - } + var fullPath = Path.Combine(_location.Location, path); + Should.Throw(() => _sut.FileSystemInfoFromPath(fullPath)); + + Should.Throw(() => _sut.FileSystemInfoFromPath(path)); } [Test] - public void NewFileSystemFile() + public void FileFromFullPath() { - using (var dir = new TempDirectory()) - { - var fileName = Path.Combine(dir.Location, "11.txt"); - File.WriteAllBytes(fileName, new byte[] { 1 }); + var fileName = Path.Combine(_location.Location, "11.txt"); + File.WriteAllBytes(fileName, [1]); - var file = FileSystemFactory.FileSystemInfoFromPath(fileName); - Assert.IsInstanceOf(file); - } + var actual = _sut.FileSystemInfoFromPath(fileName).ShouldBeOfType(); + + actual.GetFullName().ShouldBe(fileName); + } + + [Test] + public void FileFromChildPath() + { + var fileName = Path.Combine(_location.Location, "11.txt"); + File.WriteAllBytes(fileName, [1]); + + var actual = _sut.FileSystemInfoFromPath("11.txt").ShouldBeOfType(); + + actual.GetFullName().ShouldBe(fileName); + } + + [Test] + [TestCase("Content.zip/11.txt")] + [TestCase("Content.zip/2/22.txt")] + [TestCase("Content.zip/inner.zip/11.txt")] + public void ZipFileFromFullPath(string fileName) + { + _location.CopyFileFromResources("Content.zip"); + + var fullName = Path.Combine(_location.Location, fileName); + + var actual = _sut.FileSystemInfoFromPath(fullName).ShouldBeOfType(); + actual.ShouldBeOfType(); + + AssertFullName(actual.GetFullName(), fullName); + actual.OpenRead().Dispose(); } [Test] [TestCase(@"Content.zip\11.txt")] [TestCase(@"Content.zip\2\22.txt")] [TestCase(@"Content.zip\inner.zip\11.txt")] - public void NewZipFile(string fileName) + public void ZipFileFromChildPath(string fileName) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + _location.CopyFileFromResources("Content.zip"); - var file = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, fileName)); - Assert.IsInstanceOf(file); + var fullName = Path.Combine(_location.Location, fileName); - ((IFile)file).OpenRead().Dispose(); - } + var actual = _sut.FileSystemInfoFromPath(fileName).ShouldBeOfType(); + actual.ShouldBeOfType(); + + AssertFullName(actual.GetFullName(), fullName); + actual.OpenRead().Dispose(); + } + + private static void AssertFullName(string actual, string expected) + { + actual = actual.Replace(@"\", "/"); + expected = expected.Replace(@"\", "/"); + expected.ShouldBe(actual); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem.Test/FileSystemFileTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFileTest.cs index 2a53e63e..f1a3da88 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFileTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFileTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs index 3c7c3e95..e852f840 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs @@ -1,6 +1,5 @@ -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.FileSystem; @@ -12,7 +11,7 @@ public class FileSystemFolderTest public void Ctor() { var folder = new FileSystemFolder(@"d:\11\22"); - Assert.AreEqual("22", folder.Name); + folder.Name.ShouldBe("22"); } [Test] @@ -21,7 +20,7 @@ public void GetFiles() using (var dir = new TempDirectory()) { var folder = new FileSystemFolder(dir.Location); - Assert.AreEqual(0, folder.GetFiles().Count()); + folder.GetFiles().ShouldBeEmpty(); dir.CopyFileFromResources("Content.zip"); Directory.CreateDirectory(Path.Combine(dir.Location, "11.txt")); @@ -29,8 +28,7 @@ public void GetFiles() File.WriteAllText(Path.Combine(dir.Location, "22.txt"), string.Empty); File.WriteAllText(Path.Combine(dir.Location, "33.txt"), string.Empty); - var files = folder.GetFiles().ToArray(); - CollectionAssert.AreEquivalent(new[] { "22.txt", "33.txt" }, files.Select(i => i.Name).ToArray()); + folder.GetFiles().Select(i => i.Name).ShouldBe(["22.txt", "33.txt"], ignoreOrder: true); } } @@ -40,7 +38,7 @@ public void GetFolders() using (var dir = new TempDirectory()) { var folder = new FileSystemFolder(dir.Location); - Assert.AreEqual(0, folder.GetFolders().Count()); + folder.GetFolders().ShouldBeEmpty(); File.WriteAllText(Path.Combine(dir.Location, "11.txt"), string.Empty); @@ -48,8 +46,7 @@ public void GetFolders() Directory.CreateDirectory(Path.Combine(dir.Location, "22.txt")); Directory.CreateDirectory(Path.Combine(dir.Location, "33")); - var folders = folder.GetFolders().ToArray(); - CollectionAssert.AreEquivalent(new[] { "22.txt", "33", "Content.zip" }, folders.Select(i => i.Name).ToArray()); + folder.GetFolders().Select(i => i.Name).ShouldBe(["22.txt", "33", "Content.zip"], ignoreOrder: true); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem.Test/InLineScriptFileTest.cs b/Sources/SqlDatabase.FileSystem.Test/InLineScriptFileTest.cs index fe6133ba..c37f0245 100644 --- a/Sources/SqlDatabase.FileSystem.Test/InLineScriptFileTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/InLineScriptFileTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; namespace SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs b/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs index 5c0048c6..0ad0ddcb 100644 --- a/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs @@ -1,6 +1,4 @@ -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; @@ -23,14 +21,14 @@ public void BeforeEachTest() [TearDown] public void AfterEachTest() { - _temp?.Dispose(); + _temp.Dispose(); } [Test] public void Ctor() { var folder = new ZipFolder(@"d:\11.zip"); - Assert.AreEqual("11.zip", folder.Name); + folder.Name.ShouldBe("11.zip"); } [Test] @@ -38,24 +36,22 @@ public void GetFolders() { var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); - CollectionAssert.AreEqual( - new[] { "1", "2", "inner.zip" }, - subFolders.Select(i => i.Name).ToArray()); + subFolders.Select(i => i.Name).ShouldBe(["1", "2", "inner.zip"], ignoreOrder: true); } [Test] public void GetFiles() { var files = _sut.GetFiles().OrderBy(i => i.Name).ToArray(); - CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); + files.Select(i => i.Name).ShouldBe(["11.txt"]); using (var stream = files[0].OpenRead()) using (var reader = new StreamReader(stream)) { - Assert.AreEqual("11", reader.ReadToEnd()); + reader.ReadToEnd().ShouldBe("11"); } - files[0].GetParent()!.GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); + files[0].GetParent().ShouldNotBeNull().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); } [Test] @@ -64,19 +60,19 @@ public void GetContentOfSubFolders() var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); // 1 - Assert.AreEqual(0, subFolders[0].GetFolders().Count()); - Assert.AreEqual(0, subFolders[0].GetFiles().Count()); + subFolders[0].GetFolders().ShouldBeEmpty(); + subFolders[0].GetFiles().ShouldBeEmpty(); // 2 - Assert.AreEqual(1, subFolders[1].GetFolders().Count()); + subFolders[1].GetFolders().Count().ShouldBe(1); var files = subFolders[1].GetFiles().ToArray(); - CollectionAssert.AreEqual(new[] { "22.txt" }, files.Select(i => i.Name).ToArray()); + files.Select(i => i.Name).ShouldBe(["22.txt"]); using (var stream = files[0].OpenRead()) using (var reader = new StreamReader(stream)) { - Assert.AreEqual("22", reader.ReadToEnd()); + reader.ReadToEnd().ShouldBe("22"); } files[0].GetParent().ShouldBe(subFolders[1]); @@ -87,17 +83,17 @@ public void ReadContentOfEmbeddedZip() { var innerZip = _sut.GetFolders().OrderBy(i => i.Name).Last(); - Assert.AreEqual(2, innerZip.GetFolders().Count()); + innerZip.GetFolders().Count().ShouldBe(2); var files = innerZip.GetFiles().ToArray(); - CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); + files.Select(i => i.Name).ShouldBe(["11.txt"]); using (var stream = files[0].OpenRead()) using (var reader = new StreamReader(stream)) { - Assert.AreEqual("11", reader.ReadToEnd()); + reader.ReadToEnd().ShouldBe("11"); } - files[0].GetParent()!.GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); + files[0].GetParent().ShouldNotBeNull().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/CodeAnalysis/AllowNullAttribute.cs b/Sources/SqlDatabase.FileSystem/CodeAnalysis/AllowNullAttribute.cs new file mode 100644 index 00000000..5226e104 --- /dev/null +++ b/Sources/SqlDatabase.FileSystem/CodeAnalysis/AllowNullAttribute.cs @@ -0,0 +1,4 @@ +namespace System.Diagnostics.CodeAnalysis; + +[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] +internal sealed class AllowNullAttribute : Attribute; diff --git a/Sources/SqlDatabase.FileSystem/CodeAnalysis/NotNullWhenAttribute.cs b/Sources/SqlDatabase.FileSystem/CodeAnalysis/NotNullWhenAttribute.cs new file mode 100644 index 00000000..eec257bb --- /dev/null +++ b/Sources/SqlDatabase.FileSystem/CodeAnalysis/NotNullWhenAttribute.cs @@ -0,0 +1,8 @@ +namespace System.Diagnostics.CodeAnalysis; + +internal sealed class NotNullWhenAttribute : Attribute +{ + public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; + + public bool ReturnValue { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs b/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs index 835dff00..2b1cf9e9 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs @@ -1,15 +1,18 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; +[DebuggerDisplay("{CurrentDirectory}")] public sealed class FileSystemFactory : IFileSystemFactory { - public static IFileSystemInfo FileSystemInfoFromPath(string? path) + public FileSystemFactory(string currentDirectory) + { + CurrentDirectory = currentDirectory; + } + + public string CurrentDirectory { get; } + + public IFileSystemInfo FileSystemInfoFromPath(string? path) { - path = FileTools.RootPath(path); + path = FileTools.RootPath(path, CurrentDirectory); if (File.Exists(path)) { @@ -26,8 +29,7 @@ public static IFileSystemInfo FileSystemInfoFromPath(string? path) while (!string.IsNullOrEmpty(path)) { - entryPoint = TryToResolveEntryPoint(path); - if (entryPoint != null) + if (TryToResolveEntryPoint(path, out entryPoint)) { break; } @@ -71,18 +73,14 @@ public static IFileSystemInfo FileSystemInfoFromPath(string? path) return folder; } - IFileSystemInfo IFileSystemFactory.FileSystemInfoFromPath(string? path) => FileSystemInfoFromPath(path); + public IFileSystemInfo FromContent(string name, string content) => new InLineScriptFile(name, content); - public IFileSystemInfo FromContent(string name, string content) - { - return new InLineScriptFile(name, content); - } - - private static IFolder? TryToResolveEntryPoint(string path) + private static bool TryToResolveEntryPoint(string path, [NotNullWhen(true)] out IFolder? entryPoint) { if (Directory.Exists(path)) { - return new FileSystemFolder(path); + entryPoint = new FileSystemFolder(path); + return true; } if (File.Exists(path)) @@ -92,9 +90,11 @@ public IFileSystemInfo FromContent(string name, string content) throw new NotSupportedException($"File format [{Path.GetExtension(path)}] is not supported as .zip container."); } - return new ZipFolder(path); + entryPoint = new ZipFolder(path); + return true; } - return null; + entryPoint = null; + return false; } } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFile.cs b/Sources/SqlDatabase.FileSystem/FileSystemFile.cs index 1ab6b787..74639f7d 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFile.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFile.cs @@ -1,6 +1,4 @@ -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal sealed class FileSystemFile : IFile { @@ -17,13 +15,9 @@ public FileSystemFile(string location) public string Extension { get; } - public IFolder GetParent() - { - return new FileSystemFolder(Path.GetDirectoryName(Location)!); - } + public string GetFullName() => Location; - public Stream OpenRead() - { - return File.OpenRead(Location); - } + public IFolder GetParent() => new FileSystemFolder(Path.GetDirectoryName(Location)!); + + public Stream OpenRead() => File.OpenRead(Location); } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs b/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs index da1877b2..bf295144 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal sealed class FileSystemFolder : IFolder { @@ -16,6 +12,8 @@ public FileSystemFolder(string location) public string Location { get; } + public string GetFullName() => Location; + public IEnumerable GetFolders() { var folders = Directory diff --git a/Sources/SqlDatabase.FileSystem/FileTools.cs b/Sources/SqlDatabase.FileSystem/FileTools.cs index 280a16b1..fa8c6ded 100644 --- a/Sources/SqlDatabase.FileSystem/FileTools.cs +++ b/Sources/SqlDatabase.FileSystem/FileTools.cs @@ -1,37 +1,26 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal static class FileTools { private const string ZipExtension = ".zip"; private const string NuGetExtension = ".nupkg"; - public static string RootPath(string? path) + public static string RootPath(string? path, string basePath) { if (string.IsNullOrEmpty(path)) { - return AppDomain.CurrentDomain.BaseDirectory; + return basePath; } if (!Path.IsPathRooted(path)) { - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); + return Path.Combine(basePath, path); } return path!; } - public static IEnumerable GetZipExtensions() - { - return new[] - { - ZipExtension, - NuGetExtension - }; - } + public static IEnumerable GetZipExtensions() => [ZipExtension, NuGetExtension]; public static bool IsZip(string path) { diff --git a/Sources/SqlDatabase.FileSystem/IFile.cs b/Sources/SqlDatabase.FileSystem/IFile.cs index 1d095d54..302a4b33 100644 --- a/Sources/SqlDatabase.FileSystem/IFile.cs +++ b/Sources/SqlDatabase.FileSystem/IFile.cs @@ -1,6 +1,4 @@ -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; public interface IFile : IFileSystemInfo { diff --git a/Sources/SqlDatabase.FileSystem/IFileSystemInfo.cs b/Sources/SqlDatabase.FileSystem/IFileSystemInfo.cs index 607562d4..4a793b69 100644 --- a/Sources/SqlDatabase.FileSystem/IFileSystemInfo.cs +++ b/Sources/SqlDatabase.FileSystem/IFileSystemInfo.cs @@ -3,4 +3,6 @@ public interface IFileSystemInfo { string Name { get; } + + string GetFullName(); } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/IFolder.cs b/Sources/SqlDatabase.FileSystem/IFolder.cs index 3122829c..a1cad054 100644 --- a/Sources/SqlDatabase.FileSystem/IFolder.cs +++ b/Sources/SqlDatabase.FileSystem/IFolder.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; public interface IFolder : IFileSystemInfo { diff --git a/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs b/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs index 22007008..6877a42d 100644 --- a/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs +++ b/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs @@ -1,7 +1,4 @@ -using System.IO; -using System.Text; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal sealed class InLineScriptFile : IFile { @@ -18,10 +15,9 @@ public InLineScriptFile(string name, string content) public string Extension { get; } + public string GetFullName() => Name; + public IFolder? GetParent() => null; - public Stream OpenRead() - { - return new MemoryStream(Encoding.UTF8.GetBytes(Content)); - } + public Stream OpenRead() => new MemoryStream(Encoding.UTF8.GetBytes(Content)); } \ No newline at end of file diff --git a/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs b/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs index 2dbf2ce7..bf3b2329 100644 --- a/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs +++ b/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs @@ -1,14 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; [DebuggerDisplay("{Name}")] internal sealed class ZipEntryFolder : IFolder { - public ZipEntryFolder(string name) + private readonly string _fullName; + + public ZipEntryFolder(string name, string fullName) { + _fullName = fullName; Name = name; FolderByName = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -21,6 +20,8 @@ public ZipEntryFolder(string name) public IList Files { get; } + public string GetFullName() => _fullName; + public IEnumerable GetFolders() => FolderByName.Values; public IEnumerable GetFiles() => Files; diff --git a/Sources/SqlDatabase.FileSystem/ZipFolder.cs b/Sources/SqlDatabase.FileSystem/ZipFolder.cs index e2844b1b..24b9bd91 100644 --- a/Sources/SqlDatabase.FileSystem/ZipFolder.cs +++ b/Sources/SqlDatabase.FileSystem/ZipFolder.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.IO.Compression; -using System.Linq; +using System.IO.Compression; namespace SqlDatabase.FileSystem; @@ -30,6 +25,16 @@ public ZipFolder(ZipFolder? parent, string zipEntryFullName) public string FileName { get; } + public string GetFullName() + { + if (_parent == null) + { + return FileName; + } + + return Path.Combine(_parent.GetFullName(), FileName); + } + public IEnumerable GetFolders() => BuildOrGetTree().GetFolders(); public IEnumerable GetFiles() => BuildOrGetTree().GetFiles(); @@ -69,19 +74,20 @@ private IFolder BuildTree(IEnumerable entries) inner.zip */ - var tree = new ZipEntryFolder(Name); + var tree = new ZipEntryFolder(Name, GetFullName()); foreach (var entry in entries) { var owner = tree; - var path = entry.FullName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + var path = entry.FullName.Split(['/'], StringSplitOptions.RemoveEmptyEntries); + var fullName = Path.Combine(GetFullName(), entry.FullName); for (var i = 0; i < path.Length - 1; i++) { var pathItem = path[i]; if (!owner.FolderByName.TryGetValue(pathItem, out var next)) { - next = new ZipEntryFolder(pathItem); + next = new ZipEntryFolder(pathItem, fullName); owner.FolderByName.Add(pathItem, next); } @@ -93,7 +99,7 @@ private IFolder BuildTree(IEnumerable entries) { if (!owner.FolderByName.ContainsKey(entryName)) { - owner.FolderByName.Add(entryName, new ZipEntryFolder(entryName)); + owner.FolderByName.Add(entryName, new ZipEntryFolder(entryName, fullName)); } } else if (FileTools.IsZip(entry.FullName)) diff --git a/Sources/SqlDatabase.FileSystem/ZipFolderFile.EntryStream.cs b/Sources/SqlDatabase.FileSystem/ZipFolderFile.EntryStream.cs index b4853cc9..ac46e0a6 100644 --- a/Sources/SqlDatabase.FileSystem/ZipFolderFile.EntryStream.cs +++ b/Sources/SqlDatabase.FileSystem/ZipFolderFile.EntryStream.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal partial class ZipFolderFile { diff --git a/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs b/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs index 00088c2e..23e8cefd 100644 --- a/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs +++ b/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs @@ -1,7 +1,4 @@ -using System.Diagnostics; -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; [DebuggerDisplay(@"zip\{EntryName}")] internal sealed partial class ZipFolderFile : IFile @@ -25,6 +22,8 @@ public ZipFolderFile(ZipFolder container, IFolder parent, string entryFullName) public string Extension { get; } + public string GetFullName() => Path.Combine(_container.GetFullName(), EntryFullName); + public IFolder GetParent() => _parent; public Stream OpenRead() diff --git a/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec b/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec index 0c2d01af..3f20d798 100644 --- a/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec +++ b/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec @@ -19,7 +19,7 @@ Requires Powershell Core 6.1+ or PowerShell Desktop 5.1. https://github.com/max-ieremenko/SqlDatabase/releases (C) 2018-2022 Max Ieremenko. - sqlserver sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data + sqlserver sqlcmd migration-tool c-sharp command-line-tool migration-step sql-script sql-database database-migrations export-data diff --git a/Sources/SqlDatabase.Package/nuget/package.nuspec b/Sources/SqlDatabase.Package/nuget/package.nuspec index 7e94f6dd..ba320900 100644 --- a/Sources/SqlDatabase.Package/nuget/package.nuspec +++ b/Sources/SqlDatabase.Package/nuget/package.nuspec @@ -13,9 +13,9 @@ false Command-line tool and PowerShell module for MSSQL Server, PostgreSQL and MySQL. SqlDatabase is a tool for MSSQL Server, PostgreSQL and MySQL, allows to execute scripts, database migrations and export data. - https://github.com/max-ieremenko/SqlDatabase/releases - (C) 2018-2023 Max Ieremenko. - sqlserver postgresql mysql mysql-database sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data + https://github.com/max-ieremenko/SqlDatabase/releases/tag/$Version$ + (C) 2018-2024 Max Ieremenko. + sqlserver postgresql mysql mysql-database sqlcmd migration-tool c-sharp command-line-tool migration-step sql-script sql-database database-migrations export-data diff --git a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs index 55858e6a..bf33a6a7 100644 --- a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs @@ -1,7 +1,6 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -27,28 +26,18 @@ public void BuildCommandLine(string commandName) }); commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + var actual = commandLines[0].ShouldBeOfType(); - commandLine.Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLine.Connection.ShouldBe("connection string"); + actual.Database.ShouldBe("connection string"); + actual.From.ShouldBe([new(false, "file 1"), new(false, "file 2")]); + actual.Configuration.ShouldBe("app.config"); + actual.Log.ShouldBe("log.txt"); + actual.UsePowerShell.ShouldBeNull(); + actual.WhatIf.ShouldBeTrue(); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - - commandLine.WhatIf.ShouldBeTrue(); - - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); + actual.Variables.Keys.ShouldBe(new[] { "x", "y" }); + actual.Variables["x"].ShouldBe("1"); + actual.Variables["y"].ShouldBe("2"); } [Test] @@ -64,18 +53,12 @@ public void BuildPipeCommandLine(string commandName) commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + var actual0 = commandLines[0].ShouldBeOfType(); + actual0.Database.ShouldBe("connection string"); + actual0.From.ShouldBe([new(false, "file 1")]); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); + var actual1 = commandLines[1].ShouldBeOfType(); + actual1.Database.ShouldBe("connection string"); + actual1.From.ShouldBe([new(false, "file 2")]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs index c0db652c..14722577 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs @@ -1,7 +1,7 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -21,7 +21,7 @@ public void BuildCommandLine(string commandName) c.Parameters.Add(nameof(ExecuteCmdLet.Database), "connection string"); c.Parameters.Add(nameof(ExecuteCmdLet.From), new[] { "file 1", "file 2" }); c.Parameters.Add(nameof(ExecuteCmdLet.FromSql), new[] { "sql text 1", "sql text 2" }); - c.Parameters.Add(nameof(ExecuteCmdLet.Transaction), TransactionMode.PerStep); + c.Parameters.Add(nameof(ExecuteCmdLet.Transaction), PSTransactionMode.PerStep); c.Parameters.Add(nameof(ExecuteCmdLet.Configuration), "app.config"); c.Parameters.Add(nameof(ExecuteCmdLet.Var), new[] { "x=1", "y=2" }); c.Parameters.Add(nameof(ExecuteCmdLet.WhatIf)); @@ -29,31 +29,24 @@ public void BuildCommandLine(string commandName) }); commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + var actual = commandLines[0].ShouldBeOfType(); - commandLine.Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLine.Connection.ShouldBe("connection string"); + actual.Database.ShouldBe("connection string"); + actual.From.ShouldBe([ + new(false, "file 1"), + new(false, "file 2"), + new(true, "sql text 1"), + new(true, "sql text 2") + ]); + actual.Transaction.ShouldBe(TransactionMode.PerStep); + actual.Configuration.ShouldBe("app.config"); + actual.Log.ShouldBe("log.txt"); + actual.UsePowerShell.ShouldBeNull(); + actual.WhatIf.ShouldBeTrue(); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - - commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); - commandLine.Transaction.ShouldBe(TransactionMode.PerStep); - - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - - commandLine.WhatIf.ShouldBeTrue(); - - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); + actual.Variables.Keys.ShouldBe(new[] { "x", "y" }); + actual.Variables["x"].ShouldBe("1"); + actual.Variables["y"].ShouldBe("2"); } [Test] @@ -69,18 +62,12 @@ public void BuildPipeCommandLine(string commandName) commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + var actual0 = commandLines[0].ShouldBeOfType(); + actual0.Database.ShouldBe("connection string"); + actual0.From.ShouldBe([new(false, "file 1")]); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); + var actual1 = commandLines[1].ShouldBeOfType(); + actual1.Database.ShouldBe("connection string"); + actual1.From.ShouldBe([new(false, "file 2")]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs index 527194ca..0f918959 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs @@ -1,7 +1,6 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -27,29 +26,22 @@ public void BuildCommandLine() }); commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; - - commandLine.Command.ShouldBe(CommandLineFactory.CommandExport); - commandLine.Connection.ShouldBe("connection string"); - - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - - commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); - commandLine.ExportToFile.ShouldBe("to file"); - commandLine.ExportToTable.ShouldBe("to table"); - - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); + var actual = commandLines[0].ShouldBeOfType(); + + actual.Database.ShouldBe("connection string"); + actual.From.ShouldBe([ + new(false, "file 1"), + new(false, "file 2"), + new(true, "sql text 1"), + new(true, "sql text 2") + ]); + actual.DestinationTableName.ShouldBe("to table"); + actual.DestinationFileName.ShouldBe("to file"); + actual.Configuration.ShouldBe("app.config"); + actual.Log.ShouldBe("log.txt"); + + actual.Variables.Keys.ShouldBe(new[] { "x", "y" }); + actual.Variables["x"].ShouldBe("1"); + actual.Variables["y"].ShouldBe("2"); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs index a1dac9d4..faca11d8 100644 --- a/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using NUnit.Framework; using Shouldly; using SqlDatabase.PowerShell.TestApi; diff --git a/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs index 6044cd5a..894df28e 100644 --- a/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs deleted file mode 100644 index bf524275..00000000 --- a/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NUnit.Framework; -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -[TestFixture] -public class PowerShellCommandBaseTest -{ - [Test] - public void AppendDefaultConfiguration() - { - var command = new GenericCommandLine(); - - PowerShellCommandBase.AppendDefaultConfiguration(command); - - FileAssert.Exists(command.ConfigurationFile); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs index a66d3177..7624da95 100644 --- a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; +using System.Collections.ObjectModel; using System.Management.Automation; using System.Management.Automation.Runspaces; using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.Internal; using SqlDatabase.TestApi; using Command = System.Management.Automation.Runspaces.Command; @@ -17,7 +14,7 @@ namespace SqlDatabase.PowerShell.TestApi; public abstract class SqlDatabaseCmdLetTest { - private readonly IList _commandLines = new List(); + private readonly List _commandLines = new(); private Runspace _runSpace = null!; private System.Management.Automation.PowerShell _powerShell = null!; @@ -39,17 +36,17 @@ public void BeforeEachTest() var program = new Mock(MockBehavior.Strict); program - .Setup(p => p.ExecuteCommand(It.IsNotNull())) - .Callback(cmd => _commandLines.Add(cmd)); + .Setup(p => p.ExecuteCommand(It.IsNotNull())) + .Callback(_commandLines.Add); _commandLines.Clear(); - PowerShellCommandBase.Program = program.Object; + PowerShellCommand.Program = program.Object; } [TearDown] public void AfterEachTest() { - PowerShellCommandBase.Program = null; + PowerShellCommand.Program = null; foreach (var row in _powerShell.Streams.Information) { @@ -68,12 +65,9 @@ protected Collection InvokeCommand(string name) return _powerShell.Invoke(); } - protected GenericCommandLine[] InvokeSqlDatabase(string name, Action builder) - { - return InvokeInvokeSqlDatabasePipeLine(name, builder); - } + protected ICommandLine[] InvokeSqlDatabase(string name, Action builder) => InvokeInvokeSqlDatabasePipeLine(name, builder); - protected GenericCommandLine[] InvokeInvokeSqlDatabasePipeLine(string name, Action builder, params object[] args) + protected ICommandLine[] InvokeInvokeSqlDatabasePipeLine(string name, Action builder, params object[] args) { _commandLines.Clear(); diff --git a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs index 9ca0e54e..2b1048dd 100644 --- a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs @@ -1,7 +1,7 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -20,7 +20,7 @@ public void BuildCommandLine(string commandName) { c.Parameters.Add(nameof(UpgradeCmdLet.Database), "connection string"); c.Parameters.Add(nameof(UpgradeCmdLet.From), new[] { "file 1", "file 2" }); - c.Parameters.Add(nameof(UpgradeCmdLet.Transaction), TransactionMode.PerStep); + c.Parameters.Add(nameof(UpgradeCmdLet.Transaction), PSTransactionMode.PerStep); c.Parameters.Add(nameof(UpgradeCmdLet.Configuration), "app.config"); c.Parameters.Add(nameof(UpgradeCmdLet.Var), new[] { "x=1", "y=2" }); c.Parameters.Add(nameof(UpgradeCmdLet.WhatIf)); @@ -29,31 +29,20 @@ public void BuildCommandLine(string commandName) }); commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + var actual = commandLines[0].ShouldBeOfType(); - commandLine.Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLine.Connection.ShouldBe("connection string"); + actual.Database.ShouldBe("connection string"); + actual.From.ShouldBe([new(false, "file 1"), new(false, "file 2")]); + actual.Transaction.ShouldBe(TransactionMode.PerStep); + actual.Configuration.ShouldBe("app.config"); + actual.Log.ShouldBe("log.txt"); + actual.UsePowerShell.ShouldBeNull(); + actual.WhatIf.ShouldBeTrue(); + actual.FolderAsModuleName.ShouldBeTrue(); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - - commandLine.Transaction.ShouldBe(TransactionMode.PerStep); - - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - - commandLine.WhatIf.ShouldBeTrue(); - commandLine.FolderAsModuleName.ShouldBeTrue(); - - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); + actual.Variables.Keys.ShouldBe(new[] { "x", "y" }); + actual.Variables["x"].ShouldBe("1"); + actual.Variables["y"].ShouldBe("2"); } [Test] @@ -69,18 +58,12 @@ public void BuildPipeCommandLine(string commandName) commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + var actual0 = commandLines[0].ShouldBeOfType(); + actual0.Database.ShouldBe("connection string"); + actual0.From.ShouldBe([new(false, "file 1")]); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); + var actual1 = commandLines[1].ShouldBeOfType(); + actual1.Database.ShouldBe("connection string"); + actual1.From.ShouldBe([new(false, "file 2")]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs b/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs index 4051027b..dd3ddf53 100644 --- a/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs @@ -1,11 +1,11 @@ using System.Management.Automation; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.Internal; namespace SqlDatabase.PowerShell; [Cmdlet(VerbsCommon.New, "SqlDatabase")] -[Alias(CommandLineFactory.CommandCreate + "-SqlDatabase")] +[Alias("Create-SqlDatabase")] public sealed class CreateCmdLet : PSCmdlet { [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] @@ -32,6 +32,17 @@ public sealed class CreateCmdLet : PSCmdlet protected override void ProcessRecord() { - new CreatePowerShellCommand(this).Execute(); + var commandLine = new CreateCommandLine + { + Database = Database, + Configuration = Configuration, + Log = Log, + WhatIf = WhatIf + }; + + CommandLineTools.AppendFrom(commandLine.From, false, From); + CommandLineTools.AppendVariables(commandLine.Variables, Var); + + PowerShellCommand.Execute(this, commandLine); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs b/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs index a2bdcc8a..31c81f8a 100644 --- a/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs @@ -1,11 +1,12 @@ using System.Management.Automation; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.Internal; namespace SqlDatabase.PowerShell; [Cmdlet(VerbsLifecycle.Invoke, "SqlDatabase")] -[Alias(CommandLineFactory.CommandExecute + "-SqlDatabase")] +[Alias("Execute-SqlDatabase")] public sealed class ExecuteCmdLet : PSCmdlet { [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] @@ -40,6 +41,19 @@ public sealed class ExecuteCmdLet : PSCmdlet protected override void ProcessRecord() { - new ExecutePowerShellCommand(this).Execute(); + var commandLine = new ExecuteCommandLine + { + Database = Database, + Transaction = (TransactionMode)Transaction, + Configuration = Configuration, + Log = Log, + WhatIf = WhatIf + }; + + CommandLineTools.AppendFrom(commandLine.From, false, From); + CommandLineTools.AppendFrom(commandLine.From, true, FromSql); + CommandLineTools.AppendVariables(commandLine.Variables, Var); + + PowerShellCommand.Execute(this, commandLine); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs b/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs index e3b2d386..78b288c4 100644 --- a/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs @@ -1,4 +1,5 @@ using System.Management.Automation; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.Internal; namespace SqlDatabase.PowerShell; @@ -37,6 +38,19 @@ public sealed class ExportCmdLet : PSCmdlet protected override void ProcessRecord() { - new ExportPowerShellCommand(this).Execute(); + var commandLine = new ExportCommandLine + { + Database = Database, + Configuration = Configuration, + DestinationFileName = ToFile, + DestinationTableName = ToTable, + Log = Log + }; + + CommandLineTools.AppendFrom(commandLine.From, false, From); + CommandLineTools.AppendFrom(commandLine.From, true, FromSql); + CommandLineTools.AppendVariables(commandLine.Variables, Var); + + PowerShellCommand.Execute(this, commandLine); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs index c6e0b05f..7c675884 100644 --- a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Management.Automation; +using System.Management.Automation; using System.Runtime.InteropServices; using SqlDatabase.Configuration; using SqlDatabase.PowerShell.Internal; @@ -21,7 +20,6 @@ protected override void ProcessRecord() private void WriteInfo() { var assembly = GetType().Assembly; - var location = Path.GetDirectoryName(assembly.Location); this.TryGetPSVersionTable(out var psVersionTable); @@ -30,13 +28,14 @@ private void WriteInfo() psVersionTable.PSEdition, psVersionTable.PSVersion, Version = assembly.GetName().Version, + ClrVersion = Environment.Version, RuntimeInformation.FrameworkDescription, RuntimeInformation.OSDescription, RuntimeInformation.OSArchitecture, RuntimeInformation.ProcessArchitecture, - Location = location, + Location = Path.GetDirectoryName(assembly.Location), WorkingDirectory = this.GetWorkingDirectory(), - DefaultConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(location) + DefaultConfigurationFile = ConfigurationManager.GetDefaultConfigurationFile() }); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs b/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs index 5287de6d..da3b8bab 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.PowerShell.Internal; diff --git a/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs b/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs index 3977da0f..c9980719 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs @@ -1,5 +1,4 @@ -using System; -using System.Management.Automation; +using System.Management.Automation; using SqlDatabase.Log; namespace SqlDatabase.PowerShell.Internal; diff --git a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs index 75019134..311472b5 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs @@ -1,6 +1,4 @@ -using System.IO; -using System.Management.Automation; -using SqlDatabase.Configuration; +using System.Management.Automation; namespace SqlDatabase.PowerShell.Internal; @@ -17,16 +15,6 @@ public static string GetWorkingDirectory(this PSCmdlet cmdlet) return root; } - public static string? RootPath(this PSCmdlet cmdlet, string? path) - { - if (string.IsNullOrEmpty(path) || Path.IsPathRooted(path)) - { - return path; - } - - return Path.Combine(GetWorkingDirectory(cmdlet), path); - } - public static bool TryGetPSVersionTable(this PSCmdlet cmdlet, out PSVersionTable value) { var psVersionTable = cmdlet.GetVariableValue("PSVersionTable"); @@ -39,21 +27,4 @@ public static bool TryGetPSVersionTable(this PSCmdlet cmdlet, out PSVersionTable value = new PSVersionTable(psVersionTable); return true; } - - public static void AppendFrom(this PSCmdlet cmdlet, string[]? from, GenericCommandLineBuilder target) - { - if (from == null) - { - return; - } - - for (var i = 0; i < from.Length; i++) - { - var path = cmdlet.RootPath(from[i]); - if (path != null) - { - target.SetScripts(path); - } - } - } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/CommandLineTools.cs b/Sources/SqlDatabase.PowerShell/Internal/CommandLineTools.cs new file mode 100644 index 00000000..36d36950 --- /dev/null +++ b/Sources/SqlDatabase.PowerShell/Internal/CommandLineTools.cs @@ -0,0 +1,36 @@ +using SqlDatabase.CommandLine; + +namespace SqlDatabase.PowerShell.Internal; + +internal static class CommandLineTools +{ + public static void AppendFrom(List target, bool isInline, string[]? from) + { + if (from == null) + { + return; + } + + for (var i = 0; i < from.Length; i++) + { + var path = from[i]; + if (!string.IsNullOrEmpty(path)) + { + target.Add(new ScriptSource(isInline, path)); + } + } + } + + public static void AppendVariables(Dictionary target, string[]? from) + { + if (from == null) + { + return; + } + + for (var i = 0; i < from.Length; i++) + { + CommandLineParser.AddVariable(target, from[i]); + } + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs deleted file mode 100644 index cd33cba2..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs +++ /dev/null @@ -1,35 +0,0 @@ -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -internal sealed class CreatePowerShellCommand : PowerShellCommandBase -{ - public CreatePowerShellCommand(CreateCmdLet cmdlet) - : base(cmdlet) - { - } - - public new CreateCmdLet Cmdlet => (CreateCmdLet)base.Cmdlet; - - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandCreate) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - - if (Cmdlet.Var != null) - { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } - } - - Cmdlet.AppendFrom(Cmdlet.From, builder); - - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetWhatIf(Cmdlet.WhatIf); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs b/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs index d5b95449..0779cb14 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Management.Automation; +using System.Management.Automation; namespace SqlDatabase.PowerShell.Internal; diff --git a/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs deleted file mode 100644 index 06bdebf4..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -internal sealed class ExecutePowerShellCommand : PowerShellCommandBase -{ - public ExecutePowerShellCommand(ExecuteCmdLet cmdLet) - : base(cmdLet) - { - } - - public new ExecuteCmdLet Cmdlet => (ExecuteCmdLet)base.Cmdlet; - - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandExecute) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - - if (Cmdlet.Var != null) - { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } - } - - Cmdlet.AppendFrom(Cmdlet.From, builder); - - if (Cmdlet.FromSql != null) - { - for (var i = 0; i < Cmdlet.FromSql.Length; i++) - { - builder.SetInLineScript(Cmdlet.FromSql[i]); - } - } - - builder - .SetTransaction((TransactionMode)Cmdlet.Transaction) - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetWhatIf(Cmdlet.WhatIf); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs deleted file mode 100644 index d54ccc1f..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -internal sealed class ExportPowerShellCommand : PowerShellCommandBase -{ - public ExportPowerShellCommand(ExportCmdLet cmdLet) - : base(cmdLet) - { - } - - public new ExportCmdLet Cmdlet => (ExportCmdLet)base.Cmdlet; - - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandExport) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - - if (Cmdlet.Var != null) - { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } - } - - Cmdlet.AppendFrom(Cmdlet.From, builder); - - if (Cmdlet.FromSql != null) - { - for (var i = 0; i < Cmdlet.FromSql.Length; i++) - { - builder.SetInLineScript(Cmdlet.FromSql[i]); - } - } - - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetExportToTable(Cmdlet.ToTable) - .SetExportToFile(Cmdlet.ToFile); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs index a84005ad..e7b9cd82 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.PowerShell.Internal; +namespace SqlDatabase.PowerShell.Internal; internal interface IDependencyResolver : IDisposable { diff --git a/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs index 3039537d..90e95727 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs @@ -1,8 +1,8 @@ -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; namespace SqlDatabase.PowerShell.Internal; internal interface ISqlDatabaseProgram { - void ExecuteCommand(GenericCommandLine command); + void ExecuteCommand(ICommandLine command); } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs b/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs index 051dfd21..7f9be133 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; namespace SqlDatabase.PowerShell.Internal; diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommand.cs new file mode 100644 index 00000000..6bd90a91 --- /dev/null +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommand.cs @@ -0,0 +1,30 @@ +using System.Management.Automation; +using SqlDatabase.CommandLine; + +namespace SqlDatabase.PowerShell.Internal; + +internal static class PowerShellCommand +{ + // only for tests + internal static ISqlDatabaseProgram? Program { get; set; } + + public static void Execute(PSCmdlet cmdlet, ICommandLine command) + { + using (var resolver = DependencyResolverFactory.Create(cmdlet)) + { + resolver.Initialize(); + + ResolveProgram(cmdlet).ExecuteCommand(command); + } + } + + private static ISqlDatabaseProgram ResolveProgram(PSCmdlet cmdlet) + { + if (Program != null) + { + return Program; + } + + return new SqlDatabaseProgram(new CmdLetLogger(cmdlet), cmdlet.GetWorkingDirectory()); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs deleted file mode 100644 index 9bfb5f80..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.IO; -using System.Management.Automation; -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -internal abstract class PowerShellCommandBase -{ - protected PowerShellCommandBase(PSCmdlet cmdlet) - { - Cmdlet = cmdlet; - } - - public PSCmdlet Cmdlet { get; } - - // only for tests - internal static ISqlDatabaseProgram? Program { get; set; } - - public void Execute() - { - using (var resolver = DependencyResolverFactory.Create(Cmdlet)) - { - resolver.Initialize(); - ExecuteCore(); - } - } - - internal static void AppendDefaultConfiguration(GenericCommandLine command) - { - if (string.IsNullOrEmpty(command.ConfigurationFile)) - { - var probingPath = Path.GetDirectoryName(typeof(PowerShellCommandBase).Assembly.Location); - command.ConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(probingPath); - } - } - - protected abstract void BuildCommandLine(GenericCommandLineBuilder builder); - - private void ExecuteCore() - { - var builder = new GenericCommandLineBuilder(); - BuildCommandLine(builder); - - var command = builder.Build(); - AppendDefaultConfiguration(command); - - ResolveProgram().ExecuteCommand(command); - } - - private ISqlDatabaseProgram ResolveProgram() - { - if (Program != null) - { - return Program; - } - - return new SqlDatabaseProgram(new CmdLetLogger(Cmdlet)); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs index 5a8bdd60..243545e6 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Management.Automation; +using System.Management.Automation; using System.Reflection; using System.Runtime.Loader; diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs index 9e033675..7909698f 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.Reflection; +using System.Reflection; namespace SqlDatabase.PowerShell.Internal; diff --git a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs index 0dba068e..753c5d69 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs @@ -1,20 +1,21 @@ using SqlDatabase.Adapter; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; namespace SqlDatabase.PowerShell.Internal; internal sealed class SqlDatabaseProgram : ISqlDatabaseProgram { private readonly ILogger _logger; + private readonly string _currentDirectory; - public SqlDatabaseProgram(ILogger logger) + public SqlDatabaseProgram(ILogger logger, string currentDirectory) { _logger = logger; + _currentDirectory = currentDirectory; } - public void ExecuteCommand(GenericCommandLine command) + public void ExecuteCommand(ICommandLine command) { - var args = new GenericCommandLineBuilder(command).BuildArray(); - Program.Run(_logger, args); + Program.RunPowershell(_logger, command, _currentDirectory); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs deleted file mode 100644 index cac64cfc..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs +++ /dev/null @@ -1,37 +0,0 @@ -using SqlDatabase.Configuration; - -namespace SqlDatabase.PowerShell.Internal; - -internal sealed class UpgradePowerShellCommand : PowerShellCommandBase -{ - public UpgradePowerShellCommand(UpgradeCmdLet cmdLet) - : base(cmdLet) - { - } - - public new UpgradeCmdLet Cmdlet => (UpgradeCmdLet)base.Cmdlet; - - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - - if (Cmdlet.Var != null) - { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } - } - - Cmdlet.AppendFrom(Cmdlet.From, builder); - - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetTransaction((TransactionMode)Cmdlet.Transaction) - .SetWhatIf(Cmdlet.WhatIf) - .SetFolderAsModuleName(Cmdlet.FolderAsModuleName); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs b/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs index f539df1e..c3cfc867 100644 --- a/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs +++ b/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs @@ -1,4 +1,4 @@ -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; namespace SqlDatabase.PowerShell; diff --git a/Sources/SqlDatabase.PowerShell/SqlDatabase.PowerShell.csproj b/Sources/SqlDatabase.PowerShell/SqlDatabase.PowerShell.csproj index a7bdf37c..d37044c8 100644 --- a/Sources/SqlDatabase.PowerShell/SqlDatabase.PowerShell.csproj +++ b/Sources/SqlDatabase.PowerShell/SqlDatabase.PowerShell.csproj @@ -3,11 +3,14 @@ netstandard2.0 ..\..\bin\SqlDatabase.PowerShell - true + false + + + @@ -24,22 +27,27 @@ - - + + + - - - - - - - + + + + + - - - + + - - + + + + + + + + + \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 index 8bf15a68..8958a10f 100644 Binary files a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 and b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 differ diff --git a/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs b/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs index 1080221f..8a584af0 100644 --- a/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs @@ -1,11 +1,12 @@ using System.Management.Automation; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.Internal; namespace SqlDatabase.PowerShell; [Cmdlet(VerbsData.Update, "SqlDatabase")] -[Alias(CommandLineFactory.CommandUpgrade + "-SqlDatabase")] +[Alias("Upgrade-SqlDatabase")] public sealed class UpgradeCmdLet : PSCmdlet { [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] @@ -39,6 +40,19 @@ public sealed class UpgradeCmdLet : PSCmdlet protected override void ProcessRecord() { - new UpgradePowerShellCommand(this).Execute(); + var commandLine = new UpgradeCommandLine + { + Database = Database, + Transaction = (TransactionMode)Transaction, + Configuration = Configuration, + Log = Log, + WhatIf = WhatIf, + FolderAsModuleName = FolderAsModuleName + }; + + CommandLineTools.AppendFrom(commandLine.From, false, From); + CommandLineTools.AppendVariables(commandLine.Variables, Var); + + PowerShellCommand.Execute(this, commandLine); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs index 1bcf819f..757b4d38 100644 --- a/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs @@ -1,7 +1,6 @@ -using System.Collections.Generic; -using System.Linq; -using Moq; +using Moq; using NUnit.Framework; +using Shouldly; using SqlDatabase.Adapter; using SqlDatabase.FileSystem; using SqlDatabase.TestApi; @@ -71,17 +70,14 @@ public void BuildSequenceFromOneFolder() var actual = _sut.BuildSequence(); // sorted A-Z, first files then folders - CollectionAssert.AreEqual( - new[] - { - @"root\" + files[1].Name, - @"root\" + files[0].Name, - @"root\a\" + folderA[1].Name, - @"root\a\" + folderA[0].Name, - @"root\x\" + folderX[0].Name, - @"root\x\" + folderX[1].Name - }, - actual.Select(i => i.DisplayName).ToArray()); + actual.Select(i => i.DisplayName).ShouldBe([ + @"root\" + files[1].Name, + @"root\" + files[0].Name, + @"root\a\" + folderA[1].Name, + @"root\a\" + folderA[0].Name, + @"root\x\" + folderX[0].Name, + @"root\x\" + folderX[1].Name + ]); } [Test] @@ -95,8 +91,6 @@ public void BuildSequenceFromFolderAndFile() var actual = _sut.BuildSequence(); // sorted A-Z, first files then folders - CollectionAssert.AreEqual( - new[] { @"root\10.sql", @"root\20.sql", "02.sql", "01.sql" }, - actual.Select(i => i.DisplayName).ToArray()); + actual.Select(i => i.DisplayName).ShouldBe([@"root\10.sql", @"root\20.sql", "02.sql", "01.sql"]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Sequence.Test/DependencyParserTest.cs b/Sources/SqlDatabase.Sequence.Test/DependencyParserTest.cs index 6fa611ba..63198cc5 100644 --- a/Sources/SqlDatabase.Sequence.Test/DependencyParserTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/DependencyParserTest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Sequence.Test/ModuleVersionResolverTest.cs b/Sources/SqlDatabase.Sequence.Test/ModuleVersionResolverTest.cs index 90ae5268..258ed244 100644 --- a/Sources/SqlDatabase.Sequence.Test/ModuleVersionResolverTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/ModuleVersionResolverTest.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; diff --git a/Sources/SqlDatabase.Sequence.Test/UpgradeScriptCollectionTest.cs b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptCollectionTest.cs index 031f5fcc..271410e5 100644 --- a/Sources/SqlDatabase.Sequence.Test/UpgradeScriptCollectionTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptCollectionTest.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs index f88189d9..930b9e45 100644 --- a/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Moq; +using Moq; using Newtonsoft.Json; using NUnit.Framework; using Shouldly; @@ -73,7 +69,7 @@ public void BuildSequence(BuildSequenceCase testCase) foreach (var version in testCase.Version) { _versionResolver - .Setup(r => r.GetCurrentVersion(version.Module ?? string.Empty)) + .Setup(r => r.GetCurrentVersion(version.Module)) .Returns(new Version(version.Version)); } @@ -180,6 +176,8 @@ public SourceFolder(string name) public string Name { get; } + public string GetFullName() => throw new NotSupportedException(); + public IEnumerable GetFolders() => _subFolderByName.Values; public IEnumerable GetFiles() => _fileByName.Values; diff --git a/Sources/SqlDatabase.Sequence/CodeAnalysis/AllowNullAttribute.cs b/Sources/SqlDatabase.Sequence/CodeAnalysis/AllowNullAttribute.cs index 39be8db8..5226e104 100644 --- a/Sources/SqlDatabase.Sequence/CodeAnalysis/AllowNullAttribute.cs +++ b/Sources/SqlDatabase.Sequence/CodeAnalysis/AllowNullAttribute.cs @@ -1,8 +1,4 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] -internal sealed class AllowNullAttribute : Attribute -{ -} -#endif \ No newline at end of file +internal sealed class AllowNullAttribute : Attribute; diff --git a/Sources/SqlDatabase.Sequence/CodeAnalysis/NotNullWhenAttribute.cs b/Sources/SqlDatabase.Sequence/CodeAnalysis/NotNullWhenAttribute.cs index e3d56cf7..eec257bb 100644 --- a/Sources/SqlDatabase.Sequence/CodeAnalysis/NotNullWhenAttribute.cs +++ b/Sources/SqlDatabase.Sequence/CodeAnalysis/NotNullWhenAttribute.cs @@ -1,10 +1,8 @@ -#if NET472 || NETSTANDARD2_0 -namespace System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics.CodeAnalysis; internal sealed class NotNullWhenAttribute : Attribute { public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; public bool ReturnValue { get; } -} -#endif +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Sequence/CreateScriptSequence.cs b/Sources/SqlDatabase.Sequence/CreateScriptSequence.cs index 826f0e89..8b583aa7 100644 --- a/Sources/SqlDatabase.Sequence/CreateScriptSequence.cs +++ b/Sources/SqlDatabase.Sequence/CreateScriptSequence.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.FileSystem; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence/DependencyParser.cs b/Sources/SqlDatabase.Sequence/DependencyParser.cs index e96db1e8..80fbf7b7 100644 --- a/Sources/SqlDatabase.Sequence/DependencyParser.cs +++ b/Sources/SqlDatabase.Sequence/DependencyParser.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence/GetDatabaseCurrentVersion.cs b/Sources/SqlDatabase.Sequence/GetDatabaseCurrentVersion.cs index 6f5fb245..96d40582 100644 --- a/Sources/SqlDatabase.Sequence/GetDatabaseCurrentVersion.cs +++ b/Sources/SqlDatabase.Sequence/GetDatabaseCurrentVersion.cs @@ -1,5 +1,3 @@ -using System; - -namespace SqlDatabase.Sequence; +namespace SqlDatabase.Sequence; public delegate Version GetDatabaseCurrentVersion(string? moduleName); \ No newline at end of file diff --git a/Sources/SqlDatabase.Sequence/ICreateScriptSequence.cs b/Sources/SqlDatabase.Sequence/ICreateScriptSequence.cs index a2024e4f..54fdd952 100644 --- a/Sources/SqlDatabase.Sequence/ICreateScriptSequence.cs +++ b/Sources/SqlDatabase.Sequence/ICreateScriptSequence.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence/IModuleVersionResolver.cs b/Sources/SqlDatabase.Sequence/IModuleVersionResolver.cs index 6f863691..509f80c4 100644 --- a/Sources/SqlDatabase.Sequence/IModuleVersionResolver.cs +++ b/Sources/SqlDatabase.Sequence/IModuleVersionResolver.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Sequence; +namespace SqlDatabase.Sequence; internal interface IModuleVersionResolver { diff --git a/Sources/SqlDatabase.Sequence/IUpgradeScriptSequence.cs b/Sources/SqlDatabase.Sequence/IUpgradeScriptSequence.cs index 333d30ee..3f11cf69 100644 --- a/Sources/SqlDatabase.Sequence/IUpgradeScriptSequence.cs +++ b/Sources/SqlDatabase.Sequence/IUpgradeScriptSequence.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace SqlDatabase.Sequence; +namespace SqlDatabase.Sequence; public interface IUpgradeScriptSequence { diff --git a/Sources/SqlDatabase.Sequence/ModuleVersionResolver.cs b/Sources/SqlDatabase.Sequence/ModuleVersionResolver.cs index 64bc845d..8a63b5cc 100644 --- a/Sources/SqlDatabase.Sequence/ModuleVersionResolver.cs +++ b/Sources/SqlDatabase.Sequence/ModuleVersionResolver.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence/ScriptDependency.cs b/Sources/SqlDatabase.Sequence/ScriptDependency.cs index 17704981..47ee1dc3 100644 --- a/Sources/SqlDatabase.Sequence/ScriptDependency.cs +++ b/Sources/SqlDatabase.Sequence/ScriptDependency.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Sequence; +namespace SqlDatabase.Sequence; internal readonly struct ScriptDependency : IEquatable { diff --git a/Sources/SqlDatabase.Sequence/ScriptStep.cs b/Sources/SqlDatabase.Sequence/ScriptStep.cs index b008b11d..7d21758a 100644 --- a/Sources/SqlDatabase.Sequence/ScriptStep.cs +++ b/Sources/SqlDatabase.Sequence/ScriptStep.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Sequence/UpgradeScriptCollection.cs b/Sources/SqlDatabase.Sequence/UpgradeScriptCollection.cs index 83cf967e..5e9eaac8 100644 --- a/Sources/SqlDatabase.Sequence/UpgradeScriptCollection.cs +++ b/Sources/SqlDatabase.Sequence/UpgradeScriptCollection.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; +using System.Globalization; using SqlDatabase.Adapter; using SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase.Sequence/UpgradeScriptSequence.cs b/Sources/SqlDatabase.Sequence/UpgradeScriptSequence.cs index 3c838782..e6cc6c5b 100644 --- a/Sources/SqlDatabase.Sequence/UpgradeScriptSequence.cs +++ b/Sources/SqlDatabase.Sequence/UpgradeScriptSequence.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.FileSystem; namespace SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs index 33bff8ac..d382ba7f 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using SqlDatabase.Adapter; using SqlDatabase.Configuration; diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs index f337b178..4fb5f50c 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using SqlDatabase.Adapter; using SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs index d0885ccc..080dc8fa 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs @@ -1,7 +1,4 @@ -using System; -using System.Data; -using System.IO; -using Moq; +using Moq; using NUnit.Framework; using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql.Export; diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs index c93c5380..bb8f760c 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using SqlDatabase.Adapter; using SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs deleted file mode 100644 index a2635078..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Moq; -using NUnit.Framework; -using Shouldly; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class CommandLineBaseTest -{ - private Mock _fs = null!; - private CommandLineBase _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _fs = new Mock(MockBehavior.Strict); - - _sut = new Mock { CallBase = true }.Object; - _sut.ConnectionString = "connection-string"; - _sut.FileSystemFactory = _fs.Object; - } - - [Test] - public void ParseFrom() - { - var file = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\11.sql")) - .Returns(file.Object); - - _sut.Parse(new CommandLine(new Arg("from", @"c:\11.sql"))); - - _sut.Scripts.ShouldBe(new[] { file.Object }); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs deleted file mode 100644 index 27b3e0f9..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using NUnit.Framework; -using Shouldly; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class CommandLineFactoryTest -{ - private CommandLineFactory _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _sut = new CommandLineFactory(); - } - - [Test] - [TestCase(CommandLineFactory.CommandCreate, typeof(CreateCommandLine))] - [TestCase(CommandLineFactory.CommandUpgrade, typeof(UpgradeCommandLine))] - [TestCase(CommandLineFactory.CommandExecute, typeof(ExecuteCommandLine))] - [TestCase(CommandLineFactory.CommandExport, typeof(ExportCommandLine))] - [TestCase(CommandLineFactory.CommandEcho, typeof(EchoCommandLine))] - public void Bind(string command, Type commandLine) - { - _sut.Args = new CommandLine(new Arg(command)); - - _sut.Bind().ShouldBeTrue(); - - _sut.ActiveCommandName.ShouldBe(command); - _sut.ShowCommandHelp.ShouldBeFalse(); - - CommandLineFactory.CreateCommand(_sut.ActiveCommandName).ShouldBeOfType(commandLine); - } - - [Test] - public void BindEmptyCommandLine() - { - _sut.Args = new CommandLine(Array.Empty(), Array.Empty()); - - _sut.Bind().ShouldBeFalse(); - } - - [Test] - public void BindUnknownCommand() - { - _sut.Args = new CommandLine(new Arg("Unknown")); - - var ex = Assert.Throws(() => _sut.Bind()); - - ex?.Message.ShouldContain("[Unknown]"); - } - - [Test] - public void BindNoCommand() - { - _sut.Args = new CommandLine(new Arg("key", "value")); - - Assert.Throws(() => _sut.Bind()); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs deleted file mode 100644 index 66a7baa6..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs +++ /dev/null @@ -1,84 +0,0 @@ -using NUnit.Framework; -using Shouldly; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class CommandLineParserTest -{ - private CommandLineParser _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _sut = new CommandLineParser(); - } - - [Test] - [TestCase("-x=y", "x", "y", true)] - [TestCase("x=y", null, "x=y", true)] - [TestCase("-x", "x", null, true)] - [TestCase("-x=", "x", null, true)] - [TestCase("-=x", null, null, false)] - [TestCase("-=", null, null, false)] - [TestCase("-", null, null, false)] - public void SplitArg(string keyValue, string? expectedKey, string? expectedValue, bool isValid) - { - CommandLineParser.ParseArg(keyValue, out var actual).ShouldBe(isValid); - if (isValid) - { - if (expectedKey == null) - { - actual.IsPair.ShouldBeFalse(); - - actual.Value.ShouldBe(expectedValue); - } - else - { - actual.IsPair.ShouldBeTrue(); - - actual.Key.ShouldBe(expectedKey); - actual.Value.ShouldBe(expectedValue); - } - } - } - - [Test] - public void Parse() - { - var actual = _sut - .Parse( - "execute", - "create", - "-database=connection string", - "-from=folder 1", - "-from=folder 2") - .Args; - - actual.Count.ShouldBe(5); - - actual[0].IsPair.ShouldBeFalse(); - actual[0].Value.ShouldBe("execute"); - - actual[1].IsPair.ShouldBeFalse(); - actual[1].Value.ShouldBe("create"); - - actual[2].IsPair.ShouldBeTrue(); - actual[2].Key.ShouldBe("database"); - actual[2].Value.ShouldBe("connection string"); - - actual[3].IsPair.ShouldBeTrue(); - actual[3].Key.ShouldBe("from"); - actual[3].Value.ShouldBe("folder 1"); - - actual[4].IsPair.ShouldBeTrue(); - actual[4].Key.ShouldBe("from"); - actual[4].Value.ShouldBe("folder 2"); - } - - [Test] - public void ParseFail() - { - Assert.Throws(() => _sut.Parse("-")); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs deleted file mode 100644 index bbd31da4..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Moq; -using NUnit.Framework; -using Shouldly; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class CreateCommandLineTest -{ - private Mock _log = null!; - private Mock _fs = null!; - private CreateCommandLine _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new CreateCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), -#if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), -#endif - new Arg("whatIf"))); - - _sut.Scripts.ShouldBe(new[] { folder.Object }); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - -#if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); -#endif - - _sut.WhatIf.ShouldBeTrue(); - } - - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.ConnectionString = "connection string"; - _sut.UsePowerShell = @"c:\PowerShell"; - - var builder = new EnvironmentBuilderMock() - .WithLogger(_log.Object) - .WithConfiguration(_sut.ConfigurationFile) - .WithPowerShellScripts(_sut.UsePowerShell) - .WithAssemblyScripts() - .WithVariables(_sut.Variables) - .WithDataBase(_sut.ConnectionString, TransactionMode.None, _sut.WhatIf) - .WithCreateSequence(_sut.Scripts); - - var actual = _sut - .CreateCommand(_log.Object, builder.Build()) - .ShouldBeOfType(); - - builder.VerifyAll(); - - actual.Log.ShouldBe(_log.Object); - actual.Database.ShouldBe(builder.Database); - actual.ScriptResolver.ShouldBe(builder.ScriptResolver); - actual.ScriptSequence.ShouldBe(builder.CreateSequence); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs deleted file mode 100644 index 1d911f81..00000000 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Moq; -using Shouldly; -using SqlDatabase.Adapter; -using SqlDatabase.FileSystem; -using SqlDatabase.Scripts; -using SqlDatabase.Sequence; - -namespace SqlDatabase.Configuration; - -internal sealed class EnvironmentBuilderMock -{ - private readonly Mock _mock = new(MockBehavior.Strict); - private readonly List _mockSequence = new(); - - public IDatabase Database { get; } = new Mock(MockBehavior.Strict).Object; - - public IScriptResolver ScriptResolver { get; } = new Mock(MockBehavior.Strict).Object; - - public IUpgradeScriptSequence UpgradeSequence { get; } = new Mock(MockBehavior.Strict).Object; - - public ICreateScriptSequence CreateSequence { get; } = new Mock(MockBehavior.Strict).Object; - - public EnvironmentBuilderMock WithLogger(ILogger logger) - { - _mock.Setup(b => b.WithLogger(logger)).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithLogger)); - return this; - } - - public EnvironmentBuilderMock WithConfiguration(string? configurationFile) - { - _mock.Setup(b => b.WithConfiguration(configurationFile)).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithConfiguration)); - return this; - } - - public EnvironmentBuilderMock WithPowerShellScripts(string? installationPath) - { - _mock.Setup(b => b.WithPowerShellScripts(installationPath)).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithPowerShellScripts)); - return this; - } - - public EnvironmentBuilderMock WithAssemblyScripts() - { - _mock.Setup(b => b.WithAssemblyScripts()).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithAssemblyScripts)); - return this; - } - - public EnvironmentBuilderMock WithVariables(IDictionary variables) - { - _mock.Setup(b => b.WithVariables(variables)).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithVariables)); - return this; - } - - public EnvironmentBuilderMock WithDataBase(string connectionString, TransactionMode transaction, bool whatIf) - { - _mock.Setup(b => b.WithDataBase(connectionString, transaction, whatIf)).Returns(_mock.Object); - _mockSequence.Add(nameof(IEnvironmentBuilder.WithDataBase)); - return this; - } - - public EnvironmentBuilderMock WithUpgradeSequence(IList scripts, bool folderAsModuleName) - { - _mock.Setup(b => b.BuildUpgradeSequence(scripts, folderAsModuleName)).Returns(UpgradeSequence); - _mockSequence.Add(nameof(IEnvironmentBuilder.BuildUpgradeSequence)); - return this; - } - - public EnvironmentBuilderMock WithCreateSequence(IList scripts) - { - _mock.Setup(b => b.BuildCreateSequence(scripts)).Returns(CreateSequence); - _mockSequence.Add(nameof(IEnvironmentBuilder.BuildCreateSequence)); - return this; - } - - public IEnvironmentBuilder Build() - { - _mock.Setup(b => b.BuildDatabase()).Returns(Database); - _mock.Setup(b => b.BuildScriptResolver()).Returns(ScriptResolver); - - return _mock.Object; - } - - public void VerifyAll() - { - _mock.VerifyAll(); - - var sequence = _mock - .Invocations - .Select(i => i.Method.Name) - .Where(i => i != nameof(IEnvironmentBuilder.BuildDatabase) && i != nameof(IEnvironmentBuilder.BuildScriptResolver)) - .ToArray(); - sequence.ShouldBe(_mockSequence); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs index fc8e4477..ed227067 100644 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; +using SqlDatabase.FileSystem; using SqlDatabase.Scripts; namespace SqlDatabase.Configuration; @@ -21,7 +20,7 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _configuration = new AppConfiguration(); - _sut = new EnvironmentBuilder(); + _sut = new EnvironmentBuilder(HostedRuntimeResolver.GetRuntime(false), new Mock(MockBehavior.Strict).Object); _sut .WithConfiguration(_configuration) diff --git a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs deleted file mode 100644 index 5ed2b3c9..00000000 --- a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs +++ /dev/null @@ -1,100 +0,0 @@ -using Moq; -using NUnit.Framework; -using Shouldly; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class ExecuteCommandLineTest -{ - private Mock _log = null!; - private Mock _fs = null!; - private ExecuteCommandLine _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new ExecuteCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - var sql = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - _fs - .Setup(f => f.FromContent("from2.sql", "drop 1")) - .Returns(sql.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("fromSql", "drop 1"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), - new Arg("transaction", "perStep"), -#if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), -#endif - new Arg("whatIf"))); - - _sut.Scripts.Count.ShouldBe(2); - _sut.Scripts[0].ShouldBe(folder.Object); - _sut.Scripts[1].ShouldBe(sql.Object); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - - _sut.Transaction.ShouldBe(TransactionMode.PerStep); - -#if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); -#endif - - _sut.WhatIf.ShouldBeTrue(); - } - - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.ConnectionString = "connection string"; - _sut.Transaction = TransactionMode.PerStep; - _sut.UsePowerShell = @"c:\PowerShell"; - - var builder = new EnvironmentBuilderMock() - .WithLogger(_log.Object) - .WithConfiguration(_sut.ConfigurationFile) - .WithPowerShellScripts(_sut.UsePowerShell) - .WithAssemblyScripts() - .WithVariables(_sut.Variables) - .WithDataBase(_sut.ConnectionString, _sut.Transaction, _sut.WhatIf) - .WithCreateSequence(_sut.Scripts); - - var actual = _sut - .CreateCommand(_log.Object, builder.Build()) - .ShouldBeOfType(); - - builder.VerifyAll(); - - actual.Log.ShouldBe(_log.Object); - actual.Database.ShouldBe(builder.Database); - actual.ScriptResolver.ShouldBe(builder.ScriptResolver); - actual.ScriptSequence.ShouldBe(builder.CreateSequence); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs deleted file mode 100644 index 39d8986e..00000000 --- a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.IO; -using Moq; -using NUnit.Framework; -using Shouldly; -using SqlDatabase.Adapter; -using SqlDatabase.Adapter.Sql.Export; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; -using SqlDatabase.TestApi; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class ExportCommandLineTest -{ - private Mock _log = null!; - private Mock _fs = null!; - private ExportCommandLine _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new ExportCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - var sql = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - _fs - .Setup(f => f.FromContent("from1.sql", "select 1")) - .Returns(sql.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("fromSql", "select 1"), - new Arg("from", @"c:\folder"), - new Arg("toTable", "dbo.ExportedData"), - new Arg("toFile", "file path"))); - - _sut.Scripts.Count.ShouldBe(2); - _sut.Scripts[0].ShouldBe(sql.Object); - _sut.Scripts[1].ShouldBe(folder.Object); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.DestinationTableName.ShouldBe("dbo.ExportedData"); - _sut.DestinationFileName.ShouldBe("file path"); - } - - [Test] - public void CreateCommand() - { - _sut.ConnectionString = "connection string"; - _sut.DestinationTableName = "table 1"; - - var builder = new EnvironmentBuilderMock() - .WithLogger(_log.Object) - .WithConfiguration(_sut.ConfigurationFile) - .WithVariables(_sut.Variables) - .WithDataBase(_sut.ConnectionString, TransactionMode.None, false) - .WithCreateSequence(_sut.Scripts); - - var actual = _sut - .CreateCommand(_log.Object, builder.Build()) - .ShouldBeOfType(); - - builder.VerifyAll(); - - actual.Log.ShouldNotBe(_log.Object); - actual.Database.ShouldBe(builder.Database); - actual.ScriptResolver.ShouldBe(builder.ScriptResolver); - actual.ScriptSequence.ShouldBe(builder.CreateSequence); - actual.OpenOutput.ShouldNotBeNull(); - actual.DestinationTableName.ShouldBe("table 1"); - } - - [Test] - public void CreateOutputConsole() - { - var actual = _sut.CreateOutput(); - - string output; - using (var console = new TempConsoleOut()) - { - using (var writer = actual()) - { - writer.Write("hello"); - } - - output = console.GetOutput(); - } - - output.ShouldBe("hello"); - } - - [Test] - public void WrapLoggerConsole() - { - _sut.WrapLogger(_log.Object).ShouldBeOfType(); - } - - [Test] - public void CreateOutputFile() - { - using (var file = new TempFile(".sql")) - { - _sut.DestinationFileName = file.Location; - - var actual = _sut.CreateOutput(); - - using (var writer = actual()) - { - writer.Write("hello 1"); - } - - FileAssert.Exists(file.Location); - File.ReadAllText(file.Location).ShouldBe("hello 1"); - - using (var writer = actual()) - { - writer.Write("hello 2"); - } - - File.ReadAllText(file.Location).ShouldBe("hello 2"); - } - } - - [Test] - public void WrapLoggerFile() - { - _sut.DestinationFileName = "file"; - - _sut.WrapLogger(_log.Object).ShouldBe(_log.Object); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs b/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs deleted file mode 100644 index 016a2772..00000000 --- a/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs +++ /dev/null @@ -1,119 +0,0 @@ -using NUnit.Framework; -using Shouldly; -using SqlDatabase.TestApi; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class GenericCommandLineBuilderTest -{ - private GenericCommandLineBuilder _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _sut = new GenericCommandLineBuilder(); - } - - [Test] - public void BuildArray() - { - var args = _sut - .SetCommand("some command") - .SetConnection("Data Source=.;Initial Catalog=SqlDatabaseTest") - .SetScripts("file1") - .SetScripts("file2") - .SetConfigurationFile("configuration file") - .SetTransaction(TransactionMode.PerStep) - .SetVariable("var1", "value 1") - .SetWhatIf(true) - .SetFolderAsModuleName(true) - .SetLogFileName("log file") - .BuildArray(); - - foreach (var arg in args) - { - TestOutput.WriteLine(arg); - } - - CommandLineParser.GetLogFileName(args).ShouldBe("log file"); - var actual = new CommandLineParser().Parse(args); - - actual.Args.Count.ShouldBe(9); - - actual.Args[0].IsPair.ShouldBe(false); - actual.Args[0].Value.ShouldBe("some command"); - - actual.Args[1].Key.ShouldBe("database"); - actual.Args[1].Value.ShouldBe("Data Source=.;Initial Catalog=SqlDatabaseTest"); - - actual.Args[2].Key.ShouldBe("from"); - actual.Args[2].Value.ShouldBe("file1"); - - actual.Args[3].Key.ShouldBe("from"); - actual.Args[3].Value.ShouldBe("file2"); - - actual.Args[4].Key.ShouldBe("transaction"); - actual.Args[4].Value.ShouldBe("PerStep"); - - actual.Args[5].Key.ShouldBe("configuration"); - actual.Args[5].Value.ShouldBe("configuration file"); - - actual.Args[6].Key.ShouldBe("varvar1"); - actual.Args[6].Value.ShouldBe("value 1"); - - actual.Args[7].Key.ShouldBe("whatIf"); - actual.Args[7].Value.ShouldBe("True"); - - actual.Args[8].Key.ShouldBe("folderAsModuleName"); - actual.Args[8].Value.ShouldBe("True"); - } - - [Test] - public void BuildArrayScripts() - { - var actual = _sut - .SetScripts("file1") - .SetScripts("file2") - .BuildArray(); - - actual.Length.ShouldBe(4); - actual[2].ShouldBe("-from=file1"); - actual[3].ShouldBe("-from=file2"); - } - - [Test] - public void BuildArrayInLineScripts() - { - var actual = _sut - .SetInLineScript("file1") - .SetInLineScript("file2") - .BuildArray(); - - actual.Length.ShouldBe(4); - actual[2].ShouldBe("-fromSql=file1"); - actual[3].ShouldBe("-fromSql=file2"); - } - - [Test] - public void BuildArrayExportToTable() - { - var actual = _sut - .SetExportToTable("name") - .BuildArray(); - - actual.Length.ShouldBe(3); - actual[2].ShouldBe("-toTable=name"); - } - - [Test] - public void BuildArrayExportToFile() - { - var actual = _sut - .SetExportToFile("file name") - .BuildArray(); - - actual.Length.ShouldBe(3); - actual[2].ShouldBe("-toFile=file name"); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/HostedRuntimeResolverTest.cs b/Sources/SqlDatabase.Test/Configuration/HostedRuntimeResolverTest.cs new file mode 100644 index 00000000..aabe6e51 --- /dev/null +++ b/Sources/SqlDatabase.Test/Configuration/HostedRuntimeResolverTest.cs @@ -0,0 +1,46 @@ +using System.Runtime.InteropServices; +using NUnit.Framework; +using Shouldly; +using SqlDatabase.Adapter; +using SqlDatabase.TestApi; + +namespace SqlDatabase.Configuration; + +[TestFixture] +public class HostedRuntimeResolverTest +{ + [Test] + public void GetRuntime() + { + TestOutput.WriteLine($"Version: {Environment.Version}"); + TestOutput.WriteLine($"FrameworkDescription: {RuntimeInformation.FrameworkDescription}"); + +#if NET472 + var expected = FrameworkVersion.Net472; +#elif NET6_0 + var expected = FrameworkVersion.Net6; +#elif NET7_0 + var expected = FrameworkVersion.Net7; +#else + var expected = FrameworkVersion.Net8; +#endif + + var actual = HostedRuntimeResolver.GetRuntime(false); + + actual.Version.ShouldBe(expected); + } + + [Test] + [TestCase(".NET Framework 4.8.9181.0", "4.0.30319.42000", FrameworkVersion.Net472, TestName = ".net 4.8")] + [TestCase(".NET Core 4.6.26725.06", "4.0.30319.42000", FrameworkVersion.Net6, TestName = "6.1.0-ubuntu-18.04")] + [TestCase(".NET Core 4.6.27317.03", "4.0.30319.42000", FrameworkVersion.Net6, TestName = "6.1.3-ubuntu-18.04")] + [TestCase(".NET Core 4.6.27817.01", "4.0.30319.42000", FrameworkVersion.Net6, TestName = "6.2.2-ubuntu-18.04")] + [TestCase(".NET Core 4.6.28008.01", "4.0.30319.42000", FrameworkVersion.Net6, TestName = "6.2.4-ubuntu-18.04")] + [TestCase(".NET Core 3.1.2", "3.1.2", FrameworkVersion.Net6, TestName = "7.0.0-ubuntu-18.04")] + [TestCase(".NET Core 3.1.6", "3.1.6", FrameworkVersion.Net6, TestName = "7.0.0-ubuntu-18.04")] + [TestCase(".NET 5.0.0", "5.0.0", FrameworkVersion.Net6, TestName = "7.1.0-ubuntu-18.04")] + public void ResolveVersion(string description, string version, FrameworkVersion expected) + { + HostedRuntimeResolver.ResolveVersion(description, new Version(version)).ShouldBe(expected); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs deleted file mode 100644 index e2bb4077..00000000 --- a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Moq; -using NUnit.Framework; -using Shouldly; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -[TestFixture] -public class UpgradeCommandLineTest -{ - private Mock _log = null!; - private Mock _fs = null!; - private UpgradeCommandLine _sut = null!; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new UpgradeCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), - new Arg("transaction", "perStep"), - new Arg("folderAsModuleName"), -#if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), -#endif - new Arg("whatIf"))); - - _sut.Scripts.ShouldBe(new[] { folder.Object }); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - - _sut.Transaction.ShouldBe(TransactionMode.PerStep); - -#if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); -#endif - - _sut.WhatIf.ShouldBeTrue(); - _sut.FolderAsModuleName.ShouldBeTrue(); - } - - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.FolderAsModuleName = true; - _sut.Transaction = TransactionMode.PerStep; - _sut.ConnectionString = "connection string"; - _sut.UsePowerShell = @"c:\PowerShell"; - - var builder = new EnvironmentBuilderMock() - .WithLogger(_log.Object) - .WithConfiguration(_sut.ConfigurationFile) - .WithPowerShellScripts(_sut.UsePowerShell) - .WithAssemblyScripts() - .WithVariables(_sut.Variables) - .WithDataBase(_sut.ConnectionString, _sut.Transaction, _sut.WhatIf) - .WithUpgradeSequence(_sut.Scripts, _sut.FolderAsModuleName); - - var actual = _sut - .CreateCommand(_log.Object, builder.Build()) - .ShouldBeOfType(); - - builder.VerifyAll(); - - actual.Log.ShouldBe(_log.Object); - actual.Database.ShouldBe(builder.Database); - actual.ScriptResolver.ShouldBe(builder.ScriptResolver); - actual.ScriptSequence.ShouldBe(builder.UpgradeSequence); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs b/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs index 5e887bb0..55acdd00 100644 --- a/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs +++ b/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; diff --git a/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs b/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs index 27b373cb..37420127 100644 --- a/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs +++ b/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs index 09cef943..8105fce5 100644 --- a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs +++ b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using Moq; +using Moq; using Moq.Protected; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Log; @@ -36,9 +36,8 @@ public void Info() { _sut.Info("the text"); - Assert.AreEqual(1, _info.Count); - Assert.AreEqual(0, _error.Count); - Assert.AreEqual("the text", _info[0]); + _info.ShouldBe(["the text"]); + _error.ShouldBeEmpty(); } [Test] @@ -46,9 +45,8 @@ public void Error() { _sut.Error("the text"); - Assert.AreEqual(0, _info.Count); - Assert.AreEqual(1, _error.Count); - Assert.AreEqual("the text", _error[0]); + _info.ShouldBeEmpty(); + _error.ShouldBe(["the text"]); } [Test] @@ -57,7 +55,7 @@ public void NoIndentOnError() _sut.Indent(); _sut.Error("the text"); - Assert.AreEqual("the text", _error[0]); + _error[0].ShouldBe("the text"); } [Test] @@ -77,10 +75,11 @@ public void IndentInfo() _sut.Info("2+"); } - Assert.AreEqual(4, _info.Count); - Assert.AreEqual("1-", _info[0]); - Assert.AreEqual(" 2-", _info[1]); - Assert.AreEqual(" 3", _info[2]); - Assert.AreEqual(" 2+", _info[3]); + _info.ShouldBe([ + "1-", + " 2-", + " 3", + " 2+" + ]); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs b/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs index 5834b92c..27fc724f 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; diff --git a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs index a0712b80..50b61b0c 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Linq; +using System.Data.Common; using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; -using SqlDatabase.Configuration; using SqlDatabase.TestApi; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase.Test/Scripts/ScriptResolverTest.cs b/Sources/SqlDatabase.Test/Scripts/ScriptResolverTest.cs index b343c2e9..2d5f2639 100644 --- a/Sources/SqlDatabase.Test/Scripts/ScriptResolverTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/ScriptResolverTest.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; diff --git a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs index 4d4cfb53..33f096e1 100644 --- a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs @@ -1,5 +1,5 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Scripts; @@ -23,13 +23,13 @@ public void GetValueEnvironmentVariable(VariableSource source, bool isOverridden { const string Key = "TEMP"; - Assert.IsNotNull(_sut.GetValue(Key)); - Assert.AreEqual(Environment.GetEnvironmentVariable(Key), _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldNotBeNull(); + _sut.GetValue(Key).ShouldBe(Environment.GetEnvironmentVariable(Key)); _sut.SetValue(source, Key, "new value"); var expected = isOverridden ? "new value" : Environment.GetEnvironmentVariable(Key); - Assert.AreEqual(expected, _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe(expected); } [Test] @@ -37,16 +37,16 @@ public void NullValue() { const string Key = "some name"; - Assert.IsNull(_sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBeNull(); _sut.SetValue(VariableSource.CommandLine, Key, "1"); - Assert.AreEqual("1", _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe("1"); _sut.SetValue(VariableSource.CommandLine, Key, string.Empty); - Assert.AreEqual(string.Empty, _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe(string.Empty); _sut.SetValue(VariableSource.CommandLine, Key, null); - Assert.IsNull(_sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBeNull(); } [Test] @@ -63,28 +63,28 @@ public void ResolvePriority(VariableSource expected, VariableSource competitor) const string CompetitorValue = "competitor"; // default - Assert.IsNull(_sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBeNull(); // competitor, expected _sut.SetValue(competitor, Key, CompetitorValue); _sut.SetValue(expected, Key, ExpectedValue); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe(ExpectedValue); // try to remove by competitor _sut.SetValue(competitor, Key, null); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe(ExpectedValue); // try to remove by expected _sut.SetValue(expected, Key, null); - Assert.IsNull(_sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBeNull(); // expected, competitor _sut.SetValue(expected, Key, ExpectedValue); _sut.SetValue(competitor, Key, CompetitorValue); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); + _sut.GetValue(Key).ShouldBe(ExpectedValue); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj.user b/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj.user deleted file mode 100644 index 88a55094..00000000 --- a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs index 5a8843f9..53382ec6 100644 --- a/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs +++ b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Xml; +using System.Xml; using Shouldly; namespace SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.TestApi/FileFactory.cs b/Sources/SqlDatabase.TestApi/FileFactory.cs index 69b58c61..bfb05567 100644 --- a/Sources/SqlDatabase.TestApi/FileFactory.cs +++ b/Sources/SqlDatabase.TestApi/FileFactory.cs @@ -1,8 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; -using Moq; +using Moq; using Shouldly; using SqlDatabase.FileSystem; @@ -44,6 +40,7 @@ public static IFolder Folder(string name, params IFileSystemInfo[] content) var folder = new Mock(MockBehavior.Strict); folder.SetupGet(f => f.Name).Returns(name); + folder.Setup(f => f.GetFullName()).Returns(name); var files = content.OfType().ToArray(); folder.Setup(f => f.GetFiles()).Returns(files); diff --git a/Sources/SqlDatabase.TestApi/ResourceReader.cs b/Sources/SqlDatabase.TestApi/ResourceReader.cs index 5e751431..d840dffc 100644 --- a/Sources/SqlDatabase.TestApi/ResourceReader.cs +++ b/Sources/SqlDatabase.TestApi/ResourceReader.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; +using System.Reflection; using Shouldly; namespace SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.TestApi/TempConsoleOut.cs b/Sources/SqlDatabase.TestApi/TempConsoleOut.cs index 942c8cb7..32d50635 100644 --- a/Sources/SqlDatabase.TestApi/TempConsoleOut.cs +++ b/Sources/SqlDatabase.TestApi/TempConsoleOut.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; - -namespace SqlDatabase.TestApi; +namespace SqlDatabase.TestApi; public sealed class TempConsoleOut : IDisposable { diff --git a/Sources/SqlDatabase.TestApi/TempDirectory.cs b/Sources/SqlDatabase.TestApi/TempDirectory.cs index 9f646124..54ca4be5 100644 --- a/Sources/SqlDatabase.TestApi/TempDirectory.cs +++ b/Sources/SqlDatabase.TestApi/TempDirectory.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; -using Shouldly; +using Shouldly; namespace SqlDatabase.TestApi; @@ -19,10 +16,11 @@ public string CopyFileFromResources(string resourceName, Type? resourceAnchor = { if (resourceAnchor == null) { - resourceAnchor = new StackTrace().GetFrame(1)!.GetMethod()!.DeclaringType; + resourceAnchor = new StackTrace().GetFrame(1)?.GetMethod()?.DeclaringType; } - var source = resourceAnchor!.Assembly.GetManifestResourceStream(resourceAnchor.Namespace + "." + resourceName); + resourceAnchor.ShouldNotBeNull(); + var source = resourceAnchor.Assembly.GetManifestResourceStream(resourceAnchor.Namespace + "." + resourceName); source.ShouldNotBeNull(resourceName); var fileName = Path.Combine(Location, resourceName); @@ -30,7 +28,7 @@ public string CopyFileFromResources(string resourceName, Type? resourceAnchor = using (source) using (var dest = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite)) { - source!.CopyTo(dest); + source.CopyTo(dest); } return fileName; diff --git a/Sources/SqlDatabase.TestApi/TempFile.cs b/Sources/SqlDatabase.TestApi/TempFile.cs index d327c9bf..5524ca44 100644 --- a/Sources/SqlDatabase.TestApi/TempFile.cs +++ b/Sources/SqlDatabase.TestApi/TempFile.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; - -namespace SqlDatabase.TestApi; +namespace SqlDatabase.TestApi; public sealed class TempFile : IDisposable { diff --git a/Sources/SqlDatabase.TestApi/TestOutput.cs b/Sources/SqlDatabase.TestApi/TestOutput.cs index 21d173a8..5c5469f7 100644 --- a/Sources/SqlDatabase.TestApi/TestOutput.cs +++ b/Sources/SqlDatabase.TestApi/TestOutput.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; - -namespace SqlDatabase.TestApi; +namespace SqlDatabase.TestApi; public static class TestOutput { diff --git a/Sources/SqlDatabase.TestApi/TextExtensions.cs b/Sources/SqlDatabase.TestApi/TextExtensions.cs index a70c8949..2935e21a 100644 --- a/Sources/SqlDatabase.TestApi/TextExtensions.cs +++ b/Sources/SqlDatabase.TestApi/TextExtensions.cs @@ -1,8 +1,4 @@ -using System; -using System.IO; -using System.Text; - -namespace SqlDatabase.TestApi; +namespace SqlDatabase.TestApi; public static class TextExtensions { diff --git a/Sources/SqlDatabase.sln b/Sources/SqlDatabase.sln index c0bc870f..1d02e208 100644 --- a/Sources/SqlDatabase.sln +++ b/Sources/SqlDatabase.sln @@ -60,9 +60,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlDatabase.Adapter.MySql", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlDatabase.Adapter.MySql.Test", "SqlDatabase.Adapter.MySql.Test\SqlDatabase.Adapter.MySql.Test.csproj", "{D017ECF1-F2E3-4EAF-970B-F46991AD86F6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlDatabase.Configuration", "SqlDatabase.Configuration\SqlDatabase.Configuration.csproj", "{A351BD5C-F646-42BB-A1E0-EA63E88934D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlDatabase.Configuration", "SqlDatabase.Configuration\SqlDatabase.Configuration.csproj", "{A351BD5C-F646-42BB-A1E0-EA63E88934D9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlDatabase.Configuration.Test", "SqlDatabase.Configuration.Test\SqlDatabase.Configuration.Test.csproj", "{1D6B0790-DE5A-4057-AC65-76FA2E7EF198}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlDatabase.Configuration.Test", "SqlDatabase.Configuration.Test\SqlDatabase.Configuration.Test.csproj", "{1D6B0790-DE5A-4057-AC65-76FA2E7EF198}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlDatabase.CommandLine", "SqlDatabase.CommandLine\SqlDatabase.CommandLine.csproj", "{627ED9FC-20A6-48EF-90D7-7888397CF712}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlDatabase.CommandLine.Test", "SqlDatabase.CommandLine.Test\SqlDatabase.CommandLine.Test.csproj", "{E0ACD46D-CE78-4B04-B0F7-110ACE118EAD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -174,6 +178,14 @@ Global {1D6B0790-DE5A-4057-AC65-76FA2E7EF198}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D6B0790-DE5A-4057-AC65-76FA2E7EF198}.Release|Any CPU.ActiveCfg = Release|Any CPU {1D6B0790-DE5A-4057-AC65-76FA2E7EF198}.Release|Any CPU.Build.0 = Release|Any CPU + {627ED9FC-20A6-48EF-90D7-7888397CF712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {627ED9FC-20A6-48EF-90D7-7888397CF712}.Debug|Any CPU.Build.0 = Debug|Any CPU + {627ED9FC-20A6-48EF-90D7-7888397CF712}.Release|Any CPU.ActiveCfg = Release|Any CPU + {627ED9FC-20A6-48EF-90D7-7888397CF712}.Release|Any CPU.Build.0 = Release|Any CPU + {E0ACD46D-CE78-4B04-B0F7-110ACE118EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0ACD46D-CE78-4B04-B0F7-110ACE118EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0ACD46D-CE78-4B04-B0F7-110ACE118EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0ACD46D-CE78-4B04-B0F7-110ACE118EAD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -192,6 +204,7 @@ Global {33749EF7-49CE-4564-BF9D-5713806CC646} = {6E9C8ACC-7A1B-47F4-B7C0-78DE8C931A08} {D017ECF1-F2E3-4EAF-970B-F46991AD86F6} = {6E9C8ACC-7A1B-47F4-B7C0-78DE8C931A08} {1D6B0790-DE5A-4057-AC65-76FA2E7EF198} = {6E9C8ACC-7A1B-47F4-B7C0-78DE8C931A08} + {E0ACD46D-CE78-4B04-B0F7-110ACE118EAD} = {6E9C8ACC-7A1B-47F4-B7C0-78DE8C931A08} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CFDC1B98-55BE-40C3-BF95-A2BA8182DC40} diff --git a/Sources/SqlDatabase/Commands/CommandFactory.cs b/Sources/SqlDatabase/Commands/CommandFactory.cs new file mode 100644 index 00000000..6a9c3390 --- /dev/null +++ b/Sources/SqlDatabase/Commands/CommandFactory.cs @@ -0,0 +1,164 @@ +using SqlDatabase.Adapter; +using SqlDatabase.Adapter.Sql.Export; +using SqlDatabase.CommandLine; +using SqlDatabase.Configuration; +using SqlDatabase.FileSystem; +using SqlDatabase.Sequence; + +namespace SqlDatabase.Commands; + +internal sealed class CommandFactory +{ + private readonly ILogger _logger; + private readonly IEnvironmentBuilder _builder; + private readonly IFileSystemFactory _fileSystem; + + public CommandFactory(ILogger logger, IEnvironmentBuilder builder, IFileSystemFactory fileSystem) + { + _logger = logger; + _builder = builder; + _fileSystem = fileSystem; + } + + public ICommand CreateCommand(ICommandLine commandLine) + { + if (commandLine is CreateCommandLine create) + { + return NewCreateCommand(create); + } + + if (commandLine is ExecuteCommandLine execute) + { + return NewExecuteCommand(execute); + } + + if (commandLine is UpgradeCommandLine upgrade) + { + return NewUpgradeCommand(upgrade); + } + + if (commandLine is ExportCommandLine export) + { + return NewExportCommand(export); + } + + throw new NotSupportedException(); + } + + private static Func CreateExportOutput(string? fileName) + { + if (string.IsNullOrEmpty(fileName)) + { + return static () => Console.Out; + } + + return () => new StreamWriter(fileName, false); + } + + private DatabaseCreateCommand NewCreateCommand(CreateCommandLine commandLine) + { + _builder + .WithLogger(_logger) + .WithConfiguration(commandLine.Configuration) + .WithPowerShellScripts(commandLine.UsePowerShell) + .WithAssemblyScripts() + .WithVariables(commandLine.Variables) + .WithDataBase(commandLine.Database, TransactionMode.None, commandLine.WhatIf); + + var database = _builder.BuildDatabase(); + var scriptResolver = _builder.BuildScriptResolver(); + var sequence = ToCreateScriptSequence(commandLine.From); + + return new DatabaseCreateCommand(sequence, scriptResolver, database, _logger); + } + + private DatabaseExecuteCommand NewExecuteCommand(ExecuteCommandLine commandLine) + { + _builder + .WithLogger(_logger) + .WithConfiguration(commandLine.Configuration) + .WithPowerShellScripts(commandLine.UsePowerShell) + .WithAssemblyScripts() + .WithVariables(commandLine.Variables) + .WithDataBase(commandLine.Database, commandLine.Transaction, commandLine.WhatIf); + + var database = _builder.BuildDatabase(); + var scriptResolver = _builder.BuildScriptResolver(); + var sequence = ToCreateScriptSequence(commandLine.From); + + return new DatabaseExecuteCommand(sequence, scriptResolver, database, _logger); + } + + private DatabaseUpgradeCommand NewUpgradeCommand(UpgradeCommandLine commandLine) + { + _builder + .WithLogger(_logger) + .WithConfiguration(commandLine.Configuration) + .WithPowerShellScripts(commandLine.UsePowerShell) + .WithAssemblyScripts() + .WithVariables(commandLine.Variables) + .WithDataBase(commandLine.Database, commandLine.Transaction, commandLine.WhatIf); + + var database = _builder.BuildDatabase(); + var scriptResolver = _builder.BuildScriptResolver(); + + var from = ToFileSystem(commandLine.From); + + var sequence = new UpgradeScriptSequence( + _builder.BuildScriptFactory(), + database.GetCurrentVersion, + from, + _logger, + commandLine.FolderAsModuleName, + commandLine.WhatIf); + + return new DatabaseUpgradeCommand(sequence, scriptResolver, database, _logger); + } + + private DatabaseExportCommand NewExportCommand(ExportCommandLine commandLine) + { + _builder + .WithLogger(_logger) + .WithConfiguration(commandLine.Configuration) + .WithVariables(commandLine.Variables) + .WithDataBase(commandLine.Database, TransactionMode.None, false); + + var database = _builder.BuildDatabase(); + var scriptResolver = _builder.BuildScriptResolver(); + var sequence = ToCreateScriptSequence(commandLine.From); + + var logger = string.IsNullOrEmpty(commandLine.DestinationFileName) ? new DataExportLogger(_logger) : _logger; + + return new DatabaseExportCommand( + sequence, + scriptResolver, + CreateExportOutput(commandLine.DestinationFileName), + database, + logger) + { + DestinationTableName = commandLine.DestinationTableName + }; + } + + private CreateScriptSequence ToCreateScriptSequence(List sources) + { + var from = ToFileSystem(sources); + return new CreateScriptSequence(from, _builder.BuildScriptFactory()); + } + + private List ToFileSystem(List sources) + { + var result = new List(sources.Count); + + for (var i = 0; i < sources.Count; i++) + { + var source = sources[i]; + var script = source.IsInline + ? _fileSystem.FromContent($"from{i + 1}.sql", source.Value) + : _fileSystem.FileSystemInfoFromPath(source.Value); + result.Add(script); + } + + return result; + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs b/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs index cfd63119..9374f477 100644 --- a/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Configuration; using SqlDatabase.Scripts; using SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs b/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs index fba1f2cf..6d285877 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Scripts; using SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs index 82769fc0..a0fc5910 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs @@ -1,8 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Text; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql.Export; using SqlDatabase.Scripts; using SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs index fa0d8d6f..ff2869f3 100644 --- a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Scripts; using SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase/Commands/EchoCommand.cs b/Sources/SqlDatabase/Commands/EchoCommand.cs deleted file mode 100644 index 31423d4d..00000000 --- a/Sources/SqlDatabase/Commands/EchoCommand.cs +++ /dev/null @@ -1,28 +0,0 @@ -using SqlDatabase.Adapter; -using SqlDatabase.Configuration; - -namespace SqlDatabase.Commands; - -internal sealed class EchoCommand : ICommand -{ - public EchoCommand(ILogger logger, CommandLine args) - { - Logger = logger; - Args = args; - } - - public ILogger Logger { get; } - - public CommandLine Args { get; } - - public void Execute() - { - if (Args.Original != null) - { - foreach (var arg in Args.Original) - { - Logger.Info(arg); - } - } - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLine.cs b/Sources/SqlDatabase/Configuration/CommandLine.cs deleted file mode 100644 index 77e1a669..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLine.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; - -internal readonly struct CommandLine -{ - public CommandLine(IList args, string[]? original) - { - Args = args; - Original = original; - } - - public CommandLine(params Arg[] args) - { - Args = args; - Original = null; - } - - public IList Args { get; } - - public string[]? Original { get; } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt index bbeb66a7..d2f6c449 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt +++ b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt @@ -11,6 +11,8 @@ Upgrade an existing database -from=C:\MyDatabase\UpgradeScripts.zip - execute migration steps on MyDatabase from UpgradeScripts.zip archive -from=C:\MyDatabase.zip\UpgradeScripts - execute migration steps on MyDatabase from UpgradeScripts folder in MyDatabase.zip archive + -folderAsModuleName + -var: set a variable in format "-var[name of variable]=[value of variable]" -varRecoveryModel=FULL - usage: ALTER DATABASE [{{NewDatabase}}] SET RECOVERY {{RecoveryModel}} WITH NO_WAIT diff --git a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt index f53cd075..30e1dece 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt +++ b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt @@ -11,6 +11,8 @@ Upgrade an existing database -from=C:\MyDatabase\UpgradeScripts.zip - execute migration steps on MyDatabase from UpgradeScripts.zip archive -from=C:\MyDatabase.zip\UpgradeScripts - execute migration steps on MyDatabase from UpgradeScripts folder in MyDatabase.zip archive + -folderAsModuleName + -var: set a variable in format "-var[name of variable]=[value of variable]" -varRecoveryModel=FULL - usage: ALTER DATABASE [{{NewDatabase}}] SET RECOVERY {{RecoveryModel}} WITH NO_WAIT diff --git a/Sources/SqlDatabase/Configuration/CommandLineBase.cs b/Sources/SqlDatabase/Configuration/CommandLineBase.cs deleted file mode 100644 index ad5d9ff2..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineBase.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Collections.Generic; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -internal abstract class CommandLineBase : ICommandLine -{ - public string? ConnectionString { get; set; } - - public IList Scripts { get; } = new List(); - - public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - - public string? ConfigurationFile { get; set; } - - public IFileSystemFactory FileSystemFactory { get; set; } = new FileSystemFactory(); - - public void Parse(CommandLine args) - { - foreach (var arg in args.Args) - { - ApplyArg(arg); - } - - if (string.IsNullOrWhiteSpace(ConnectionString)) - { - throw new InvalidCommandLineException($"Options {Arg.Database} is not specified."); - } - - if (Scripts.Count == 0) - { - throw new InvalidCommandLineException($"Options {Arg.Scripts} is not specified."); - } - - Validate(); - } - - public abstract ICommand CreateCommand(ILogger logger); - - protected internal virtual void Validate() - { - } - - protected static bool TryParseSwitchParameter(Arg arg, string parameterName, out bool value) - { - if (parameterName.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - value = string.IsNullOrEmpty(arg.Value) || bool.Parse(arg.Value); - return true; - } - - if (!arg.IsPair && parameterName.Equals(arg.Value, StringComparison.OrdinalIgnoreCase)) - { - value = true; - return true; - } - - value = false; - return false; - } - - protected static bool TryParseWhatIf(Arg arg, out bool whatIf) => TryParseSwitchParameter(arg, Arg.WhatIf, out whatIf); - - protected virtual bool ParseArg(Arg arg) - { - return false; - } - - protected void SetInLineScript(string? value) - { - if (string.IsNullOrEmpty(value)) - { - return; - } - - var index = Scripts.Count + 1; - var script = FileSystemFactory.FromContent($"from{index}.sql", value!); - - Scripts.Add(script); - } - - private void ApplyArg(Arg arg) - { - bool isParsed; - try - { - isParsed = (arg.IsPair && TryParseKnownPair(arg)) || ParseArg(arg); - } - catch (InvalidCommandLineException) - { - throw; - } - catch (Exception ex) - { - throw new InvalidCommandLineException($"Fail to parse option [{arg}].", ex); - } - - if (!isParsed) - { - throw new InvalidCommandLineException($"Unknown option [{arg}]."); - } - } - - private bool TryParseKnownPair(Arg arg) - { - if (Arg.Database.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - ConnectionString = arg.Value; - return true; - } - - if (Arg.Scripts.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetScripts(arg.Value); - return true; - } - - if (arg.Key != null && arg.Key.StartsWith(Arg.Variable, StringComparison.OrdinalIgnoreCase)) - { - SetVariable(arg.Key.Substring(Arg.Variable.Length), arg.Value); - return true; - } - - if (Arg.Configuration.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetConfigurationFile(arg.Value); - return true; - } - - return false; - } - - private void SetScripts(string? value) - { - Scripts.Add(FileSystemFactory.FileSystemInfoFromPath(value)); - } - - private void SetVariable(string? name, string? value) - { - name = name?.Trim(); - if (string.IsNullOrEmpty(name)) - { - throw new InvalidCommandLineException(Arg.Variable, $"Invalid variable name [{name}]."); - } - - if (Variables.ContainsKey(name!)) - { - throw new InvalidCommandLineException(Arg.Variable, $"Variable with name [{name}] is duplicated."); - } - - Variables.Add(name!, value ?? string.Empty); - } - - private void SetConfigurationFile(string? configurationFile) - { - ConfigurationFile = configurationFile; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs deleted file mode 100644 index 1aa4aa41..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Linq; - -namespace SqlDatabase.Configuration; - -internal sealed class CommandLineFactory -{ - internal const string CommandUpgrade = "Upgrade"; - internal const string CommandCreate = "Create"; - internal const string CommandExecute = "Execute"; - internal const string CommandExport = "Export"; - internal const string CommandEcho = "Echo"; - - public CommandLine Args { get; set; } - - public string ActiveCommandName { get; private set; } = null!; - - public bool ShowCommandHelp { get; private set; } - - public bool Bind() - { - var commandArgs = Args.Args.ToList(); - if (commandArgs.Count == 0) - { - return false; - } - - if (commandArgs[0].IsPair) - { - throw new InvalidCommandLineException(" not found."); - } - - ActiveCommandName = commandArgs[0].Value!; - var command = CreateCommand(ActiveCommandName); - - if (command == null) - { - throw new InvalidCommandLineException($"Unknown command [{ActiveCommandName}]."); - } - - commandArgs.RemoveAt(0); - - for (var i = 0; i < commandArgs.Count; i++) - { - var arg = commandArgs[i]; - - if (arg.IsPair - && (Arg.Help.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) - || Arg.HelpShort.Equals(arg.Key, StringComparison.OrdinalIgnoreCase))) - { - ShowCommandHelp = true; - commandArgs.RemoveAt(i); - break; - } - } - - Args = new CommandLine(commandArgs, Args.Original); - return true; - } - - public ICommandLine? Resolve() - { - var command = CreateCommand(ActiveCommandName); - command?.Parse(Args); - return command; - } - - internal static ICommandLine? CreateCommand(string? name) - { - if (CommandCreate.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new CreateCommandLine(); - } - - if (CommandUpgrade.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new UpgradeCommandLine(); - } - - if (CommandExecute.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new ExecuteCommandLine(); - } - - if (CommandExport.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new ExportCommandLine(); - } - - if (CommandEcho.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new EchoCommandLine(); - } - - return null; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLineParser.cs b/Sources/SqlDatabase/Configuration/CommandLineParser.cs deleted file mode 100644 index aec19af6..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineParser.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; - -internal sealed class CommandLineParser -{ - public static string? GetLogFileName(IList args) - { - for (var i = 0; i < args.Count; i++) - { - if (ParseArg(args[i], out var value) - && IsLog(value)) - { - return value.Value; - } - } - - return null; - } - - public CommandLine Parse(params string[] args) - { - var result = new List(args.Length); - - foreach (var arg in args) - { - if (!ParseArg(arg, out var value)) - { - throw new InvalidCommandLineException($"Invalid option [{arg}]."); - } - - if (!IsLog(value)) - { - result.Add(value); - } - } - - return new CommandLine(result, args); - } - - internal static bool ParseArg(string input, out Arg arg) - { - arg = default; - - if (string.IsNullOrEmpty(input)) - { - return false; - } - - if (input.StartsWith(Arg.Sign, StringComparison.OrdinalIgnoreCase)) - { - if (SplitKeyValue(input, 1, out var key, out var value)) - { - arg = new Arg(key, value); - return true; - } - - return false; - } - - arg = new Arg(input); - return true; - } - - private static bool SplitKeyValue(string keyValue, int offset, out string key, out string? value) - { - keyValue = keyValue.Substring(offset); - key = keyValue; - value = null; - - if (key.Length == 0) - { - return false; - } - - var index = keyValue.IndexOf("=", StringComparison.OrdinalIgnoreCase); - if (index < 0) - { - return true; - } - - if (index == 0) - { - return false; - } - - key = keyValue.Substring(0, index).Trim(); - value = index == keyValue.Length - 1 ? null : keyValue.Substring(index + 1).Trim(); - - return true; - } - - private static bool IsLog(Arg arg) - { - return arg.IsPair - && Arg.Log.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) - && !string.IsNullOrWhiteSpace(arg.Value); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs b/Sources/SqlDatabase/Configuration/CreateCommandLine.cs deleted file mode 100644 index 6556c3c8..00000000 --- a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs +++ /dev/null @@ -1,49 +0,0 @@ -using SqlDatabase.Adapter; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal sealed class CreateCommandLine : CommandLineBase -{ - public string? UsePowerShell { get; set; } - - public bool WhatIf { get; set; } - - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); - - internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) - { - builder - .WithLogger(logger) - .WithConfiguration(ConfigurationFile) - .WithPowerShellScripts(UsePowerShell) - .WithAssemblyScripts() - .WithVariables(Variables) - .WithDataBase(ConnectionString!, TransactionMode.None, WhatIf); - - var database = builder.BuildDatabase(); - var scriptResolver = builder.BuildScriptResolver(); - var sequence = builder.BuildCreateSequence(Scripts); - - return new DatabaseCreateCommand(sequence, scriptResolver, database, logger); - } - - protected override bool ParseArg(Arg arg) - { -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, System.StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } -#endif - - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/EchoCommandLine.cs b/Sources/SqlDatabase/Configuration/EchoCommandLine.cs deleted file mode 100644 index 9d40232f..00000000 --- a/Sources/SqlDatabase/Configuration/EchoCommandLine.cs +++ /dev/null @@ -1,16 +0,0 @@ -using SqlDatabase.Adapter; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal sealed class EchoCommandLine : ICommandLine -{ - private CommandLine _args; - - public void Parse(CommandLine args) - { - _args = args; - } - - public ICommand CreateCommand(ILogger logger) => new EchoCommand(logger, _args); -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs index 8061a7d3..e9b1cc1d 100644 --- a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Adapter.AssemblyScripts; using SqlDatabase.Adapter.PowerShellScripts; using SqlDatabase.Adapter.Sql; +using SqlDatabase.CommandLine; using SqlDatabase.FileSystem; using SqlDatabase.Scripts; -using SqlDatabase.Sequence; namespace SqlDatabase.Configuration; internal sealed class EnvironmentBuilder : IEnvironmentBuilder { + private readonly HostedRuntime _runtime; + private readonly IFileSystemFactory _fileSystem; + private ILogger? _logger; private AppConfiguration? _configuration; private string? _connectionString; @@ -24,12 +24,16 @@ internal sealed class EnvironmentBuilder : IEnvironmentBuilder private ScriptResolver? _scriptResolver; private IDatabase? _database; - public IEnvironmentBuilder WithConfiguration(string? configurationFile) + public EnvironmentBuilder(HostedRuntime runtime, IFileSystemFactory fileSystem) { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(configurationFile); + _runtime = runtime; + _fileSystem = fileSystem; + } - return WithConfiguration(configuration.SqlDatabase); + public IEnvironmentBuilder WithConfiguration(string? configurationFile) + { + var configuration = new ConfigurationManager(_fileSystem).LoadFrom(configurationFile); + return WithConfiguration(configuration); } public IEnvironmentBuilder WithLogger(ILogger logger) @@ -41,14 +45,14 @@ public IEnvironmentBuilder WithLogger(ILogger logger) public IEnvironmentBuilder WithPowerShellScripts(string? installationPath) { - _powerShellScript = new PowerShellScriptFactory(installationPath); + _powerShellScript = new PowerShellScriptFactory(_runtime, installationPath); return this; } public IEnvironmentBuilder WithAssemblyScripts() { var configuration = GetConfiguration().AssemblyScript; - _assemblyScript = new AssemblyScriptFactory(configuration.ClassName, configuration.MethodName); + _assemblyScript = new AssemblyScriptFactory(_runtime.Version, configuration.ClassName, configuration.MethodName); return this; } @@ -86,25 +90,7 @@ public IScriptResolver BuildScriptResolver() return _scriptResolver; } - public IUpgradeScriptSequence BuildUpgradeSequence(IList scripts, bool folderAsModuleName) - { - var scriptResolver = (ScriptResolver)BuildScriptResolver(); - var database = BuildDatabase(); - - return new UpgradeScriptSequence( - scriptResolver, - database.GetCurrentVersion, - scripts.ToArray(), - GetLogger(), - folderAsModuleName, - _whatIf); - } - - public ICreateScriptSequence BuildCreateSequence(IList scripts) - { - var scriptResolver = (ScriptResolver)BuildScriptResolver(); - return new CreateScriptSequence(scripts.ToArray(), scriptResolver); - } + public IScriptFactory BuildScriptFactory() => (ScriptResolver)BuildScriptResolver(); internal IEnvironmentBuilder WithConfiguration(AppConfiguration configuration) { @@ -126,7 +112,7 @@ private Database CreateDatabase() } catch (Exception ex) { - throw new InvalidCommandLineException(Arg.Database, "Invalid connection string value.", ex); + throw new InvalidCommandLineException("Invalid connection string value.", ex); } var database = new Database(adapter, GetLogger(), _transactionMode, _whatIf); diff --git a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs deleted file mode 100644 index b8158def..00000000 --- a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal sealed class ExecuteCommandLine : CommandLineBase -{ - public TransactionMode Transaction { get; set; } - - public string? UsePowerShell { get; set; } - - public bool WhatIf { get; set; } - - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); - - internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) - { - builder - .WithLogger(logger) - .WithConfiguration(ConfigurationFile) - .WithPowerShellScripts(UsePowerShell) - .WithAssemblyScripts() - .WithVariables(Variables) - .WithDataBase(ConnectionString!, Transaction, WhatIf); - - var database = builder.BuildDatabase(); - var scriptResolver = builder.BuildScriptResolver(); - var sequence = builder.BuildCreateSequence(Scripts); - - return new DatabaseExecuteCommand(sequence, scriptResolver, database, logger); - } - - protected override bool ParseArg(Arg arg) - { - if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetTransaction(arg.Value); - return true; - } - - if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetInLineScript(arg.Value); - return true; - } - -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } -#endif - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } - - return false; - } - - private void SetTransaction(string? modeName) - { - if (!Enum.TryParse(modeName, true, out var mode)) - { - throw new InvalidCommandLineException(Arg.Transaction, $"Unknown transaction mode [{modeName}]."); - } - - Transaction = mode; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs deleted file mode 100644 index e968de25..00000000 --- a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.IO; -using SqlDatabase.Adapter; -using SqlDatabase.Adapter.Sql.Export; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal sealed class ExportCommandLine : CommandLineBase -{ - public string? DestinationTableName { get; set; } - - public string? DestinationFileName { get; set; } - - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); - - internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) - { - builder - .WithLogger(logger) - .WithConfiguration(ConfigurationFile) - .WithVariables(Variables) - .WithDataBase(ConnectionString!, TransactionMode.None, false); - - var database = builder.BuildDatabase(); - var scriptResolver = builder.BuildScriptResolver(); - var sequence = builder.BuildCreateSequence(Scripts); - - return new DatabaseExportCommand( - sequence, - scriptResolver, - CreateOutput(), - database, - WrapLogger(logger)) - { - DestinationTableName = DestinationTableName - }; - } - - internal Func CreateOutput() - { - var fileName = DestinationFileName; - - if (string.IsNullOrEmpty(fileName)) - { - return () => Console.Out; - } - - return () => new StreamWriter(fileName, false); - } - - internal ILogger WrapLogger(ILogger logger) - { - return string.IsNullOrEmpty(DestinationFileName) ? new DataExportLogger(logger) : logger; - } - - protected override bool ParseArg(Arg arg) - { - if (Arg.ExportToTable.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - DestinationTableName = arg.Value; - return true; - } - - if (Arg.ExportToFile.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - DestinationFileName = arg.Value; - return true; - } - - if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetInLineScript(arg.Value); - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs b/Sources/SqlDatabase/Configuration/GenericCommandLine.cs deleted file mode 100644 index a6214ceb..00000000 --- a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; - -public sealed class GenericCommandLine -{ - public string? Command { get; set; } - - public string? Connection { get; set; } - - public TransactionMode Transaction { get; set; } - - public IList Scripts { get; } = new List(); - - public IList InLineScript { get; } = new List(); - - public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - - public string? ConfigurationFile { get; set; } - - public string? ExportToTable { get; set; } - - public string? ExportToFile { get; set; } - - public bool WhatIf { get; set; } - - public bool FolderAsModuleName { get; set; } - - public string? LogFileName { get; set; } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs b/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs deleted file mode 100644 index c49d3814..00000000 --- a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System.Collections.Generic; -using System.Text; - -namespace SqlDatabase.Configuration; - -internal sealed class GenericCommandLineBuilder -{ - public GenericCommandLineBuilder() - : this(new GenericCommandLine()) - { - } - - public GenericCommandLineBuilder(GenericCommandLine line) - { - Line = line; - } - - internal GenericCommandLine Line { get; } - - public GenericCommandLineBuilder SetCommand(string command) - { - Line.Command = command; - return this; - } - - public GenericCommandLineBuilder SetConnection(string connectionString) - { - Line.Connection = connectionString; - return this; - } - - public GenericCommandLineBuilder SetScripts(string value) - { - Line.Scripts.Add(value); - - return this; - } - - public GenericCommandLineBuilder SetInLineScript(string value) - { - Line.InLineScript.Add(value); - - return this; - } - - public GenericCommandLineBuilder SetTransaction(TransactionMode mode) - { - Line.Transaction = mode; - return this; - } - - public GenericCommandLineBuilder SetVariable(string? name, string? value) - { - name = name?.Trim(); - if (string.IsNullOrEmpty(name)) - { - throw new InvalidCommandLineException(Arg.Variable, $"Invalid variable name [{name}]."); - } - - if (Line.Variables.ContainsKey(name!)) - { - throw new InvalidCommandLineException(Arg.Variable, $"Variable with name [{name}] is duplicated."); - } - - Line.Variables.Add(name!, value ?? string.Empty); - - return this; - } - - public GenericCommandLineBuilder SetVariable(string nameValue) - { - if (!CommandLineParser.ParseArg(Arg.Sign + nameValue, out var arg) - || !arg.IsPair) - { - throw new InvalidCommandLineException(Arg.Variable, $"Invalid variable value definition [{nameValue}]."); - } - - return SetVariable(arg.Key, arg.Value); - } - - public GenericCommandLineBuilder SetConfigurationFile(string? configurationFile) - { - Line.ConfigurationFile = configurationFile; - return this; - } - - public GenericCommandLineBuilder SetExportToTable(string? name) - { - Line.ExportToTable = name; - return this; - } - - public GenericCommandLineBuilder SetExportToFile(string? fileName) - { - Line.ExportToFile = fileName; - return this; - } - - public GenericCommandLineBuilder SetWhatIf(bool value) - { - Line.WhatIf = value; - return this; - } - - public GenericCommandLineBuilder SetFolderAsModuleName(bool value) - { - Line.FolderAsModuleName = value; - return this; - } - - public GenericCommandLineBuilder SetLogFileName(string? fileName) - { - Line.LogFileName = fileName; - return this; - } - - public GenericCommandLine Build() - { - return Line; - } - - public string[] BuildArray() - { - var cmd = Build(); - - var result = new List - { - cmd.Command!, - CombineArg(Arg.Database, cmd.Connection!) - }; - - foreach (var script in cmd.Scripts) - { - result.Add(CombineArg(Arg.Scripts, script)); - } - - foreach (var script in cmd.InLineScript) - { - result.Add(CombineArg(Arg.InLineScript, script)); - } - - if (cmd.Transaction != default(TransactionMode)) - { - result.Add(CombineArg(Arg.Transaction, cmd.Transaction.ToString())); - } - - if (!string.IsNullOrEmpty(cmd.ConfigurationFile)) - { - result.Add(CombineArg(Arg.Configuration, cmd.ConfigurationFile!)); - } - - if (!string.IsNullOrEmpty(cmd.ExportToTable)) - { - result.Add(CombineArg(Arg.ExportToTable, cmd.ExportToTable!)); - } - - if (!string.IsNullOrEmpty(cmd.ExportToFile)) - { - result.Add(CombineArg(Arg.ExportToFile, cmd.ExportToFile!)); - } - - foreach (var entry in cmd.Variables) - { - result.Add(CombineArg(Arg.Variable + entry.Key, entry.Value)); - } - - if (cmd.WhatIf) - { - result.Add(CombineArg(Arg.WhatIf, cmd.WhatIf.ToString())); - } - - if (cmd.FolderAsModuleName) - { - result.Add(CombineArg(Arg.FolderAsModuleName, cmd.FolderAsModuleName.ToString())); - } - - if (!string.IsNullOrEmpty(cmd.LogFileName)) - { - result.Add(CombineArg(Arg.Log, cmd.LogFileName!)); - } - - return result.ToArray(); - } - - private static string CombineArg(string key, string value) - { - var result = new StringBuilder() - .Append(Arg.Sign) - .Append(key) - .Append("=") - .Append(value); - - return result.ToString(); - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/HostedRuntimeResolver.cs b/Sources/SqlDatabase/Configuration/HostedRuntimeResolver.cs new file mode 100644 index 00000000..f47a3cf5 --- /dev/null +++ b/Sources/SqlDatabase/Configuration/HostedRuntimeResolver.cs @@ -0,0 +1,58 @@ +using System.Runtime.InteropServices; +using SqlDatabase.Adapter; + +namespace SqlDatabase.Configuration; + +internal static class HostedRuntimeResolver +{ + public static HostedRuntime GetRuntime(bool isPowershell) + { + var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + var version = ResolveVersion(RuntimeInformation.FrameworkDescription, Environment.Version); + + if (version == FrameworkVersion.Net472 && !isWindows) + { + Throw(); + } + + return new HostedRuntime(isPowershell, isWindows, version); + } + + public static bool SupportUsePowerShell(this HostedRuntime runtime) => !runtime.IsPowershell && runtime.Version != FrameworkVersion.Net472; + + // https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed + internal static FrameworkVersion ResolveVersion(string description, Version version) + { + if (description.IndexOf(" Framework ", StringComparison.OrdinalIgnoreCase) > 0) + { + return FrameworkVersion.Net472; + } + + if (description.IndexOf(" Core ", StringComparison.OrdinalIgnoreCase) > 0) + { + return FrameworkVersion.Net6; + } + + switch (version.Major) + { + case <= 6: + return FrameworkVersion.Net6; + case 7: + return FrameworkVersion.Net7; + default: + return FrameworkVersion.Net8; + } + } + + private static void Throw() + { + var message = new StringBuilder("Runtime framework version is not supported. OSDescription: ") + .Append(RuntimeInformation.OSDescription) + .Append(", EnvironmentVersion: ") + .Append(Environment.Version) + .Append(", FrameworkDescription: ") + .Append(RuntimeInformation.FrameworkDescription); + + throw new NotSupportedException(message.ToString()); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ICommandLine.cs b/Sources/SqlDatabase/Configuration/ICommandLine.cs deleted file mode 100644 index a16d5062..00000000 --- a/Sources/SqlDatabase/Configuration/ICommandLine.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SqlDatabase.Adapter; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal interface ICommandLine -{ - void Parse(CommandLine args); - - ICommand CreateCommand(ILogger logger); -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs b/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs index 47d7e0b9..51c3d283 100644 --- a/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs @@ -1,8 +1,5 @@ -using System.Collections.Generic; -using SqlDatabase.Adapter; -using SqlDatabase.FileSystem; +using SqlDatabase.Adapter; using SqlDatabase.Scripts; -using SqlDatabase.Sequence; namespace SqlDatabase.Configuration; @@ -24,7 +21,5 @@ internal interface IEnvironmentBuilder IScriptResolver BuildScriptResolver(); - IUpgradeScriptSequence BuildUpgradeSequence(IList scripts, bool folderAsModuleName); - - ICreateScriptSequence BuildCreateSequence(IList scripts); + IScriptFactory BuildScriptFactory(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs b/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs deleted file mode 100644 index 253ff89a..00000000 --- a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace SqlDatabase.Configuration; - -public sealed class InvalidCommandLineException : SystemException -{ - public InvalidCommandLineException() - { - } - - public InvalidCommandLineException(string message) - : base(message) - { - } - - public InvalidCommandLineException(string message, Exception inner) - : base(message, inner) - { - } - - public InvalidCommandLineException(string argument, string message) - : base(message) - { - Argument = argument; - } - - public InvalidCommandLineException(string argument, string message, Exception inner) - : base(message, inner) - { - Argument = argument; - } - - public string? Argument { get; } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs deleted file mode 100644 index 3d33bff7..00000000 --- a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using SqlDatabase.Adapter; -using SqlDatabase.Commands; - -namespace SqlDatabase.Configuration; - -internal sealed class UpgradeCommandLine : CommandLineBase -{ - public TransactionMode Transaction { get; set; } - - public string? UsePowerShell { get; set; } - - public bool FolderAsModuleName { get; set; } - - public bool WhatIf { get; set; } - - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); - - internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) - { - builder - .WithLogger(logger) - .WithConfiguration(ConfigurationFile) - .WithPowerShellScripts(UsePowerShell) - .WithAssemblyScripts() - .WithVariables(Variables) - .WithDataBase(ConnectionString!, Transaction, WhatIf); - - var database = builder.BuildDatabase(); - var scriptResolver = builder.BuildScriptResolver(); - var sequence = builder.BuildUpgradeSequence(Scripts, FolderAsModuleName); - - return new DatabaseUpgradeCommand(sequence, scriptResolver, database, logger); - } - - protected override bool ParseArg(Arg arg) - { - if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetTransaction(arg.Value); - return true; - } - - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } - -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } -#endif - - if (TryParseSwitchParameter(arg, Arg.FolderAsModuleName, out value)) - { - FolderAsModuleName = value; - return true; - } - - return false; - } - - private void SetTransaction(string? modeName) - { - if (!Enum.TryParse(modeName, true, out var mode)) - { - throw new InvalidCommandLineException(Arg.Transaction, $"Unknown transaction mode [{modeName}]."); - } - - Transaction = mode; - } -} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/CombinedLogger.cs b/Sources/SqlDatabase/Log/CombinedLogger.cs index 12bea88d..febaf939 100644 --- a/Sources/SqlDatabase/Log/CombinedLogger.cs +++ b/Sources/SqlDatabase/Log/CombinedLogger.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Log; diff --git a/Sources/SqlDatabase/Log/ConsoleLogger.cs b/Sources/SqlDatabase/Log/ConsoleLogger.cs index eb5d386f..daf72bca 100644 --- a/Sources/SqlDatabase/Log/ConsoleLogger.cs +++ b/Sources/SqlDatabase/Log/ConsoleLogger.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Log; +namespace SqlDatabase.Log; internal sealed class ConsoleLogger : LoggerBase { diff --git a/Sources/SqlDatabase/Log/DisposableAction.cs b/Sources/SqlDatabase/Log/DisposableAction.cs index a9d6947e..e661522b 100644 --- a/Sources/SqlDatabase/Log/DisposableAction.cs +++ b/Sources/SqlDatabase/Log/DisposableAction.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Log; +namespace SqlDatabase.Log; internal sealed class DisposableAction : IDisposable { diff --git a/Sources/SqlDatabase/Log/FileLogger.cs b/Sources/SqlDatabase/Log/FileLogger.cs index d3b68e45..8b389475 100644 --- a/Sources/SqlDatabase/Log/FileLogger.cs +++ b/Sources/SqlDatabase/Log/FileLogger.cs @@ -1,6 +1,4 @@ -using System; -using System.Globalization; -using System.IO; +using System.Globalization; namespace SqlDatabase.Log; diff --git a/Sources/SqlDatabase/Log/LoggerBase.cs b/Sources/SqlDatabase/Log/LoggerBase.cs index 9cbad70c..4bac8fb3 100644 --- a/Sources/SqlDatabase/Log/LoggerBase.cs +++ b/Sources/SqlDatabase/Log/LoggerBase.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Log; diff --git a/Sources/SqlDatabase/Log/LoggerFactory.cs b/Sources/SqlDatabase/Log/LoggerFactory.cs index b6b73c22..5b704f48 100644 --- a/Sources/SqlDatabase/Log/LoggerFactory.cs +++ b/Sources/SqlDatabase/Log/LoggerFactory.cs @@ -8,4 +8,24 @@ public static ILogger CreateDefault() { return new ConsoleLogger(); } + + public static ILogger WrapWithUsersLogger(ILogger logger, string? fileName) + { + if (string.IsNullOrEmpty(fileName)) + { + return logger; + } + + ILogger fileLogger; + try + { + fileLogger = new FileLogger(fileName!); + } + catch (Exception ex) + { + throw new InvalidOperationException("Fail to create file log.", ex); + } + + return new CombinedLogger(logger, false, fileLogger, true); + } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Program.cs b/Sources/SqlDatabase/Program.cs index 5d4d4539..e721e793 100644 --- a/Sources/SqlDatabase/Program.cs +++ b/Sources/SqlDatabase/Program.cs @@ -1,8 +1,8 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; +using SqlDatabase.Commands; using SqlDatabase.Configuration; +using SqlDatabase.FileSystem; using SqlDatabase.Log; namespace SqlDatabase; @@ -12,132 +12,75 @@ internal static class Program public static int Main(string[] args) { var logger = LoggerFactory.CreateDefault(); - return Run(logger, args); - } - - internal static int Run(ILogger logger, string[] args) - { - if (!TryWrapWithUsersLogger(logger, args, out var userLogger)) - { - return ExitCode.InvalidCommandLine; - } try { - return MainCore(userLogger ?? logger, args); - } - finally - { - userLogger?.Dispose(); - } - } + var runtime = HostedRuntimeResolver.GetRuntime(false); - private static int MainCore(ILogger logger, string[] args) - { - var factory = ResolveFactory(args, logger); - if (factory == null) - { - logger.Info(LoadHelpContent("CommandLine.txt")); - return ExitCode.InvalidCommandLine; - } + if (CommandLineParser.HelpRequested(args, out var command)) + { + logger.Info(LoadHelpContent(GetHelpFileName(runtime, command))); + return ExitCode.InvalidCommandLine; + } - if (factory.ShowCommandHelp) - { - logger.Info(LoadHelpContent(GetHelpFileName(factory.ActiveCommandName))); - return ExitCode.InvalidCommandLine; + var commandLine = CommandLineParser.Parse(runtime, args); + logger = LoggerFactory.WrapWithUsersLogger(logger, commandLine.Log); + MainCore(logger, runtime, commandLine, Environment.CurrentDirectory); } - - var cmd = ResolveCommandLine(factory, logger); - if (cmd == null) + catch (InvalidCommandLineException ex) { + logger.Error($"Invalid command line: {ex.Message}.", ex); return ExitCode.InvalidCommandLine; } - - var exitCode = ExecuteCommand(cmd, logger) ? ExitCode.Ok : ExitCode.ExecutionErrors; - return exitCode; - } - - private static bool ExecuteCommand(ICommandLine cmd, ILogger logger) - { - try - { - cmd.CreateCommand(logger).Execute(); - return true; - } catch (Exception ex) { - logger.Error(ex); - return false; - } - } - - private static ICommandLine? ResolveCommandLine(CommandLineFactory factory, ILogger logger) - { - try - { - return factory.Resolve(); + logger.Error("Something went wrong.", ex); + return ExitCode.ExecutionErrors; } - catch (Exception ex) + finally { - logger.Error("Invalid command line.", ex); + (logger as IDisposable)?.Dispose(); } - return null; + return ExitCode.Ok; } - private static CommandLineFactory? ResolveFactory(string[] args, ILogger logger) + internal static void RunPowershell(ILogger logger, ICommandLine commandLine, string currentDirectory) { + logger = LoggerFactory.WrapWithUsersLogger(logger, commandLine.Log); try { - var command = new CommandLineParser().Parse(args); - if (command.Args.Count == 0) - { - return null; - } - - var factory = new CommandLineFactory { Args = command }; - return factory.Bind() ? factory : null; + var runtime = HostedRuntimeResolver.GetRuntime(true); + MainCore(logger, runtime, commandLine, currentDirectory); } - catch (Exception ex) + finally { - logger.Error("Invalid command line.", ex); + (logger as IDisposable)?.Dispose(); } + } - return null; + private static void MainCore(ILogger logger, HostedRuntime runtime, ICommandLine commandLine, string currentDirectory) + { + var fileSystem = new FileSystemFactory(currentDirectory); + var factory = new CommandFactory(logger, new EnvironmentBuilder(runtime, fileSystem), fileSystem); + var command = factory.CreateCommand(commandLine); + command.Execute(); } - private static bool TryWrapWithUsersLogger(ILogger logger, string[] args, out CombinedLogger? combined) + private static string GetHelpFileName(HostedRuntime runtime, string? commandName) { - combined = null; - var fileName = CommandLineParser.GetLogFileName(args); - if (string.IsNullOrEmpty(fileName)) + if (runtime.IsPowershell) { - return true; + throw new NotSupportedException(); } - ILogger fileLogger; - try + if (commandName == null) { - fileLogger = new FileLogger(fileName!); - } - catch (Exception ex) - { - logger.Error("Fail to create file log.", ex); - return false; + return "CommandLine.txt"; } - combined = new CombinedLogger(logger, false, fileLogger, true); - return true; - } - - private static string GetHelpFileName(string commandName) - { -#if NET472 - const string Runtime = ".net472"; -#else - const string? Runtime = null; -#endif - return "CommandLine." + commandName + Runtime + ".txt"; + var suffix = runtime.Version == FrameworkVersion.Net472 ? ".net472" : null; + return "CommandLine." + commandName + suffix + ".txt"; } private static string LoadHelpContent(string fileName) diff --git a/Sources/SqlDatabase/Scripts/Database.cs b/Sources/SqlDatabase/Scripts/Database.cs index ceadcbac..0bc782fe 100644 --- a/Sources/SqlDatabase/Scripts/Database.cs +++ b/Sources/SqlDatabase/Scripts/Database.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; +using System.Data.Common; using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql; -using SqlDatabase.Configuration; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs b/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs index 9eaf2874..7841af20 100644 --- a/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs +++ b/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Adapter.MsSql; using SqlDatabase.Adapter.MySql; using SqlDatabase.Adapter.PgSql; diff --git a/Sources/SqlDatabase/Scripts/IDatabase.cs b/Sources/SqlDatabase/Scripts/IDatabase.cs index 6f9807fb..a095a637 100644 --- a/Sources/SqlDatabase/Scripts/IDatabase.cs +++ b/Sources/SqlDatabase/Scripts/IDatabase.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/Scripts/IScriptResolver.cs b/Sources/SqlDatabase/Scripts/IScriptResolver.cs index 65915cc9..93e977f1 100644 --- a/Sources/SqlDatabase/Scripts/IScriptResolver.cs +++ b/Sources/SqlDatabase/Scripts/IScriptResolver.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/Scripts/ScriptResolver.cs b/Sources/SqlDatabase/Scripts/ScriptResolver.cs index eb690796..1239dd4f 100644 --- a/Sources/SqlDatabase/Scripts/ScriptResolver.cs +++ b/Sources/SqlDatabase/Scripts/ScriptResolver.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.FileSystem; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/Scripts/Variables.cs b/Sources/SqlDatabase/Scripts/Variables.cs index a9826ff7..f4347549 100644 --- a/Sources/SqlDatabase/Scripts/Variables.cs +++ b/Sources/SqlDatabase/Scripts/Variables.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/SqlDatabase.csproj b/Sources/SqlDatabase/SqlDatabase.csproj index 9a434fc5..1481e2cb 100644 --- a/Sources/SqlDatabase/SqlDatabase.csproj +++ b/Sources/SqlDatabase/SqlDatabase.csproj @@ -19,6 +19,7 @@ + diff --git a/Sources/global.json b/Sources/global.json index 5815c394..44694383 100644 --- a/Sources/global.json +++ b/Sources/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "8.0.100-rc.2.23502.2", - "allowPrerelease": true, + "version": "8.0.200", + "allowPrerelease": false, "rollForward": "latestFeature" } } \ No newline at end of file