From 9f19ee2d8bc477f072e627adcf41f37f71319f38 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Tue, 28 Nov 2023 03:40:00 +0100 Subject: [PATCH 01/27] update version to 4.2.1 --- Sources/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index 72014747..f7fe85aa 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -17,7 +17,7 @@ - 4.2.0 + 4.2.1 $(SqlDatabaseVersion) $(SqlDatabaseVersion).0 $(SqlDatabaseVersion).0 From 9c8df7738a0a2c7464e2f589c0ec0c43889013ea Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:04:10 +0100 Subject: [PATCH 02/27] .sln update dependencies --- Sources/Directory.Packages.props | 14 +++++++------- .../SqlDatabase.Adapter.PowerShellScripts.csproj | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) 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.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj b/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj index d7b2f9c1..12a480d6 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj @@ -5,7 +5,7 @@ - + From 540fcebde71fbd3a41f8c2a61470d22b284b8889 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:06:01 +0100 Subject: [PATCH 03/27] chang unit tests assertions to Shouldly --- .../DefaultEntryPointTest.cs | 21 ++++++------ ...cuteMethodResolverCommandDictionaryTest.cs | 16 ++++++---- .../ExecuteMethodResolverCommandTest.cs | 15 ++++++--- .../ExecuteMethodResolverDbConnectionTest.cs | 14 +++++--- ...cuteMethodResolverDictionaryCommandTest.cs | 16 ++++++---- .../Net472/Net472SubDomainTest.cs | 8 ++--- .../FileSystemFactoryTest.cs | 27 ++++++++-------- .../FileSystemFolderTest.cs | 13 ++++---- .../ZipFolderTest.cs | 32 +++++++++---------- .../Internal/PowerShellCommandBaseTest.cs | 2 +- .../CreateScriptSequenceTest.cs | 24 ++++++-------- .../Configuration/ExportCommandLineTest.cs | 2 +- .../SqlDatabase.Test/Log/LoggerBaseTest.cs | 24 +++++++------- .../SqlDatabase.Test/Scripts/VariablesTest.cs | 25 ++++++++------- 14 files changed, 126 insertions(+), 113 deletions(-) diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs index 2b9e41b4..1444bc1b 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs @@ -3,6 +3,7 @@ using System.Data; using Moq; using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -49,16 +50,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 +69,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 +81,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/ExecuteMethodResolverCommandDictionaryTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs index a8d70899..d2602bf4 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs @@ -3,6 +3,7 @@ using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -23,28 +24,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..69455dc0 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs @@ -2,6 +2,7 @@ using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -21,24 +22,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..06cea07c 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs @@ -2,6 +2,7 @@ using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -21,15 +22,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 +43,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..e4cf7d84 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs @@ -3,6 +3,7 @@ using System.Reflection; using Moq; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Adapter.AssemblyScripts; @@ -23,28 +24,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/Net472/Net472SubDomainTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs index 93f7e122..5115b928 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs @@ -52,8 +52,8 @@ public void BeforeEachTest() [TearDown] public void AfterEachTest() { - _sut?.Unload(); - _sut?.Dispose(); + _sut.Unload(); + _sut.Dispose(); } [Test] @@ -67,11 +67,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.FileSystem.Test/FileSystemFactoryTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs index c15a81c8..869b9cd3 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs @@ -1,6 +1,7 @@ using System.IO; using System.Linq; using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.FileSystem; @@ -14,7 +15,7 @@ public void NewFileSystemFolder() using (var dir = new TempDirectory("Content.zip")) { var folder = FileSystemFactory.FileSystemInfoFromPath(dir.Location); - Assert.IsInstanceOf(folder); + folder.ShouldBeOfType(); } } @@ -24,20 +25,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 NewZipFolder(string path, string? fileName) { using (var dir = new TempDirectory()) { dir.CopyFileFromResources("Content.zip"); var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); - Assert.IsNotNull(folder); + folder.ShouldNotBeNull(); 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); } } } @@ -46,7 +47,7 @@ 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 NewNuGetFolder(string path, string? fileName) { using (var dir = new TempDirectory()) { @@ -54,13 +55,13 @@ public void NewNuGetFolder(string path, string fileName) 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); + folder.ShouldNotBeNull(); 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); } } } @@ -86,7 +87,7 @@ public void ZipNotFound(string path) dir.CopyFileFromResources("Content.zip"); var fullPath = Path.Combine(dir.Location, path); - Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); + Should.Throw(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); } } @@ -96,10 +97,10 @@ public void NewFileSystemFile() using (var dir = new TempDirectory()) { var fileName = Path.Combine(dir.Location, "11.txt"); - File.WriteAllBytes(fileName, new byte[] { 1 }); + File.WriteAllBytes(fileName, [1]); var file = FileSystemFactory.FileSystemInfoFromPath(fileName); - Assert.IsInstanceOf(file); + file.ShouldBeOfType(); } } @@ -114,7 +115,7 @@ public void NewZipFile(string fileName) dir.CopyFileFromResources("Content.zip"); var file = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, fileName)); - Assert.IsInstanceOf(file); + file.ShouldBeOfType(); ((IFile)file).OpenRead().Dispose(); } diff --git a/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs index 3c7c3e95..5331348f 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs @@ -1,6 +1,7 @@ using System.IO; using System.Linq; using NUnit.Framework; +using Shouldly; using SqlDatabase.TestApi; namespace SqlDatabase.FileSystem; @@ -12,7 +13,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 +22,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 +30,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 +40,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 +48,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/ZipFolderTest.cs b/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs index 5c0048c6..8dcb2819 100644 --- a/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs @@ -23,14 +23,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 +38,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 +62,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 +85,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.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs index bf524275..229af099 100644 --- a/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs @@ -13,6 +13,6 @@ public void AppendDefaultConfiguration() PowerShellCommandBase.AppendDefaultConfiguration(command); - FileAssert.Exists(command.ConfigurationFile); + Assert.That(command.ConfigurationFile, Does.Exist.IgnoreDirectories); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs index 1bcf819f..e91eb6f3 100644 --- a/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs @@ -2,6 +2,7 @@ using System.Linq; using Moq; using NUnit.Framework; +using Shouldly; using SqlDatabase.Adapter; using SqlDatabase.FileSystem; using SqlDatabase.TestApi; @@ -71,17 +72,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 +93,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.Test/Configuration/ExportCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs index 39d8986e..8db50281 100644 --- a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs @@ -120,7 +120,7 @@ public void CreateOutputFile() writer.Write("hello 1"); } - FileAssert.Exists(file.Location); + Assert.That(file.Location, Does.Exist.IgnoreDirectories); File.ReadAllText(file.Location).ShouldBe("hello 1"); using (var writer = actual()) diff --git a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs index 09cef943..436c2cc8 100644 --- a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs +++ b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs @@ -2,6 +2,7 @@ using Moq; using Moq.Protected; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Log; @@ -36,9 +37,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 +46,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 +56,7 @@ public void NoIndentOnError() _sut.Indent(); _sut.Error("the text"); - Assert.AreEqual("the text", _error[0]); + _error[0].ShouldBe("the text"); } [Test] @@ -77,10 +76,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/VariablesTest.cs b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs index 4d4cfb53..11223f36 100644 --- a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using Shouldly; namespace SqlDatabase.Scripts; @@ -23,13 +24,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 +38,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 +64,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 From 5012dfea3dba0663ebe543e24f5cde7bf233ec56 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:07:27 +0100 Subject: [PATCH 04/27] third party notices update dependencies --- .../{2.1.15 => 2.1.35}/index.json | 0 .../{2.1.15 => 2.1.35}/package.nuspec | 5 +- .../{2.1.15 => 2.1.35}/project-License.txt | 0 .../{2.1.15 => 2.1.35}/readme.md | 2 +- .../{2.1.15 => 2.1.35}/remarks.md | 0 .../{2.1.15 => 2.1.35}/repository-License.txt | 0 .../third-party-notices.txt | 0 .../17.7.2/package-LICENSE_NET.txt | 65 ------------------- .../{17.7.2 => 17.9.0}/index.json | 8 +-- .../17.9.0/package-LICENSE_MIT.txt | 24 +++++++ .../{17.7.2 => 17.9.0}/package.nuspec | 6 +- .../{17.7.2 => 17.9.0}/project-LICENSE | 0 .../{17.7.2 => 17.9.0}/readme.md | 6 +- .../{17.7.2 => 17.9.0}/remarks.md | 0 .../{17.7.2 => 17.9.0}/repository-LICENSE | 0 .../third-party-notices.txt | 0 .../17.7.2/package-LICENSE_NET.txt | 65 ------------------- .../{17.7.2 => 17.9.0}/index.json | 12 ++-- .../17.9.0/package-LICENSE_MIT.txt | 24 +++++++ .../{17.7.2 => 17.9.0}/package.nuspec | 12 ++-- .../{17.7.2 => 17.9.0}/project-LICENSE | 0 .../{17.7.2 => 17.9.0}/readme.md | 10 +-- .../{17.7.2 => 17.9.0}/remarks.md | 0 .../{17.7.2 => 17.9.0}/repository-LICENSE | 0 .../third-party-notices.txt | 0 .../17.7.2/package-LICENSE_NET.txt | 65 ------------------- .../{17.7.2 => 17.9.0}/index.json | 12 ++-- .../17.9.0/package-LICENSE_MIT.txt | 24 +++++++ .../{17.7.2 => 17.9.0}/package.nuspec | 9 +-- .../{17.7.2 => 17.9.0}/project-LICENSE | 0 .../{17.7.2 => 17.9.0}/readme.md | 9 ++- .../{17.7.2 => 17.9.0}/remarks.md | 0 .../{17.7.2 => 17.9.0}/repository-LICENSE | 0 .../third-party-notices.txt | 0 .../17.7.2/package-LICENSE_NET.txt | 65 ------------------- .../{17.7.2 => 17.9.0}/index.json | 10 +-- .../17.9.0/package-LICENSE_MIT.txt | 24 +++++++ .../{17.7.2 => 17.9.0}/package.nuspec | 8 +-- .../{17.7.2 => 17.9.0}/project-LICENSE | 0 .../{17.7.2 => 17.9.0}/readme.md | 8 +-- .../{17.7.2 => 17.9.0}/remarks.md | 0 .../{17.7.2 => 17.9.0}/repository-LICENSE | 0 .../third-party-notices.txt | 0 .../moq/{4.20.69 => 4.20.70}/index.json | 0 .../moq/{4.20.69 => 4.20.70}/package.nuspec | 4 +- .../{4.20.69 => 4.20.70}/project-License.txt | 0 .../moq/{4.20.69 => 4.20.70}/readme.md | 2 +- .../moq/{4.20.69 => 4.20.70}/remarks.md | 0 .../repository-License.txt | 0 .../third-party-notices.txt | 0 .../nuget.frameworks/6.5.0/index.json | 37 ----------- .../nuget.frameworks/6.5.0/package.nuspec | 23 ------- .../nuget.frameworks/6.5.0/readme.md | 27 -------- .../6.5.0/repository-LICENSE.txt | 15 ----- .../nuget.org/nunit/3.14.0/package.nuspec | 38 ----------- .../packages/nuget.org/nunit/3.14.0/readme.md | 33 ---------- .../nunit/{3.14.0 => 4.1.0}/index.json | 3 +- .../{3.14.0 => 4.1.0}/package-LICENSE.txt | 2 +- .../nuget.org/nunit/4.1.0/package.nuspec | 40 ++++++++++++ .../packages/nuget.org/nunit/4.1.0/readme.md | 38 +++++++++++ .../6.5.0 => nunit/4.1.0}/remarks.md | 0 .../{3.14.0 => 4.1.0}/repository-LICENSE.txt | 2 +- .../4.1.0}/third-party-notices.txt | 0 .../{5.1.0 => 5.1.1}/index.json | 0 .../{5.1.0 => 5.1.1}/package-LICENSE.txt | 0 .../{5.1.0 => 5.1.1}/package.nuspec | 5 +- .../{5.1.0 => 5.1.1}/project-LICENSE.txt | 0 .../{5.1.0 => 5.1.1}/readme.md | 2 +- .../5.1.1}/remarks.md | 0 .../5.1.1}/third-party-notices.txt | 0 .../{1.2.0.507 => 1.2.0.556}/index.json | 0 .../{1.2.0.507 => 1.2.0.556}/package-LICENSE | 0 .../{1.2.0.507 => 1.2.0.556}/package.nuspec | 4 +- .../{1.2.0.507 => 1.2.0.556}/project-LICENSE | 0 .../{1.2.0.507 => 1.2.0.556}/readme.md | 2 +- .../1.2.0.556}/remarks.md | 0 .../1.2.0.556}/third-party-notices.txt | 0 .../system.data.sqlclient/4.8.5/remarks.md | 0 .../4.8.5/third-party-notices.txt | 0 .../{4.8.5 => 4.8.6}/index.json | 0 .../package-LICENSE.TXT} | 0 .../{4.8.5 => 4.8.6}/package.nuspec | 2 +- .../{4.8.5 => 4.8.6}/readme.md | 2 +- .../4.8.6}/remarks.md | 0 .../4.8.6}/third-party-notices.txt | 0 .../4.5.3/index.json | 4 ++ .../4.5.3/readme.md | 2 +- .../4.5.4/index.json | 4 ++ .../4.5.4/readme.md | 2 +- Build/third-party-libraries/readme.md | 29 ++++----- 90 files changed, 268 insertions(+), 527 deletions(-) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/index.json (100%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/package.nuspec (90%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/project-License.txt (100%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/readme.md (88%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/repository-License.txt (100%) rename Build/third-party-libraries/packages/nuget.org/dapper.strongname/{2.1.15 => 2.1.35}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.7.2/package-LICENSE_NET.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/index.json (76%) create mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.9.0/package-LICENSE_MIT.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/package.nuspec (88%) rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/project-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/readme.md (64%) rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/repository-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/{17.7.2 => 17.9.0}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.7.2/package-LICENSE_NET.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/index.json (76%) create mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.9.0/package-LICENSE_MIT.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/package.nuspec (78%) rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/project-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/readme.md (63%) rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/repository-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/{17.7.2 => 17.9.0}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.7.2/package-LICENSE_NET.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/index.json (73%) create mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.9.0/package-LICENSE_MIT.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/package.nuspec (86%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/project-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/readme.md (57%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/repository-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/{17.7.2 => 17.9.0}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.7.2/package-LICENSE_NET.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/index.json (79%) create mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.9.0/package-LICENSE_MIT.txt rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/package.nuspec (87%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/project-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/readme.md (64%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/repository-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/{17.7.2 => 17.9.0}/third-party-notices.txt (100%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/index.json (100%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/package.nuspec (94%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/project-License.txt (100%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/readme.md (93%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/repository-License.txt (100%) rename Build/third-party-libraries/packages/nuget.org/moq/{4.20.69 => 4.20.70}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/index.json delete mode 100644 Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/package.nuspec delete mode 100644 Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/readme.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/nuget.frameworks/6.5.0/repository-LICENSE.txt delete mode 100644 Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/package.nuspec delete mode 100644 Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/readme.md rename Build/third-party-libraries/packages/nuget.org/nunit/{3.14.0 => 4.1.0}/index.json (84%) rename Build/third-party-libraries/packages/nuget.org/nunit/{3.14.0 => 4.1.0}/package-LICENSE.txt (95%) create mode 100644 Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/package.nuspec create mode 100644 Build/third-party-libraries/packages/nuget.org/nunit/4.1.0/readme.md rename Build/third-party-libraries/packages/nuget.org/{nuget.frameworks/6.5.0 => nunit/4.1.0}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/nunit/{3.14.0 => 4.1.0}/repository-LICENSE.txt (95%) rename Build/third-party-libraries/packages/nuget.org/{nuget.frameworks/6.5.0 => nunit/4.1.0}/third-party-notices.txt (100%) rename Build/third-party-libraries/packages/nuget.org/powershellstandard.library/{5.1.0 => 5.1.1}/index.json (100%) rename Build/third-party-libraries/packages/nuget.org/powershellstandard.library/{5.1.0 => 5.1.1}/package-LICENSE.txt (100%) rename Build/third-party-libraries/packages/nuget.org/powershellstandard.library/{5.1.0 => 5.1.1}/package.nuspec (85%) rename Build/third-party-libraries/packages/nuget.org/powershellstandard.library/{5.1.0 => 5.1.1}/project-LICENSE.txt (100%) rename Build/third-party-libraries/packages/nuget.org/powershellstandard.library/{5.1.0 => 5.1.1}/readme.md (83%) rename Build/third-party-libraries/packages/nuget.org/{nunit/3.14.0 => powershellstandard.library/5.1.1}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/{nunit/3.14.0 => powershellstandard.library/5.1.1}/third-party-notices.txt (100%) rename Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/{1.2.0.507 => 1.2.0.556}/index.json (100%) rename Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/{1.2.0.507 => 1.2.0.556}/package-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/{1.2.0.507 => 1.2.0.556}/package.nuspec (92%) rename Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/{1.2.0.507 => 1.2.0.556}/project-LICENSE (100%) rename Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/{1.2.0.507 => 1.2.0.556}/readme.md (81%) rename Build/third-party-libraries/packages/nuget.org/{powershellstandard.library/5.1.0 => stylecop.analyzers.unstable/1.2.0.556}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/{powershellstandard.library/5.1.0 => stylecop.analyzers.unstable/1.2.0.556}/third-party-notices.txt (100%) delete mode 100644 Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/remarks.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/third-party-notices.txt rename Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/{4.8.5 => 4.8.6}/index.json (100%) rename Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/{4.8.5/package-LICENSE.txt => 4.8.6/package-LICENSE.TXT} (100%) rename Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/{4.8.5 => 4.8.6}/package.nuspec (99%) rename Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/{4.8.5 => 4.8.6}/readme.md (94%) rename Build/third-party-libraries/packages/nuget.org/{stylecop.analyzers.unstable/1.2.0.507 => system.data.sqlclient/4.8.6}/remarks.md (100%) rename Build/third-party-libraries/packages/nuget.org/{stylecop.analyzers.unstable/1.2.0.507 => system.data.sqlclient/4.8.6}/third-party-notices.txt (100%) 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.codecoverage/17.9.0/package-LICENSE_MIT.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/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.codecoverage/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.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/microsoft.net.test.sdk/17.9.0/package-LICENSE_MIT.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/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.net.test.sdk/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.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/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/moq/4.20.69/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/moq/4.20.69/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/moq/4.20.69/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/moq/4.20.69/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/nuget.frameworks/6.5.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/nuget.frameworks/6.5.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/nuget.frameworks/6.5.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/nuget.frameworks/6.5.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/index.json b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/index.json similarity index 100% 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 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/powershellstandard.library/5.1.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/powershellstandard.library/5.1.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 83% 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..924ab249 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,4 +1,4 @@ -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 diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.14.0/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/nunit/3.14.0/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/nunit/3.14.0/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/nunit/3.14.0/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/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/powershellstandard.library/5.1.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/powershellstandard.library/5.1.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/powershellstandard.library/5.1.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/powershellstandard.library/5.1.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.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/stylecop.analyzers.unstable/1.2.0.507/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/stylecop.analyzers.unstable/1.2.0.507/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/stylecop.analyzers.unstable/1.2.0.507/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/stylecop.analyzers.unstable/1.2.0.507/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.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.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..dac0fbfb 100644 --- a/Build/third-party-libraries/readme.md +++ b/Build/third-party-libraries/readme.md @@ -3,48 +3,47 @@ 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|42| +|[ms-net-library](licenses/ms-net-library)|no|no|2| |[PostgreSQL](licenses/postgresql)|no|no|1| -Packages 50 +Packages 49 -------- |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| From 78b47eafa2cff3d4dd469c86d519b3d7ce2db133 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:14:30 +0100 Subject: [PATCH 05/27] upgrade to actions/*@v4 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: | From b1008ef8ea1508992c2ec61b8963c568e27038a0 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:22:21 +0100 Subject: [PATCH 06/27] .net sdk 8.0.200 --- Sources/global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 81a77016cbd626f7b054366938a4945a4e4100a3 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:22:42 +0100 Subject: [PATCH 07/27] upgrade sdk versions --- Build/install-dependencies.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 8141e7b74de47d2c5535c120f24951cdacf76d93 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:27:58 +0100 Subject: [PATCH 08/27] c 2024 --- LICENSE.md | 2 +- Sources/Directory.Build.props | 2 +- .../SqlDatabase.Package/nuget/package.nuspec | 2 +- .../SqlDatabase.PowerShell/SqlDatabase.psd1 | Bin 2968 -> 2968 bytes 4 files changed, 3 insertions(+), 3 deletions(-) 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 f7fe85aa..92b8c163 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -30,7 +30,7 @@ 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 diff --git a/Sources/SqlDatabase.Package/nuget/package.nuspec b/Sources/SqlDatabase.Package/nuget/package.nuspec index 7e94f6dd..5d38fba2 100644 --- a/Sources/SqlDatabase.Package/nuget/package.nuspec +++ b/Sources/SqlDatabase.Package/nuget/package.nuspec @@ -14,7 +14,7 @@ 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. + (C) 2018-2024 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 diff --git a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 index 8bf15a68727790677f5377e4d1132a4bc25f5791..4f0b7f2a3e7592471e3e7f953790301c943b342e 100644 GIT binary patch delta 14 VcmbOsK0|zi7bBy|W^YDcE&w691LXh! delta 14 VcmbOsK0|zi7bBz5W^YDcE&w5|1LFVy From 6d00732038111476119fc0e354daa2587958749d Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:33:30 +0100 Subject: [PATCH 09/27] update dependencies --- Build/README.md | 4 ++-- Build/build.ps1 | 4 ++-- Build/create-images.ps1 | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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 From ebec0414e1367f14649b2f88268ed590c73fc023 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 14:48:15 +0100 Subject: [PATCH 10/27] nuget/pwsh module release notes: target the concrete release page --- Sources/Directory.Build.props | 2 +- .../SqlDatabase.Package/nuget/package.nuspec | 2 +- .../SqlDatabase.PowerShell/SqlDatabase.psd1 | Bin 2968 -> 2988 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index 92b8c163..e521e4d6 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -24,7 +24,7 @@ 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 diff --git a/Sources/SqlDatabase.Package/nuget/package.nuspec b/Sources/SqlDatabase.Package/nuget/package.nuspec index 5d38fba2..ac19e808 100644 --- a/Sources/SqlDatabase.Package/nuget/package.nuspec +++ b/Sources/SqlDatabase.Package/nuget/package.nuspec @@ -13,7 +13,7 @@ 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 + 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 miration-step sql-script sql-database database-migrations export-data diff --git a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 index 4f0b7f2a3e7592471e3e7f953790301c943b342e..8958a10ffa88030677aa40a8c8dd148eed299775 100644 GIT binary patch delta 31 lcmbOszD9gQ4Y#m9LkUA7Lpp;#gCT<+gAouLPp;;c1ps(127dqm delta 11 ScmZ1@K0|y%4fo^;+%f Date: Sun, 17 Mar 2024 15:02:33 +0100 Subject: [PATCH 11/27] enable --- Sources/Directory.Build.props | 8 ++++++++ .../AssemblyScriptFactoryTest.cs | 3 +-- .../AssemblyScriptTest.cs | 7 +------ .../DbCommandStub.cs | 4 +--- .../DefaultEntryPointTest.cs | 5 +---- .../EntryPointResolverTest.Stubs.cs | 5 +---- .../EntryPointResolverTest.cs | 3 +-- .../ExecuteMethodResolverCommandDictionaryTest.cs | 4 +--- .../ExecuteMethodResolverCommandTest.cs | 3 +-- .../ExecuteMethodResolverDbConnectionTest.cs | 3 +-- .../ExecuteMethodResolverDictionaryCommandTest.cs | 4 +--- .../ExecuteMethodResolverSqlConnectionTest.cs | 3 +-- .../NetCore/NetCoreSubDomainTest.StepWithSubDomain.cs | 5 +---- .../SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs | 7 +------ .../AssemblyScriptFactory.cs | 5 +---- .../ConsoleListener.cs | 7 +------ .../DefaultEntryPoint.cs | 6 +----- .../EntryPointResolver.cs | 5 +---- .../ExecuteMethodResolverBase.cs | 5 +---- .../ExecuteMethodResolverCommand.cs | 5 +---- .../ExecuteMethodResolverCommandDictionary.cs | 5 +---- .../ExecuteMethodResolverDbConnection.cs | 5 +---- .../ExecuteMethodResolverDictionaryCommand.cs | 5 +---- .../ExecuteMethodResolverSqlConnection.cs | 5 +---- .../SqlDatabase.Adapter.AssemblyScripts/IEntryPoint.cs | 5 +---- Sources/SqlDatabase.Adapter.AssemblyScripts/ISubDomain.cs | 5 +---- .../Net472/AppDomainAdapter.cs | 4 +--- .../Net472/DomainAgent.cs | 7 +------ .../Net472/DomainDirectory.cs | 5 +---- .../Net472/LoggerProxy.cs | 5 +---- .../Net472/Net472SubDomain.cs | 6 +----- .../NetCore/AssemblyContext.cs | 2 -- .../NetCore/NetCoreSubDomain.cs | 5 +---- .../SubDomainFactory.cs | 3 +-- .../SqlDatabase.Adapter.AssemblyScripts/VariablesProxy.cs | 5 +---- .../MsSqlDataExporterTest.cs | 6 +----- .../MsSqlDatabaseAdapterTest.cs | 4 +--- .../SqlDatabase.Adapter.MsSql.Test/MsSqlTextReaderTest.cs | 5 +---- Sources/SqlDatabase.Adapter.MsSql.Test/MsSqlWriterTest.cs | 5 +---- .../TextScriptOutputMsSqlTest.cs | 4 +--- Sources/SqlDatabase.Adapter.MsSql/MsSqlDatabaseAdapter.cs | 4 +--- .../MsSqlDatabaseAdapterFactory.cs | 3 +-- Sources/SqlDatabase.Adapter.MsSql/MsSqlTextReader.cs | 6 +----- Sources/SqlDatabase.Adapter.MsSql/MsSqlWriter.cs | 7 +------ .../MySqlDataExporterTest.cs | 6 +----- .../MySqlDatabaseAdapterTest.cs | 4 +--- Sources/SqlDatabase.Adapter.MySql.Test/MySqlWriterTest.cs | 5 +---- .../TextScriptOutputMySqlTest.cs | 4 +--- Sources/SqlDatabase.Adapter.MySql/MySqlDatabaseAdapter.cs | 4 +--- .../MySqlDatabaseAdapterFactory.cs | 3 +-- Sources/SqlDatabase.Adapter.MySql/MySqlTextReader.cs | 6 +----- Sources/SqlDatabase.Adapter.MySql/MySqlWriter.cs | 7 +------ .../PgSqlDataExporterTest.cs | 6 +----- .../PgSqlDatabaseAdapterTest.cs | 4 +--- Sources/SqlDatabase.Adapter.PgSql.Test/PgSqlWriterTest.cs | 6 +----- .../TextScriptOutputPgSqlTest.cs | 4 +--- Sources/SqlDatabase.Adapter.PgSql/PgSqlDatabaseAdapter.cs | 4 +--- .../PgSqlDatabaseAdapterFactory.cs | 3 +-- Sources/SqlDatabase.Adapter.PgSql/PgSqlTextReader.cs | 6 +----- Sources/SqlDatabase.Adapter.PgSql/PgSqlWriter.cs | 8 +------- .../DiagnosticsToolsTest.cs | 4 +--- .../InstallationSeekerTest.cs | 5 +---- .../PowerShellScriptFactoryTest.cs | 3 +-- .../PowerShellScriptTest.cs | 6 +----- .../PowerShellTest.cs | 6 +----- .../DiagnosticsTools.cs | 4 +--- .../SqlDatabase.Adapter.PowerShellScripts/IPowerShell.cs | 4 +--- .../InstallationInfo.cs | 5 +---- .../InstallationSeeker.cs | 8 +------- .../SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs | 4 +--- .../PowerShellFactory.cs | 4 +--- .../PowerShellFactory.hosted.cs | 2 -- .../PowerShellScript.cs | 7 +------ .../PowerShellScriptFactory.cs | 5 +---- .../PowerShellStreamsListener.cs | 3 +-- .../ReflectionTools.cs | 3 +-- .../VariablesProxy.cs | 3 +-- .../Export/DataExportLoggerTest.cs | 3 +-- .../SqlScriptVariableParserTest.cs | 3 +-- Sources/SqlDatabase.Adapter.Sql.Test/TextScriptTest.cs | 6 +----- .../SqlDatabase.Adapter.Sql/Export/DataExportLogger.cs | 6 +----- Sources/SqlDatabase.Adapter.Sql/Export/DataExporter.cs | 4 +--- Sources/SqlDatabase.Adapter.Sql/Export/IDataExporter.cs | 4 +--- .../SqlDatabase.Adapter.Sql/SqlScriptVariableParser.cs | 4 +--- Sources/SqlDatabase.Adapter.Sql/TextScript.cs | 7 +------ Sources/SqlDatabase.Adapter.Sql/TextScriptFactory.cs | 3 +-- Sources/SqlDatabase.Adapter/DataReaderTools.cs | 4 +--- Sources/SqlDatabase.Adapter/ExportTable.cs | 4 +--- Sources/SqlDatabase.Adapter/IDatabaseAdapter.cs | 5 +---- Sources/SqlDatabase.Adapter/ILogger.cs | 4 +--- Sources/SqlDatabase.Adapter/IScript.cs | 6 +----- Sources/SqlDatabase.Adapter/ISqlTextReader.cs | 5 +---- Sources/SqlDatabase.Adapter/LoggerExtensions.cs | 5 +---- Sources/SqlDatabase.Adapter/SqlWriterBase.cs | 6 +----- .../ConfigurationManagerTest.cs | 3 +-- Sources/SqlDatabase.Configuration/AppConfiguration.cs | 5 +---- .../ConfigurationErrorsException.cs | 4 +--- Sources/SqlDatabase.Configuration/ConfigurationManager.cs | 5 +---- Sources/SqlDatabase.Configuration/ConfigurationReader.cs | 5 +---- .../SqlDatabase.Configuration/DatabaseConfiguration.cs | 5 +---- .../SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs | 4 +--- Sources/SqlDatabase.FileSystem.Test/FileSystemFileTest.cs | 3 +-- .../SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs | 4 +--- .../SqlDatabase.FileSystem.Test/InLineScriptFileTest.cs | 3 +-- Sources/SqlDatabase.FileSystem.Test/ZipFolderTest.cs | 4 +--- Sources/SqlDatabase.FileSystem/FileSystemFactory.cs | 7 +------ Sources/SqlDatabase.FileSystem/FileSystemFile.cs | 4 +--- Sources/SqlDatabase.FileSystem/FileSystemFolder.cs | 6 +----- Sources/SqlDatabase.FileSystem/FileTools.cs | 6 +----- Sources/SqlDatabase.FileSystem/IFile.cs | 4 +--- Sources/SqlDatabase.FileSystem/IFolder.cs | 4 +--- Sources/SqlDatabase.FileSystem/InLineScriptFile.cs | 5 +---- Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs | 6 +----- Sources/SqlDatabase.FileSystem/ZipFolder.cs | 7 +------ .../SqlDatabase.FileSystem/ZipFolderFile.EntryStream.cs | 5 +---- Sources/SqlDatabase.FileSystem/ZipFolderFile.cs | 5 +---- Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs | 3 +-- Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs | 3 +-- Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs | 3 +-- Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs | 3 +-- .../Internal/DependencyResolverFactoryTest.cs | 3 +-- .../TestApi/SqlDatabaseCmdLetTest.cs | 5 +---- Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs | 3 +-- Sources/SqlDatabase.PowerShell/InfoCmdLet.cs | 3 +-- Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs | 5 +---- Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs | 3 +-- .../SqlDatabase.PowerShell/Internal/CmdletExtensions.cs | 3 +-- .../Internal/DependencyResolverFactory.cs | 3 +-- .../Internal/IDependencyResolver.cs | 4 +--- Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs | 3 +-- .../Internal/PowerShellCommandBase.cs | 3 +-- .../Internal/PowerShellCoreDependencyResolver.cs | 3 +-- .../Internal/PowerShellDesktopDependencyResolver.cs | 4 +--- .../SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs | 4 +--- Sources/SqlDatabase.Sequence.Test/DependencyParserTest.cs | 6 +----- .../ModuleVersionResolverTest.cs | 4 +--- .../UpgradeScriptCollectionTest.cs | 3 +-- .../UpgradeScriptSequenceTest.cs | 6 +----- Sources/SqlDatabase.Sequence/CreateScriptSequence.cs | 5 +---- Sources/SqlDatabase.Sequence/DependencyParser.cs | 6 +----- Sources/SqlDatabase.Sequence/GetDatabaseCurrentVersion.cs | 4 +--- Sources/SqlDatabase.Sequence/ICreateScriptSequence.cs | 3 +-- Sources/SqlDatabase.Sequence/IModuleVersionResolver.cs | 4 +--- Sources/SqlDatabase.Sequence/IUpgradeScriptSequence.cs | 4 +--- Sources/SqlDatabase.Sequence/ModuleVersionResolver.cs | 4 +--- Sources/SqlDatabase.Sequence/ScriptDependency.cs | 4 +--- Sources/SqlDatabase.Sequence/ScriptStep.cs | 4 +--- Sources/SqlDatabase.Sequence/UpgradeScriptCollection.cs | 6 +----- Sources/SqlDatabase.Sequence/UpgradeScriptSequence.cs | 6 +----- .../Commands/DatabaseCreateCommandTest.cs | 3 +-- .../Commands/DatabaseExecuteCommandTest.cs | 3 +-- .../Commands/DatabaseExportCommandTest.cs | 5 +---- .../Commands/DatabaseUpgradeCommandTest.cs | 3 +-- .../Configuration/CommandLineFactoryTest.cs | 3 +-- .../Configuration/EnvironmentBuilderMock.cs | 4 +--- .../Configuration/EnvironmentBuilderTest.cs | 4 +--- .../Configuration/ExportCommandLineTest.cs | 3 +-- Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs | 3 +-- Sources/SqlDatabase.Test/Log/FileLoggerTest.cs | 3 +-- Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs | 3 +-- .../Scripts/DatabaseAdapterFactoryTest.cs | 3 +-- Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs | 6 +----- Sources/SqlDatabase.Test/Scripts/ScriptResolverTest.cs | 3 +-- Sources/SqlDatabase.Test/Scripts/VariablesTest.cs | 3 +-- Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs | 4 +--- Sources/SqlDatabase.TestApi/FileFactory.cs | 5 +---- Sources/SqlDatabase.TestApi/ResourceReader.cs | 6 +----- Sources/SqlDatabase.TestApi/TempConsoleOut.cs | 5 +---- Sources/SqlDatabase.TestApi/TempDirectory.cs | 4 +--- Sources/SqlDatabase.TestApi/TempFile.cs | 5 +---- Sources/SqlDatabase.TestApi/TestOutput.cs | 3 +-- Sources/SqlDatabase.TestApi/TextExtensions.cs | 4 +--- Sources/SqlDatabase/Commands/DatabaseExportCommand.cs | 4 +--- Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs | 4 +--- Sources/SqlDatabase/Configuration/CommandLine.cs | 4 +--- Sources/SqlDatabase/Configuration/CommandLineBase.cs | 4 +--- Sources/SqlDatabase/Configuration/CommandLineFactory.cs | 5 +---- Sources/SqlDatabase/Configuration/CommandLineParser.cs | 5 +---- Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs | 5 +---- Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs | 3 +-- Sources/SqlDatabase/Configuration/ExportCommandLine.cs | 4 +--- Sources/SqlDatabase/Configuration/GenericCommandLine.cs | 5 +---- .../Configuration/GenericCommandLineBuilder.cs | 3 +-- Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs | 3 +-- .../Configuration/InvalidCommandLineException.cs | 5 +---- Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs | 3 +-- Sources/SqlDatabase/Log/CombinedLogger.cs | 3 +-- Sources/SqlDatabase/Log/ConsoleLogger.cs | 4 +--- Sources/SqlDatabase/Log/DisposableAction.cs | 4 +--- Sources/SqlDatabase/Log/FileLogger.cs | 4 +--- Sources/SqlDatabase/Log/LoggerBase.cs | 3 +-- Sources/SqlDatabase/Program.cs | 5 +---- Sources/SqlDatabase/Scripts/Database.cs | 4 +--- Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs | 3 +-- Sources/SqlDatabase/Scripts/IDatabase.cs | 4 +--- Sources/SqlDatabase/Scripts/IScriptResolver.cs | 3 +-- Sources/SqlDatabase/Scripts/ScriptResolver.cs | 4 +--- Sources/SqlDatabase/Scripts/Variables.cs | 4 +--- 198 files changed, 203 insertions(+), 669 deletions(-) diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index e521e4d6..a16a7677 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -9,6 +9,7 @@ ..\SqlDatabase.snk latest enable + enable false en @@ -39,4 +40,11 @@ + + + + + + + \ 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..9d155a44 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; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs index 0a1a2862..e152b58c 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; 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 1444bc1b..ad11012d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/DefaultEntryPointTest.cs @@ -1,7 +1,4 @@ -using System; -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.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 d2602bf4..b25de909 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandDictionaryTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs index 69455dc0..74a57d71 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverCommandTest.cs @@ -1,5 +1,4 @@ -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs index 06cea07c..aa653ed4 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDbConnectionTest.cs @@ -1,5 +1,4 @@ -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs index e4cf7d84..5021fa2d 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/ExecuteMethodResolverDictionaryCommandTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; 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/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/AssemblyScript.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs index ab3360f4..2f73a1ac 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs @@ -1,9 +1,4 @@ -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 { diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs index 2b67dd46..ae1e9b34 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Adapter.AssemblyScripts; 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..fcb671bf 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs @@ -1,6 +1,4 @@ #if !NET472 -using System; -using System.IO; using System.Reflection; using System.Runtime.Loader; 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..c37abe46 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace SqlDatabase.Adapter.AssemblyScripts; 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.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/DiagnosticsToolsTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs index bc4bbf79..5c0a8318 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs index 99329240..05fd02dc 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; +using System.Reflection; using Moq; using NUnit.Framework; using Shouldly; 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..a055b197 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs index 269719e7..fdcd0abe 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs @@ -1,6 +1,4 @@ -using System; -using System.Globalization; -using System.IO; +using System.Globalization; using System.Runtime.InteropServices; namespace SqlDatabase.Adapter.PowerShellScripts; 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..345c144e 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; [DebuggerDisplay("{Version}")] internal readonly struct InstallationInfo : IComparable diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs index 989409f3..214d77e6 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs @@ -1,10 +1,4 @@ -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 { diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs index f7885734..ed3f8827 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Management.Automation; +using System.Management.Automation; using System.Management.Automation.Runspaces; namespace SqlDatabase.Adapter.PowerShellScripts; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs index 3d9761ce..533ce381 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs @@ -1,6 +1,4 @@ -using System; - -namespace SqlDatabase.Adapter.PowerShellScripts; +namespace SqlDatabase.Adapter.PowerShellScripts; internal sealed partial class PowerShellFactory : IPowerShellFactory { diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs index ef3d7c27..19d30942 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs @@ -1,6 +1,4 @@ #if NET5_0_OR_GREATER -using System; -using System.IO; using System.Management.Automation; using System.Reflection; using System.Runtime.CompilerServices; 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..d3a02115 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; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs index 86b1164c..68ecc7d2 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; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs index de42ed57..e4254da0 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; 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/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.Test/ConfigurationManagerTest.cs b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs index 7098185d..6c3698e1 100644 --- a/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs +++ b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; 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..0fa79942 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.FileSystem; +using SqlDatabase.FileSystem; namespace SqlDatabase.Configuration; 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.FileSystem.Test/FileSystemFactoryTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs index 869b9cd3..9fcd89f7 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs @@ -1,6 +1,4 @@ -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; 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 5331348f..e852f840 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFolderTest.cs @@ -1,6 +1,4 @@ -using System.IO; -using System.Linq; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; 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 8dcb2819..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; diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs b/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs index 835dff00..e4e8939f 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; public sealed class FileSystemFactory : IFileSystemFactory { diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFile.cs b/Sources/SqlDatabase.FileSystem/FileSystemFile.cs index 1ab6b787..f1096e25 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 { diff --git a/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs b/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs index da1877b2..7af50d3f 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 { diff --git a/Sources/SqlDatabase.FileSystem/FileTools.cs b/Sources/SqlDatabase.FileSystem/FileTools.cs index 280a16b1..9229e09d 100644 --- a/Sources/SqlDatabase.FileSystem/FileTools.cs +++ b/Sources/SqlDatabase.FileSystem/FileTools.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; internal static class FileTools { 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/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..40a30885 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 { diff --git a/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs b/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs index 2dbf2ce7..e1f62dfb 100644 --- a/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs +++ b/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace SqlDatabase.FileSystem; +namespace SqlDatabase.FileSystem; [DebuggerDisplay("{Name}")] internal sealed class ZipEntryFolder : IFolder diff --git a/Sources/SqlDatabase.FileSystem/ZipFolder.cs b/Sources/SqlDatabase.FileSystem/ZipFolder.cs index e2844b1b..7b68eea0 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; 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..9cc1ad42 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 diff --git a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs index 55858e6a..5e1819dd 100644 --- a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; diff --git a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs index c0db652c..4333c7c1 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; diff --git a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs index 527194ca..ae845021 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; 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/TestApi/SqlDatabaseCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs index a66d3177..e0c7356a 100644 --- a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs @@ -1,7 +1,4 @@ -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; diff --git a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs index 9ca0e54e..9459c3bb 100644 --- a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; diff --git a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs index c6e0b05f..61a49678 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; 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..6eee7e78 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Management.Automation; +using System.Management.Automation; using SqlDatabase.Configuration; namespace SqlDatabase.PowerShell.Internal; 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/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/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/PowerShellCommandBase.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs index 9bfb5f80..f8317c75 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Management.Automation; +using System.Management.Automation; using SqlDatabase.Configuration; namespace SqlDatabase.PowerShell.Internal; 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.Sequence.Test/CreateScriptSequenceTest.cs b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs index e91eb6f3..757b4d38 100644 --- a/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/CreateScriptSequenceTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; 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..7ee9c977 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; 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/CommandLineFactoryTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs index 27b3e0f9..40094242 100644 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; namespace SqlDatabase.Configuration; diff --git a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs index 1d911f81..86267df6 100644 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs +++ b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Moq; +using Moq; using Shouldly; using SqlDatabase.Adapter; using SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs index fc8e4477..5dcdb739 100644 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.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.Test/Configuration/ExportCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs index 8db50281..dc65de2b 100644 --- a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs @@ -1,5 +1,4 @@ -using System.IO; -using Moq; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; 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 436c2cc8..8105fce5 100644 --- a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs +++ b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Moq; +using Moq; using Moq.Protected; using NUnit.Framework; using Shouldly; 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..4a7ed1f0 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs @@ -1,8 +1,4 @@ -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; 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 11223f36..33f096e1 100644 --- a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; using Shouldly; namespace SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs index 5a8843f9..9f9c8bf2 100644 --- a/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs +++ b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; +using System.Diagnostics; using System.Xml; using Shouldly; diff --git a/Sources/SqlDatabase.TestApi/FileFactory.cs b/Sources/SqlDatabase.TestApi/FileFactory.cs index 69b58c61..0d4d8310 100644 --- a/Sources/SqlDatabase.TestApi/FileFactory.cs +++ b/Sources/SqlDatabase.TestApi/FileFactory.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; +using System.Text; using Moq; using Shouldly; using SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase.TestApi/ResourceReader.cs b/Sources/SqlDatabase.TestApi/ResourceReader.cs index 5e751431..ce666dfe 100644 --- a/Sources/SqlDatabase.TestApi/ResourceReader.cs +++ b/Sources/SqlDatabase.TestApi/ResourceReader.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; +using System.Diagnostics; using System.Reflection; using System.Text; using Shouldly; 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..0f359f03 100644 --- a/Sources/SqlDatabase.TestApi/TempDirectory.cs +++ b/Sources/SqlDatabase.TestApi/TempDirectory.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; +using System.Diagnostics; using Shouldly; namespace SqlDatabase.TestApi; 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..19404056 100644 --- a/Sources/SqlDatabase.TestApi/TestOutput.cs +++ b/Sources/SqlDatabase.TestApi/TestOutput.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; namespace SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.TestApi/TextExtensions.cs b/Sources/SqlDatabase.TestApi/TextExtensions.cs index a70c8949..0fc15321 100644 --- a/Sources/SqlDatabase.TestApi/TextExtensions.cs +++ b/Sources/SqlDatabase.TestApi/TextExtensions.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.Text; +using System.Text; namespace SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs index 82769fc0..95f5f013 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; +using System.Diagnostics; using System.Text; using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql.Export; diff --git a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs index fa0d8d6f..e407f871 100644 --- a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; +using System.Diagnostics; using System.Text; using SqlDatabase.Adapter; using SqlDatabase.Scripts; diff --git a/Sources/SqlDatabase/Configuration/CommandLine.cs b/Sources/SqlDatabase/Configuration/CommandLine.cs index 77e1a669..64f31618 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.cs +++ b/Sources/SqlDatabase/Configuration/CommandLine.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; internal readonly struct CommandLine { diff --git a/Sources/SqlDatabase/Configuration/CommandLineBase.cs b/Sources/SqlDatabase/Configuration/CommandLineBase.cs index ad5d9ff2..3207c370 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineBase.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineBase.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Commands; using SqlDatabase.FileSystem; diff --git a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs index 1aa4aa41..1fd3c85e 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; internal sealed class CommandLineFactory { diff --git a/Sources/SqlDatabase/Configuration/CommandLineParser.cs b/Sources/SqlDatabase/Configuration/CommandLineParser.cs index aec19af6..a495a627 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineParser.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineParser.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; internal sealed class CommandLineParser { diff --git a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs index 8061a7d3..e0e885c3 100644 --- a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs @@ -1,7 +1,4 @@ -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; diff --git a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs index b8158def..9d7d4b76 100644 --- a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Commands; namespace SqlDatabase.Configuration; diff --git a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs index e968de25..1309e563 100644 --- a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql.Export; using SqlDatabase.Commands; diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs b/Sources/SqlDatabase/Configuration/GenericCommandLine.cs index a6214ceb..84944ed4 100644 --- a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/GenericCommandLine.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; public sealed class GenericCommandLine { diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs b/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs index c49d3814..8d665fdc 100644 --- a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs +++ b/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Text; +using System.Text; namespace SqlDatabase.Configuration; diff --git a/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs b/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs index 47d7e0b9..9059ae92 100644 --- a/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.FileSystem; using SqlDatabase.Scripts; using SqlDatabase.Sequence; diff --git a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs b/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs index 253ff89a..8cc7f5a2 100644 --- a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs +++ b/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs @@ -1,7 +1,4 @@ -using System; -using System.Runtime.Serialization; - -namespace SqlDatabase.Configuration; +namespace SqlDatabase.Configuration; public sealed class InvalidCommandLineException : SystemException { diff --git a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs index 3d33bff7..161a3702 100644 --- a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs @@ -1,5 +1,4 @@ -using System; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Commands; namespace SqlDatabase.Configuration; 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/Program.cs b/Sources/SqlDatabase/Program.cs index 5d4d4539..9b17da6a 100644 --- a/Sources/SqlDatabase/Program.cs +++ b/Sources/SqlDatabase/Program.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using SqlDatabase.Adapter; +using SqlDatabase.Adapter; using SqlDatabase.Configuration; using SqlDatabase.Log; diff --git a/Sources/SqlDatabase/Scripts/Database.cs b/Sources/SqlDatabase/Scripts/Database.cs index ceadcbac..9130b94e 100644 --- a/Sources/SqlDatabase/Scripts/Database.cs +++ b/Sources/SqlDatabase/Scripts/Database.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; +using System.Data; using System.Data.Common; using SqlDatabase.Adapter; using SqlDatabase.Adapter.Sql; 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..1e97178f 100644 --- a/Sources/SqlDatabase/Scripts/IDatabase.cs +++ b/Sources/SqlDatabase/Scripts/IDatabase.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; +using System.Data; 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; From 35b51464e583fd2e53eb7ad8d1e119cfa8340c92 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 15:22:50 +0100 Subject: [PATCH 12/27] always pull images --- Build/tasks/build-tasks.ps1 | 6 ++---- Build/tasks/create-images-tasks.ps1 | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Build/tasks/build-tasks.ps1 b/Build/tasks/build-tasks.ps1 index f311e9ee..516d1f0d 100644 --- a/Build/tasks/build-tasks.ps1 +++ b/Build/tasks/build-tasks.ps1 @@ -206,12 +206,10 @@ task PsCoreTest { , "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 } - } - $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 ` . From db2723f8eb4c482fc017425fc7c59d6053c8d1d0 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 15:23:13 +0100 Subject: [PATCH 13/27] handle pattern preview-[version] --- Build/show-powershell-images.ps1 | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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 From 1bf94338232d0bdbf8a4ece1de1d2ec98e46c33a Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 16:03:32 +0100 Subject: [PATCH 14/27] powershell 7.4 test coverage --- Build/tasks/build-tasks.ps1 | 3 ++- Examples/PowerShellScript/readme.md | 3 ++- .../SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs | 2 +- .../InstallationSeeker.cs | 4 ---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Build/tasks/build-tasks.ps1 b/Build/tasks/build-tasks.ps1 index 516d1f0d..38ea05a7 100644 --- a/Build/tasks/build-tasks.ps1 +++ b/Build/tasks/build-tasks.ps1 @@ -204,7 +204,8 @@ 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") + , "mcr.microsoft.com/powershell:7.3-ubuntu-20.04" + , "mcr.microsoft.com/powershell:7.4-ubuntu-20.04") $builds = @() foreach ($image in $images) { diff --git a/Examples/PowerShellScript/readme.md b/Examples/PowerShellScript/readme.md index 44a06a19..5acb9e84 100644 --- a/Examples/PowerShellScript/readme.md +++ b/Examples/PowerShellScript/readme.md @@ -73,7 +73,8 @@ 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 PowerShell location can be passed via command line: diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs index 345c144e..66e3ac98 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs @@ -3,7 +3,7 @@ [DebuggerDisplay("{Version}")] internal readonly struct InstallationInfo : IComparable { - public InstallationInfo(string location, Version version, string productVersion) + public InstallationInfo(string location, Version version, string? productVersion) { Location = location; Version = version; diff --git a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs index 214d77e6..ba78231a 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs @@ -131,10 +131,6 @@ private static bool IsCompatibleVersion(Version version) 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 From 791a7b757ea59fbc338f98a10488d5e40338c960 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sun, 17 Mar 2024 16:10:21 +0100 Subject: [PATCH 15/27] powershell 7.5 test coverage --- Build/tasks/build-tasks.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Build/tasks/build-tasks.ps1 b/Build/tasks/build-tasks.ps1 index 38ea05a7..4fa0a432 100644 --- a/Build/tasks/build-tasks.ps1 +++ b/Build/tasks/build-tasks.ps1 @@ -205,7 +205,8 @@ task PsCoreTest { , "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" - , "mcr.microsoft.com/powershell:7.4-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) { From 43d59223596e235ad5c267d446193952da83bf7d Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:16:34 +0100 Subject: [PATCH 16/27] gitignore .csproj.user --- .gitignore | 1 + .../SqlDatabase.Adapter.AssemblyScripts.Test.csproj.user | 9 --------- Sources/SqlDatabase.Test/SqlDatabase.Test.csproj.user | 4 ---- 3 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 Sources/SqlDatabase.Adapter.AssemblyScripts.Test/SqlDatabase.Adapter.AssemblyScripts.Test.csproj.user delete mode 100644 Sources/SqlDatabase.Test/SqlDatabase.Test.csproj.user diff --git a/.gitignore b/.gitignore index de2aa5c1..bcf5aa93 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ build.out/ launchSettings.json *.sln.DotSettings.user +*.csproj.user todo.txt \ No newline at end of file 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.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 From 72b33711148d4e66ed44cb50f9b7042db54805c0 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:18:06 +0100 Subject: [PATCH 17/27] resolve environment version at runtime --- Sources/SqlDatabase.Adapter/HostedRuntime.cs | 25 ++++++++ Sources/SqlDatabase.PowerShell/InfoCmdLet.cs | 1 + .../HostedRuntimeResolverTest.cs | 46 +++++++++++++++ .../Configuration/HostedRuntimeResolver.cs | 58 +++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 Sources/SqlDatabase.Adapter/HostedRuntime.cs create mode 100644 Sources/SqlDatabase.Test/Configuration/HostedRuntimeResolverTest.cs create mode 100644 Sources/SqlDatabase/Configuration/HostedRuntimeResolver.cs 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.PowerShell/InfoCmdLet.cs b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs index 61a49678..2087c5f9 100644 --- a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs @@ -29,6 +29,7 @@ private void WriteInfo() psVersionTable.PSEdition, psVersionTable.PSVersion, Version = assembly.GetName().Version, + ClrVersion = Environment.Version, RuntimeInformation.FrameworkDescription, RuntimeInformation.OSDescription, RuntimeInformation.OSArchitecture, 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/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 From c0afa206268ec391a5bd4c59ff55f284f7d57a71 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:21:03 +0100 Subject: [PATCH 18/27] PowerShellScripts netstandard2.0 --- .../InstallationInfoTest.cs | 62 ++++++++ .../InstallationSeekerTest.cs | 94 +++--------- ...icsToolsTest.cs => PowerShellLinuxTest.cs} | 14 +- .../PowerShellTest.cs | 17 ++- .../PowerShellWindowsTest.cs | 16 ++ .../CodeAnalysis/AllowNullAttribute.cs | 8 +- .../CodeAnalysis/NotNullWhenAttribute.cs | 6 +- .../DiagnosticsTools.cs | 137 ++++-------------- .../InstallationInfo.cs | 18 ++- .../InstallationSeeker.cs | 78 ++-------- .../PowerShell.cs | 9 +- ...llAssemblyLoadContextInitializerAdapter.cs | 24 +++ .../PowerShellFactory.cs | 120 +++++++++++++-- .../PowerShellFactory.hosted.cs | 104 ------------- .../PowerShellFactory.native.cs | 7 - .../PowerShellLinux.cs | 75 ++++++++++ .../PowerShellScriptFactory.cs | 43 +++--- .../PowerShellStreamsListener.cs | 17 +-- .../PowerShellWindows.cs | 51 +++++++ .../ReflectionTools.cs | 36 +++++ ...lDatabase.Adapter.PowerShellScripts.csproj | 13 +- 21 files changed, 512 insertions(+), 437 deletions(-) create mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationInfoTest.cs rename Sources/SqlDatabase.Adapter.PowerShellScripts.Test/{DiagnosticsToolsTest.cs => PowerShellLinuxTest.cs} (63%) create mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellWindowsTest.cs create mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellAssemblyLoadContextInitializerAdapter.cs delete mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs delete mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.native.cs create mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellLinux.cs create mode 100644 Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellWindows.cs 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 05fd02dc..09182755 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/InstallationSeekerTest.cs @@ -1,5 +1,5 @@ using System.Reflection; -using Moq; +using System.Runtime.InteropServices; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; @@ -9,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); @@ -22,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); } @@ -40,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(); @@ -55,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 63% rename from Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs rename to Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellLinuxTest.cs index 5c0a8318..d2dec536 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/DiagnosticsToolsTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellLinuxTest.cs @@ -5,25 +5,17 @@ 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/PowerShellTest.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs index a055b197..2bf5aca2 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts.Test/PowerShellTest.cs @@ -1,4 +1,5 @@ -using Moq; +using System.Runtime.InteropServices; +using Moq; using NUnit.Framework; using Shouldly; using SqlDatabase.TestApi; @@ -31,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 fdcd0abe..24ab9875 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/DiagnosticsTools.cs @@ -1,133 +1,60 @@ -using System.Globalization; -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/InstallationInfo.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs index 66e3ac98..f629f45f 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationInfo.cs @@ -1,7 +1,7 @@ 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) { @@ -45,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 ba78231a..42194bca 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/InstallationSeeker.cs @@ -2,29 +2,24 @@ 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; @@ -36,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); } @@ -57,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; @@ -75,64 +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)) + if (runtimeVersion == FrameworkVersion.Net6) { - // try parent - return FindPowerShellProcess(parentId.Value, processStartTime); + return version < new Version("7.3"); } - return Path.GetDirectoryName(parentLocation); - } - - private static string GetDefaultInstallationRoot() - { - if (DiagnosticsTools.IsOSPlatformWindows()) - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell"); - } - - 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"); -#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 ed3f8827..2700f42c 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShell.cs @@ -5,6 +5,13 @@ 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; @@ -28,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 533ce381..c7b8f7c1 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.cs @@ -1,20 +1,24 @@ -namespace SqlDatabase.Adapter.PowerShellScripts; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Loader; -internal sealed partial class PowerShellFactory : IPowerShellFactory +namespace SqlDatabase.Adapter.PowerShellScripts; + +// 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) { @@ -24,7 +28,11 @@ public void Initialize(ILogger logger) } _initialized = true; - DoInitialize(logger); + + if (!Runtime.IsPowershell && Runtime.Version != FrameworkVersion.Net472) + { + InitializePowerShellAssemblyLoadContext(logger); + } } public IPowerShell Create() @@ -34,8 +42,98 @@ public IPowerShell Create() throw new InvalidOperationException("PowerShell host is not initialized."); } - return new PowerShell(); + return new PowerShell(Runtime.Version); } - partial void DoInitialize(ILogger logger); + [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); + } + } + + 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 19d30942..00000000 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellFactory.hosted.cs +++ /dev/null @@ -1,104 +0,0 @@ -#if NET5_0_OR_GREATER -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/PowerShellScriptFactory.cs b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs index d3a02115..63e5055e 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellScriptFactory.cs @@ -6,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)) { } @@ -16,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 68ecc7d2..969d754e 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/PowerShellStreamsListener.cs @@ -9,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; @@ -32,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 @@ -57,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 e4254da0..786b000b 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/ReflectionTools.cs @@ -15,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 12a480d6..8ce5fa20 100644 --- a/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj +++ b/Sources/SqlDatabase.Adapter.PowerShellScripts/SqlDatabase.Adapter.PowerShellScripts.csproj @@ -1,21 +1,14 @@  - net472;net6.0;net7.0;net8.0;netstandard2.0 + netstandard2.0 - + + - - - - - - - - From d22d9c0ced964325f49cac07a20a3bd017528ce0 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:22:03 +0100 Subject: [PATCH 19/27] AssemblyScripts netstandard2.0 --- .../AssemblyScriptFactoryTest.cs | 6 ++-- .../AssemblyScriptTest.cs | 17 ++++++--- .../Net472/Net472SubDomainTest.cs | 11 +++--- .../NetCore/NetCoreSubDomainTest.cs | 5 +-- .../AssemblyScript.cs | 6 +++- .../AssemblyScriptFactory.cs | 35 ++++++++----------- .../CodeAnalysis/AllowNullAttribute.cs | 8 ++--- .../CodeAnalysis/NotNullWhenAttribute.cs | 6 ++-- .../NetCore/AssemblyContext.cs | 6 ++-- .../SubDomainFactory.cs | 16 +++------ 10 files changed, 50 insertions(+), 66 deletions(-) diff --git a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs index 9d155a44..e4b62caa 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptFactoryTest.cs @@ -14,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] @@ -37,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(); @@ -45,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 e152b58c..9e4f84b2 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/AssemblyScriptTest.cs @@ -34,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] @@ -55,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); } @@ -91,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/Net472/Net472SubDomainTest.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts.Test/Net472/Net472SubDomainTest.cs index 5115b928..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(); 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/AssemblyScript.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs index 2f73a1ac..99d86941 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScript.cs @@ -5,13 +5,17 @@ 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!; @@ -31,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 ae1e9b34..de4c43ac 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/AssemblyScriptFactory.cs @@ -4,39 +4,34 @@ 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/NetCore/AssemblyContext.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs index fcb671bf..bbdb023f 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/NetCore/AssemblyContext.cs @@ -1,5 +1,4 @@ -#if !NET472 -using System.Reflection; +using System.Reflection; using System.Runtime.Loader; namespace SqlDatabase.Adapter.AssemblyScripts.NetCore; @@ -27,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/SubDomainFactory.cs b/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs index c37abe46..69ba3219 100644 --- a/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs +++ b/Sources/SqlDatabase.Adapter.AssemblyScripts/SubDomainFactory.cs @@ -1,13 +1,12 @@ using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; 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(); } @@ -17,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); } @@ -27,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) { From 804a418e7e84ef59af09e901974af754482ed704 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:23:14 +0100 Subject: [PATCH 20/27] remove #if --- .../ConfigurationManager.cs | 2 +- .../Internal/SqlDatabaseProgram.cs | 2 +- .../SqlDatabase.PowerShell.csproj | 38 +++++++++++-------- .../CodeAnalysis/AllowNullAttribute.cs | 8 +--- .../CodeAnalysis/NotNullWhenAttribute.cs | 6 +-- .../Configuration/CreateCommandLineTest.cs | 16 ++++---- .../Configuration/EnvironmentBuilderTest.cs | 2 +- .../Configuration/ExecuteCommandLineTest.cs | 15 +++----- .../Configuration/UpgradeCommandLineTest.cs | 17 ++++----- .../Configuration/CommandLineBase.cs | 2 + .../Configuration/CommandLineFactory.cs | 17 ++++++++- .../Configuration/CreateCommandLine.cs | 6 +-- .../Configuration/EnvironmentBuilder.cs | 11 +++++- .../Configuration/ExecuteCommandLine.cs | 7 ++-- .../Configuration/ExportCommandLine.cs | 2 +- .../Configuration/UpgradeCommandLine.cs | 6 +-- Sources/SqlDatabase/Program.cs | 32 ++++++++-------- 17 files changed, 101 insertions(+), 88 deletions(-) diff --git a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs index 0fa79942..65d05e5a 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs @@ -40,7 +40,7 @@ public void LoadFrom(string? configurationFile) } } - private static IFile ResolveConfigurationFile(string probingPath) + private static IFile ResolveConfigurationFile(string? probingPath) { var info = FileSystemFactory.FileSystemInfoFromPath(probingPath); return ResolveFile(info); diff --git a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs index 0dba068e..74c11152 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs @@ -15,6 +15,6 @@ public SqlDatabaseProgram(ILogger logger) public void ExecuteCommand(GenericCommandLine command) { var args = new GenericCommandLineBuilder(command).BuildArray(); - Program.Run(_logger, args); + Program.Run(_logger, true, args); } } \ No newline at end of file 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.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.Test/Configuration/CreateCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs index bbd31da4..85ef3975 100644 --- a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs @@ -20,7 +20,11 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _fs = new Mock(MockBehavior.Strict); - _sut = new CreateCommandLine { FileSystemFactory = _fs.Object }; + _sut = new CreateCommandLine + { + FileSystemFactory = _fs.Object, + Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) + }; } [Test] @@ -37,25 +41,19 @@ public void Parse() 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.Scripts.ShouldBe([folder.Object]); _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables.Keys.ShouldBe(["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(); } diff --git a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs index 5dcdb739..5afa8dfd 100644 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs @@ -19,7 +19,7 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _configuration = new AppConfiguration(); - _sut = new EnvironmentBuilder(); + _sut = new EnvironmentBuilder(HostedRuntimeResolver.GetRuntime(false)); _sut .WithConfiguration(_configuration) diff --git a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs index 5ed2b3c9..1bc404e7 100644 --- a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs @@ -20,7 +20,11 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _fs = new Mock(MockBehavior.Strict); - _sut = new ExecuteCommandLine { FileSystemFactory = _fs.Object }; + _sut = new ExecuteCommandLine + { + FileSystemFactory = _fs.Object, + Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) + }; } [Test] @@ -43,9 +47,7 @@ public void Parse() 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); @@ -54,18 +56,13 @@ public void Parse() _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables.Keys.ShouldBe(["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(); } diff --git a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs index e2bb4077..95c6e05b 100644 --- a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs @@ -20,7 +20,11 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _fs = new Mock(MockBehavior.Strict); - _sut = new UpgradeCommandLine { FileSystemFactory = _fs.Object }; + _sut = new UpgradeCommandLine + { + FileSystemFactory = _fs.Object, + Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) + }; } [Test] @@ -39,27 +43,20 @@ public void Parse() 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.Scripts.ShouldBe([folder.Object]); _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables.Keys.ShouldBe(["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(); } diff --git a/Sources/SqlDatabase/Configuration/CommandLineBase.cs b/Sources/SqlDatabase/Configuration/CommandLineBase.cs index 3207c370..972295f1 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineBase.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineBase.cs @@ -6,6 +6,8 @@ namespace SqlDatabase.Configuration; internal abstract class CommandLineBase : ICommandLine { + public HostedRuntime Runtime { get; set; } + public string? ConnectionString { get; set; } public IList Scripts { get; } = new List(); diff --git a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs index 1fd3c85e..83d125ee 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs @@ -1,4 +1,6 @@ -namespace SqlDatabase.Configuration; +using SqlDatabase.Adapter; + +namespace SqlDatabase.Configuration; internal sealed class CommandLineFactory { @@ -10,6 +12,8 @@ internal sealed class CommandLineFactory public CommandLine Args { get; set; } + public HostedRuntime Runtime { get; set; } + public string ActiveCommandName { get; private set; } = null!; public bool ShowCommandHelp { get; private set; } @@ -58,7 +62,16 @@ public bool Bind() public ICommandLine? Resolve() { var command = CreateCommand(ActiveCommandName); - command?.Parse(Args); + if (command != null) + { + if (command is CommandLineBase supportRuntime) + { + supportRuntime.Runtime = Runtime; + } + + command.Parse(Args); + } + return command; } diff --git a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs b/Sources/SqlDatabase/Configuration/CreateCommandLine.cs index 6556c3c8..d8c496a6 100644 --- a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/CreateCommandLine.cs @@ -9,7 +9,7 @@ internal sealed class CreateCommandLine : CommandLineBase public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); + public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder(Runtime)); internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) { @@ -30,13 +30,11 @@ internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) protected override bool ParseArg(Arg arg) { -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, System.StringComparison.OrdinalIgnoreCase)) + if (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { UsePowerShell = arg.Value; return true; } -#endif if (TryParseWhatIf(arg, out var value)) { diff --git a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs index e0e885c3..e7dc0050 100644 --- a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs @@ -10,6 +10,8 @@ namespace SqlDatabase.Configuration; internal sealed class EnvironmentBuilder : IEnvironmentBuilder { + private readonly HostedRuntime _runtime; + private ILogger? _logger; private AppConfiguration? _configuration; private string? _connectionString; @@ -21,6 +23,11 @@ internal sealed class EnvironmentBuilder : IEnvironmentBuilder private ScriptResolver? _scriptResolver; private IDatabase? _database; + public EnvironmentBuilder(HostedRuntime runtime) + { + _runtime = runtime; + } + public IEnvironmentBuilder WithConfiguration(string? configurationFile) { var configuration = new ConfigurationManager(); @@ -38,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; } diff --git a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs index 9d7d4b76..3f313225 100644 --- a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs @@ -11,7 +11,7 @@ internal sealed class ExecuteCommandLine : CommandLineBase public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); + public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder(Runtime)); internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) { @@ -44,13 +44,12 @@ protected override bool ParseArg(Arg arg) return true; } -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + if (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { UsePowerShell = arg.Value; return true; } -#endif + if (TryParseWhatIf(arg, out var value)) { WhatIf = value; diff --git a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs index 1309e563..29d3a464 100644 --- a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs @@ -10,7 +10,7 @@ internal sealed class ExportCommandLine : CommandLineBase public string? DestinationFileName { get; set; } - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); + public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder(Runtime)); internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) { diff --git a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs index 161a3702..dc7c65d2 100644 --- a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs @@ -13,7 +13,7 @@ internal sealed class UpgradeCommandLine : CommandLineBase public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder()); + public override ICommand CreateCommand(ILogger logger) => CreateCommand(logger, new EnvironmentBuilder(Runtime)); internal ICommand CreateCommand(ILogger logger, IEnvironmentBuilder builder) { @@ -46,13 +46,11 @@ protected override bool ParseArg(Arg arg) return true; } -#if NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + if (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { UsePowerShell = arg.Value; return true; } -#endif if (TryParseSwitchParameter(arg, Arg.FolderAsModuleName, out value)) { diff --git a/Sources/SqlDatabase/Program.cs b/Sources/SqlDatabase/Program.cs index 9b17da6a..17193d2a 100644 --- a/Sources/SqlDatabase/Program.cs +++ b/Sources/SqlDatabase/Program.cs @@ -9,10 +9,10 @@ internal static class Program public static int Main(string[] args) { var logger = LoggerFactory.CreateDefault(); - return Run(logger, args); + return Run(logger, false, args); } - internal static int Run(ILogger logger, string[] args) + internal static int Run(ILogger logger, bool isPowershell, string[] args) { if (!TryWrapWithUsersLogger(logger, args, out var userLogger)) { @@ -21,7 +21,7 @@ internal static int Run(ILogger logger, string[] args) try { - return MainCore(userLogger ?? logger, args); + return MainCore(userLogger ?? logger, isPowershell, args); } finally { @@ -29,9 +29,10 @@ internal static int Run(ILogger logger, string[] args) } } - private static int MainCore(ILogger logger, string[] args) + private static int MainCore(ILogger logger, bool isPowershell, string[] args) { - var factory = ResolveFactory(args, logger); + var runtime = HostedRuntimeResolver.GetRuntime(isPowershell); + var factory = ResolveFactory(runtime, args, logger); if (factory == null) { logger.Info(LoadHelpContent("CommandLine.txt")); @@ -40,7 +41,7 @@ private static int MainCore(ILogger logger, string[] args) if (factory.ShowCommandHelp) { - logger.Info(LoadHelpContent(GetHelpFileName(factory.ActiveCommandName))); + logger.Info(LoadHelpContent(GetHelpFileName(runtime, factory.ActiveCommandName))); return ExitCode.InvalidCommandLine; } @@ -82,7 +83,7 @@ private static bool ExecuteCommand(ICommandLine cmd, ILogger logger) return null; } - private static CommandLineFactory? ResolveFactory(string[] args, ILogger logger) + private static CommandLineFactory? ResolveFactory(HostedRuntime runtime, string[] args, ILogger logger) { try { @@ -92,7 +93,7 @@ private static bool ExecuteCommand(ICommandLine cmd, ILogger logger) return null; } - var factory = new CommandLineFactory { Args = command }; + var factory = new CommandLineFactory { Args = command, Runtime = runtime }; return factory.Bind() ? factory : null; } catch (Exception ex) @@ -127,14 +128,15 @@ private static bool TryWrapWithUsersLogger(ILogger logger, string[] args, out Co return true; } - private static string GetHelpFileName(string commandName) + private static string GetHelpFileName(HostedRuntime runtime, string commandName) { -#if NET472 - const string Runtime = ".net472"; -#else - const string? Runtime = null; -#endif - return "CommandLine." + commandName + Runtime + ".txt"; + if (runtime.IsPowershell) + { + throw new NotSupportedException(); + } + + var suffix = runtime.Version == FrameworkVersion.Net472 ? ".net472" : null; + return "CommandLine." + commandName + suffix + ".txt"; } private static string LoadHelpContent(string fileName) From 59d24fa5914238cadd3f6c3dc2dfae9cbbc1f593 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:23:47 +0100 Subject: [PATCH 21/27] MsSql netstandard2.0 --- .../SqlDatabase.Adapter.MsSql.csproj | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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\ - - + From 6081544e3c7a23f5e336d3d966fd93261f931255 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:24:42 +0100 Subject: [PATCH 22/27] PowerShell rm netstandard2.0 from bin --- Build/tasks/build-tasks.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build/tasks/build-tasks.ps1 b/Build/tasks/build-tasks.ps1 index 4fa0a432..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 From fae0e9e5203662360d54234d8ada509cdd6baae7 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Fri, 29 Mar 2024 11:25:25 +0100 Subject: [PATCH 23/27] update third party notices --- .../microsoft.wsman.runtime/7.2.0/index.json | 32 ------------------- .../7.2.0/package.nuspec | 24 -------------- .../7.2.0/project-LICENSE.txt | 21 ------------ .../microsoft.wsman.runtime/7.2.0/readme.md | 26 --------------- .../microsoft.wsman.runtime/7.2.0/remarks.md | 0 .../7.2.0/third-party-notices.txt | 0 .../microsoft.wsman.runtime/7.3.0/index.json | 32 ------------------- .../7.3.0/package.nuspec | 24 -------------- .../7.3.0/project-LICENSE.txt | 21 ------------ .../microsoft.wsman.runtime/7.3.0/readme.md | 26 --------------- .../microsoft.wsman.runtime/7.3.0/remarks.md | 0 .../7.3.0/third-party-notices.txt | 0 .../5.1.1/index.json | 3 -- .../5.1.1/readme.md | 2 +- .../nuget.org/system.buffers/4.5.1/index.json | 1 - .../nuget.org/system.buffers/4.5.1/readme.md | 2 +- .../4.7.0/index.json | 1 - .../4.7.0/readme.md | 2 +- .../nuget.org/system.memory/4.5.4/index.json | 1 - .../nuget.org/system.memory/4.5.4/readme.md | 2 +- .../system.numerics.vectors/4.4.0/index.json | 1 - .../system.numerics.vectors/4.4.0/readme.md | 2 +- .../4.7.0/index.json | 1 - .../4.7.0/readme.md | 2 +- .../4.7.0/index.json | 1 - .../4.7.0/readme.md | 2 +- Build/third-party-libraries/readme.md | 6 ++-- 27 files changed, 9 insertions(+), 226 deletions(-) delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/package.nuspec delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/project-LICENSE.txt delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/remarks.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/third-party-notices.txt delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md delete mode 100644 Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.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/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/project-LICENSE.txt deleted file mode 100644 index b2f52a2b..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/project-LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Microsoft Corporation. - -MIT License - -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.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.2.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/remarks.md deleted file mode 100644 index e69de29b..00000000 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/microsoft.wsman.runtime/7.2.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 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/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt deleted file mode 100644 index b2f52a2b..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Microsoft Corporation. - -MIT License - -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.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/microsoft.wsman.runtime/7.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md deleted file mode 100644 index e69de29b..00000000 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/microsoft.wsman.runtime/7.3.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.1/index.json b/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.1/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.1/readme.md b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md index 924ab249..9456ed96 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.1/readme.md @@ -3,7 +3,7 @@ PowerShellStandard.Library [5.1.1](https://www.nuget.org/packages/PowerShellStan 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/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.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.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/readme.md b/Build/third-party-libraries/readme.md index dac0fbfb..8e5dc548 100644 --- a/Build/third-party-libraries/readme.md +++ b/Build/third-party-libraries/readme.md @@ -6,13 +6,13 @@ Licenses |[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|42| +|[MIT](licenses/mit)|no|no|40| |[ms-net-library](licenses/ms-net-library)|no|no|2| |[PostgreSQL](licenses/postgresql)|no|no|1| -Packages 49 +Packages 47 -------- |Name|Version|Source|License|Used by| @@ -27,8 +27,6 @@ Packages 49 |[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.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| From f3e68e52cdeb6e09ac6184add2d8b09d1e3a48a1 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sat, 13 Apr 2024 11:03:42 +0200 Subject: [PATCH 24/27] file system is relative to the current directory --- .../ConfigurationManagerTest.cs | 82 +++++---- .../ConfigurationManager.cs | 66 ++++--- .../FileSystemFactoryTest.cs | 170 ++++++++++++------ .../CodeAnalysis/AllowNullAttribute.cs | 4 + .../CodeAnalysis/NotNullWhenAttribute.cs | 8 + .../FileSystemFactory.cs | 33 ++-- .../SqlDatabase.FileSystem/FileSystemFile.cs | 12 +- .../FileSystemFolder.cs | 2 + Sources/SqlDatabase.FileSystem/FileTools.cs | 15 +- .../SqlDatabase.FileSystem/IFileSystemInfo.cs | 2 + .../InLineScriptFile.cs | 7 +- .../SqlDatabase.FileSystem/ZipEntryFolder.cs | 7 +- Sources/SqlDatabase.FileSystem/ZipFolder.cs | 19 +- .../SqlDatabase.FileSystem/ZipFolderFile.cs | 2 + .../ConfigurationExtensions.cs | 3 +- Sources/SqlDatabase.TestApi/FileFactory.cs | 4 +- Sources/SqlDatabase.TestApi/ResourceReader.cs | 4 +- Sources/SqlDatabase.TestApi/TempDirectory.cs | 10 +- Sources/SqlDatabase.TestApi/TestOutput.cs | 4 +- Sources/SqlDatabase.TestApi/TextExtensions.cs | 4 +- 20 files changed, 270 insertions(+), 188 deletions(-) create mode 100644 Sources/SqlDatabase.FileSystem/CodeAnalysis/AllowNullAttribute.cs create mode 100644 Sources/SqlDatabase.FileSystem/CodeAnalysis/NotNullWhenAttribute.cs diff --git a/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs index 6c3698e1..4763cc84 100644 --- a/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs +++ b/Sources/SqlDatabase.Configuration.Test/ConfigurationManagerTest.cs @@ -1,5 +1,7 @@ -using NUnit.Framework; +using Moq; +using NUnit.Framework; using Shouldly; +using SqlDatabase.FileSystem; using SqlDatabase.TestApi; namespace SqlDatabase.Configuration; @@ -13,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] @@ -67,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/ConfigurationManager.cs b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs index 65d05e5a..ff63d160 100644 --- a/Sources/SqlDatabase.Configuration/ConfigurationManager.cs +++ b/Sources/SqlDatabase.Configuration/ConfigurationManager.cs @@ -2,69 +2,65 @@ 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.FileSystem.Test/FileSystemFactoryTest.cs b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs index 9fcd89f7..70c7b2c1 100644 --- a/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs +++ b/Sources/SqlDatabase.FileSystem.Test/FileSystemFactoryTest.cs @@ -7,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); - folder.ShouldBeOfType(); - } + 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] @@ -23,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)); - folder.ShouldNotBeNull(); + var folder = _sut + .FileSystemInfoFromPath(Path.Combine(_location.Location, path)) + .ShouldBeAssignableTo() + .ShouldNotBeNull(); - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - files.Count.ShouldBe(1); - files[0].Name.ShouldBe(fileName); - } + var files = folder.GetFiles().ToList(); + if (fileName != null) + { + files.Count.ShouldBe(1); + files[0].Name.ShouldBe(fileName); } } @@ -45,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)); - folder.ShouldNotBeNull(); - - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - files.Count.ShouldBe(1); - files[0].Name.ShouldBe(fileName); - } + files.Count.ShouldBe(1); + files[0].Name.ShouldBe(fileName); } } @@ -70,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] @@ -80,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); - Should.Throw(() => 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, [1]); + var fileName = Path.Combine(_location.Location, "11.txt"); + File.WriteAllBytes(fileName, [1]); - var file = FileSystemFactory.FileSystemInfoFromPath(fileName); - file.ShouldBeOfType(); - } + 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)); - file.ShouldBeOfType(); + 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/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 e4e8939f..2b1cf9e9 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFactory.cs @@ -1,10 +1,18 @@ namespace SqlDatabase.FileSystem; +[DebuggerDisplay("{CurrentDirectory}")] public sealed class FileSystemFactory : IFileSystemFactory { - public static IFileSystemInfo FileSystemInfoFromPath(string? path) + public FileSystemFactory(string currentDirectory) { - path = FileTools.RootPath(path); + CurrentDirectory = currentDirectory; + } + + public string CurrentDirectory { get; } + + public IFileSystemInfo FileSystemInfoFromPath(string? path) + { + path = FileTools.RootPath(path, CurrentDirectory); if (File.Exists(path)) { @@ -21,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; } @@ -66,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)) @@ -87,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 f1096e25..74639f7d 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFile.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFile.cs @@ -15,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 7af50d3f..bf295144 100644 --- a/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs +++ b/Sources/SqlDatabase.FileSystem/FileSystemFolder.cs @@ -12,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 9229e09d..fa8c6ded 100644 --- a/Sources/SqlDatabase.FileSystem/FileTools.cs +++ b/Sources/SqlDatabase.FileSystem/FileTools.cs @@ -5,29 +5,22 @@ 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/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/InLineScriptFile.cs b/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs index 40a30885..6877a42d 100644 --- a/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs +++ b/Sources/SqlDatabase.FileSystem/InLineScriptFile.cs @@ -15,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 e1f62dfb..bf3b2329 100644 --- a/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs +++ b/Sources/SqlDatabase.FileSystem/ZipEntryFolder.cs @@ -3,8 +3,11 @@ [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); @@ -17,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 7b68eea0..24b9bd91 100644 --- a/Sources/SqlDatabase.FileSystem/ZipFolder.cs +++ b/Sources/SqlDatabase.FileSystem/ZipFolder.cs @@ -25,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(); @@ -64,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); } @@ -88,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.cs b/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs index 9cc1ad42..23e8cefd 100644 --- a/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs +++ b/Sources/SqlDatabase.FileSystem/ZipFolderFile.cs @@ -22,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.TestApi/ConfigurationExtensions.cs b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs index 9f9c8bf2..53382ec6 100644 --- a/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs +++ b/Sources/SqlDatabase.TestApi/ConfigurationExtensions.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -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 0d4d8310..bfb05567 100644 --- a/Sources/SqlDatabase.TestApi/FileFactory.cs +++ b/Sources/SqlDatabase.TestApi/FileFactory.cs @@ -1,5 +1,4 @@ -using System.Text; -using Moq; +using Moq; using Shouldly; using SqlDatabase.FileSystem; @@ -41,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 ce666dfe..d840dffc 100644 --- a/Sources/SqlDatabase.TestApi/ResourceReader.cs +++ b/Sources/SqlDatabase.TestApi/ResourceReader.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -using System.Reflection; -using System.Text; +using System.Reflection; using Shouldly; namespace SqlDatabase.TestApi; diff --git a/Sources/SqlDatabase.TestApi/TempDirectory.cs b/Sources/SqlDatabase.TestApi/TempDirectory.cs index 0f359f03..54ca4be5 100644 --- a/Sources/SqlDatabase.TestApi/TempDirectory.cs +++ b/Sources/SqlDatabase.TestApi/TempDirectory.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using Shouldly; +using Shouldly; namespace SqlDatabase.TestApi; @@ -17,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); @@ -28,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/TestOutput.cs b/Sources/SqlDatabase.TestApi/TestOutput.cs index 19404056..5c5469f7 100644 --- a/Sources/SqlDatabase.TestApi/TestOutput.cs +++ b/Sources/SqlDatabase.TestApi/TestOutput.cs @@ -1,6 +1,4 @@ -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 0fc15321..2935e21a 100644 --- a/Sources/SqlDatabase.TestApi/TextExtensions.cs +++ b/Sources/SqlDatabase.TestApi/TextExtensions.cs @@ -1,6 +1,4 @@ -using System.Text; - -namespace SqlDatabase.TestApi; +namespace SqlDatabase.TestApi; public static class TextExtensions { From 61deeba3f2a41c2defdb12bb5c6def80edf61483 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sat, 13 Apr 2024 11:05:06 +0200 Subject: [PATCH 25/27] SqlDatabase.CommandLine --- .gitignore | 1 + .../TransactionMode.cs | 2 +- .../CommandLineParserTest.cs | 149 ++++++++++++++ .../Internal/ArgTest.cs | 27 +++ .../SqlDatabase.CommandLine.Test.csproj | 19 ++ .../CodeAnalysis/AllowNullAttribute.cs | 4 + .../CodeAnalysis/NotNullWhenAttribute.cs | 8 + .../CommandLineParser.cs | 157 ++++++++++++++ .../CreateCommandLine.cs | 18 ++ .../ExecuteCommandLine.cs | 22 ++ .../ExportCommandLine.cs | 18 ++ .../SqlDatabase.CommandLine/ICommandLine.cs | 6 + .../SqlDatabase.CommandLine/Internal/Arg.cs | 56 +++++ .../Internal/ArgNames.cs} | 45 +--- .../Internal/CommandLineBinder.cs | 67 ++++++ .../Internal/CommandLineBinderExtensions.cs | 76 +++++++ .../Internal/EnumArgBinder.cs | 37 ++++ .../Internal/IArgBinder.cs | 12 ++ .../Internal/ScriptSourceArgBinder.cs | 31 +++ .../Internal/StringArgBinder.cs | 38 ++++ .../Internal/SwitchArgBinder.cs | 37 ++++ .../Internal/VariableArgBinder.cs | 31 +++ .../InvalidCommandLineException.cs | 18 ++ .../Properties/AssemblyInfo.cs | 3 + .../SqlDatabase.CommandLine/ScriptSource.cs | 23 +++ .../SqlDatabase.CommandLine.csproj | 11 + .../UpgradeCommandLine.cs | 24 +++ .../IConfigurationManager.cs | 6 - .../CreateCmdLetTest.cs | 50 ++--- .../ExecuteCmdLetTest.cs | 62 +++--- .../ExportCmdLetTest.cs | 43 ++-- .../Internal/PowerShellCommandBaseTest.cs | 18 -- .../TestApi/SqlDatabaseCmdLetTest.cs | 19 +- .../UpgradeCmdLetTest.cs | 58 ++---- .../SqlDatabase.PowerShell/CreateCmdLet.cs | 17 +- .../SqlDatabase.PowerShell/ExecuteCmdLet.cs | 20 +- .../SqlDatabase.PowerShell/ExportCmdLet.cs | 16 +- Sources/SqlDatabase.PowerShell/InfoCmdLet.cs | 5 +- .../Internal/CmdletExtensions.cs | 28 --- .../Internal/CommandLineTools.cs | 36 ++++ .../Internal/CreatePowerShellCommand.cs | 35 ---- .../Internal/ExecutePowerShellCommand.cs | 44 ---- .../Internal/ExportPowerShellCommand.cs | 44 ---- .../Internal/ISqlDatabaseProgram.cs | 4 +- .../Internal/PowerShellCommand.cs | 30 +++ .../Internal/PowerShellCommandBase.cs | 58 ------ .../Internal/SqlDatabaseProgram.cs | 11 +- .../Internal/UpgradePowerShellCommand.cs | 37 ---- .../PSTransactionMode.cs | 2 +- .../SqlDatabase.PowerShell/UpgradeCmdLet.cs | 20 +- .../UpgradeScriptSequenceTest.cs | 4 +- .../Configuration/CommandLineBaseTest.cs | 36 ---- .../Configuration/CommandLineFactoryTest.cs | 60 ------ .../Configuration/CommandLineParserTest.cs | 84 -------- .../Configuration/CreateCommandLineTest.cs | 87 -------- .../Configuration/EnvironmentBuilderMock.cs | 98 --------- .../Configuration/EnvironmentBuilderTest.cs | 3 +- .../Configuration/ExecuteCommandLineTest.cs | 97 --------- .../Configuration/ExportCommandLineTest.cs | 141 ------------- .../GenericCommandLineBuilderTest.cs | 119 ----------- .../Configuration/UpgradeCommandLineTest.cs | 93 --------- .../SqlDatabase.Test/Scripts/DatabaseTest.cs | 1 - Sources/SqlDatabase.sln | 17 +- .../SqlDatabase/Commands/CommandFactory.cs | 164 +++++++++++++++ .../Commands/DatabaseCreateCommand.cs | 3 +- .../Commands/DatabaseExecuteCommand.cs | 3 +- .../Commands/DatabaseExportCommand.cs | 4 +- .../Commands/DatabaseUpgradeCommand.cs | 4 +- Sources/SqlDatabase/Commands/EchoCommand.cs | 28 --- .../SqlDatabase/Configuration/CommandLine.cs | 20 -- .../CommandLine.upgrade.net472.txt | 2 + .../Configuration/CommandLine.upgrade.txt | 2 + .../Configuration/CommandLineBase.cs | 161 --------------- .../Configuration/CommandLineFactory.cs | 107 ---------- .../Configuration/CommandLineParser.cs | 97 --------- .../Configuration/CreateCommandLine.cs | 47 ----- .../Configuration/EchoCommandLine.cs | 16 -- .../Configuration/EnvironmentBuilder.cs | 34 +-- .../Configuration/ExecuteCommandLine.cs | 71 ------- .../Configuration/ExportCommandLine.cs | 77 ------- .../Configuration/GenericCommandLine.cs | 28 --- .../GenericCommandLineBuilder.cs | 194 ------------------ .../SqlDatabase/Configuration/ICommandLine.cs | 11 - .../Configuration/IEnvironmentBuilder.cs | 6 +- .../InvalidCommandLineException.cs | 32 --- .../Configuration/UpgradeCommandLine.cs | 73 ------- Sources/SqlDatabase/Log/LoggerFactory.cs | 20 ++ Sources/SqlDatabase/Program.cs | 128 ++++-------- Sources/SqlDatabase/Scripts/Database.cs | 4 +- Sources/SqlDatabase/Scripts/IDatabase.cs | 3 +- Sources/SqlDatabase/SqlDatabase.csproj | 1 + 91 files changed, 1391 insertions(+), 2392 deletions(-) rename Sources/{SqlDatabase/Configuration => SqlDatabase.Adapter}/TransactionMode.cs (57%) create mode 100644 Sources/SqlDatabase.CommandLine.Test/CommandLineParserTest.cs create mode 100644 Sources/SqlDatabase.CommandLine.Test/Internal/ArgTest.cs create mode 100644 Sources/SqlDatabase.CommandLine.Test/SqlDatabase.CommandLine.Test.csproj create mode 100644 Sources/SqlDatabase.CommandLine/CodeAnalysis/AllowNullAttribute.cs create mode 100644 Sources/SqlDatabase.CommandLine/CodeAnalysis/NotNullWhenAttribute.cs create mode 100644 Sources/SqlDatabase.CommandLine/CommandLineParser.cs create mode 100644 Sources/SqlDatabase.CommandLine/CreateCommandLine.cs create mode 100644 Sources/SqlDatabase.CommandLine/ExecuteCommandLine.cs create mode 100644 Sources/SqlDatabase.CommandLine/ExportCommandLine.cs create mode 100644 Sources/SqlDatabase.CommandLine/ICommandLine.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/Arg.cs rename Sources/{SqlDatabase/Configuration/Arg.cs => SqlDatabase.CommandLine/Internal/ArgNames.cs} (51%) create mode 100644 Sources/SqlDatabase.CommandLine/Internal/CommandLineBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/CommandLineBinderExtensions.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/EnumArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/IArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/ScriptSourceArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/StringArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/SwitchArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/Internal/VariableArgBinder.cs create mode 100644 Sources/SqlDatabase.CommandLine/InvalidCommandLineException.cs create mode 100644 Sources/SqlDatabase.CommandLine/Properties/AssemblyInfo.cs create mode 100644 Sources/SqlDatabase.CommandLine/ScriptSource.cs create mode 100644 Sources/SqlDatabase.CommandLine/SqlDatabase.CommandLine.csproj create mode 100644 Sources/SqlDatabase.CommandLine/UpgradeCommandLine.cs delete mode 100644 Sources/SqlDatabase.Configuration/IConfigurationManager.cs delete mode 100644 Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs create mode 100644 Sources/SqlDatabase.PowerShell/Internal/CommandLineTools.cs delete mode 100644 Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs delete mode 100644 Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs delete mode 100644 Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs create mode 100644 Sources/SqlDatabase.PowerShell/Internal/PowerShellCommand.cs delete mode 100644 Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs delete mode 100644 Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs delete mode 100644 Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs create mode 100644 Sources/SqlDatabase/Commands/CommandFactory.cs delete mode 100644 Sources/SqlDatabase/Commands/EchoCommand.cs delete mode 100644 Sources/SqlDatabase/Configuration/CommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/CommandLineBase.cs delete mode 100644 Sources/SqlDatabase/Configuration/CommandLineFactory.cs delete mode 100644 Sources/SqlDatabase/Configuration/CommandLineParser.cs delete mode 100644 Sources/SqlDatabase/Configuration/CreateCommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/EchoCommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/ExportCommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/GenericCommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs delete mode 100644 Sources/SqlDatabase/Configuration/ICommandLine.cs delete mode 100644 Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs delete mode 100644 Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs diff --git a/.gitignore b/.gitignore index bcf5aa93..bb33e3d1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bin/ build.out/ launchSettings.json +launchSettings.txt *.sln.DotSettings.user *.csproj.user 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/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.PowerShell.Test/CreateCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs index 5e1819dd..bf33a6a7 100644 --- a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs @@ -1,6 +1,6 @@ using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -26,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] @@ -63,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 4333c7c1..14722577 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -20,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)); @@ -28,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] @@ -68,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 ae845021..0f918959 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs @@ -1,6 +1,6 @@ using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -26,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/Internal/PowerShellCommandBaseTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs deleted file mode 100644 index 229af099..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); - - Assert.That(command.ConfigurationFile, Does.Exist.IgnoreDirectories); - } -} \ 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 e0c7356a..7624da95 100644 --- a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs @@ -5,7 +5,7 @@ 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; @@ -14,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!; @@ -36,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) { @@ -65,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 9459c3bb..2b1048dd 100644 --- a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using Shouldly; -using SqlDatabase.Configuration; +using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; using SqlDatabase.PowerShell.TestApi; namespace SqlDatabase.PowerShell; @@ -19,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)); @@ -28,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] @@ -68,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 2087c5f9..7c675884 100644 --- a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs @@ -20,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); @@ -34,9 +33,9 @@ private void WriteInfo() 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/CmdletExtensions.cs b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs index 6eee7e78..311472b5 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs @@ -1,5 +1,4 @@ using System.Management.Automation; -using SqlDatabase.Configuration; namespace SqlDatabase.PowerShell.Internal; @@ -16,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"); @@ -38,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/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/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/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 f8317c75..00000000 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs +++ /dev/null @@ -1,58 +0,0 @@ -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/SqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs index 74c11152..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, true, 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/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/UpgradeScriptSequenceTest.cs b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs index 7ee9c977..930b9e45 100644 --- a/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Sequence.Test/UpgradeScriptSequenceTest.cs @@ -69,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)); } @@ -176,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.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 40094242..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs +++ /dev/null @@ -1,60 +0,0 @@ -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 85ef3975..00000000 --- a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs +++ /dev/null @@ -1,87 +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, - Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) - }; - } - - [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("usePowerShell", @"c:\PowerShell"), - new Arg("whatIf"))); - - _sut.Scripts.ShouldBe([folder.Object]); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - - _sut.Variables.Keys.ShouldBe(["X", "Y"]); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); - _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 86267df6..00000000 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderMock.cs +++ /dev/null @@ -1,98 +0,0 @@ -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 5afa8dfd..ed227067 100644 --- a/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/EnvironmentBuilderTest.cs @@ -2,6 +2,7 @@ using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; +using SqlDatabase.FileSystem; using SqlDatabase.Scripts; namespace SqlDatabase.Configuration; @@ -19,7 +20,7 @@ public void BeforeEachTest() _log = new Mock(MockBehavior.Strict); _configuration = new AppConfiguration(); - _sut = new EnvironmentBuilder(HostedRuntimeResolver.GetRuntime(false)); + _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 1bc404e7..00000000 --- a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs +++ /dev/null @@ -1,97 +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, - Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) - }; - } - - [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"), - new Arg("usePowerShell", @"c:\PowerShell"), - 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(["X", "Y"]); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - _sut.Transaction.ShouldBe(TransactionMode.PerStep); - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); - _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 dc65de2b..00000000 --- a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs +++ /dev/null @@ -1,141 +0,0 @@ -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"); - } - - Assert.That(file.Location, Does.Exist.IgnoreDirectories); - 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/UpgradeCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs deleted file mode 100644 index 95c6e05b..00000000 --- a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs +++ /dev/null @@ -1,93 +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, - Runtime = new HostedRuntime(false, true, FrameworkVersion.Net8) - }; - } - - [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"), - new Arg("usePowerShell", @"c:\PowerShell"), - new Arg("whatIf"))); - - _sut.Scripts.ShouldBe([folder.Object]); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - - _sut.Variables.Keys.ShouldBe(["X", "Y"]); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); - - _sut.ConfigurationFile.ShouldBe("app.config"); - _sut.Transaction.ShouldBe(TransactionMode.PerStep); - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); - _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/Scripts/DatabaseTest.cs b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs index 4a7ed1f0..50b61b0c 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs @@ -3,7 +3,6 @@ using NUnit.Framework; using Shouldly; using SqlDatabase.Adapter; -using SqlDatabase.Configuration; using SqlDatabase.TestApi; namespace SqlDatabase.Scripts; 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 95f5f013..a0fc5910 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -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 e407f871..ff2869f3 100644 --- a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -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 64f31618..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLine.cs +++ /dev/null @@ -1,20 +0,0 @@ -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..2161f4e5 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: TODO + -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..e1a874ee 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: TODO + -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 972295f1..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineBase.cs +++ /dev/null @@ -1,161 +0,0 @@ -using SqlDatabase.Adapter; -using SqlDatabase.Commands; -using SqlDatabase.FileSystem; - -namespace SqlDatabase.Configuration; - -internal abstract class CommandLineBase : ICommandLine -{ - public HostedRuntime Runtime { get; set; } - - 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 83d125ee..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs +++ /dev/null @@ -1,107 +0,0 @@ -using SqlDatabase.Adapter; - -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 HostedRuntime Runtime { 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); - if (command != null) - { - if (command is CommandLineBase supportRuntime) - { - supportRuntime.Runtime = Runtime; - } - - 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 a495a627..00000000 --- a/Sources/SqlDatabase/Configuration/CommandLineParser.cs +++ /dev/null @@ -1,97 +0,0 @@ -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 d8c496a6..00000000 --- a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs +++ /dev/null @@ -1,47 +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(Runtime)); - - 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 (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } - - 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 e7dc0050..e9b1cc1d 100644 --- a/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/EnvironmentBuilder.cs @@ -2,15 +2,16 @@ 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; @@ -23,17 +24,16 @@ internal sealed class EnvironmentBuilder : IEnvironmentBuilder private ScriptResolver? _scriptResolver; private IDatabase? _database; - public EnvironmentBuilder(HostedRuntime runtime) + public EnvironmentBuilder(HostedRuntime runtime, IFileSystemFactory fileSystem) { _runtime = runtime; + _fileSystem = fileSystem; } public IEnvironmentBuilder WithConfiguration(string? configurationFile) { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(configurationFile); - - return WithConfiguration(configuration.SqlDatabase); + var configuration = new ConfigurationManager(_fileSystem).LoadFrom(configurationFile); + return WithConfiguration(configuration); } public IEnvironmentBuilder WithLogger(ILogger logger) @@ -90,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) { @@ -130,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 3f313225..00000000 --- a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs +++ /dev/null @@ -1,71 +0,0 @@ -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(Runtime)); - - 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 (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } - - 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 29d3a464..00000000 --- a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs +++ /dev/null @@ -1,77 +0,0 @@ -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(Runtime)); - - 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 84944ed4..00000000 --- a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs +++ /dev/null @@ -1,28 +0,0 @@ -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 8d665fdc..00000000 --- a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -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/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 9059ae92..51c3d283 100644 --- a/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs +++ b/Sources/SqlDatabase/Configuration/IEnvironmentBuilder.cs @@ -1,7 +1,5 @@ using SqlDatabase.Adapter; -using SqlDatabase.FileSystem; using SqlDatabase.Scripts; -using SqlDatabase.Sequence; namespace SqlDatabase.Configuration; @@ -23,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 8cc7f5a2..00000000 --- a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs +++ /dev/null @@ -1,32 +0,0 @@ -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 dc7c65d2..00000000 --- a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs +++ /dev/null @@ -1,73 +0,0 @@ -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(Runtime)); - - 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 (Runtime.SupportUsePowerShell() && Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } - - 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/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 17193d2a..e721e793 100644 --- a/Sources/SqlDatabase/Program.cs +++ b/Sources/SqlDatabase/Program.cs @@ -1,5 +1,8 @@ using SqlDatabase.Adapter; +using SqlDatabase.CommandLine; +using SqlDatabase.Commands; using SqlDatabase.Configuration; +using SqlDatabase.FileSystem; using SqlDatabase.Log; namespace SqlDatabase; @@ -9,132 +12,73 @@ internal static class Program public static int Main(string[] args) { var logger = LoggerFactory.CreateDefault(); - return Run(logger, false, args); - } - - internal static int Run(ILogger logger, bool isPowershell, string[] args) - { - if (!TryWrapWithUsersLogger(logger, args, out var userLogger)) - { - return ExitCode.InvalidCommandLine; - } try { - return MainCore(userLogger ?? logger, isPowershell, args); - } - finally - { - userLogger?.Dispose(); - } - } + var runtime = HostedRuntimeResolver.GetRuntime(false); - private static int MainCore(ILogger logger, bool isPowershell, string[] args) - { - var runtime = HostedRuntimeResolver.GetRuntime(isPowershell); - var factory = ResolveFactory(runtime, 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(runtime, 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; + logger.Error("Something went wrong.", ex); + return ExitCode.ExecutionErrors; } - } - - private static ICommandLine? ResolveCommandLine(CommandLineFactory factory, ILogger logger) - { - try - { - return factory.Resolve(); - } - catch (Exception ex) + finally { - logger.Error("Invalid command line.", ex); + (logger as IDisposable)?.Dispose(); } - return null; + return ExitCode.Ok; } - private static CommandLineFactory? ResolveFactory(HostedRuntime runtime, 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, Runtime = runtime }; - 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 bool TryWrapWithUsersLogger(ILogger logger, string[] args, out CombinedLogger? combined) + private static void MainCore(ILogger logger, HostedRuntime runtime, ICommandLine commandLine, string currentDirectory) { - combined = null; - var fileName = CommandLineParser.GetLogFileName(args); - if (string.IsNullOrEmpty(fileName)) - { - return true; - } - - ILogger fileLogger; - try - { - fileLogger = new FileLogger(fileName!); - } - catch (Exception ex) - { - logger.Error("Fail to create file log.", ex); - return false; - } - - combined = new CombinedLogger(logger, false, fileLogger, true); - return true; + var fileSystem = new FileSystemFactory(currentDirectory); + var factory = new CommandFactory(logger, new EnvironmentBuilder(runtime, fileSystem), fileSystem); + var command = factory.CreateCommand(commandLine); + command.Execute(); } - private static string GetHelpFileName(HostedRuntime runtime, string commandName) + private static string GetHelpFileName(HostedRuntime runtime, string? commandName) { if (runtime.IsPowershell) { throw new NotSupportedException(); } + if (commandName == null) + { + return "CommandLine.txt"; + } + var suffix = runtime.Version == FrameworkVersion.Net472 ? ".net472" : null; return "CommandLine." + commandName + suffix + ".txt"; } diff --git a/Sources/SqlDatabase/Scripts/Database.cs b/Sources/SqlDatabase/Scripts/Database.cs index 9130b94e..0bc782fe 100644 --- a/Sources/SqlDatabase/Scripts/Database.cs +++ b/Sources/SqlDatabase/Scripts/Database.cs @@ -1,8 +1,6 @@ -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/IDatabase.cs b/Sources/SqlDatabase/Scripts/IDatabase.cs index 1e97178f..a095a637 100644 --- a/Sources/SqlDatabase/Scripts/IDatabase.cs +++ b/Sources/SqlDatabase/Scripts/IDatabase.cs @@ -1,5 +1,4 @@ -using System.Data; -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 @@ + From e6d8b232d2e4b54be5b41d6056865927984b0667 Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sat, 13 Apr 2024 13:01:30 +0200 Subject: [PATCH 26/27] fix typo --- Sources/SqlDatabase.Package/choco/sqldatabase.nuspec | 2 +- Sources/SqlDatabase.Package/nuget/package.nuspec | 2 +- .../SqlDatabase/Configuration/CommandLine.upgrade.net472.txt | 2 +- Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 ac19e808..ba320900 100644 --- a/Sources/SqlDatabase.Package/nuget/package.nuspec +++ b/Sources/SqlDatabase.Package/nuget/package.nuspec @@ -15,7 +15,7 @@ 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/tag/$Version$ (C) 2018-2024 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 + 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/Configuration/CommandLine.upgrade.net472.txt b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt index 2161f4e5..d2f6c449 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt +++ b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.net472.txt @@ -11,7 +11,7 @@ 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: TODO + -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 e1a874ee..30e1dece 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt +++ b/Sources/SqlDatabase/Configuration/CommandLine.upgrade.txt @@ -11,7 +11,7 @@ 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: TODO + -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 From 46cca196642bf2c6536af1ecda7c694f265335bf Mon Sep 17 00:00:00 2001 From: max-ieremenko Date: Sat, 13 Apr 2024 13:02:07 +0200 Subject: [PATCH 27/27] add pwsh rlease history link --- Examples/PowerShellScript/readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/PowerShellScript/readme.md b/Examples/PowerShellScript/readme.md index 5acb9e84..65c29b27 100644 --- a/Examples/PowerShellScript/readme.md +++ b/Examples/PowerShellScript/readme.md @@ -77,6 +77,8 @@ Pre-installed Powershell Core is required, will be used by SqlDatabase as extern * 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