From f89136ee33187a7c010cc7f9b3ec48f7e5373a92 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Sat, 5 Dec 2026 10:33:14 -0800 Subject: [PATCH] Take Source/SqlClient out of the build: the System.Data.SqlClient package has no version 11 The package stays out of version 11 (not packable, never published for it), so the solution, Core's InternalsVisibleTo and the Core.Tests project reference no longer carry it. Its code stays in Source/SqlClient for reference, with a short README that says so and points to Open.Database.Extensions.MSSqlClient. Tests: the cases that exercised only the System.Data.SqlClient package are dropped; each has a twin on the Microsoft.Data.SqlClient package (MSSqlClient) that stays. The parameter-binding compile tests no longer filter the legacy assembly out. Release notes and the version 11 article say the last release, 10.3.0, works with Core 10.x only. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/tests.yml | 2 +- Open.Database.Extensions.sln | 14 ----- .../Core/Open.Database.Extensions.Core.csproj | 1 - Source/SqlClient/README.md | 34 +---------- .../AddParamIfConditionTests.cs | 21 ------- .../CaptureLibraryCommandTests.cs | 15 +---- .../NameCacheSourceTests.cs | 58 ------------------- ...Open.Database.Extensions.Core.Tests.csproj | 1 - .../ParameterBindingMatrixTests.cs | 12 +--- .../ParameterByteZeroCompileTests.cs | 10 ---- .../RowMapTests.cs | 2 +- .../SingleResultBeforeMapTests.cs | 7 --- .../SqlServerParameterTypeTests.cs | 21 ++----- docsite/api/index.md | 2 - docsite/articles/release-notes.md | 2 + docsite/articles/whats-new-11.md | 2 +- 16 files changed, 17 insertions(+), 187 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ba2e79e6..01fda1f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -278,7 +278,7 @@ jobs: - name: dotnet format style and analyzers (any finding fails the run) run: | $projects = @( - 'Source\Core', 'Source\SqlClient', 'Source\MSSqlClient', 'Source\Channel', 'Source\Dataflow', 'Source\Extensions', + 'Source\Core', 'Source\MSSqlClient', 'Source\Channel', 'Source\Dataflow', 'Source\Extensions', 'Tests\Open.Database.Extensions.Core.Tests', 'Tests\Open.Database.Extensions.LegacyCompiler.Tests', 'docsite\samples', 'Benchmarks\Open.Database.Extensions.Benchmarks', 'Source\Generator', 'Tests\Open.Database.Extensions.Generator.Models', 'Tests\Open.Database.Extensions.Generator.Tests', 'Benchmarks\Open.Database.Extensions.Benchmarks.Generated') $failures = @() diff --git a/Open.Database.Extensions.sln b/Open.Database.Extensions.sln index 8396ec98..319608f3 100644 --- a/Open.Database.Extensions.sln +++ b/Open.Database.Extensions.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Database.Extensions.Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Database.Extensions.Dataflow", "Source\Dataflow\Open.Database.Extensions.Dataflow.csproj", "{862710B0-C5B4-458D-803E-AD79F70DDEF1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Database.Extensions.SqlClient", "Source\SqlClient\Open.Database.Extensions.SqlClient.csproj", "{F2402B6B-652B-479F-8F7E-885ED175D584}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Database.Extensions.Channel", "Source\Channel\Open.Database.Extensions.Channel.csproj", "{EE37225F-0B2B-4225-B07D-2BCE007B780C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Database.Extensions.Core.Tests", "Tests\Open.Database.Extensions.Core.Tests\Open.Database.Extensions.Core.Tests.csproj", "{B2C2E89F-3B08-4CF8-B363-468C0918F867}" @@ -68,18 +66,6 @@ Global {862710B0-C5B4-458D-803E-AD79F70DDEF1}.Release|x64.Build.0 = Release|Any CPU {862710B0-C5B4-458D-803E-AD79F70DDEF1}.Release|x86.ActiveCfg = Release|Any CPU {862710B0-C5B4-458D-803E-AD79F70DDEF1}.Release|x86.Build.0 = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|x64.ActiveCfg = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|x64.Build.0 = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|x86.ActiveCfg = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Debug|x86.Build.0 = Debug|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|Any CPU.Build.0 = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|x64.ActiveCfg = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|x64.Build.0 = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|x86.ActiveCfg = Release|Any CPU - {F2402B6B-652B-479F-8F7E-885ED175D584}.Release|x86.Build.0 = Release|Any CPU {EE37225F-0B2B-4225-B07D-2BCE007B780C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE37225F-0B2B-4225-B07D-2BCE007B780C}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE37225F-0B2B-4225-B07D-2BCE007B780C}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Source/Core/Open.Database.Extensions.Core.csproj b/Source/Core/Open.Database.Extensions.Core.csproj index 629f2b2a..9d837a28 100644 --- a/Source/Core/Open.Database.Extensions.Core.csproj +++ b/Source/Core/Open.Database.Extensions.Core.csproj @@ -35,7 +35,6 @@ - diff --git a/Source/SqlClient/README.md b/Source/SqlClient/README.md index 774135e6..637f1594 100644 --- a/Source/SqlClient/README.md +++ b/Source/SqlClient/README.md @@ -1,35 +1,7 @@ # Open.Database.Extensions.SqlClient -[![Open.Database.Extensions.SqlClient: You write the SQL. ODX writes the other twenty lines.](https://raw.githubusercontent.com/Open-NET-Libraries/Open.Database.Extensions/master/docsite/images/hero-sqlclient.svg)](https://open-net-libraries.github.io/Open.Database.Extensions/) +This package is not built and not published for version 11. Its last release is 10.3.0, which works with Core 10.x only. -**Not published for version 11.** Use [Open.Database.Extensions.MSSqlClient](https://www.nuget.org/packages/Open.Database.Extensions.MSSqlClient/), which uses `Microsoft.Data.SqlClient` and has the same API. It includes [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Database.Extensions.Core/). +For SQL Server, use [Open.Database.Extensions.MSSqlClient](https://www.nuget.org/packages/Open.Database.Extensions.MSSqlClient/). It is built on `Microsoft.Data.SqlClient`, has the same API, and includes [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Database.Extensions.Core/). -```cs -using Open.Database.Extensions; - -public record Post(int Id, string Title); - -// Create the factory once per application. -// connectionString is yours. System.Data.SqlClient comes with this package. -var connectionFactory = new SqlConnectionFactory(connectionString); -int author = 42; - -Post[] posts = await connectionFactory - .Command("select * from posts where author = @author") - .AddParam(author) // name and type inferred from the variable - .Map() - .ToArrayAsync(); -``` - -It is used the same way as MSSqlClient: `Command(...)`, `StoredProcedure(...)`, `AddParam(...)` and `Map()`. The [MSSqlClient README](https://www.nuget.org/packages/Open.Database.Extensions.MSSqlClient/) has the stored-procedure examples, including parameter names taken from the argument. - -## The packages - -| Package | What it adds | Targets | -|---|---|---| -| [Open.Database.Extensions.Core](https://www.nuget.org/packages/Open.Database.Extensions.Core/) | The foundation, expressive commands and `Map()`. Provider-agnostic: start here. | netstandard2.0, netstandard2.1, net10.0, net11.0 | -| [Open.Database.Extensions.MSSqlClient](https://www.nuget.org/packages/Open.Database.Extensions.MSSqlClient/) | `SqlConnectionFactory` and stored procedures on `Microsoft.Data.SqlClient`. | net472, net10.0, net11.0 | -| [Open.Database.Extensions.Channel](https://www.nuget.org/packages/Open.Database.Extensions.Channel/) | Rows into `System.Threading.Channels`. | netstandard2.0, netstandard2.1, net10.0, net11.0 | -| [Open.Database.Extensions.Dataflow](https://www.nuget.org/packages/Open.Database.Extensions.Dataflow/) | Rows into TPL Dataflow blocks. | netstandard2.0, netstandard2.1, net10.0, net11.0 | - -[Documentation](https://open-net-libraries.github.io/Open.Database.Extensions/) · [API reference](https://open-net-libraries.github.io/Open.Database.Extensions/api/index.html) · [Source and issues](https://github.com/Open-NET-Libraries/Open.Database.Extensions) · MIT license +The code of this folder stays in the repository for reference. It is not part of the solution, and nothing in it is maintained. diff --git a/Tests/Open.Database.Extensions.Core.Tests/AddParamIfConditionTests.cs b/Tests/Open.Database.Extensions.Core.Tests/AddParamIfConditionTests.cs index b7e076ec..1a7236f6 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/AddParamIfConditionTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/AddParamIfConditionTests.cs @@ -16,11 +16,6 @@ static ExpressiveCommand Classic() static ExpressiveDbCommand Db() => new ConnectionProbe(ConnectionState.Open, dbConnection: true).Db!.Command("select 1"); -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - static ExpressiveSqlCommand Legacy() - => new(new System.Data.SqlClient.SqlConnection(), CommandType.Text, "select 1"); -#pragma warning restore CS0618 - static mssql::Open.Database.Extensions.ExpressiveSqlCommand Microsoft() => new(new Microsoft.Data.SqlClient.SqlConnection(), CommandType.Text, "select 1"); @@ -31,18 +26,15 @@ public static void FalseCondition_AddsNothing_AndNeverLooksAtTheArgument() { var classic = Classic(); var db = Db(); - var legacy = Legacy(); var microsoft = Microsoft(); // The literal 1 has no derivable name: a true condition would throw (see the next test). Assert.Same(classic, classic.AddParamIf(false, 1)); Assert.Same(db, db.AddParamIf(false, 1)); - Assert.Same(legacy, legacy.AddParamIf(false, 1)); Assert.Same(microsoft, microsoft.AddParamIf(false, 1)); AssertNone(classic.Params); AssertNone(db.Params); - AssertNone(legacy.Params); AssertNone(microsoft.Params); } @@ -51,18 +43,15 @@ public static void FalseCondition_WithAnArgumentTheCompilerDidNotSupply_AddsNoth { var classic = Classic(); var db = Db(); - var legacy = Legacy(); var microsoft = Microsoft(); // A compiler before C# 10 passes no text; with a false condition that is no error either. classic.AddParamIf(false, value: 1, expression: null); db.AddParamIf(false, value: 1, expression: null); - legacy.AddParamIf(false, value: 1, expression: null); microsoft.AddParamIf(false, value: 1, expression: null); AssertNone(classic.Params); AssertNone(db.Params); - AssertNone(legacy.Params); AssertNone(microsoft.Params); } @@ -71,7 +60,6 @@ public static void TrueCondition_WithAnArgumentThatHasNoName_Throws_AndAddsNothi { var classic = Classic(); var db = Db(); - var legacy = Legacy(); var microsoft = Microsoft(); static void Throws(Action add) @@ -83,13 +71,11 @@ static void Throws(Action add) Throws(() => classic.AddParamIf(true, 1)); Throws(() => db.AddParamIf(true, 1)); - Throws(() => legacy.AddParamIf(true, 1)); Throws(() => microsoft.AddParamIf(true, 1)); Throws(() => classic.AddParamIf(true, value: 1, expression: null)); AssertNone(classic.Params); AssertNone(db.Params); - AssertNone(legacy.Params); AssertNone(microsoft.Params); } @@ -99,21 +85,17 @@ public static void TrueCondition_WithADerivableArgument_AddsTheParameter_UnderTh const int author = 42; var classic = Classic(); var db = Db(); - var legacy = Legacy(); var microsoft = Microsoft(); classic.AddParamIf(true, author); db.AddParamIf(true, author); - legacy.AddParamIf(true, author); microsoft.AddParamIf(true, author); Assert.Equal("author", Assert.Single(classic.Params).Name); Assert.Equal("author", Assert.Single(db.Params).Name); - Assert.Equal("author", Assert.Single(legacy.Params).Name); Assert.Equal("author", Assert.Single(microsoft.Params).Name); Assert.Equal(42, classic.Params[0].Value); Assert.Equal(42, db.Params[0].Value); - Assert.Equal(42, legacy.Params[0].Value); Assert.Equal(42, microsoft.Params[0].Value); } @@ -123,17 +105,14 @@ public static void FalseCondition_WithADerivableArgument_AddsNothing() const int author = 42; var classic = Classic(); var db = Db(); - var legacy = Legacy(); var microsoft = Microsoft(); classic.AddParamIf(false, author); db.AddParamIf(false, author); - legacy.AddParamIf(false, author); microsoft.AddParamIf(false, author); AssertNone(classic.Params); AssertNone(db.Params); - AssertNone(legacy.Params); AssertNone(microsoft.Params); } } diff --git a/Tests/Open.Database.Extensions.Core.Tests/CaptureLibraryCommandTests.cs b/Tests/Open.Database.Extensions.Core.Tests/CaptureLibraryCommandTests.cs index 55dfd84e..4e1734e8 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/CaptureLibraryCommandTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/CaptureLibraryCommandTests.cs @@ -4,8 +4,8 @@ namespace Open.Database.Extensions.Tests; -// The library's own SQL Server commands are decided without a lookup, as the -// base commands are: the exact type test is in each assembly. +// The library's own SQL Server command is decided without a lookup, as the +// base commands are: the exact type test is in its assembly. [ExcludeFromCodeCoverage] public static class CaptureLibraryCommandTests { @@ -14,13 +14,8 @@ public sealed record Row(int Id); // A query capture checks the command's type at the call, so nothing is // opened or run. [Fact] - public static void TheSqlCommands_NeedNoLookup_ForACapture() + public static void TheSqlCommand_NeedsNoLookup_ForACapture() { -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - using var legacy = new System.Data.SqlClient.SqlConnection(); - _ = new ExpressiveSqlCommand(legacy, CommandType.StoredProcedure, "p") - .Map() - .CaptureOutput(out DbCapture _, "total"); using var connection = new Microsoft.Data.SqlClient.SqlConnection(); _ = new mssql::Open.Database.Extensions.ExpressiveSqlCommand( connection, @@ -29,10 +24,6 @@ public static void TheSqlCommands_NeedNoLookup_ForACapture() .Map() .CaptureOutput(out DbCapture _, "total"); - Assert.Equal( - 0, - ReaderReplacement.LookupCount(typeof(ExpressiveSqlCommand))); -#pragma warning restore CS0618 Assert.Equal( 0, ReaderReplacement.LookupCount( diff --git a/Tests/Open.Database.Extensions.Core.Tests/NameCacheSourceTests.cs b/Tests/Open.Database.Extensions.Core.Tests/NameCacheSourceTests.cs index 9d5b1958..994e2a80 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/NameCacheSourceTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/NameCacheSourceTests.cs @@ -1,7 +1,6 @@ extern alias mssql; using Microsoft.Data.SqlClient; using System.Data.Common; -using LegacyCommand = global::Open.Database.Extensions.ExpressiveSqlCommand; using MsCommand = mssql::Open.Database.Extensions.ExpressiveSqlCommand; using MsExtensions = mssql::Open.Database.Extensions.SqlConnectionExtensions; @@ -130,12 +129,6 @@ static async Task RunAsync(MsCommand command) => await command.AddParam(value: 1, expression: "filter.Region") .ExecuteNonQueryAsync(Token); -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - static async Task RunAsync(LegacyCommand command) - => await command.AddParam(value: 1, expression: "filter.Region") - .ExecuteNonQueryAsync(Token); -#pragma warning restore CS0618 - static string Procedure() => ParameterNameHarness.NewProcedure(); @@ -315,25 +308,6 @@ static Func CountingMs(Trips trips) return connection; }; -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - static Func CountingLegacy(Trips trips) - => () => - { - var connection = new System.Data.SqlClient.SqlConnection(LocalDbFixture.ConnectionString) - { - StatisticsEnabled = true, - }; - connection.StateChange += (_, e) => - { - if (e.CurrentState == ConnectionState.Closed) - { - trips.Add((long)connection.RetrieveStatistics()["ServerRoundtrips"]!); - } - }; - return connection; - }; -#pragma warning restore CS0618 - [Fact] public static async Task TwoCommands_FromOneSqlServerFunction_ReadTheNamesOnce() { @@ -356,29 +330,6 @@ await RunAsync( Assert.Equal(second, third); } -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - [Fact] - public static async Task TwoCommands_FromOneLegacySqlServerFunction_ReadTheNamesOnce() - { - LocalDbFixture.SkipUnlessAvailable(); - using LocalDbFixture.Scratch procedure = LocalDbFixture.CreateProcedure("@region int"); - string name = "dbo." + procedure.Name; - var trips = new Trips(); - Func create = CountingLegacy(trips); - - await RunAsync(create.StoredProcedure(name)); - long first = trips.Take(); - await RunAsync(create.StoredProcedure(name)); - long second = trips.Take(); - await RunAsync(create.Command(name, CommandType.StoredProcedure)); - long third = trips.Take(); - - Assert.True(first > 0); - Assert.True(second < first, $"The second command paid for the names again: {first} round trips, then {second}."); - Assert.Equal(second, third); - } -#pragma warning restore CS0618 - // ---- distinct sources stay distinct (for a name without a schema) ---- [Fact] @@ -560,14 +511,5 @@ public static void ANullFunction_IsRefused_BySqlServerExtensions() { Assert.Equal("ArgumentNullException:factory", Refusal(() => MsExtensions.StoredProcedure((Func)null!, "proc"))); Assert.Equal("ArgumentNullException:factory", Refusal(() => MsExtensions.Command((Func)null!, "proc", CommandType.StoredProcedure))); -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - Func none = null!; - Assert.Equal( - "ArgumentNullException:factory", - Refusal(() => none.StoredProcedure("proc"))); - Assert.Equal( - "ArgumentNullException:factory", - Refusal(() => none.Command("proc", CommandType.StoredProcedure))); -#pragma warning restore CS0618 } } diff --git a/Tests/Open.Database.Extensions.Core.Tests/Open.Database.Extensions.Core.Tests.csproj b/Tests/Open.Database.Extensions.Core.Tests/Open.Database.Extensions.Core.Tests.csproj index 23ab8169..22836992 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/Open.Database.Extensions.Core.Tests.csproj +++ b/Tests/Open.Database.Extensions.Core.Tests/Open.Database.Extensions.Core.Tests.csproj @@ -30,7 +30,6 @@ - diff --git a/Tests/Open.Database.Extensions.Core.Tests/ParameterBindingMatrixTests.cs b/Tests/Open.Database.Extensions.Core.Tests/ParameterBindingMatrixTests.cs index 96f9aefe..657c6418 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/ParameterBindingMatrixTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/ParameterBindingMatrixTests.cs @@ -46,21 +46,13 @@ public static TheoryData Versions return [.. paths.Select(static p => (MetadataReference)MetadataReference.CreateFromFile(p))]; }); - // The same, without the legacy System.Data.SqlClient adapter, which - // defines a type of the same name (CS0433), and with the - // Microsoft.Data.SqlClient package. + // The same, with the Microsoft.Data.SqlClient package. static readonly Lazy SqlReferences = new(static () => [ - .. References.Value.Where(static r => !IsLegacySqlClient(r)), + .. References.Value, MetadataReference.CreateFromFile(typeof(mssql::Open.Database.Extensions.ExpressiveSqlCommand).Assembly.Location), ]); - static bool IsLegacySqlClient(MetadataReference reference) - => reference is PortableExecutableReference { FilePath: { } path } - && Path.GetFileName(path).Equals( - "Open.Database.Extensions.SqlClient.dll", - StringComparison.OrdinalIgnoreCase); - // Each statement is compiled in a method with: c (ExpressiveCommand), // q (the SQL Server command, when sql is true), s (string), i (int), // l (long), t (DbType?), st (SqlDbType?). diff --git a/Tests/Open.Database.Extensions.Core.Tests/ParameterByteZeroCompileTests.cs b/Tests/Open.Database.Extensions.Core.Tests/ParameterByteZeroCompileTests.cs index f7741c58..68000507 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/ParameterByteZeroCompileTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/ParameterByteZeroCompileTests.cs @@ -18,16 +18,6 @@ public static class ParameterByteZeroCompileTests { foreach (string path in tpa.Split(Path.PathSeparator)) { - // The legacy adapter defines types of the same name as the SQL - // Server package (CS0433): only the package is referenced. - string file = Path.GetFileName(path); - if (file.Equals( - "Open.Database.Extensions.SqlClient.dll", - StringComparison.OrdinalIgnoreCase)) - { - continue; - } - paths.Add(path); } } diff --git a/Tests/Open.Database.Extensions.Core.Tests/RowMapTests.cs b/Tests/Open.Database.Extensions.Core.Tests/RowMapTests.cs index 45aa7323..f3020be2 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/RowMapTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/RowMapTests.cs @@ -421,7 +421,7 @@ public static void EveryOverrideParameterIsAMap() Assembly[] assemblies = [ typeof(RowMap<>).Assembly, typeof(ChannelDbExtensions).Assembly, typeof(DataflowExtensions).Assembly, - Assembly.Load("Open.Database.Extensions"), Assembly.Load("Open.Database.Extensions.SqlClient"), Assembly.Load("Open.Database.Extensions.MSSqlClient"), + Assembly.Load("Open.Database.Extensions"), Assembly.Load("Open.Database.Extensions.MSSqlClient"), ]; const BindingFlags all = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; MethodBase[] methods = [.. assemblies.SelectMany(a => a.GetExportedTypes()).SelectMany(t => t.GetMethods(all).Cast().Concat(t.GetConstructors(all)))]; diff --git a/Tests/Open.Database.Extensions.Core.Tests/SingleResultBeforeMapTests.cs b/Tests/Open.Database.Extensions.Core.Tests/SingleResultBeforeMapTests.cs index dafb918e..5d2cf655 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/SingleResultBeforeMapTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/SingleResultBeforeMapTests.cs @@ -732,11 +732,6 @@ static void Is(T value) [Fact] public static void TheLibrarysCommandTypes_BindToTheRightMap() { -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - using var legacyConnection = new System.Data.SqlClient.SqlConnection(); - using var legacyCommand = new System.Data.SqlClient.SqlCommand(); - var legacyExpressive = new ExpressiveSqlCommand(legacyConnection, CommandType.Text, "select 1"); -#pragma warning restore CS0618 using var connection = new Microsoft.Data.SqlClient.SqlConnection(); using var sqlCommand = new Microsoft.Data.SqlClient.SqlCommand(); var expressiveSql = new mssql::Open.Database.Extensions.ExpressiveSqlCommand(connection, CommandType.Text, "select 1"); @@ -744,7 +739,6 @@ public static void TheLibrarysCommandTypes_BindToTheRightMap() var expressiveDb = new ExpressiveDbCommand(new FakeDbConnection(), CommandType.Text, "select 1"); // The expressive commands implement IExecuteReader only. - Is(legacyExpressive.SingleResult().Map()); Is(expressiveSql.SingleResult().Map()); Is(expressive.SingleResult().Map()); Is(expressiveDb.SingleResult().Map()); @@ -752,7 +746,6 @@ public static void TheLibrarysCommandTypes_BindToTheRightMap() Is(expressiveDb.SingleResult().Map(r => r.GetInt32(0))); // Raw commands are IDbCommand only. - Is(legacyCommand.SingleResult().Map()); Is(sqlCommand.SingleResult().Map()); Is(sqlCommand.SingleResult().Map(RowMap.Default)); diff --git a/Tests/Open.Database.Extensions.Core.Tests/SqlServerParameterTypeTests.cs b/Tests/Open.Database.Extensions.Core.Tests/SqlServerParameterTypeTests.cs index 7272cc56..d187a27f 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/SqlServerParameterTypeTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/SqlServerParameterTypeTests.cs @@ -4,15 +4,10 @@ namespace Open.Database.Extensions.Tests; #nullable enable -// The SQL Server commands add no overloads of their own: a literal 0, a char, a string and a SqlDbType keep their meaning, on both packages (System.Data.SqlClient and Microsoft.Data.SqlClient, the second reached through an extern alias, as both define ExpressiveSqlCommand). +// The SQL Server commands add no overloads of their own: a literal 0, a char, a string and a SqlDbType keep their meaning, on the Microsoft.Data.SqlClient package (reached through an extern alias). [ExcludeFromCodeCoverage] public static class SqlServerParameterTypeTests { -#pragma warning disable CS0618 // System.Data.SqlClient is obsolete; it is one of the two packages under test - static ExpressiveSqlCommand Legacy() - => new(new System.Data.SqlClient.SqlConnection(), CommandType.StoredProcedure, "dbo.p"); -#pragma warning restore CS0618 - static mssql::Open.Database.Extensions.ExpressiveSqlCommand Microsoft() => new(new Microsoft.Data.SqlClient.SqlConnection(), CommandType.StoredProcedure, "dbo.p"); @@ -20,11 +15,6 @@ static string Show(object? value) => value is null ? "null" : value is DBNull ? "DBNull" : Convert.ToString(value, System.Globalization.CultureInfo.InvariantCulture)!; // What the command holds: name=value databaseType, "-" when no database type was given. -#pragma warning disable CS0618 // Obsolete in 11.0, removed in 12: kept covered until then. - static string Sent(ExpressiveSqlCommand command) - => string.Join("; ", command.Params.Select(p => $"{p.Name}={Show(p.Value)} {(p.Type.HasValue ? p.Type.Value.ToString() : "-")}")); -#pragma warning restore CS0618 - static string Sent(mssql::Open.Database.Extensions.ExpressiveSqlCommand command) => string.Join("; ", command.Params.Select(p => $"{p.Name}={Show(p.Value)} {(p.Type.HasValue ? p.Type.Value.ToString() : "-")}")); @@ -36,20 +26,17 @@ public static void AValueIsStillAValue_AboveAllALiteralZero() { int zero = 0; - Assert.Equal("@x=0 -", Sent(Legacy().AddParam("@x", 0))); Assert.Equal("@x=0 -", Sent(Microsoft().AddParam("@x", 0))); - Assert.Equal("@x=0 -", Sent(Legacy().AddParam("@x", zero))); Assert.Equal("@x=0 -", Sent(Microsoft().AddParam("@x", zero))); - Assert.Equal("@x=0 -", Sent(Legacy().AddParam("@x", 0L))); + Assert.Equal("@x=0 -", Sent(Microsoft().AddParam("@x", 0L))); Assert.Equal("@x=0 Int", Sent(Microsoft().AddParam("@x", 0, SqlDbType.Int))); - Assert.Equal("@x=0 Int", Sent(Legacy().AddParamIf(true, "@x", 0, SqlDbType.Int))); + Assert.Equal("@x=0 Int", Sent(Microsoft().AddParamIf(true, "@x", 0, SqlDbType.Int))); Assert.Equal("@x=0 -", Sent(Microsoft().AddParamIf(true, "@x", 0))); - Assert.Equal("@x=c -", Sent(Legacy().AddParam("@x", 'c'))); Assert.Equal("@x=c -", Sent(Microsoft().AddParam("@x", 'c'))); Assert.Equal("@x=a -", Sent(Microsoft().AddParam("@x", "a"))); } [Fact] public static void ASqlDbTypeIsStillASqlDbType() - => Assert.Equal("@x=5 Int", Sent(Legacy().AddParam("@x", 5, SqlDbType.Int))); + => Assert.Equal("@x=5 Int", Sent(Microsoft().AddParam("@x", 5, SqlDbType.Int))); } diff --git a/docsite/api/index.md b/docsite/api/index.md index 1d7ab91f..c8e91e95 100644 --- a/docsite/api/index.md +++ b/docsite/api/index.md @@ -9,6 +9,4 @@ The reference is generated from the code and its XML documentation on every buil | `Open.Database.Extensions.Dataflow` | Reading into TPL Dataflow blocks. | | `Open.Database.Extensions.MSSqlClient` | `SqlConnectionFactory` and SQL Server specializations on `Microsoft.Data.SqlClient`. | -`Open.Database.Extensions.SqlClient` (built on `System.Data.SqlClient`) declares the same type names as `MSSqlClient` in the same namespace, so only `MSSqlClient`, the package on `Microsoft.Data.SqlClient`, is documented here. - Start from the [namespaces](xref:Open.Database.Extensions) in the table of contents. diff --git a/docsite/articles/release-notes.md b/docsite/articles/release-notes.md index 22ec24f0..4c008b3d 100644 --- a/docsite/articles/release-notes.md +++ b/docsite/articles/release-notes.md @@ -4,6 +4,8 @@ Version 11 is `11.0.0`. For moving a 10.x codebase, read [Coming from earlier ve ## Version 11.0.0 +There is no version 11 of the `Open.Database.Extensions.SqlClient` package (`System.Data.SqlClient`): use `Open.Database.Extensions.MSSqlClient` for SQL Server. The last release of the old package, 10.3.0, works with Core 10.x only, not with Core 11. + ### Changes since rc.18 - **Changed: a return code read on a text command or a text definition no longer throws.** `ExecuteReturnAsync()` on a call of a `DbNonQuery.Text` definition, a `ReturnValue` member in `ExecuteOutputAsync()` on a text command or in `Output()` on a text definition, and `CaptureReturn` (or a captured model with a `ReturnValue` member) on a text command or a text definition threw `InvalidOperationException` ("needs a stored procedure"); they now run and give what the provider reports for a text command (SQL Server: 0, and `RETURN n` in text is a server error). A return code comes from a stored procedure called by name; from text, read it with `EXEC @r = dbo.p` and an output parameter. The command of the SQL Server package is the exception: the next item. diff --git a/docsite/articles/whats-new-11.md b/docsite/articles/whats-new-11.md index 87fdc622..d6b7c5c0 100644 --- a/docsite/articles/whats-new-11.md +++ b/docsite/articles/whats-new-11.md @@ -4,7 +4,7 @@ Version 11 is a significant break from 10.x: rebuild every consumer, because 11 Each member that is gone has a replacement that is shorter, and the old way is not kept beside it. The compiler names the member that is missing; find it here by its theme. For each change of version 11 in order, see the [release notes](release-notes.md). -Packages: use `Open.Database.Extensions.MSSqlClient` (on `Microsoft.Data.SqlClient`) for SQL Server. The `Open.Database.Extensions.SqlClient` package (on `System.Data.SqlClient`) is not published for 11; every type in it has its twin in `MSSqlClient`. Version 11 targets `net11.0` next to `net10.0`, `netstandard2.0` and `netstandard2.1` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`). +Packages: use `Open.Database.Extensions.MSSqlClient` (on `Microsoft.Data.SqlClient`) for SQL Server. The `Open.Database.Extensions.SqlClient` package (on `System.Data.SqlClient`) is not published for 11 (its last release, 10.3.0, works with Core 10.x only); every type in it has its twin in `MSSqlClient`. Version 11 targets `net11.0` next to `net10.0`, `netstandard2.0` and `netstandard2.1` (`MSSqlClient`: `net472`, `net10.0` and `net11.0`). ## `DbQuery`