New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New scaffolding framework #3098
Conversation
59eb5d3
to
d69eaa0
Compare
d69eaa0
to
cb8f80c
Compare
7d00522
to
1069f1e
Compare
41e93b2
to
a072c9a
Compare
e31742d
to
5263da0
Compare
5263da0
to
740666e
Compare
740666e
to
fe1386a
Compare
If anyone interested in testing and giving feedback for current dev. build, he can try it using attached nuget (unzip first) linq2db.cli.0.0.52.zip
What is missing from this version:
Check nuget readme for starters: https://github.com/linq2db/linq2db/blob/685a75093832e430e41411d72da64f5b40f62051/NuGet/CLI/README.md |
- move codegenerator to linq2db.tools - dotnet tool nuget generation
…l, sybase - partial pgsql enum scaffolding support (as string for now) - fix some broken T4 templates due to providers refactoring (from other prs)
…er-stage-0 # Conflicts: # NuGet/linq2db.AspNet.nuspec # NuGet/linq2db.Firebird.nuspec # NuGet/linq2db.PostgreSQL.nuspec # NuGet/linq2db.SQLite.MS.nuspec # Source/LinqToDB/DataProvider/MySql/MySqlProviderAdapter.cs
…er-stage-0 # Conflicts: # NuGet/linq2db.MySql.nuspec # NuGet/linq2db.PostgreSQL.nuspec # Source/LinqToDB/DataProvider/DB2/DB2ProviderAdapter.cs # Source/LinqToDB/DataProvider/Firebird/FirebirdDataProvider.cs # Source/LinqToDB/DataProvider/MySql/MySqlDataProvider.cs # Source/LinqToDB/DataProvider/MySql/MySqlProviderAdapter.cs # Source/LinqToDB/DataProvider/Oracle/OracleDataProvider.cs # Source/LinqToDB/Mapping/AssociationAttribute.cs # Source/LinqToDB/Mapping/EntityMappingBuilder.cs # Tests/Linq/DataProvider/OracleTests.cs
/azp run test-all |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run test-all |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run test-all |
Azure Pipelines successfully started running 1 pipeline(s). |
Test baselines changed by this PR. Don't forget to merge/close baselines PR after this pr merged/closed. |
Source/LinqToDB.CLI/CommandLine/Commands/ScaffoldCommand.Execute.cs
Outdated
Show resolved
Hide resolved
* [Linux / Informix 14.10] baselines * [Linux / MariaDB (both providers)] baselines * [Linux / MySQL 5.5 (both providers)] baselines * [Linux / Firebird 3.0] baselines * [Linux / Firebird 2.5] baselines * [Linux / Firebird 4.0] baselines * [Linux / DB2 LUW 11.5] baselines * [Linux / PostgreSQL 10] baselines * [Linux / MySQL 8 (both providers)] baselines * [Linux / Oracle 11g XE] baselines * [Linux / PostgreSQL 11] baselines * [Linux / PostgreSQL 14] baselines * [Linux / PostgreSQL 13] baselines * [Linux / PostgreSQL 12] baselines * [Linux / SQLite (specialized tests)] baselines * [Linux / SQLite (both providers)] baselines * [Linux / SQL Server 2017] baselines * [Linux / Sybase ASE 16] baselines * [Linux / Oracle 12c] baselines * [Linux / SQL Server 2019] baselines * [Windows / Access ACE (OLEDB/ODBC) x86] baselines * [Windows / SQLite (both providers)] baselines * [Windows / Access MDB (Jet/ODBC)] baselines * [Linux / SAP HANA 2] baselines * [Windows / SQLite (specialized tests)] baselines * [Windows / SQL Server 2005] baselines * [Windows / SQL CE] baselines * [Windows / SQL Server 2012] baselines * [Windows / SQL Server 2008] baselines * [Windows / SQL Server 2005] baselines * [Windows / SQL Server 2008] baselines * [Windows / SQL Server 2017] baselines * [Windows / SQL Server 2012] baselines * [Windows / SQL Server 2014] baselines * [Windows / SQL Server 2019] baselines * [Windows / SQL Server 2016] baselines * [Windows / SQL Server EXTRAS] baselines * [Windows / SQL Server 2014] baselines Co-authored-by: Azure Pipelines Bot <azp@linq2db.com>
Fix #1383
Fix #1586 (proper fix instead of old hack)
Fix #1825
Fix #1897 (wasn't actually fixed before)
Fix #1971
Fix #2168 (proper fix instead of old hack)
Fix #2515
Fix #2793
Fix #3345
Goal
Provide new code-generation library and command-line tool for database model scaffolding to be used by:
Currently we use:
Issues with current approach:
Architecture
Instead of semi-monolitic approach, here we try to separate code generation into several distinctive steps:
Tasks
Equatable.ttinclude
There are also a bunch of schema/T4 issues that could be addressed during current feature implmentation or later, which are not mentioned as they probably will be done separately.
Implemented changes
Main feature
linq2db.Tools
project:Source\LinqToDB.Tools\CodeModel
: code model and code generation (currently C#-only)Source\LinqToDB.Tools\DataModel
: cotext data model to code AST conversionSource\LinqToDB.Tools\Metadata
: context metadata model and generation (currently attribute-based only)Source\LinqToDB.Tools\Naming
: model pluralization and identifier normalizationSource\LinqToDB.Tools\Scaffold
: database schema to context data model conversionSource\LinqToDB.Tools\Schema
: database schema API (currently wrapper over existing schema API)dotnet tool
. Planned nuget name:linq2db.cli
, dotnet tool name:dotnet-linq2db
. Target framework:netcoreapp3.1
(with plan to switch tonet6
after 3.1 EOL)Various scaffolding fixes/improvements
@return
parameter support for SQL Server stored procedures. Fix [Request, T4 template] Support for ParameterDirection.ReturnValue #1897 (previous fix wasn't included into T4 by mistake)--architecture
cli tool switch to start it as x64 or x86 process. This is needed for unmanaged providers, especially Access. VS2019- always used x86 T4 host and VS2022 use x64 test host, which made it hard to use with such databases.ColumnType
for procedure schema in schema providerDataAccess
in name as Access connection (asDataAccess
is a part of oracle managed provider name)Find
extensions generation (Fix question T4 how to custom add FindQuery() without custom LinqToDB.ttinclude #2793)FindAsync
method generationFindQuery
method generationITable<T>
)Find
generation)Other fixes
AfterExecuteReader
to handle user-requested case with oracle reader configuration. Proposed workaround was unusable due to use of internal APIAssociationAttribute
properties (KeyName
,BackReferenceName
,IsBackReference
,Relationship
) andRelationship
enum as they were never usedDataConnection.OnTrace
static propertyStringComparison.Invariant*
toStringComparison.Ordinal*
enum valuesInfrastructure changes
Source\Shared
fromLinqToDB
project and included to all projects (seeBuild/linq2db.Default.props
)InternalsVisibleTo
removalThis attribute used by
linq2db
to open some internal stuff to tests which had several negative consequences:dotMorten.Microsoft.SqlServer.Types
is not signed - we used custom signed build for it instead of nugetTo solve it I've:
Opened API:
LinqToDB.Common.Compilation.CompileExpression
methods exposed forlinq2db.Tools
and tests, but still marked as internal API. It's needed mostly forTools
and we can remove use of it from testsLinqToDB.Common.EnumerableHelper.Batch
methods exposed (were covered by tests)InvariantCultureRegion
made public (for tests)MappingSchema.CombineSchemas
method made public (for tests)LinqExtensions.Updatable
made public (for tests)Query.Queries
property,Query<T>
class (for methodClarCache
, propertyCacheMissCount
and methodGetQuery
) andQueryInfo
class made public for testsInternalExtensions
class, methodsUnwrap
,IsSameGenericMethod
,EvaluateExpression
(for tests)TypeWrapperNameAttribute
,ValueTaskToTaskMapper
,CustomMapperAttribute
andICustomMapper
made public (should've been public from start)ReflectionExtensions.IsSubClassOf
method (forlinq2db.Tools
)SqlServerTransientExceptionDetector.IsHandled
method (forlinq2db.Tools
)SqlServerTools.QuoteIdentifier
method (for tests)PostgreSQLDataProvider.HasMacAddr8
property (for tests)DataContext
methodsGetDataConnection
,ReleaseQuery
,ReleaseQueryAsync
(for tests)I plan to review it later and probably hide some API back (requires tests refactoring). Also some tests are commented due to internal APIs - will address it too