Skip to content

Commit

Permalink
Merge branch 'cincuranet:master' into fb-blob-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
la-we authored Oct 28, 2024
2 parents 19f24dc + f00a9a9 commit 39189a2
Show file tree
Hide file tree
Showing 95 changed files with 2,378 additions and 519 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: .NET 7.0
uses: actions/setup-dotnet@v3
- name: .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build
run: |
Expand Down Expand Up @@ -51,6 +51,7 @@ jobs:
shell: powershell

- name: Publish Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: 'ci_${{ matrix.TEST_SUITE }}_${{ matrix.FIREBIRD_SELECTION }}_${{ env.CONFIGURATION }}'
path: '.\\out\\'
27 changes: 19 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ $baseDir = Split-Path -Parent $PSCommandPath
. "$baseDir\include.ps1"

$outDir = "$baseDir\out"
$version = ''
$versionProvider = ''
$versionEFCore = ''
$versionEF6 = ''

function Clean() {
if (Test-Path $outDir) {
Expand All @@ -29,19 +31,28 @@ function Build() {
b 'Restore' $False
b 'Restore'
b 'Build'
$script:version = (Get-Item $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\$(Get-UsedTargetFramework)\FirebirdSql.Data.FirebirdClient.dll).VersionInfo.ProductVersion -replace '(\d+)\.(\d+)\.(\d+)(-[a-z0-9]+)?(.*)','$1.$2.$3$4'
}

function Versions() {
function v($file) {
return (Get-Item $file).VersionInfo.ProductVersion -replace '(\d+)\.(\d+)\.(\d+)(-[a-z0-9]+)?.*','$1.$2.$3$4'
}
$script:versionProvider = v $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\net8.0\FirebirdSql.Data.FirebirdClient.dll
$script:versionEFCore = v $baseDir\src\FirebirdSql.EntityFrameworkCore.Firebird\bin\$Configuration\net8.0\FirebirdSql.EntityFrameworkCore.Firebird.dll
$script:versionEF6 = v $baseDir\src\EntityFramework.Firebird\bin\$Configuration\net48\EntityFramework.Firebird.dll
}

function NuGets() {
cp $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\FirebirdSql.Data.FirebirdClient.$version.nupkg $outDir
cp $baseDir\src\EntityFramework.Firebird\bin\$Configuration\EntityFramework.Firebird.$version.nupkg $outDir
cp $baseDir\src\FirebirdSql.EntityFrameworkCore.Firebird\bin\$Configuration\FirebirdSql.EntityFrameworkCore.Firebird.$version.nupkg $outDir
cp $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\FirebirdSql.Data.FirebirdClient.$versionProvider.nupkg $outDir
cp $baseDir\src\FirebirdSql.EntityFrameworkCore.Firebird\bin\$Configuration\FirebirdSql.EntityFrameworkCore.Firebird.$versionEFCore.nupkg $outDir
cp $baseDir\src\EntityFramework.Firebird\bin\$Configuration\EntityFramework.Firebird.$versionEF6.nupkg $outDir

cp $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\FirebirdSql.Data.FirebirdClient.$version.snupkg $outDir
cp $baseDir\src\EntityFramework.Firebird\bin\$Configuration\EntityFramework.Firebird.$version.snupkg $outDir
cp $baseDir\src\FirebirdSql.EntityFrameworkCore.Firebird\bin\$Configuration\FirebirdSql.EntityFrameworkCore.Firebird.$version.snupkg $outDir
cp $baseDir\src\FirebirdSql.Data.FirebirdClient\bin\$Configuration\FirebirdSql.Data.FirebirdClient.$versionProvider.snupkg $outDir
cp $baseDir\src\FirebirdSql.EntityFrameworkCore.Firebird\bin\$Configuration\FirebirdSql.EntityFrameworkCore.Firebird.$versionEFCore.snupkg $outDir
cp $baseDir\src\EntityFramework.Firebird\bin\$Configuration\EntityFramework.Firebird.$versionEF6.snupkg $outDir
}

Clean
Build
Versions
NuGets
2 changes: 1 addition & 1 deletion docs/entity-framework-core.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Entity Framework Core 7.x
# Entity Framework Core 8.x

* Install `FirebirdSql.EntityFrameworkCore.Firebird` from NuGet.
* Create your `DbContext`.
Expand Down
4 changes: 0 additions & 4 deletions include.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ function Check-ExitCode() {
echo "Non-zero ($exitCode) exit code. Exiting..."
exit $exitCode
}
}

function Get-UsedTargetFramework() {
return 'net7.0'
}
8 changes: 5 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project>
<Import Project="Versions.props" />
<PropertyGroup>
<LangVersion>latest</LangVersion>
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>10.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Company>FirebirdSQL</Company>
<Product>NETProvider</Product>
<Authors>FirebirdSQL</Authors>
Expand All @@ -20,14 +19,17 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseFile>license.txt</PackageLicenseFile>
</PropertyGroup>
<PropertyGroup>
<CopyrightEndYear>2024</CopyrightEndYear>
</PropertyGroup>

<!-- SourceLink -->
<PropertyGroup Condition="'$(SkipSourceLink)'!='true'">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<ItemGroup Condition="'$(SkipSourceLink)'!='true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Figure out a way to run it on net4.8 (FirebirdSql.Data.TestsBase uses IAsyncDisposable) -->
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<SkipSourceLink>true</SkipSourceLink>
Expand All @@ -12,7 +11,8 @@
<OutputType>Exe</OutputType>
<StartupObject>FirebirdSql.Data.TestsBase.Program</StartupObject>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net7.0'">
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<!-- left in repo as an example/documentation for .NET Framework -->
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -22,7 +22,6 @@
<PackageReference Include="NUnitLite" Version="3.13.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FirebirdSql.Data.FirebirdClient\FirebirdSql.Data.FirebirdClient.csproj" />
<ProjectReference Include="..\EntityFramework.Firebird\EntityFramework.Firebird.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class EntityFrameworkTestsBase : FbTestsBase
static EntityFrameworkTestsBase()
{
#if !NETFRAMEWORK
// example/documentation for .NET Framework
System.Data.Common.DbProviderFactories.RegisterFactory(FbProviderServices.ProviderInvariantName, FirebirdClientFactory.Instance);
#endif
DbConfiguration.SetConfiguration(new FbTestDbContext.Conf());
Expand Down
12 changes: 8 additions & 4 deletions src/EntityFramework.Firebird/EntityFramework.Firebird.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup>
<Version>$(EF6ProviderVersion)</Version>
<AssemblyTitle>NETProvider - Entity Framework Provider</AssemblyTitle>
<Copyright>(c) 2014-2023</Copyright>
<Copyright>(c) 2014-$(CopyrightEndYear)</Copyright>
</PropertyGroup>
<PropertyGroup>
<PackageId>EntityFramework.Firebird</PackageId>
<Title>Firebird Entity Framework Provider</Title>
<PackageDescription>The Entity Framework provider for Firebird enables you to develop .NET applications that connect to the Firebird database using Entity Framework.</PackageDescription>
<PackageTags>firebird;firebirsql;firebirdclient;entityframewor;adonet;database</PackageTags>
<PackageTags>firebird firebirsql firebirdclient entityframewor adonet database</PackageTags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>EF6;TRACE</DefineConstants>
Expand Down Expand Up @@ -45,15 +46,18 @@
<None Include="..\..\firebird-logo.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="EntityFramework" Version="$(EF6ReferencePackageVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<Reference Include="System.Configuration" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(Configuration)'!='Debug'">
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="$(EF6ReferenceProviderVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Debug'">
<ProjectReference Include="..\FirebirdSql.Data.FirebirdClient\FirebirdSql.Data.FirebirdClient.csproj" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions src/FirebirdSql.Data.FirebirdClient.Tests/FbCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ public async Task NamedParametersReuseTest()
}
}

[Test]
public async Task NamedParametersPublicAccessor()
{
await using (var command = new FbCommand("select * from test where int_field >= @x1 and int_field <= @x2", Connection))
{
Assert.IsNotNull(command.NamedParameters, "Unexpected null reference.");
Assert.IsTrue(command.NamedParameters.Count == 0, "Expected count 0 of named parameters before command prepare.");

await command.PrepareAsync();

Assert.IsTrue(command.NamedParameters.Count == 2, "Expected count 2 of named parameters after command prepare.");
Assert.AreEqual(command.NamedParameters[0], "@x1");
Assert.AreEqual(command.NamedParameters[1], "@x2");
}
}

[Test]
public async Task ExecuteStoredProcTest()
{
Expand Down
49 changes: 47 additions & 2 deletions src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,49 @@ public async Task BackupRestoreTest()
await Connection.CloseAsync();
}

[Test]
public async Task BackupRestoreZipTest()
{
if (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))
return;

var backupName = $"{Guid.NewGuid()}.bak";
var csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);
var connectionString = csb.ToString();
await BackupPartHelper(backupName, connectionString, x =>
{
x.Options |= FbBackupFlags.Zip;
});
await RestorePartHelper(backupName, connectionString);
// test the database was actually restored fine
await Connection.OpenAsync();
await Connection.CloseAsync();
}

