Skip to content

Commit 5e0901f

Browse files
committed
Merge remote-tracking branch 'GH_CSharp/GenFreeWin'
2 parents e25aaf7 + 65b5b02 commit 5e0901f

91 files changed

Lines changed: 5299 additions & 191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GenFreeWin/.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Apply these defaults when working in this repository unless the user explicitly
1414
- Use BaseLib filesystem abstractions like `BaseLib.Models.Interfaces.IFile` and `BaseLib.Models.FileProxy` to avoid explicit file system dependencies, and add further interfaces/proxy classes when sensible.
1515
- Note that the `ArtifactsPath/UseArtifactsPath` migration has been rolled back for now because it is a larger separate undertaking and should not be pursued as part of the current parser work.
1616
- Avoid global usings; each file/class should declare its own usings so dependencies remain explicit.
17+
- Prefer built-in .NET database abstractions from `System.Data/System.Data.Common` (for example `DbProviderFactory`, `DbConnection`, `DbCommand`, `DbDataReader`, `IDbConnection`) over custom database interface hierarchies when making data access provider-agnostic.
1718

1819
## Testing
1920
- Use `MSTest` in the latest practical version for new or updated tests.

GenFreeWin/.info.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,72 @@
2020
- `DevOps\Tasks\T-RNZ-TRAUER-002-Move-database-access-into-repository.md`
2121
- `DevOps\Tasks\T-RNZ-TRAUER-003-Add-regression-tests-for-mapping-and-delegation.md`
2222

