Skip to content

Commit cc1f24d

Browse files
Merge pull request #23 from Open-NET-Libraries/feature/10.1-phase1
Phase 1: TFM & compatibility foundation (10.1.0)
2 parents 64ad8c2 + 6932fb3 commit cc1f24d

8 files changed

Lines changed: 37 additions & 10 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#if !NET10_0_OR_GREATER
2+
// Polyfill for System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.
3+
// The attribute ships in-box on .NET 9+, but net10.0 is this library's modern target, so
4+
// everything below it (the netstandard shims and net472) gets this internal definition.
5+
// The C# 13+ compiler recognizes it by full metadata name and honors a source-defined copy,
6+
// decoding the priority from the attribute blob without requiring the type to be public or
7+
// from the runtime. Verified on netstandard2.0 both in-assembly (the ns2.0 compiler honors it)
8+
// and cross-assembly (a net10 consumer honors this internal attribute read from ns2.0 metadata),
9+
// with a no-attribute negative control confirming causation. This is what lets the modern span
10+
// overloads added during API modernization win overload resolution uniformly across every TFM.
11+
namespace System.Runtime.CompilerServices;
12+
13+
[AttributeUsage(
14+
AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property,
15+
AllowMultiple = false,
16+
Inherited = false)]
17+
internal sealed class OverloadResolutionPriorityAttribute(int priority) : Attribute
18+
{
19+
/// <summary>The priority of the target within its overload set.</summary>
20+
public int Priority { get; } = priority;
21+
}
22+
#endif

Source/Core/ExpressiveDbCommandBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public ValueTask<IEnumerable<T0>> FirstOrdinalResultsAsync<T0>()
217217
/// <param name="n">The first ordinal to include in the request to the reader for each record.</param>
218218
/// <param name="others">The remaining ordinals to request from the reader for each record.</param>
219219
/// <returns>The QueryResult that contains all the results and the column mappings.</returns>
220-
#if NET8_0_OR_GREATER
220+
#if NET10_0_OR_GREATER
221221
public ValueTask<QueryResultQueue<object[]>> RetrieveAsync(int n, params IEnumerable<int> others)
222222
=> RetrieveAsync(others.Prepend(n));
223223
#else
@@ -231,7 +231,7 @@ public ValueTask<QueryResultQueue<object[]>> RetrieveAsync(int n, params int[] o
231231
/// <param name="c">The first column name to include in the request to the reader for each record.</param>
232232
/// <param name="others">The remaining column names to request from the reader for each record.</param>
233233
/// <returns>The QueryResult that contains all the results and the column mappings.</returns>
234-
#if NET8_0_OR_GREATER
234+
#if NET10_0_OR_GREATER
235235
public ValueTask<QueryResultQueue<object[]>> RetrieveAsync(string c, params IEnumerable<string> others)
236236
=> RetrieveAsync(others.Prepend(c));
237237
#else

Source/Core/Extensions/DataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public static IEnumerable<object[]> AsEnumerable(this IDataReader reader, IEnume
277277
/// <param name="n">The first ordinal to include in the request to the reader for each record.</param>
278278
/// <param name="others">The remaining ordinals to request from the reader for each record.</param>
279279
/// <inheritdoc cref="AsEnumerable(IDataReader, ArrayPool{object?}, int, int[])"/>
280-
#if NET8_0_OR_GREATER
280+
#if NET10_0_OR_GREATER
281281
public static IEnumerable<object[]> AsEnumerable(this IDataReader reader, int n, params IEnumerable<int> others)
282282
=> AsEnumerableInternal(reader, others.Prepend(n), false);
283283
#else

Source/Core/Extensions/_.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ internal static IEnumerable<T> Concat<T>(T first, ICollection<T> remaining)
126126
if (values is null) throw new ArgumentNullException(nameof(values));
127127
Contract.EndContractBlock();
128128

129-
#if NET8_0_OR_GREATER
129+
#if NET10_0_OR_GREATER
130130
var span = System.Runtime.InteropServices.CollectionsMarshal.AsSpan(values);
131131
for (int i = 0; i < span.Length; i++)
132132
{
@@ -187,7 +187,7 @@ static IEnumerable<DataRow> AsEnumerableCore(DataRowCollection rows)
187187
.Results(table, clearSourceTable);
188188

189189
/// <inheritdoc cref="To{T}(DataTable, IEnumerable{KeyValuePair{string, string?}}?, bool)"/>
190-
#if NET8_0_OR_GREATER
190+
#if NET10_0_OR_GREATER
191191
public static IEnumerable<T> To<T>(this DataTable table, params IEnumerable<(string Field, string? Column)> fieldMappingOverrides) where T : new()
192192
#else
193193
public static IEnumerable<T> To<T>(this DataTable table, params (string Field, string? Column)[] fieldMappingOverrides) where T : new()

Source/Directory.Build.props

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
<PropertyGroup>
44
<RootNamespace>Open.Database.Extensions</RootNamespace>
55

6+
<!-- Stays at 10.0.1 through the phase stack; bumped to 10.1.0 only in the final release phase. -->
67
<VersionPrefix>10.0.1</VersionPrefix>
78
<VersionSuffix Condition="'$(Configuration)' == 'Debug'">debug</VersionSuffix>
8-
9-
<TargetFrameworks>netstandard2.0; netstandard2.1; net8.0; net10.0;</TargetFrameworks>
9+
10+
<!-- net10.0 is the primary/modern target. netstandard2.0/2.1 are retained as shimmed
11+
legacy paths (via #if switching + BCL compat packages). net472 lives only on the
12+
MSSqlClient adapter; .NET Framework consumers of the other packages use the
13+
netstandard2.0 build. net8/net9 consumers fall back to netstandard2.1. -->
14+
<TargetFrameworks>netstandard2.0; netstandard2.1; net10.0;</TargetFrameworks>
1015
<LangVersion>latest</LangVersion>
1116
<Nullable>enable</Nullable>
1217
<ImplicitUsings>true</ImplicitUsings>

Source/MSSqlClient/Extensions/Transaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static (bool Commit, T Value) ExecuteTransactionConditional<T>(
6060
if (connection.State != ConnectionState.Open)
6161
await connection.EnsureOpenAsync(cancellationToken);
6262

63-
#if NET8_0_OR_GREATER
63+
#if NET10_0_OR_GREATER
6464
await
6565
#endif
6666
using SqlTransaction transaction = connection.BeginTransaction(isolationLevel);

Source/MSSqlClient/Open.Database.Extensions.MSSqlClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472; net8.0; net10.0;</TargetFrameworks>
4+
<TargetFrameworks>net472; net10.0;</TargetFrameworks>
55
<Description>Useful set of utilities and abstractions for simplifying modern SQL Client data-access operations and ensuring DI compatibility.</Description>
66
<PackageTags>ado;ado extensions;sql;connection factory;extensions;</PackageTags>
77
</PropertyGroup>

Source/SqlClient/Extensions/Transaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static (bool Commit, T Value) ExecuteTransactionConditional<T>(
6060
if (connection.State != ConnectionState.Open)
6161
await connection.EnsureOpenAsync(cancellationToken);
6262

63-
#if NET8_0_OR_GREATER
63+
#if NET10_0_OR_GREATER
6464
await
6565
#endif
6666
using SqlTransaction transaction = connection.BeginTransaction(isolationLevel);

0 commit comments

Comments
 (0)