Skip to content

Commit

Permalink
Merge pull request #3 from xin9le/feature/modernize
Browse files Browse the repository at this point in the history
Modernize to .NET 8
  • Loading branch information
xin9le authored Apr 7, 2024
2 parents db6ade7 + 814b0cc commit ee7b494
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 4,203 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target-framework: [ 'net6.0' ]
tfm: [ net6, net8 ]
include:
- tfm: net6
dotnet-version: 6.0.x
- tfm: net8
dotnet-version: 8.0.x

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: ${{ matrix.dotnet-version }}
- name: Display dotnet version
run: dotnet --version
- name: Build
run: dotnet build --configuration Release --framework ${{ matrix.target-framework }} ./src/QLimitive/QLimitive.csproj
run: dotnet build --configuration Release --framework ${{ matrix.tfm }} ./src/QLimitive/QLimitive.csproj
- name: Test
run: dotnet test --verbosity normal --configuration Release --framework ${{ matrix.target-framework }} ./src/UnitTests/UnitTests.csproj
run: dotnet test --verbosity normal --configuration Release --framework ${{ matrix.tfm }} ./src/UnitTests/UnitTests.csproj
52 changes: 16 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
Expand All @@ -13,23 +12,17 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand All @@ -43,10 +36,9 @@ Generated\ Files/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUnit
# NUNIT
*.VisualState.xml
TestResult.xml
nunit-*.xml

# Build Results of an ATL Project
[Dd]ebugPS/
Expand All @@ -60,14 +52,15 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*_i.h
*.ilk
*.meta
*.obj
Expand All @@ -84,7 +77,6 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
Expand Down Expand Up @@ -127,6 +119,9 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

Expand Down Expand Up @@ -184,8 +179,6 @@ PublishScripts/

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand All @@ -210,14 +203,12 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
!*.[Cc]ache/

# Others
ClientBin/
Expand All @@ -230,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -261,9 +252,6 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

# Microsoft Fakes
FakesAssemblies/
Expand Down Expand Up @@ -299,8 +287,12 @@ paket-files/
# FAKE - F# Make
.fake/

# CodeRush personal settings
.cr/personal
# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
Expand All @@ -325,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -334,17 +326,5 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
32 changes: 31 additions & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,39 @@ indent_size = 4
dotnet_code_quality_unused_parameters = all:silent
dotnet_code_quality.ca1822.api_surface = private

dotnet_diagnostic.CA1848.severity = silent
dotnet_diagnostic.CA1304.severity = error
dotnet_diagnostic.CA1305.severity = error
dotnet_diagnostic.CA1307.severity = error
dotnet_diagnostic.CA1310.severity = error
dotnet_diagnostic.CA1848.severity = error
dotnet_diagnostic.CA2016.severity = error
dotnet_diagnostic.CA2254.severity = error
dotnet_diagnostic.CS9124.severity = error
dotnet_diagnostic.IDE0004.severity = error
dotnet_diagnostic.IDE0005.severity = warning
dotnet_diagnostic.IDE0009.severity = error
dotnet_diagnostic.IDE0028.severity = error
dotnet_diagnostic.IDE0034.severity = error
dotnet_diagnostic.IDE0041.severity = error
dotnet_diagnostic.IDE0044.severity = error
dotnet_diagnostic.IDE0052.severity = warning
dotnet_diagnostic.IDE0079.severity = error
dotnet_diagnostic.IDE0080.severity = error
dotnet_diagnostic.IDE0082.severity = error
dotnet_diagnostic.IDE0090.severity = error
dotnet_diagnostic.IDE0100.severity = error
dotnet_diagnostic.IDE0120.severity = error
dotnet_diagnostic.IDE0161.severity = error
dotnet_diagnostic.IDE0161.severity = error
dotnet_diagnostic.IDE0170.severity = silent
dotnet_diagnostic.IDE0230.severity = error
dotnet_diagnostic.IDE0240.severity = error
dotnet_diagnostic.IDE0241.severity = error
dotnet_diagnostic.IDE0250.severity = error
dotnet_diagnostic.IDE0251.severity = error
dotnet_diagnostic.IDE0270.severity = silent
dotnet_diagnostic.IDE0290.severity = silent
dotnet_diagnostic.IDE0300.severity = error

dotnet_sort_system_directives_first = true
dotnet_style_qualification_for_field = true
Expand Down
10 changes: 10 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>

<PropertyGroup>
<TargetFrameworks>net6;net8</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