[Test]
public async Task BackupRestoreVerbIntTest()
{
if (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))
return;

var backupName = $"{Guid.NewGuid()}.bak";
var csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);
var connectionString = csb.ToString();
await BackupPartHelper(backupName, connectionString, x =>
{
x.Verbose = false;
x.VerboseInterval = 1_000_000;
});
await RestorePartHelper(backupName, connectionString, x =>
{
x.Verbose = false;
x.VerboseInterval = 1_000_000;
});
// test the database was actually restored fine
await Connection.OpenAsync();
await Connection.CloseAsync();
}

[Test]
public async Task BackupRestoreParallelTest()
{
Expand Down Expand Up @@ -453,7 +496,7 @@ public async Task NFixupTest()
Assert.DoesNotThrowAsync(() => Connection.OpenAsync());
}

static Task BackupPartHelper(string backupName, string connectionString)
static Task BackupPartHelper(string backupName, string connectionString, Action<FbBackup> configure = null)
{
var backupSvc = new FbBackup();
backupSvc.ConnectionString = connectionString;
Expand All @@ -462,9 +505,10 @@ static Task BackupPartHelper(string backupName, string connectionString)
backupSvc.Verbose = true;
backupSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;
backupSvc.ServiceOutput += ServiceOutput;
configure?.Invoke(backupSvc);
return backupSvc.ExecuteAsync();
}
static Task RestorePartHelper(string backupName, string connectionString)
static Task RestorePartHelper(string backupName, string connectionString, Action<FbRestore> configure = null)
{
var restoreSvc = new FbRestore();
restoreSvc.ConnectionString = connectionString;
Expand All @@ -474,6 +518,7 @@ static Task RestorePartHelper(string backupName, string connectionString)
restoreSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;
restoreSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048));
restoreSvc.ServiceOutput += ServiceOutput;
configure?.Invoke(restoreSvc);
return restoreSvc.ExecuteAsync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public void EqualityFalse(FbZonedDateTime expected, FbZonedDateTime actual)
Assert.AreNotEqual(expected, actual);
}

