Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit acca69a

Browse files
authored
Build updates (#334)
* updates, enable analyzers, warn-as-error * update deps, bump version, modernize build * fix CI
1 parent 44de54e commit acca69a

File tree

19 files changed

+90
-96
lines changed

19 files changed

+90
-96
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# EditorConfig is awesome: https://EditorConfig.org
2-
31
root = true
42

53
[*]

Build/linq2db.Default.props renamed to Directory.Build.props

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<Project>
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<Version>7.3.0</Version>
3+
<Version>7.6.0</Version>
44

55
<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
66
<Product>Linq to DB</Product>
@@ -11,8 +11,10 @@
1111

1212
<LangVersion>latest</LangVersion>
1313
<Nullable>enable</Nullable>
14-
<WarningLevel>4</WarningLevel>
14+
<WarningLevel>9999</WarningLevel>
1515
<ErrorReport>prompt</ErrorReport>
16+
<Features>strict</Features>
17+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
1618

1719
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
1820
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
@@ -27,16 +29,24 @@
2729
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
2830
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
2931
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
30-
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
32+
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
3133

3234
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
3335

36+
<!--required for SkipLocalInit-->
37+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
38+
39+
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
40+
3441
<TargetFrameworks>net6.0</TargetFrameworks>
3542
</PropertyGroup>
3643

3744
<PropertyGroup>
38-
<AnalysisLevel>preview</AnalysisLevel>
39-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
40-
<RunAnalyzers>true</RunAnalyzers>
45+
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
46+
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
47+
<AnalysisLevel>preview-All</AnalysisLevel>
48+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
49+
<ReportAnalyzer>true</ReportAnalyzer>
50+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
4151
</PropertyGroup>
4252
</Project>

Directory.Packages.props

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22
<ItemGroup>
3-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
4-
<PackageVersion Include="NUnit3TestAdapter" Version="4.4.2" />
3+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
4+
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
55
<PackageVersion Include="NUnit" Version="3.13.3" />
6-
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
6+
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
77

8-
<PackageVersion Include="linq2db" Version="5.2.1" />
9-
<PackageVersion Include="linq2db.Tools" Version="5.2.1" />
8+
<PackageVersion Include="linq2db" Version="5.3.0" />
9+
<PackageVersion Include="linq2db.Tools" Version="5.3.0" />
1010

1111
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
1212

@@ -17,11 +17,11 @@
1717
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
1818

1919
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
20-
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="7.0.4" />
21-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.5" />
22-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
20+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="7.0.11" />
21+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12" />
22+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
2323

2424
<PackageVersion Include="EntityFrameworkCore.FSharp" Version="6.0.7" />
25-
<PackageVersion Include="FSharp.Core" Version="7.0.300" />
25+
<PackageVersion Include="FSharp.Core" Version="7.0.400" />
2626
</ItemGroup>
2727
</Project>

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependencies>
1717
<group targetFramework="net6.0">
1818
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="7.0.0" />
19-
<dependency id="linq2db" version="5.2.1" />
19+
<dependency id="linq2db" version="5.3.0" />
2020
</group>
2121
</dependencies>
2222
</metadata>

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.Extensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ public static partial class LinqToDBForEFTools
1313
public static ITable<T> ToLinqToDBTable<T>(this DbSet<T> dbSet)
1414
where T : class
1515
{
16-
var context = Implementation.GetCurrentContext(dbSet);
17-
if (context == null)
18-
throw new LinqToDBForEFToolsException($"Can not load current context from {nameof(dbSet)}");
19-
16+
var context = Implementation.GetCurrentContext(dbSet)
17+
?? throw new LinqToDBForEFToolsException($"Can not load current context from {nameof(dbSet)}");
2018
var dc = CreateLinqToDBContext(context);
2119
return dc.GetTable<T>();
2220
}

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,8 @@ static List<Expression> CompactTree(List<Expression> items, ExpressionType nodeT
749749
/// <exception cref="InvalidOperationException"></exception>
750750
protected static TValue GetPropValue<TValue>(object obj, string propName)
751751
{
752-
var prop = obj.GetType().GetProperty(propName);
753-
if (prop == null)
754-
{
755-
throw new InvalidOperationException($"Property {obj.GetType().Name}.{propName} not found.");
756-
}
752+
var prop = obj.GetType().GetProperty(propName)
753+
?? throw new InvalidOperationException($"Property {obj.GetType().Name}.{propName} not found.");
757754
var propValue = prop.GetValue(obj);
758755
if (propValue == default)
759756
return default!;
@@ -1155,19 +1152,13 @@ static bool IsEnumerableType(Type type, MappingSchema mappingSchema)
11551152
var compilerField = typeof (EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance)!;
11561153
var compiler = (QueryCompiler)compilerField.GetValue(query.Provider)!;
11571154

1158-
var queryContextFactoryField = compiler.GetType().GetField("_queryContextFactory", BindingFlags.NonPublic | BindingFlags.Instance);
1159-
1160-
if (queryContextFactoryField == null)
1161-
throw new LinqToDBForEFToolsException($"Can not find private field '{compiler.GetType()}._queryContextFactory' in current EFCore Version.");
1162-
1155+
var queryContextFactoryField = compiler.GetType().GetField("_queryContextFactory", BindingFlags.NonPublic | BindingFlags.Instance)
1156+
?? throw new LinqToDBForEFToolsException($"Can not find private field '{compiler.GetType()}._queryContextFactory' in current EFCore Version.");
11631157
if (queryContextFactoryField.GetValue(compiler) is not RelationalQueryContextFactory queryContextFactory)
11641158
throw new LinqToDBForEFToolsException("LinqToDB Tools for EFCore support only Relational Databases.");
11651159

1166-
var dependenciesProperty = typeof(RelationalQueryContextFactory).GetProperty("Dependencies", BindingFlags.NonPublic | BindingFlags.Instance);
1167-
1168-
if (dependenciesProperty == null)
1169-
throw new LinqToDBForEFToolsException($"Can not find protected property '{nameof(RelationalQueryContextFactory)}.Dependencies' in current EFCore Version.");
1170-
1160+
var dependenciesProperty = typeof(RelationalQueryContextFactory).GetProperty("Dependencies", BindingFlags.NonPublic | BindingFlags.Instance)
1161+
?? throw new LinqToDBForEFToolsException($"Can not find protected property '{nameof(RelationalQueryContextFactory)}.Dependencies' in current EFCore Version.");
11711162
var dependencies = (QueryContextDependencies)dependenciesProperty.GetValue(queryContextFactory)!;
11721163

11731164
return dependencies.CurrentContext?.Context;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[module: SkipLocalsInit]

Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Import Project="..\..\Build\linq2db.Default.props" />
4-
53
<PropertyGroup>
64
<Description>Allows to execute Linq to DB (linq2db) queries in Entity Framework Core DbContext.</Description>
75
<Title>Linq to DB (linq2db) extensions for Entity Framework Core</Title>
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Project>
2-
<Import Project="linq2db.Default.props" />
3-
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="$(MSBuildThisFileDirectory)\..\Directory.Build.props" />
3+
44
<PropertyGroup>
55
<TargetFrameworks>net7.0</TargetFrameworks>
6+
7+
<NoWarn>$(NoWarn);CS1591</NoWarn>
68
</PropertyGroup>
7-
9+
810
<ItemGroup>
911
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1012
<PackageReference Include="NUnit3TestAdapter">
@@ -13,5 +15,4 @@
1315
</PackageReference>
1416
<PackageReference Include="NUnit" />
1517
</ItemGroup>
16-
1718
</Project>

Tests/LinqToDB.EntityFrameworkCore.BaseTests/Interceptors/TestEntityServiceInterceptor.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Data.Common;
2-
using System.Threading;
3-
using System.Threading.Tasks;
4-
using LinqToDB.Interceptors;
1+
using LinqToDB.Interceptors;
52

63
namespace LinqToDB.EntityFrameworkCore.BaseTests.Interceptors
74
{

0 commit comments

Comments
 (0)