Skip to content

Commit ba3ff97

Browse files
committed
chore(release): bump version to 1.5.1
1 parent 1654e10 commit ba3ff97

39 files changed

Lines changed: 836 additions & 169 deletions

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<Authors>vkuttyp</Authors>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<RepositoryUrl>https://github.com/vkuttyp/CosmoSQLClient-Dotnet</RepositoryUrl>
10-
<Version>1.5.0</Version>
10+
<Version>1.5.1</Version>
1111
</PropertyGroup>
1212
</Project>

src/CosmoSQLClient.Core/CosmoSQLClient.Core.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFrameworks>net10.0;netstandard2.0</TargetFrameworks>
55
<AssemblyName>CosmoSQLClient.Core</AssemblyName>
66
<RootNamespace>CosmoSQLClient.Core</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99

1010
<PackageId>CosmoSQLClient.Core</PackageId>
11-
<Version>1.5.0</Version>
11+
<Version>1.5.1</Version>
1212
<Authors>Veeran Puthumkara</Authors>
1313
<Description>Shared core types and interfaces for CosmoSQLClient — a unified .NET database driver for MSSQL, PostgreSQL, MySQL and SQLite using DotNetty.</Description>
1414
<PackageTags>sql;mssql;postgres;mysql;sqlite;database;driver;dotnetty;nio</PackageTags>
@@ -22,6 +22,9 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25+
<PackageReference Include="System.Text.Json" Version="10.0.0" />
26+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" />
27+
<PackageReference Include="System.Threading.Channels" Version="9.0.0" />
2528
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
2629
</ItemGroup>
2730

src/CosmoSQLClient.Core/ISqlDatabase.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,23 @@ public static System.Data.DataRow ToDataRow(this SqlRow row)
196196
/// onError: ex => MessageBox.Show(ex.Message));
197197
/// </code>
198198
/// </example>
199+
#if !NET10_0_OR_GREATER
199200
public static async Task FillDataTableAsync(
200201
this IAsyncEnumerable<SqlRow> rows,
201202
System.Data.DataTable table,
202203
int batchSize = 500,
203204
Action<int>? onProgress = null,
204205
Action<Exception>? onError = null,
205206
CancellationToken ct = default)
207+
#else
208+
public static async Task FillDataTableAsync(
209+
this IAsyncEnumerable<SqlRow> rows,
210+
System.Data.DataTable table,
211+
int batchSize = 500,
212+
Action<int>? onProgress = null,
213+
Action<Exception>? onError = null,
214+
CancellationToken ct = default)
215+
#endif
206216
{
207217
// Bounded channel: producer (background) reads network; consumer (UI thread) flushes batches.
208218
// Capacity of 4 batches provides back-pressure so we don't read infinitely ahead of the UI.
@@ -269,6 +279,33 @@ public static async Task FillDataTableAsync(
269279
await producer;
270280
}
271281

282+
#if !NET10_0_OR_GREATER
283+
private static void FlushBatch(System.Data.DataTable table, List<SqlRow> batch)
284+
{
285+
// Add column schema from first batch
286+
if (table.Columns.Count == 0)
287+
{
288+
foreach (var col in batch[0].Columns)
289+
table.Columns.Add(col.Name, typeof(object));
290+
}
291+
292+
table.BeginLoadData(); // suspend DataGridView notifications and index rebuilds
293+
try
294+
{
295+
foreach (var row in batch)
296+
{
297+
var dataRow = table.NewRow();
298+
for (int i = 0; i < row.ColumnCount; i++)
299+
dataRow[i] = row[i].ToClrObject() ?? DBNull.Value;
300+
table.Rows.Add(dataRow);
301+
}
302+
}
303+
finally
304+
{
305+
table.EndLoadData(); // one bulk notification → one DataGridView refresh
306+
}
307+
}
308+
#else
272309
private static void FlushBatch(System.Data.DataTable table, List<SqlRow> batch)
273310
{
274311
// Add column schema from first batch
@@ -294,4 +331,5 @@ private static void FlushBatch(System.Data.DataTable table, List<SqlRow> batch)
294331
table.EndLoadData(); // one bulk notification → one DataGridView refresh
295332
}
296333
}
334+
#endif
297335
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#if !NET10_0_OR_GREATER
2+
3+
namespace System.Runtime.CompilerServices
4+
{
5+
using System.ComponentModel;
6+
7+
[EditorBrowsable(EditorBrowsableState.Never)]
8+
internal static class IsExternalInit { }
9+
10+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
11+
internal sealed class RequiredMemberAttribute : Attribute { }
12+
13+
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
14+
internal sealed class CompilerFeatureRequiredAttribute : Attribute
15+
{
16+
public CompilerFeatureRequiredAttribute(string featureName) { FeatureName = featureName; }
17+
public string FeatureName { get; }
18+
public bool IsOptional { get; set; }
19+
public const string RequiredMembers = nameof(RequiredMembers);
20+
public const string RefStructs = nameof(RefStructs);
21+
}
22+
}
23+
24+
namespace System.Diagnostics.CodeAnalysis
25+
{
26+
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
27+
internal sealed class SetsRequiredMembersAttribute : Attribute { }
28+
29+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
30+
internal sealed class AllowNullAttribute : Attribute { }
31+
32+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
33+
internal sealed class DisallowNullAttribute : Attribute { }
34+
}
35+
36+
#endif

