Skip to content

Commit 5fece6d

Browse files
ChrisJollyAUgithub-actions
andauthored
Cleanup (#261)
* Use primary constructors Remove 2 obsolete tests * fix build * [GitHub Actions] Update green tests. --------- Co-authored-by: github-actions <github-actions@github.com>
1 parent f199d04 commit 5fece6d

141 files changed

Lines changed: 428 additions & 1218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/EFCore.Jet.Data/ConnectionPooling/ConnectionSet.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33

44
namespace EntityFrameworkCore.Jet.Data.ConnectionPooling
55
{
6-
class ConnectionSet : IDisposable
6+
class ConnectionSet(string connectionString) : IDisposable
77
{
8-
public ConnectionSet(string connectionString)
9-
{
10-
ConnectionString = connectionString;
11-
_connections = new DbConnection[10];
12-
ConnectionCount = 0;
13-
}
14-
15-
public string ConnectionString { get; }
8+
public string ConnectionString { get; } = connectionString;
169

17-
private DbConnection[] _connections;
18-
public int ConnectionCount { get; private set; }
10+
private DbConnection[] _connections = new DbConnection[10];
11+
public int ConnectionCount { get; private set; } = 0;
1912

2013
public void AddConnection(DbConnection connection)
2114
{

src/EFCore.Jet.Data/PreciseSchema.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33

44
namespace EntityFrameworkCore.Jet.Data
55
{
6-
public class PreciseSchema : SchemaProvider
6+
public class PreciseSchema(JetConnection connection, bool readOnly) : SchemaProvider
77
{
8-
private readonly Lazy<AdoxSchema> _adoxSchema;
9-
private readonly Lazy<DaoSchema> _daoSchema;
10-
11-
public PreciseSchema(JetConnection connection, bool readOnly)
12-
{
13-
_adoxSchema = new Lazy<AdoxSchema>(() => new AdoxSchema(connection, true, readOnly), false);
14-
_daoSchema = new Lazy<DaoSchema>(() => new DaoSchema(connection, true, readOnly), false);
15-
}
8+
private readonly Lazy<AdoxSchema> _adoxSchema = new(() => new AdoxSchema(connection, true, readOnly), false);
9+
private readonly Lazy<DaoSchema> _daoSchema = new(() => new DaoSchema(connection, true, readOnly), false);
1610

1711
public override void EnsureDualTable()
1812
=> _adoxSchema.Value.EnsureDualTable(); // prefer ADOX, but DAO works too (but less precise)

src/EFCore.Jet/Infrastructure/Internal/JetOptionsExtension.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,11 @@ public virtual JetOptionsExtension WithUseShortTextForSystemString(bool enabled)
198198
public override void ApplyServices(IServiceCollection services)
199199
=> services.AddEntityFrameworkJet();
200200

201-
private sealed class ExtensionInfo : RelationalExtensionInfo
201+
private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : RelationalExtensionInfo(extension)
202202
{
203203
private int? _serviceProviderHash;
204204
private string? _logFragment;
205205

206-
public ExtensionInfo(IDbContextOptionsExtension extension)
207-
: base(extension)
208-
{
209-
}
210-
211206
private new JetOptionsExtension Extension
212207
=> (JetOptionsExtension)base.Extension;
213208

src/EFCore.Jet/Metadata/Conventions/JetConventionSetBuilder.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,19 @@
1010
// ReSharper disable once CheckNamespace
1111
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions
1212
{
13-
public class JetConventionSetBuilder : RelationalConventionSetBuilder
13+
public class JetConventionSetBuilder(
14+
[NotNull] ProviderConventionSetBuilderDependencies dependencies,
15+
[NotNull] RelationalConventionSetBuilderDependencies relationalDependencies,
16+
ISqlGenerationHelper sqlGenerationHelper)
17+
: RelationalConventionSetBuilder(dependencies, relationalDependencies)
1418
{
15-
private readonly ISqlGenerationHelper _sqlGenerationHelper;
16-
public JetConventionSetBuilder(
17-
[NotNull] ProviderConventionSetBuilderDependencies dependencies,
18-
[NotNull] RelationalConventionSetBuilderDependencies relationalDependencies,
19-
ISqlGenerationHelper sqlGenerationHelper)
20-
: base(dependencies, relationalDependencies)
21-
{
22-
_sqlGenerationHelper = sqlGenerationHelper;
23-
}
24-
2519
public override ConventionSet CreateConventionSet()
2620
{
2721
var conventionSet = base.CreateConventionSet();
2822

2923
conventionSet.Add(new JetValueGenerationStrategyConvention(Dependencies, RelationalDependencies));
3024
conventionSet.Add(new RelationalMaxIdentifierLengthConvention(64, Dependencies, RelationalDependencies));
31-
conventionSet.Add(new JetIndexConvention(Dependencies, RelationalDependencies, _sqlGenerationHelper));
25+
conventionSet.Add(new JetIndexConvention(Dependencies, RelationalDependencies, sqlGenerationHelper));
3226

3327
conventionSet.Replace<CascadeDeleteConvention>(
3428
new JetOnDeleteConvention(Dependencies, RelationalDependencies));

src/EFCore.Jet/Metadata/Conventions/JetOnDeleteConvention.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;
1212
/// A convention that configures the OnDelete behavior for foreign keys on the join entity type for
1313
/// self-referencing skip navigations
1414
/// </summary>
15-
public class JetOnDeleteConvention : CascadeDeleteConvention,
16-
ISkipNavigationForeignKeyChangedConvention,
17-
IEntityTypeAnnotationChangedConvention
15+
public class JetOnDeleteConvention(
16+
ProviderConventionSetBuilderDependencies dependencies,
17+
RelationalConventionSetBuilderDependencies relationalDependencies)
18+
: CascadeDeleteConvention(dependencies),
19+
ISkipNavigationForeignKeyChangedConvention,
20+
IEntityTypeAnnotationChangedConvention
1821
{
19-
public JetOnDeleteConvention(
20-
ProviderConventionSetBuilderDependencies dependencies,
21-
RelationalConventionSetBuilderDependencies relationalDependencies)
22-
: base(dependencies)
23-
{
24-
RelationalDependencies = relationalDependencies;
25-
}
26-
2722
/// <summary>
2823
/// Relational provider-specific dependencies for this service.
2924
/// </summary>
30-
protected virtual RelationalConventionSetBuilderDependencies RelationalDependencies { get; }
25+
protected virtual RelationalConventionSetBuilderDependencies RelationalDependencies { get; } = relationalDependencies;
3126

3227
/// <inheritdoc />
3328
public virtual void ProcessSkipNavigationForeignKeyChanged(

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetConvertTranslator.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
1515
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
1616
/// directly from your code. This API may change or be removed in future releases.
1717
/// </summary>
18-
public class JetConvertTranslator : IMethodCallTranslator
18+
public class JetConvertTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMethodCallTranslator
1919
{
20-
private readonly JetSqlExpressionFactory _sqlExpressionFactory;
20+
private readonly JetSqlExpressionFactory _sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
2121

2222
// The value here is actually never used.
2323
private static readonly Dictionary<string, string> _functionName = new Dictionary<string, string>
@@ -61,9 +61,6 @@ private static readonly IEnumerable<MethodInfo> _supportedMethods
6161
.ParameterType)))
6262
.ToList();
6363

64-
public JetConvertTranslator(ISqlExpressionFactory sqlExpressionFactory)
65-
=> _sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
66-
6764

6865
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)
6966
{

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetDateDiffFunctionsTranslator.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
1212
{
13-
public class JetDateDiffFunctionsTranslator : IMethodCallTranslator
13+
public class JetDateDiffFunctionsTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMethodCallTranslator
1414
{
1515
private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
1616
= new Dictionary<MethodInfo, string>
@@ -197,14 +197,6 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
197197
},
198198
};
199199

200-
private readonly ISqlExpressionFactory _sqlExpressionFactory;
201-
202-
public JetDateDiffFunctionsTranslator(
203-
ISqlExpressionFactory sqlExpressionFactory)
204-
{
205-
_sqlExpressionFactory = sqlExpressionFactory;
206-
}
207-
208200
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)
209201
{
210202
if (_methodInfoDateDiffMapping.TryGetValue(method, out var datePart))
@@ -213,12 +205,12 @@ public JetDateDiffFunctionsTranslator(
213205
var endDate = arguments[2];
214206
var typeMapping = ExpressionExtensions.InferTypeMapping(startDate, endDate);
215207

216-
startDate = _sqlExpressionFactory.ApplyTypeMapping(startDate, typeMapping);
217-
endDate = _sqlExpressionFactory.ApplyTypeMapping(endDate, typeMapping);
208+
startDate = sqlExpressionFactory.ApplyTypeMapping(startDate, typeMapping);
209+
endDate = sqlExpressionFactory.ApplyTypeMapping(endDate, typeMapping);
218210

219-
return _sqlExpressionFactory.Function(
211+
return sqlExpressionFactory.Function(
220212
"DATEDIFF",
221-
new[] { _sqlExpressionFactory.Constant(datePart), startDate, endDate },
213+
new[] { sqlExpressionFactory.Constant(datePart), startDate, endDate },
222214
false,
223215
new[] {false, false, false},
224216
typeof(int));

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetDateTimeMemberTranslator.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
1616
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
1717
/// directly from your code. This API may change or be removed in future releases.
1818
/// </summary>
19-
public class JetDateTimeMemberTranslator : IMemberTranslator
19+
public class JetDateTimeMemberTranslator(
20+
ISqlExpressionFactory sqlExpressionFactory,
21+
IRelationalTypeMappingSource typeMappingSource)
22+
: IMemberTranslator
2023
{
2124
private static readonly Dictionary<string, string> DatePartMapping
2225
= new()
@@ -32,16 +35,8 @@ private static readonly Dictionary<string, string> DatePartMapping
3235
//{ nameof(DateTime.Millisecond), "millisecond" }
3336
};
3437

35-
private readonly JetSqlExpressionFactory _sqlExpressionFactory;
36-
private readonly IRelationalTypeMappingSource _typeMappingSource;
37-
38-
public JetDateTimeMemberTranslator(
39-
ISqlExpressionFactory sqlExpressionFactory,
40-
IRelationalTypeMappingSource typeMappingSource)
41-
{
42-
_sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
43-
_typeMappingSource = typeMappingSource;
44-
}
38+
private readonly JetSqlExpressionFactory _sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
39+
private readonly IRelationalTypeMappingSource _typeMappingSource = typeMappingSource;
4540

4641
/// <summary>
4742
/// This API supports the Entity Framework Core infrastructure and is not intended to be used

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetDateTimeMethodTranslator.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
1616
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
1717
/// directly from your code. This API may change or be removed in future releases.
1818
/// </summary>
19-
public class JetDateTimeMethodTranslator : IMethodCallTranslator
19+
public class JetDateTimeMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMethodCallTranslator
2020
{
21-
private readonly JetSqlExpressionFactory _sqlExpressionFactory;
21+
private readonly JetSqlExpressionFactory _sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
2222

2323
private readonly Dictionary<MethodInfo, string> _methodInfoDatePartMapping = new Dictionary<MethodInfo, string>
2424
{
@@ -44,9 +44,6 @@ public class JetDateTimeMethodTranslator : IMethodCallTranslator
4444
{ typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.ToUnixTimeMilliseconds), Type.EmptyTypes)!, "millisecond" }
4545
};
4646

47-
public JetDateTimeMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
48-
=> _sqlExpressionFactory = (JetSqlExpressionFactory)sqlExpressionFactory;
49-
5047
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)
5148
{
5249
if (_methodInfoDatePartMapping.TryGetValue(method, out var datePart) && instance != null)

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetIsDateFunctionTranslator.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99

1010
namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
1111
{
12-
public class JetIsDateFunctionTranslator : IMethodCallTranslator
12+
public class JetIsDateFunctionTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMethodCallTranslator
1313
{
14-
private readonly ISqlExpressionFactory _sqlExpressionFactory;
15-
1614
private static readonly MethodInfo _methodInfo = typeof(JetDbFunctionsExtensions)
1715
.GetRuntimeMethod(nameof(JetDbFunctionsExtensions.IsDate), new[] { typeof(DbFunctions), typeof(string) })!;
1816

19-
public JetIsDateFunctionTranslator(ISqlExpressionFactory sqlExpressionFactory)
20-
=> _sqlExpressionFactory = sqlExpressionFactory;
21-
2217
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)
2318
{
2419
return _methodInfo.Equals(method)
25-
? _sqlExpressionFactory.Convert(
26-
_sqlExpressionFactory.Function(
20+
? sqlExpressionFactory.Convert(
21+
sqlExpressionFactory.Function(
2722
"ISDATE",
2823
new[] { arguments[1] },
2924
false,

0 commit comments

Comments
 (0)