</Project>
12 changes: 12 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="FastMember" Version="1.5.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MSTest" Version="3.3.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="ZString" Version="2.6.0" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
2 changes: 1 addition & 1 deletion src/QLimitive/Commands/Insert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void Build(ref Utf16ValueStringBuilder builder, ref BindParameterCollecti
builder.Append(x.MemberName);
builder.Append(',');

parameters ??= new BindParameterCollection();
parameters ??= [];
parameters.Add(x.MemberName, null);
}
builder.Advance(-1);
Expand Down
5 changes: 4 additions & 1 deletion src/QLimitive/Commands/OrderBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ public OrderBy(DbDialect dialect, Expression<Func<T, object>> member, bool isAsc
public void Build(ref Utf16ValueStringBuilder builder, ref BindParameterCollection? parameters)
{
var memberName = ExpressionHelper.GetMemberName(this.Member);
if (memberName is null)
throw new InvalidOperationException();

var table = TableMappingInfo.Get<T>();
var columnName = table.ColumnByMemberNameInternal[memberName].ColumnName;
var columnName = table.ColumnByMemberName[memberName].ColumnName;
var bracket = this.Dialect.KeywordBracket;

if (builder.Length > 0)
Expand Down
5 changes: 4 additions & 1 deletion src/QLimitive/Commands/ThenBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ public ThenBy(DbDialect dialect, Expression<Func<T, object>> member, bool isAsce
public void Build(ref Utf16ValueStringBuilder builder, ref BindParameterCollection? parameters)
{
var memberName = ExpressionHelper.GetMemberName(this.Member);
if (memberName is null)
throw new InvalidOperationException();

var table = TableMappingInfo.Get<T>();
var columnName = table.ColumnByMemberNameInternal[memberName].ColumnName;
var columnName = table.ColumnByMemberName[memberName].ColumnName;
var bracket = this.Dialect.KeywordBracket;

if (builder.Length > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/QLimitive/Commands/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void Build(ref Utf16ValueStringBuilder builder, ref BindParameterCollecti
builder.Append(x.MemberName);
builder.Append(',');

parameters ??= new BindParameterCollection();
parameters ??= [];
parameters.Add(x.MemberName, null);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/QLimitive/Commands/Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected override Expression VisitMethodCall(MethodCallExpression expression)
{
this.BuildInClause(expression, true);
}
else if (t?.Namespace?.StartsWith("System.Collections") ?? false)
else if (t?.Namespace?.AsSpan().StartsWith("System.Collections") ?? false)
{
this.BuildInClause(expression, false);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ private void BuildBinary(Operator @operator, string memberName, object? value)

//--- Build sql
var bracket = this._dialect.KeywordBracket;
var columnName = this._table.ColumnByMemberNameInternal[memberName].ColumnName;
var columnName = this._table.ColumnByMemberName[memberName].ColumnName;
builder.Append(bracket.Begin);
builder.Append(columnName);
builder.Append(bracket.End);
Expand Down Expand Up @@ -300,7 +300,7 @@ private void BuildBinary(Operator @operator, string memberName, object? value)
}

//--- Cache parameter
bindParameters ??= new BindParameterCollection();
bindParameters ??= [];
var name = $"p{bindParameters.Count + 1}";
bindParameters.Add(name, value);
builder.Append(this._dialect.BindParameterPrefix);
Expand Down
11 changes: 5 additions & 6 deletions src/QLimitive/DbDialect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using QLimitive.Internals;
using System.Collections.Frozen;
using System.Collections.Generic;

namespace QLimitive;

Expand Down Expand Up @@ -61,14 +61,13 @@ private DbDialect(DbKind database, char bindParameterPrefix, in BracketPair keyw
/// </summary>
static DbDialect()
{
All = new[]
{
All = [
SqlServer,
MySql,
Sqlite,
PostgreSql,
Oracle,
};
];
ByDatabase = All.ToFrozenDictionary(static x => x.Database);
}
#endregion
Expand All @@ -84,7 +83,7 @@ static DbDialect()
/// <summary>
/// Gets all database dialects by <see cref="DbKind"/>.
/// </summary>
public static IReadOnlyDictionary<DbKind, DbDialect> ByDatabase { get; }
public static FrozenDictionary<DbKind, DbDialect> ByDatabase { get; }


/// <summary>
Expand Down
Loading

0 comments on commit ee7b494

Please sign in to comment.