[Test]
public void ConvertToDateTimeShouldNotThrow()
{
var fbZonedDateTime = new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), "UTC");

Assert.DoesNotThrow(() => Convert.ChangeType(fbZonedDateTime, typeof(DateTime)));
}

public void DateTimeShouldBeUtc()
{
Assert.Throws<ArgumentException>(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ public void EqualityFalse(FbZonedTime expected, FbZonedTime actual)
{
Assert.AreNotEqual(expected, actual);
}

[Test]
public void ConvertToTimeSpanShouldNotThrow()
{
var fbZonedTime = new FbZonedTime(TimeSpan.FromMinutes(142), "UTC");

Assert.DoesNotThrow(() => Convert.ChangeType(fbZonedTime, typeof(TimeSpan)));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<SkipSourceLink>true</SkipSourceLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static IFbClient Create(string dllName)
{
result = BuildFbClient(dllName);
cache.Add(dllName, result);
ShutdownHelper.RegisterFbClientShutdown(() => NativeHelpers.CallIfExists(() => result.fb_shutdown(0, 0)));
ShutdownHelper.RegisterFbClientShutdown(() => NativeHelpers.CallIfExists(nameof(IFbClient.fb_shutdown), () => result.fb_shutdown(0, 0)));
return result;
}
finally
Expand Down
24 changes: 14 additions & 10 deletions src/FirebirdSql.Data.FirebirdClient/Client/Native/FesStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,13 @@ public override void Execute(int timeout, IDescriptorFiller descriptorFiller)
descriptorFiller.Fill(_parameters, 0);

ClearStatusVector();
NativeHelpers.CallIfExists(() =>
{
_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);
_database.ProcessStatusVector(_statusVector);
});
NativeHelpers.CallIfExists(
nameof(IFbClient.fb_dsql_set_timeout),
() =>
{
_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);
_database.ProcessStatusVector(_statusVector);
});

ClearStatusVector();

Expand Down Expand Up @@ -441,11 +443,13 @@ public override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller desc
await descriptorFiller.FillAsync(_parameters, 0, cancellationToken).ConfigureAwait(false);

ClearStatusVector();
NativeHelpers.CallIfExists(() =>
{
_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);
_database.ProcessStatusVector(_statusVector);
});
NativeHelpers.CallIfExists(
nameof(IFbClient.fb_dsql_set_timeout),
() =>
{
_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);
_database.ProcessStatusVector(_statusVector);
});

ClearStatusVector();

Expand Down
Loading

0 comments on commit 39189a2

Please sign in to comment.