src/CosmoSQLClient.Core/SqlDataTable.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ private static Type SqlValueClrType(SqlColumn col)
100100

101101
// Pre-resolve column index → property mapping once, reused for all rows.
102102
var map = Columns
103-
.Select((col, idx) => (idx, prop: props.GetValueOrDefault(col.Name)))
103+
.Select((col, idx) => {
104+
props.TryGetValue(col.Name, out var p);
105+
return (idx, prop: p);
106+
})
104107
.Where(x => x.prop is not null)
105108
.ToList();
106109

src/CosmoSQLClient.Core/SqlDump.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static string GenerateInserts(SqlDataTable table, string? targetTableName
3737
SqlValue.Double d => d.Value.ToString("R"),
3838
SqlValue.Decimal d => d.Value.ToString(),
3939
SqlValue.Text s => $"'{s.Value.Replace("'", "''")}'",
40-
SqlValue.Bytes b => $"0x{Convert.ToHexString(b.Value)}",
40+
SqlValue.Bytes b => $"0x{BitConverter.ToString(b.Value).Replace("-", "")}",
4141
SqlValue.Uuid u => $"'{u.Value}'",
4242
SqlValue.Date d => $"'{d.Value:O}'",
4343
_ => "NULL"

src/CosmoSQLClient.Core/SqlRowDecoder.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ private static string ToSnakeCase(string s)
6666

6767
private static string ToCamelCase(string s)
6868
{
69-
var parts = s.Split('_', StringSplitOptions.RemoveEmptyEntries);
69+
var parts = s.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
7070
if (parts.Length == 0) return s;
7171
var sb = new System.Text.StringBuilder(parts[0]);
7272
for (int i = 1; i < parts.Length; i++)
7373
if (parts[i].Length > 0)
74-
sb.Append(char.ToUpper(parts[i][0])).Append(parts[i][1..]);
74+
sb.Append(char.ToUpper(parts[i][0])).Append(parts[i].Substring(1));
7575
return sb.ToString();
7676
}
7777

@@ -86,7 +86,7 @@ private static string ToCamelCase(string s)
8686
{
8787
if (v is SqlValue.Bool b) return b.Value;
8888
if (v.AsInt() is long l) return l != 0;
89-
if (v.AsString() is string s) return s is "1" or "true" or "yes";
89+
if (v.AsString() is string s) return s == "1" || s == "true" || s == "yes";
9090
return null;
9191
}
9292
// Guid
@@ -115,8 +115,14 @@ private static string ToCamelCase(string s)
115115
{
116116
if (v.AsString() is string s)
117117
{
118-
if (Enum.TryParse(underlying, s, true, out var result))
119-
return result;
118+
try
119+
{
120+
return Enum.Parse(underlying, s, true);
121+
}
122+
catch
123+
{
124+
return null;
125+
}
120126
}
121127
if (v.AsInt() is long l)
122128
{

src/CosmoSQLClient.MsSql/CosmoSQLClient.MsSql.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
</ItemGroup>
1414

1515
<PropertyGroup>
16-
<TargetFramework>net10.0</TargetFramework>
16+
<TargetFrameworks>net10.0;netstandard2.0</TargetFrameworks>
1717
<AssemblyName>CosmoSQLClient.MsSql</AssemblyName>
1818
<RootNamespace>CosmoSQLClient.MsSql</RootNamespace>
1919
<ImplicitUsings>enable</ImplicitUsings>
2020
<Nullable>enable</Nullable>
2121

2222
<PackageId>CosmoSQLClient.MsSql</PackageId>
23-
<Version>1.5.0</Version>
23+
<Version>1.5.1</Version>
2424
<Authors>Veeran Puthumkara</Authors>
2525
<Description>Microsoft SQL Server driver for CosmoSQLClient — TDS 7.4 wire protocol from scratch using DotNetty. Supports TLS, Windows/SQL auth, stored procedures and connection pooling.</Description>
2626
<PackageTags>sql;mssql;sqlserver;tds;database;driver;dotnetty;nio</PackageTags>

src/CosmoSQLClient.MsSql/JsonChunkAssembler.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ public static async IAsyncEnumerable<JsonElement> AssembleJsonObjectsAsync(
4242
{
4343
if (string.IsNullOrEmpty(chunk)) continue;
4444

45-
// ── Encode chunk UTF-8 directly into the MemoryStream's backing array ──
46-
// Avoids the intermediate byte[] allocation from Encoding.UTF8.GetBytes(string).
47-
int byteCount = Encoding.UTF8.GetByteCount(chunk);
48-
int oldLen = (int)buf.Length;
49-
buf.SetLength(oldLen + byteCount);
50-
Encoding.UTF8.GetBytes(chunk.AsSpan(), buf.GetBuffer().AsSpan(oldLen, byteCount));
45+
// ── Encode chunk UTF-8 directly into the MemoryStream ──
46+
var bytes = Encoding.UTF8.GetBytes(chunk);
47+
buf.Write(bytes, 0, bytes.Length);
5148

5249
// Inner loop: drain as many complete elements as possible from the current buffer.
5350
bool madeProgress;

0 commit comments

Comments
 (0)