23+
## Domain-Neutral DB Framework Extraction Snapshot
24+
25+
- Target areas:
26+
- `GenFreeBase\Interfaces\DB`
27+
- `GenDBImplOLEDB`
28+
- Goal: extract reusable database abstractions and common infrastructure from the current `GenFree*` genealogy context into a domain-neutral database framework.
29+
- Architectural direction:
30+
- isolate provider-neutral contracts and core helpers in neutral projects
31+
- keep provider-specific facades separated by database type such as `OleDb`, `MySql`, `SqlServer`, and `dBase`
32+
- keep temporary compatibility paths for existing `GenFree*` consumers during migration
33+
- Initial findings:
34+
- several contracts are already generally reusable but still live under `GenFree` namespaces
35+
- some interfaces still depend on `GenFree.Data` and other solution-specific types
36+
- `GenDBImplOLEDB\Data.DB\MySqlStatementRenderer.cs` appears misplaced in the `OleDb` provider project
37+
- Planning artifacts:
38+
- `DevOps\Features\F-DB-FRAMEWORK-001-Extract-domain-neutral-database-framework.md`
39+
- `DevOps\BacklogItems\BI-DB-FRAMEWORK-001-Assess-and-plan-domain-neutral-db-framework-extraction.md`
40+
- `DevOps\Tasks\T-DB-FRAMEWORK-001-Inventory-current-db-abstractions-and-couplings.md`
41+
- `DevOps\Tasks\T-DB-FRAMEWORK-002-Define-target-neutral-db-project-structure.md`
42+
- `DevOps\Tasks\T-DB-FRAMEWORK-003-Plan-incremental-migration-and-compatibility-layer.md`
43+
- `DevOps\Tasks\T-DB-FRAMEWORK-004-Plan-test-strategy-for-db-framework-extraction.md`
44+
- Validation:
45+
- planning-only increment, no code build required yet
46+
- Detailed mapping artifact:
47+
- `DevOps\Tasks\T-DB-FRAMEWORK-005-Map-current-types-to-neutral-target-architecture.md`
48+
- Recommended first extraction slice:
49+
- create a neutral SQL-abstractions project first
50+
- leave legacy recordset-oriented contracts unchanged in the first increment
51+
- relocate the misplaced `MySqlStatementRenderer` out of the `OleDb` provider project
52+
- Implemented increment 1 changes:
53+
- added `DbCoreAbstractions`
54+
- added `DbProviderMySql`
55+
- added `DbProviderMySqlTests`
56+
- copied neutral SQL abstraction contracts into `DbCoreAbstractions`
57+
- moved `MySqlStatementRenderer` from `GenDBImplOLEDB` to `DbProviderMySql`
58+
- removed the misplaced renderer file from the `OleDb` project
59+
- Browser integration update:
60+
- `MSQBrowser` now references `DbCoreAbstractions` and `DbProviderMySql`
61+
- `MdbBrowser` now references `DbCoreAbstractions` and `GenDBImplOLEDB`
62+
- `MSQBrowser` no longer carries a direct `System.Data.OleDb` package reference only for schema collection naming
63+
- TFM compatibility update required by existing browser targets:
64+
- `DbCoreAbstractions` extended to `net462;net472;net481;net6.0;net7.0;net8.0;net9.0`
65+
- `DbProviderMySql` extended to `net462;net472;net481;net6.0;net7.0;net8.0;net9.0`
66+
- `GenDBImplOLEDB` extended to `net462;net472;net481;net8.0`
67+
- `GenFreeBase` extended to `net462;net472;net481;net6.0;net7.0;net8.0;net9.0`
68+
- Validation update:
69+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MSQBrowser\MSQBrowser.csproj -nologo` succeeded
70+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MdbBrowser\MdbBrowser.csproj -nologo` succeeded
71+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\GenDBImplOLEDB\GenDBImplOLEDB.csproj -nologo` succeeded
72+
- Browser model refactoring update:
73+
- `MSQBrowser.Models.DBModel` now creates its connection through `Db.Provider.MySql.MySqlDbConnectionFactory`
74+
- `MdbBrowser.Models.DBModel` now creates its connection through `GenFree.Data.DB.OleDbConnectionFactory`
75+
- `DbProviderMySql` now exposes `MySqlDbConnectionFactory`
76+
- `GenDBImplOLEDB` now exposes `OleDbConnectionFactory`
77+
- `GenDBImplOLEDB` now also exposes an initial `OleDbStatementRenderer`
78+
- Current limitation:
79+
- browser model command/adaptor logic is still partly provider-specific and remains a later extraction step
80+
- Validation update:
81+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\DbProviderMySql\DbProviderMySql.csproj -nologo` succeeded
82+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MSQBrowser\MSQBrowser.csproj -nologo` succeeded
83+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MdbBrowser\MdbBrowser.csproj -nologo` succeeded
84+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MSQBrowserTests\MSQBrowserTests.csproj -nologo -v:minimal` succeeded
85+
- `dotnet build C:\Projekte\CSharp\Gen_FreeWin\MdbBrowserTests\MdbBrowserTests.csproj -nologo` succeeded
86+
- Unrelated broader-solution follow-up:
87+
- `WinAhnenNew\RnzTrauer` still expects a `MySqlStatementRenderer` in its own context and fails during full-solution build; not part of the browser scope
88+
2389
## FBParser Pascal-to-CSharp Port Snapshot
2490

2591
- Target area: `FBParser\FBEntryParser.cs`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<TargetFramework>net462</TargetFramework>
7+
<IsTestProject>true</IsTestProject>
8+
<IsPackable>false</IsPackable>
9+
<LangVersion>latest</LangVersion>
10+
<DisableTransitiveProjectReferences>false</DisableTransitiveProjectReferences>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="MSTest" Version="4.2.2" />
15+
<PackageReference Include="NSubstitute" Version="5.3.0" />
16+
<PackageReference Include="coverlet.collector" Version="6.0.2">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\DbCoreAbstractions\DbCoreAbstractions.csproj" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
28+
</ItemGroup>
29+
30+
</Project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using Db.Core.Abstractions.Sql;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
5+
namespace DbCoreAbstractions.UnitTests.Sql
6+
{
7+
/// <summary>
8+
/// Unit tests for the <see cref="DbFilterClause"/> constructor.
9+
/// </summary>
10+
[TestClass]
11+
public class DbFilterClauseTests
12+
{
13+
/// <summary>
14+
/// Tests that the constructor correctly assigns all properties when all arguments are provided.
15+
/// </summary>
16+
[TestMethod]
17+
public void Constructor_AllArgumentsProvided_PropertiesAssignedCorrectly()
18+
{
19+
// Arrange
20+
string field = "TestField";
21+
DbFilterOperator op = DbFilterOperator.Equal;
22+
string parameterName = "@param";
23+
24+
// Act
25+
var clause = new DbFilterClause(field, op, parameterName);
26+
27+
// Assert
28+
Assert.AreEqual(field, clause.Field);
29+
Assert.AreEqual(op, clause.Operator);
30+
Assert.AreEqual(parameterName, clause.ParameterName);
31+
}
32+
33+
/// <summary>
34+
/// Tests that the constructor assigns ParameterName to null when not provided.
35+
/// </summary>
36+
[TestMethod]
37+
public void Constructor_ParameterNameNotProvided_ParameterNameIsNull()
38+
{
39+
// Arrange
40+
string field = "TestField";
41+
DbFilterOperator op = DbFilterOperator.IsNull;
42+
43+
// Act
44+
var clause = new DbFilterClause(field, op);
45+
46+
// Assert
47+
Assert.AreEqual(field, clause.Field);
48+
Assert.AreEqual(op, clause.Operator);
49+
Assert.IsNull(clause.ParameterName);
50+
}
51+
52+
/// <summary>
53+
/// Tests that the constructor allows an empty string for field and parameterName.
54+
/// </summary>
55+
[TestMethod]
56+
public void Constructor_EmptyStrings_PropertiesAssignedCorrectly()
57+
{
58+
// Arrange
59+
string field = string.Empty;
60+
DbFilterOperator op = DbFilterOperator.Equal;
61+
string parameterName = string.Empty;
62+
63+
// Act
64+
var clause = new DbFilterClause(field, op, parameterName);
65+
66+
// Assert
67+
Assert.AreEqual(field, clause.Field);
68+
Assert.AreEqual(op, clause.Operator);
69+
Assert.AreEqual(parameterName, clause.ParameterName);
70+
}
71+
72+
}
73+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#nullable enable
2+
3+
// <auto-generated>
4+
// This file contains unit tests for the DbInsertStatement constructor in the DbCoreAbstractions.Sql namespace.
5+
// It is designed to maximize code coverage for all not-covered lines in the constructor.
6+
//
7+
// MSTest v4.2.2, NSubstitute v5.3.0
8+
//
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using Db.Core.Abstractions.Sql;
13+
using Db.Core.Abstractions.Sql;
14+
using Db.Core.Abstractions.Sql.Interfaaces;
15+
using Microsoft.VisualStudio.TestTools.UnitTesting;
16+
using NSubstitute;
17+
18+
namespace DbCoreAbstractions.UnitTests
19+
{
20+
/// <summary>
21+
/// Unit tests for the <see cref="DbInsertStatement"/> constructor.
22+
/// </summary>
23+
[TestClass]
24+
public class DbInsertStatementTests
25+
{
26+
[TestMethod]
27+
[DataRow(null)]
28+
[DataRow("")]
29+
[DataRow(" ")]
30+
public void Ctor_TableIsNullOrWhiteSpace_ThrowsArgumentException(string? table)
31+
{
32+
// Arrange
33+
IEnumerable<KeyValuePair<string, string>>? fields = null;
34+
IEnumerable<IDbFilterClause>? filters = null;
35+
int? limit = null;
36+
37+
// Act & Assert
38+
try
39+
{
40+
_ = new DbInsertStatement(table!, fields, filters, limit);
41+
Assert.Fail("Expected ArgumentException was not thrown.");
42+
}
43+
catch (ArgumentException ex)
44+
{
45+
Assert.AreEqual("A table name is required.", ex.Message.Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]);
46+
Assert.AreEqual("table", ex.ParamName);
47+
}
48+
}
49+
50+
[TestMethod]
51+
public void Ctor_ValidTableAndNullFields_FieldsIsEmptyArray()
52+
{
53+
// Arrange
54+
string table = "MyTable";
55+
IEnumerable<KeyValuePair<string, string>>? fields = null;
56+
IEnumerable<IDbFilterClause>? filters = null;
57+
int? limit = null;
58+
59+
// Act
60+
var stmt = new DbInsertStatement(table, fields, filters, limit);
61+
62+
// Assert
63+
Assert.AreEqual(table, stmt.Table);
64+
Assert.IsNotNull(stmt.Fields);
65+
Assert.AreEqual(0, stmt.Fields.Count);
66+
}
67+
68+
[TestMethod]
69+
public void Ctor_ValidTableAndFields_FieldsIsArrayWithValues()
70+
{
71+
// Arrange
72+
string table = "MyTable";
73+
var fields = new List<KeyValuePair<string, string>>
74+
{
75+
new("Col1", "Val1"),
76+
new("Col2", "Val2")
77+
};
78+
IEnumerable<IDbFilterClause>? filters = null;
79+
int? limit = null;
80+
81+
// Act
82+
var stmt = new DbInsertStatement(table, fields, filters, limit);
83+
84+
// Assert
85+
Assert.AreEqual(table, stmt.Table);
86+
Assert.IsNotNull(stmt.Fields);
87+
Assert.AreEqual(2, stmt.Fields.Count);
88+
Assert.AreEqual("Col1", stmt.Fields[0].Key);
89+
Assert.AreEqual("Val1", stmt.Fields[0].Value);
90+
Assert.AreEqual("Col2", stmt.Fields[1].Key);
91+
Assert.AreEqual("Val2", stmt.Fields[1].Value);
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)