mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-18 22:31:08 +08:00
aecffecae1
* attempt NRT makeover - annotate NRTs on GridReader API - add protected access to some of the GridReader internals - switch GridReader callbacks to be more type-independent docs lib updates; deal with yellow warnings and test failures (SQL server certs and cancellation surfacing differently) fix break simplify proposed GridReader changes to protected OnBeforeGrid and OnAfterGrid[Async] Builds: Bump library versions (#1935) Tests: Upgrade dependencies for Dependabot (#1936) I'll do a pass at all of these later, but getting CVE versions out of the pipe. Resolving 4 alerts here: https://github.com/DapperLib/Dapper/security/dependabot merge and lib updates allow Identity to be constructed on-the-fly inside GridReader fix build warnings include readme rev minor - enable [SkipLocalsInit] everywhere - use NET5_0_OR_GREATER for remoting check # Conflicts: # Dapper/CommandDefinition.cs # Dapper/DefaultTypeMap.cs # Dapper/SqlMapper.Async.cs # Dapper/SqlMapper.IDataReader.cs # Dapper/SqlMapper.Link.cs # Dapper/SqlMapper.cs # Directory.Build.props * shipped, not unshipped * fixup SqlBuilder; use is null / is not null * use central package management (#1949) * Nullable test tweaks * Nuget: let's just remove it! * 2 test fixes from review * fix FindExplicitConstructor * add GetPropertySetterOrThrow * fix NRT on FindConstructor * DapperRow: value is object? * use NotNullWhen * make constructor problem more obvious * test fixes --------- Co-authored-by: Nick Craver <nrcraver@gmail.com>
101 lines
3.7 KiB
C#
101 lines
3.7 KiB
C#
using System;
|
|
using Xunit.Sdk;
|
|
|
|
namespace Dapper.Tests
|
|
{
|
|
/// <summary>
|
|
/// <para>Override for <see cref="Xunit.FactAttribute"/> that truncates our DisplayName down.</para>
|
|
/// <para>
|
|
/// Attribute that is applied to a method to indicate that it is a fact that should
|
|
/// be run by the test runner. It can also be extended to support a customized definition
|
|
/// of a test method.
|
|
/// </para>
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
[XunitTestCaseDiscoverer("Dapper.Tests.FactDiscoverer", "Dapper.Tests")]
|
|
public class FactAttribute : Xunit.FactAttribute
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>Override for <see cref="Xunit.TheoryAttribute"/> that truncates our DisplayName down.</para>
|
|
/// <para>
|
|
/// Marks a test method as being a data theory. Data theories are tests which are
|
|
/// fed various bits of data from a data source, mapping to parameters on the test
|
|
/// method. If the data source contains multiple rows, then the test method is executed
|
|
/// multiple times (once with each data row). Data is provided by attributes which
|
|
/// derive from Xunit.Sdk.DataAttribute (notably, Xunit.InlineDataAttribute and Xunit.MemberDataAttribute).
|
|
/// </para>
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
[XunitTestCaseDiscoverer("Dapper.Tests.TheoryDiscoverer", "Dapper.Tests")]
|
|
public class TheoryAttribute : Xunit.TheoryAttribute { }
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public sealed class FactLongRunningAttribute : FactAttribute
|
|
{
|
|
public FactLongRunningAttribute()
|
|
{
|
|
#if !LONG_RUNNING
|
|
Skip = "Long running";
|
|
#endif
|
|
}
|
|
|
|
public string? Url { get; private set; }
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public class FactRequiredCompatibilityLevelAttribute : FactAttribute
|
|
{
|
|
public FactRequiredCompatibilityLevelAttribute(int level) : base()
|
|
{
|
|
if (DetectedLevel < level)
|
|
{
|
|
Skip = $"Compatibility level {level} required; detected {DetectedLevel}";
|
|
}
|
|
}
|
|
|
|
public const int SqlServer2016 = 130;
|
|
public static readonly int DetectedLevel;
|
|
static FactRequiredCompatibilityLevelAttribute()
|
|
{
|
|
using var conn = DatabaseProvider<SystemSqlClientProvider>.Instance.GetOpenConnection();
|
|
try
|
|
{
|
|
DetectedLevel = conn.QuerySingle<int>("SELECT compatibility_level FROM sys.databases where name = DB_NAME()");
|
|
}
|
|
catch { /* don't care */ }
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public class FactUnlessCaseSensitiveDatabaseAttribute : FactAttribute
|
|
{
|
|
public FactUnlessCaseSensitiveDatabaseAttribute() : base()
|
|
{
|
|
if (IsCaseSensitive)
|
|
{
|
|
Skip = "Case sensitive database";
|
|
}
|
|
}
|
|
|
|
public static readonly bool IsCaseSensitive;
|
|
static FactUnlessCaseSensitiveDatabaseAttribute()
|
|
{
|
|
using var conn = DatabaseProvider<SystemSqlClientProvider>.Instance.GetOpenConnection();
|
|
try
|
|
{
|
|
conn.Execute("declare @i int; set @I = 1;");
|
|
}
|
|
catch (Exception ex) when (ex.GetType().Name == "SqlException")
|
|
{
|
|
int err = ((dynamic)ex).Number;
|
|
if (err == 137)
|
|
IsCaseSensitive = true;
|
|
else
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|