Skip to content

Commit

Permalink
Release/0.9.3 (#339)
Browse files Browse the repository at this point in the history
### Added
- Added comments and property names to methods that construct metadata.  Makes source control diffs easier as the property name and comments provide clarity.

- Added support for MsSql 2022
	- Parity with version 2019, no 2022 version specific functionality

- Platform version specific services enabling version specific functionality
	- Scaffolding config now requires the platform version, which is generated into data services
		- Validate that scaffolding config for source.platform.version is a supported MsSql version.
	- Version specific function builders.  For example, in MsSql 2022 the [Trim function](https://docs.microsoft.com/en-us/sql/t-sql/functions/trim-transact-sql?view=sql-server-ver16) has additional method parameters.  With version specific function builders, dExpression can handle these specific cases.
	- This supports the removal of version specific configuration methods in favor of a single method:
		- dbex.AddMsSql2019Database<MyDatabase>(...) -> dbex.AddDatabase<MyDatabase>(...).

- Implemented preview version of .NET 7.0
	- Added static abstract interface method on ISqlDatabaseRuntime that enforces the runtime version of MsSql.
	- Added PlatformVersion attribute to shim this for pre .NET 7.0, with conditional compilation statements where necessary.
	- DID NOT target .NET 7.0 in projects as it causes issues with build pipeline.  Will target on release of .NET 7.0.
	- Microsoft introduced build warning CS8981, which impacts dbExpression.   This build warning states that all variables, classes, keywords, etc. that are lowercase ASCII should be changed as they should be reserved for C# (took 22 years for Microsoft to decide this?). Code generation now emits pragma warnings, will have to let the compiler catch issues with database schema naming that conflicts with “future” language keywords.  
		
### Changed
- Removed unused arg (ISqlDatabaseRuntime) from query expression builder factory.
- Removed dependency injection test project as all tests were recreations of those in other test projects.

### Fixed

### Breaking Changes
- TOOLS UPDATE IS REQUIRED
- Runtime configuration removes version specific configuration.  Any use of .Add{Platform}{Version}Database(...) (i.e. .AddMsSql2019Database(...)) must be changed to .AddDatabase(...).
- Scaffolding configuration
	- Changed "source" to be a complex object with "version" and "key".
	- "type" property name changed to "key" (source.platform.key).
	- Platform version is required and must be a supported version (source.platform.version).
  • Loading branch information
gwgrubbs committed Sep 8, 2022
1 parent 1592f05 commit e19fa27
Show file tree
Hide file tree
Showing 129 changed files with 8,169 additions and 2,089 deletions.
7 changes: 0 additions & 7 deletions DbEx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DirectoryBuildPropsFile", "
build\HatTrick\DirectoryBuildPropsFile\DirectoryBuildPropsFile.psm1 = build\HatTrick\DirectoryBuildPropsFile\DirectoryBuildPropsFile.psm1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test", "test\HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test\HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test.csproj", "{A579BCCB-F91B-4CBC-8406-385C764FAE8A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmark", "benchmark", "{DF45604D-A21C-47BD-8F21-A1C70E10F130}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmark.MsSql", "benchmark\Benchmark.MsSql\Benchmark.MsSql.csproj", "{DDD3D7B2-64B3-4565-B4CF-26D42A35EA03}"
Expand Down Expand Up @@ -147,10 +145,6 @@ Global
{72654BAA-DCC1-4CA8-AD3B-01CE1CFF0237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72654BAA-DCC1-4CA8-AD3B-01CE1CFF0237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72654BAA-DCC1-4CA8-AD3B-01CE1CFF0237}.Release|Any CPU.Build.0 = Release|Any CPU
{A579BCCB-F91B-4CBC-8406-385C764FAE8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A579BCCB-F91B-4CBC-8406-385C764FAE8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A579BCCB-F91B-4CBC-8406-385C764FAE8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A579BCCB-F91B-4CBC-8406-385C764FAE8A}.Release|Any CPU.Build.0 = Release|Any CPU
{DDD3D7B2-64B3-4565-B4CF-26D42A35EA03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDD3D7B2-64B3-4565-B4CF-26D42A35EA03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDD3D7B2-64B3-4565-B4CF-26D42A35EA03}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -182,7 +176,6 @@ Global
{DD32A58A-E630-4DF8-943F-E82395DA99FF} = {F1FF2A42-3E7E-4EDC-AFD5-9C632FD2B48D}
{72654BAA-DCC1-4CA8-AD3B-01CE1CFF0237} = {7FC9C3D5-22E3-40DD-B73D-FB60CF635B06}
{0DA28E36-0FC2-4B12-94F3-D0F5BCFAEB15} = {E009B64D-3137-4D5C-B6F2-1E7F5F846FF5}
{A579BCCB-F91B-4CBC-8406-385C764FAE8A} = {E797F978-C42D-491C-B5A4-4DEADB7342A3}
{DDD3D7B2-64B3-4565-B4CF-26D42A35EA03} = {DF45604D-A21C-47BD-8F21-A1C70E10F130}
{4B165F4C-D9C7-438E-8B18-7DD313179747} = {E009B64D-3137-4D5C-B6F2-1E7F5F846FF5}
{FD9A8F7C-D146-4EBA-8D1E-40BF252D7656} = {DF45604D-A21C-47BD-8F21-A1C70E10F130}
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<Project>
<PropertyGroup>
<VersionPrefix>0.9.2</VersionPrefix>
<VersionPrefix>0.9.3</VersionPrefix>
<PackageIcon>images/htl-nuget-logo.png</PackageIcon>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.9.2</PackageReleaseNotes>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.9.3</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<None Include="../../build/htl-nuget-logo.png" Pack="true" Visible="false" PackagePath="images/htl-nuget-logo.png" />
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Using linux versions of Microsoft SQL Server on Docker images, integration tests
| :---------------------| :---------------------------------------------|
| MSSQL 2017 | [![Build Status](https://dev.azure.com/hattricklabs/DbEx/_apis/build/status/HatTrickLabs.db-ex?branchName=master&stageName=Test%20MSSQL%20Platforms&jobName=Test%20MSSQL%202017)](https://dev.azure.com/hattricklabs/DbEx/_build/latest?definitionId=2&branchName=master) |
| MSSQL 2019 | [![Build Status](https://dev.azure.com/hattricklabs/DbEx/_apis/build/status/HatTrickLabs.db-ex?branchName=master&stageName=Test%20MSSQL%20Platforms&jobName=Test%20MSSQL%202019)](https://dev.azure.com/hattricklabs/DbEx/_build/latest?definitionId=2&branchName=master) |
| MSSQL 2022 | [![Build Status](https://dev.azure.com/hattricklabs/DbEx/_apis/build/status/HatTrickLabs.db-ex?branchName=master&stageName=Test%20MSSQL%20Platforms&jobName=Test%20MSSQL%202022)](https://dev.azure.com/hattricklabs/DbEx/_build/latest?definitionId=2&branchName=master) |

## Get dbExpression
| Package | |
Expand Down Expand Up @@ -80,7 +81,7 @@ GROUP BY
```

dbExpression was designed to work in either static or instance required scenarios. The decision for which to use is typically based on the type of project, the team environment, and just what works best for you - it's your choice!
* Statically using a static database accessor to fluently build and execute queries. This is great for environments or projects where this works best.
* Statically using a static database accessor to fluently build and execute queries.
* Instance based via dependency injection where an instance of the database accessor is used to fluently build and execute queries. Perfect for environments that use dependency injection.

## Use dbExpression
Expand Down
100 changes: 23 additions & 77 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trigger:
- release/*

pool:
vmImage: 'windows-2022'
vmImage: 'windows-latest'

name: $[ variables['branchName'] ]

Expand All @@ -31,11 +31,11 @@ variables:

stages:

- stage: Build
displayName: 'Build and Package'
- stage: Build_and_Test
displayName: 'Build, Test and Package'
jobs:
- job:
displayName: 'Build Solution and Publish Assets'
displayName: 'Build, Test, and Publish'
steps:
- task: PowerShell@2
displayName: 'Build and Package Solution'
Expand All @@ -44,50 +44,33 @@ stages:
arguments: '-Configuration $(buildConfiguration) -BranchName $(branchName) -CommitSHA $(Build.SourceVersion) -BuildIdentifier $(Build.BuildNumber) -PropertiesPath $(Build.SourcesDirectory)/Directory.Build.props -UseBranchNameInPackageSuffixWhenNotSpecified'
workingDirectory: $(Build.SourcesDirectory)
pwsh: true
- publish: $(Build.SourcesDirectory)
displayName: 'Publish to Staging Location'
artifact: $(stageLocationName)

- stage: Test_MsSql_Unit
dependsOn: Build
displayName: 'Test MSSQL Core'
jobs:
- job:
displayName: 'Test MSSQL'
steps:
- checkout: none
- download: current
artifact: $(stageLocationName)
- task: DotNetCoreCLI@2
displayName: 'Execute Tests'
displayName: 'Execute Unit Tests'
inputs:
command: test
projects: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Test.Unit\*.csproj
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=mssql-core.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql*]*" /p:Exclude="[*Test]*"'
projects: $(Build.SourcesDirectory)/test/HatTrick.DbEx.MsSql.Test.Unit/HatTrick.DbEx.MsSql.Test.Unit.csproj
arguments: '--configuration $(buildConfiguration) --framework net$(netCoreVersion) --logger "trx;LogFileName=mssql-core.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql*]*" /p:Exclude="[*Test]*"'
- task: PublishTestResults@2
displayName: 'Publish Test Results to Temp'
inputs:
testResultsFormat: xUnit
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\TestResults\mssql-core.tests.trx
testResultsFiles: $(Build.SourcesDirectory)/TestResults/mssql-core.tests.trx
testRunTitle: 'MSSQL (Core)'
mergeTestResults: true
failTaskOnFailedTests: true
- task: CopyFiles@2
displayName: 'Copy Code Coverage Files to Temp'
inputs:
contents: '*.cobertura.xml'
sourceFolder: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Test.Unit
targetFolder: $(Pipeline.Workspace)\$(stageLocationName)\tmp
- task: PublishPipelineArtifact@1
displayName: 'Publish Code Coverage Files to Staging Location'
inputs:
targetPath: $(Pipeline.Workspace)\$(stageLocationName)\tmp
targetPath: $(Build.SourcesDirectory)/test/HatTrick.DbEx.MsSql.Test.Unit
artifactName: mssql-core-results
- publish: $(Build.SourcesDirectory)
displayName: 'Publish to Staging Location'
artifact: $(stageLocationName)

- stage: Test_MsSql_Integration
pool:
vmImage: 'ubuntu-latest'
dependsOn: Build
dependsOn: Build_and_Test
displayName: 'Test MSSQL Platforms'
jobs:
- template: build/mssql/mssql-integration-testing-template.yml
Expand All @@ -97,49 +80,12 @@ stages:
buildTemplatesPath: $(Pipeline.Workspace)/$(stageLocationName)/build/mssql
buildConfiguration: $(buildConfiguration)
targetFrameworkMoniker: net$(netCoreVersion)
mssqlVersions: ['2017','2019']

- stage: Test_MsSql_Dependency_Injection
dependsOn: Build
displayName: 'Test Dependency Injection'
jobs:
- job:
displayName: 'Test MSSQL Dependency Injection'
steps:
- checkout: none
- download: current
artifact: $(stageLocationName)
- task: DotNetCoreCLI@2
displayName: 'Execute Tests'
inputs:
command: test
projects: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test\*.csproj
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=mssql-dependency-injection.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql.*]*" /p:Exclude="[*Test]*"'
- task: PublishTestResults@2
displayName: 'Publish Test Results to Temp'
inputs:
testResultsFormat: xUnit
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\TestResults\mssql-dependency-injection.tests.trx
testRunTitle: 'MSSQL (Dependency Injection)'
mergeTestResults: true
failTaskOnFailedTests: true
- task: CopyFiles@2
displayName: 'Copy Code Coverage Files to Temp'
inputs:
contents: '*.cobertura.xml'
sourceFolder: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test
targetFolder: $(Pipeline.Workspace)\$(stageLocationName)\tmp
- task: PublishPipelineArtifact@1
displayName: 'Publish Code Coverage Files to Staging Location'
inputs:
targetPath: $(Pipeline.Workspace)\$(stageLocationName)\tmp
artifactName: mssql-dependency-injection-results
mssqlVersions: ['2017','2019','2022']

- stage: Publish_Reports
dependsOn:
- Test_MsSql_Unit
- Build_and_Test
- Test_MsSql_Integration
- Test_MsSql_Dependency_Injection
displayName: 'Publish Reports'
jobs:
- job:
Expand All @@ -150,20 +96,20 @@ stages:
- task: PowerShell@2
displayName: 'Correct Source Paths in Coverage Files'
inputs:
filePath: $(Pipeline.Workspace)\$(stageLocationName)\build\fix-code-coverage-files.ps1
arguments: '-CodeCoverageFilePaths "$(Pipeline.Workspace)\mssql-core-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2017-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2019-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-dependency-injection-results\coverage.net6.0.cobertura.xml" -PathToSourceFiles "$(Pipeline.Workspace)\$(stageLocationName)\src\"'
workingDirectory: $(Pipeline.Workspace)\$(stageLocationName)\build
filePath: $(Pipeline.Workspace)/$(stageLocationName)/build/fix-code-coverage-files.ps1
arguments: '-CodeCoverageFilePaths "$(Pipeline.Workspace)\mssql-core-results\coverage.net$(netCoreVersion).cobertura.xml;$(Pipeline.Workspace)\mssql-2017-results\coverage.net$(netCoreVersion).cobertura.xml;$(Pipeline.Workspace)\mssql-2019-results\coverage.net$(netCoreVersion).cobertura.xml;$(Pipeline.Workspace)\mssql-2022-results\coverage.net$(netCoreVersion).cobertura.xml" -PathToSourceFiles "$(Pipeline.Workspace)\$(stageLocationName)\src\"'
workingDirectory: $(Pipeline.Workspace)/$(stageLocationName)\build
pwsh: true
- task: reportgenerator@5
displayName: 'Merge Code Coverage Reports'
inputs:
reports: $(Pipeline.Workspace)\mssql*\*coverage*.xml
targetdir: $(Pipeline.Workspace)\mssql-merged-results
reports: $(Pipeline.Workspace)/mssql*/*coverage*.xml
targetdir: $(Pipeline.Workspace)/mssql-merged-results
reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Reports'
inputs:
codeCoverageTool: Cobertura
pathToSources: $(Pipeline.Workspace)\$(stageLocationName)\src
summaryFileLocation: $(Pipeline.Workspace)\mssql-merged-results\cobertura.xml
reportDirectory: '$(Pipeline.Workspace)\mssql-merged-results'
pathToSources: $(Pipeline.Workspace)/$(stageLocationName)/src
summaryFileLocation: $(Pipeline.Workspace)/mssql-merged-results/cobertura.xml
reportDirectory: '$(Pipeline.Workspace)/mssql-merged-results'
3 changes: 2 additions & 1 deletion benchmark/Benchmark.MsSql/Benchmark.MsSql.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<OutputType>Exe</OutputType>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/Benchmark.MsSql/MapperBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class MapperBenchmarks
public void ConfigureDbExpression()
{
var services = new ServiceCollection();
services.AddDbExpression(dbex => dbex.AddMsSql2019Database<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
services.AddDbExpression(dbex => dbex.AddDatabase<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
var serviceProvider = services.BuildServiceProvider();

valueConverterProvider = new SqlStatementValueConverterProvider(serviceProvider.GetRequiredService<IValueConverterFactory>());
Expand Down
2 changes: 1 addition & 1 deletion benchmark/Benchmark.MsSql/QueryExpressionBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class QueryExpressionBenchmarks
public void ConfigureDbExpression()
{
var services = new ServiceCollection();
services.AddDbExpression(dbex => dbex.AddMsSql2019Database<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
services.AddDbExpression(dbex => dbex.AddDatabase<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
var serviceProvider = services.BuildServiceProvider();
serviceProvider.UseStaticRuntimeFor<BenchmarkDatabase>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class SqlStatementAssemblyBenchmarks
public void ConfigureDbExpression()
{
var services = new ServiceCollection();
services.AddDbExpression(dbex => dbex.AddMsSql2019Database<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
services.AddDbExpression(dbex => dbex.AddDatabase<BenchmarkDatabase>(c => c.ConnectionString.Use(connectionString)));
serviceProvider = services.BuildServiceProvider();
}

Expand Down

0 comments on commit e19fa27

Please sign in to comment.