From bd889ab9c9cf5d9489dd58255078a96b1adcd906 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 16 Dec 2020 23:04:01 -0800 Subject: [PATCH] Microsoft.Data.Sqlite: Target .NET Standard 2.0 again --- .../Microsoft.Data.Sqlite.Core.csproj | 2 +- .../SqliteTransaction.cs | 14 ++++++++++++++ .../SqliteValueReader.cs | 2 +- .../Utilities/AllowNullAttribute.cs | 14 ++++++++++++++ .../Microsoft.Data.Sqlite.csproj | 2 +- .../lib/{net5.0 => netstandard2.0}/_._ | 0 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/Microsoft.Data.Sqlite.Core/Utilities/AllowNullAttribute.cs rename src/Microsoft.Data.Sqlite/lib/{net5.0 => netstandard2.0}/_._ (100%) diff --git a/src/Microsoft.Data.Sqlite.Core/Microsoft.Data.Sqlite.Core.csproj b/src/Microsoft.Data.Sqlite.Core/Microsoft.Data.Sqlite.Core.csproj index bfd776ea36a..5335d9fe47e 100644 --- a/src/Microsoft.Data.Sqlite.Core/Microsoft.Data.Sqlite.Core.csproj +++ b/src/Microsoft.Data.Sqlite.Core/Microsoft.Data.Sqlite.Core.csproj @@ -15,7 +15,7 @@ Microsoft.Data.Sqlite.SqliteException Microsoft.Data.Sqlite.SqliteFactory Microsoft.Data.Sqlite.SqliteParameter Microsoft.Data.Sqlite.SqliteTransaction - net5.0 + netstandard2.0;net5.0 3.6 true Microsoft.Data.Sqlite.Core.ruleset diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteTransaction.cs b/src/Microsoft.Data.Sqlite.Core/SqliteTransaction.cs index 30e8a9a0acc..18b6da744bc 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteTransaction.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteTransaction.cs @@ -114,15 +114,21 @@ public override void Rollback() RollbackInternal(); } +#if NET /// public override bool SupportsSavepoints => true; +#endif /// /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint was /// established to be rolled back, restoring the transaction state to what it was at the time of the savepoint. /// /// The name of the savepoint to be created. +#if NET public override void Save(string savepointName) +#else + public virtual void Save(string savepointName) +#endif { if (savepointName is null) { @@ -146,7 +152,11 @@ public override void Save(string savepointName) /// Rolls back all commands that were executed after the specified savepoint was established. /// /// The name of the savepoint to roll back to. +#if NET public override void Rollback(string savepointName) +#else + public virtual void Rollback(string savepointName) +#endif { if (savepointName is null) { @@ -171,7 +181,11 @@ public override void Rollback(string savepointName) /// reclaim some resources before the transaction ends. /// /// The name of the savepoint to release. +#if NET public override void Release(string savepointName) +#else + public virtual void Release(string savepointName) +#endif { if (savepointName is null) { diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteValueReader.cs b/src/Microsoft.Data.Sqlite.Core/SqliteValueReader.cs index 5a6e8d622a6..efaacfe4b95 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteValueReader.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteValueReader.cs @@ -240,7 +240,7 @@ public virtual string GetString(int ordinal) return (T)(object)checked((ushort)GetInt64(ordinal)); } - return (T)GetValue(ordinal); + return (T)GetValue(ordinal)!; } public virtual object? GetValue(int ordinal) diff --git a/src/Microsoft.Data.Sqlite.Core/Utilities/AllowNullAttribute.cs b/src/Microsoft.Data.Sqlite.Core/Utilities/AllowNullAttribute.cs new file mode 100644 index 00000000000..b225defeee1 --- /dev/null +++ b/src/Microsoft.Data.Sqlite.Core/Utilities/AllowNullAttribute.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#if !NET + +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] + internal sealed class AllowNullAttribute : Attribute + { + } +} + +#endif diff --git a/src/Microsoft.Data.Sqlite/Microsoft.Data.Sqlite.csproj b/src/Microsoft.Data.Sqlite/Microsoft.Data.Sqlite.csproj index eda1254a068..9ce620f8e70 100644 --- a/src/Microsoft.Data.Sqlite/Microsoft.Data.Sqlite.csproj +++ b/src/Microsoft.Data.Sqlite/Microsoft.Data.Sqlite.csproj @@ -15,7 +15,7 @@ Microsoft.Data.Sqlite.SqliteFactory Microsoft.Data.Sqlite.SqliteParameter Microsoft.Data.Sqlite.SqliteTransaction false - net5.0 + netstandard2.0 3.6 SQLite;Data;ADO.NET false diff --git a/src/Microsoft.Data.Sqlite/lib/net5.0/_._ b/src/Microsoft.Data.Sqlite/lib/netstandard2.0/_._ similarity index 100% rename from src/Microsoft.Data.Sqlite/lib/net5.0/_._ rename to src/Microsoft.Data.Sqlite/lib/netstandard2.0/_._