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

Commit 0ded6b0

Browse files
authored
Build updates (v3) (#337)
* updates, enable analyzers, warn-as-error # Conflicts: # Build/linq2db.Tests.props # Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs # Conflicts: # Build/linq2db.Default.props # Build/linq2db.Tests.props # Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs # Conflicts: # Build/linq2db.Default.props # Build/linq2db.Tests.props # Directory.Packages.props # Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs # Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/Northwind/NorthwindData.cs # Tests/LinqToDB.EntityFrameworkCore.FSharpTests/LinqToDB.EntityFrameworkCore.FSharpTests.fsproj * update deps, bump version, modernize build
1 parent 4f0b797 commit 0ded6b0

27 files changed

+78
-89
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 & 6 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>3.23.0</Version>
3+
<Version>3.26.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,13 +29,22 @@
2729
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
2830
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
2931
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
32+
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
3033

3134
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
35+
36+
<!--required for SkipLocalInit-->
37+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
38+
39+
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
3240
</PropertyGroup>
3341

3442
<PropertyGroup>
35-
<AnalysisLevel>preview</AnalysisLevel>
36-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
37-
<RunAnalyzers>true</RunAnalyzers>
43+
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
44+
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
45+
<AnalysisLevel>preview-All</AnalysisLevel>
46+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
47+
<ReportAnalyzer>true</ReportAnalyzer>
48+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3849
</PropertyGroup>
3950
</Project>

Directory.Packages.props

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
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" />
12+
<PackageVersion Include="PolySharp" Version="1.13.2" />
1213
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
1314

1415
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.25" />

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>linq2db.EntityFrameworkCore</id>
5-
<title>Linq to DB (linq2db) extensions for Entity Framework Core 3.1</title>
5+
<title>Linq to DB (linq2db) extensions for Entity Framework Core</title>
66
<authors>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</authors>
77
<owners>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</owners>
88
<copyright>Copyright © 2020-2023 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</copyright>
@@ -16,7 +16,7 @@
1616
<dependencies>
1717
<group targetFramework="netstandard2.0">
1818
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.1.25" />
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/Internal/LinqToDBForEFQueryProvider.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
using System.Runtime.CompilerServices;
88
using System.Threading;
99
using System.Threading.Tasks;
10-
11-
using Microsoft.EntityFrameworkCore.Query.Internal;
12-
13-
using JetBrains.Annotations;
1410
using LinqToDB.Expressions;
11+
using Microsoft.EntityFrameworkCore.Query.Internal;
1512

1613
namespace LinqToDB.EntityFrameworkCore.Internal
1714
{
@@ -24,7 +21,7 @@ namespace LinqToDB.EntityFrameworkCore.Internal
2421
/// It may change or be removed without further notice.
2522
/// </summary>
2623
/// <typeparam name="T">Type of query element.</typeparam>
27-
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, System.Collections.Generic.IAsyncEnumerable<T>
24+
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, IAsyncEnumerable<T>
2825
{
2926
/// <summary>
3027
/// Creates instance of adapter.

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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,19 +1023,13 @@ static bool IsEnumerableType(Type type, MappingSchema mappingSchema)
10231023
var compilerField = typeof (EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance)!;
10241024
var compiler = (QueryCompiler)compilerField.GetValue(query.Provider)!;
10251025

1026-
var queryContextFactoryField = compiler.GetType().GetField("_queryContextFactory", BindingFlags.NonPublic | BindingFlags.Instance);
1027-
1028-
if (queryContextFactoryField == null)
1029-
throw new LinqToDBForEFToolsException($"Can not find private field '{compiler.GetType()}._queryContextFactory' in current EFCore Version.");
1030-
1026+
var queryContextFactoryField = compiler.GetType().GetField("_queryContextFactory", BindingFlags.NonPublic | BindingFlags.Instance)
1027+
?? throw new LinqToDBForEFToolsException($"Can not find private field '{compiler.GetType()}._queryContextFactory' in current EFCore Version.");
10311028
if (queryContextFactoryField.GetValue(compiler) is not RelationalQueryContextFactory queryContextFactory)
10321029
throw new LinqToDBForEFToolsException("LinqToDB Tools for EFCore support only Relational Databases.");
10331030

1034-
var dependenciesProperty = typeof(RelationalQueryContextFactory).GetField("_dependencies", BindingFlags.NonPublic | BindingFlags.Instance);
1035-
1036-
if (dependenciesProperty == null)
1037-
throw new LinqToDBForEFToolsException($"Can not find private property '{nameof(RelationalQueryContextFactory)}._dependencies' in current EFCore Version.");
1038-
1031+
var dependenciesProperty = typeof(RelationalQueryContextFactory).GetField("_dependencies", BindingFlags.NonPublic | BindingFlags.Instance)
1032+
?? throw new LinqToDBForEFToolsException($"Can not find private property '{nameof(RelationalQueryContextFactory)}._dependencies' in current EFCore Version.");
10391033
var dependencies = (QueryContextDependencies) dependenciesProperty.GetValue(queryContextFactory);
10401034

10411035
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: 2 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>
@@ -23,6 +21,8 @@
2321
<ItemGroup>
2422
<PackageReference Include="linq2db" />
2523
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
24+
25+
<PackageReference Include="PolySharp" />
2626
<PackageReference Include="Microsoft.SourceLink.GitHub">
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Project>
2-
<Import Project="linq2db.Default.props" />
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="$(MSBuildThisFileDirectory)\..\Directory.Build.props" />
33

44
<PropertyGroup>
5-
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
7+
<NoWarn>$(NoWarn);CS1591</NoWarn>
68
</PropertyGroup>
7-
9+
810
<ItemGroup>
911
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1012
<PackageReference Include="NUnit3TestAdapter">

0 commit comments

Comments
 (0)