Skip to content

Commit b4d52a1

Browse files
authored
Merge branch 'master' into upstream/buildDomains
2 parents ace167e + a4e02e6 commit b4d52a1

93 files changed

Lines changed: 394 additions & 347 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.

ChangeLog/7.1.0-Beta-2-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[main] Obsolete FieldInfo.IsDynalicallyDefined property's been removed (FieldInfo.IsDynamicallyDefined is still there)
1010
[main] Some EventArgs inheritors that were sealed classes transformed to read-only structures
1111
[main] DbCommandEventArgs became read-only structure
12+
[main] Xtensive.Sql.Dml.Extensions.IsNullReference() extension method is marked obsolete, use 'is null' operator instead
1213
[main] BitFaster.Caching package reference is updated to 1.0.7
1314
[main] No error caused by ambiguity due to new IQueryable extension methods of .Net 6
1415
[reprocessing] DomainBuildErrorEventArgs (not sealed) became read-only structure

Extensions/Xtensive.Orm.BulkOperations/Internals/QueryOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ private void JoinViaIn(SqlStatement statement, SqlSelect select)
142142
var s = (SqlSelect) select.Clone();
143143
foreach (var column in columns) {
144144
var ex = SqlDml.Equals(s.From.Columns[column.Name], table.Columns[column.Name]);
145-
s.Where = s.Where.IsNullReference() ? ex : SqlDml.And(s.Where, ex);
145+
s.Where = s.Where is null ? ex : SqlDml.And(s.Where, ex);
146146
}
147147
var existingColumns = s.Columns.ToChainedBuffer();
148148
s.Columns.Clear();
149149
var columnToAdd = existingColumns.First(c => c.Name.Equals(columnInfo.Name, StringComparison.Ordinal));
150150
s.Columns.Add(columnToAdd);
151151
var @in = SqlDml.In(SqlDml.TableColumn(table, columnInfo.Name), s);
152-
where = where.IsNullReference() ? @in : SqlDml.And(where, @in);
152+
where = where is null ? @in : SqlDml.And(where, @in);
153153
columns.Add(columnInfo);
154154
}
155155

Extensions/Xtensive.Orm.Logging.NLog/Log.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2020 Xtensive LLC.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
@@ -17,22 +17,6 @@ public class Log : BaseLog
1717
{
1818
private readonly Logger target;
1919

20-
private static NLogLevel ConvertLevel(LogLevel level)
21-
{
22-
switch (level) {
23-
case LogLevel.Debug:
24-
return NLogLevel.Debug;
25-
case LogLevel.Error:
26-
return NLogLevel.Error;
27-
case LogLevel.FatalError:
28-
return NLogLevel.Fatal;
29-
case LogLevel.Warning:
30-
return NLogLevel.Warn;
31-
default:
32-
return NLogLevel.Info;
33-
}
34-
}
35-
3620
/// <inheritdoc/>
3721
public override bool IsLogged(LogLevel level)
3822
{
@@ -48,6 +32,22 @@ public override void Write(in LogEventInfo info)
4832
target.Log(ConvertLevel(info.Level), info.FormattedMessage);
4933
}
5034

35+
private static NLogLevel ConvertLevel(in LogLevel level)
36+
{
37+
switch (level) {
38+
case LogLevel.Debug:
39+
return NLogLevel.Debug;
40+
case LogLevel.Error:
41+
return NLogLevel.Error;
42+
case LogLevel.FatalError:
43+
return NLogLevel.Fatal;
44+
case LogLevel.Warning:
45+
return NLogLevel.Warn;
46+
default:
47+
return NLogLevel.Info;
48+
}
49+
}
50+
5151
/// <summary>
5252
/// Creates instance of <see cref="Log"/> class.
5353
/// </summary>
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2014-2020 Xtensive LLC.
1+
// Copyright (C) 2014-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
@@ -16,25 +16,7 @@ namespace Xtensive.Orm.Logging.log4net
1616
/// </summary>
1717
public class Log : BaseLog
1818
{
19-
private log4netLog target;
20-
21-
private Level ConvertLevel(LogLevel level)
22-
{
23-
switch (level) {
24-
case LogLevel.Debug:
25-
return Level.Debug;
26-
case LogLevel.Info:
27-
return Level.Info;
28-
case LogLevel.Warning:
29-
return Level.Warn;
30-
case LogLevel.Error:
31-
return Level.Error;
32-
case LogLevel.FatalError:
33-
return Level.Fatal;
34-
default:
35-
return Level.Info;
36-
}
37-
}
19+
private readonly log4netLog target;
3820

3921
/// <inheritdoc />
4022
public override bool IsLogged(LogLevel level)
@@ -48,6 +30,24 @@ public override void Write(in LogEventInfo info)
4830
target.Logger.Log(target.Logger.GetType(), ConvertLevel(info.Level), info.FormattedMessage, info.Exception);
4931
}
5032

33+
private Level ConvertLevel(in LogLevel level)
34+
{
35+
switch (level) {
36+
case LogLevel.Debug:
37+
return Level.Debug;
38+
case LogLevel.Info:
39+
return Level.Info;
40+
case LogLevel.Warning:
41+
return Level.Warn;
42+
case LogLevel.Error:
43+
return Level.Error;
44+
case LogLevel.FatalError:
45+
return Level.Fatal;
46+
default:
47+
return Level.Info;
48+
}
49+
}
50+
5151
/// <summary>
5252
/// Creates instance of <see cref="Log"/> class.
5353
/// </summary>
@@ -57,6 +57,7 @@ public override void Write(in LogEventInfo info)
5757
public Log(Assembly repositoryAssembly, string name)
5858
{
5959
target = log4netLogManager.GetLogger(repositoryAssembly, name);
60+
6061
}
6162
}
6263
}

Extensions/Xtensive.Orm.Security/Permission.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011 Xtensive LLC.
1+
// Copyright (C) 2011 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Dmitri Maximov
@@ -41,15 +41,15 @@ public abstract class Permission
4141
/// <inheritdoc/>
4242
public bool Equals(Permission other)
4343
{
44-
if (ReferenceEquals(null, other)) return false;
44+
if (other is null) return false;
4545
if (ReferenceEquals(this, other)) return true;
4646
return Equals(other.Type, Type) && other.CanRead.Equals(CanRead) && other.CanWrite.Equals(CanWrite) && Equals(other.Query, Query);
4747
}
4848

4949
/// <inheritdoc/>
5050
public override bool Equals(object obj)
5151
{
52-
if (ReferenceEquals(null, obj)) return false;
52+
if (obj is null) return false;
5353
if (ReferenceEquals(this, obj)) return true;
5454
if (obj.GetType() != typeof (Permission)) return false;
5555
return Equals((Permission) obj);

Extensions/Xtensive.Orm.Web/ApplicationBuilderExtensions.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.AspNetCore.Mvc.Filters;
9+
using Xtensive.Orm.Web.Filters;
10+
using Xtensive.Orm.Web.Middleware;
11+
12+
namespace Xtensive.Orm.Web
13+
{
14+
/// <summary>
15+
/// Contains extensions which are used in Startup.cs to configure application
16+
/// </summary>
17+
public static class StartupConfigurationExtensions
18+
{
19+
/// <summary>
20+
/// Adds <see cref="OpenSessionMiddleware"/> to ASP.NET Core middleware pipeline.
21+
/// </summary>
22+
/// <param name="builder"><see cref="IApplicationBuilder"/> instance.</param>
23+
/// <returns><paramref name="builder"/> with <see cref="OpenSessionMiddleware"/>.</returns>
24+
public static IApplicationBuilder UseDataObjectsSessionOpener(this IApplicationBuilder builder) =>
25+
builder.UseMiddleware<OpenSessionMiddleware>();
26+
27+
/// <summary>
28+
/// Registers a <see cref="SessionAccessor"/> as scoped service to be able to
29+
/// have access to session/transaction as parameter in either MVC controllers' actions or
30+
/// constuctors, and in Razor Pages.
31+
/// </summary>
32+
/// <param name="services">A service collection to add <see cref="SessionAccessor"/>.</param>
33+
/// <returns>The same collection instance with registered accessor.</returns>
34+
public static IServiceCollection AddDataObjectsSessionAccessor(this IServiceCollection services) =>
35+
services.AddScoped<SessionAccessor>();
36+
37+
/// <summary>
38+
/// Adds <see cref="SessionActionFilter"/> to action filters.
39+
/// </summary>
40+
/// <param name="filters">The filter collection to add the filter.</param>
41+
/// <returns>A <see cref="IFilterMetadata"/> representing added filter.</returns>
42+
public static IFilterMetadata AddDataObjectsSessionActionFilter(this FilterCollection filters) =>
43+
AddDataObjectsSessionActionFilter(filters, 0);
44+
45+
/// <summary>
46+
/// Adds <see cref="SessionActionFilter"/> to action filters.
47+
/// </summary>
48+
/// <param name="filters">The filter collection to add the filter.</param>
49+
/// <param name="order">The order of the added filter.</param>
50+
/// <returns>A <see cref="IFilterMetadata"/> representing added filter.</returns>
51+
public static IFilterMetadata AddDataObjectsSessionActionFilter(this FilterCollection filters, int order) =>
52+
filters.Add(typeof(SessionActionFilter), order);
53+
}
54+
}

Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/v5_0/Compiler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ public override void Visit(SqlFunctionCall node)
190190
/// <inheritdoc/>
191191
protected override void VisitSelectLimitOffset(SqlSelect node)
192192
{
193-
if (!node.Limit.IsNullReference()) {
193+
if (node.Limit is not null) {
194194
AppendTranslated(node, SelectSection.Limit);
195195
node.Limit.AcceptVisitor(this);
196196
}
197-
if (!node.Offset.IsNullReference()) {
198-
if (node.Limit.IsNullReference()) {
197+
if (node.Offset is not null) {
198+
if (node.Limit is null) {
199199
AppendTranslated(node, SelectSection.Limit);
200200
_ = context.Output.Append(" 18446744073709551615 "); // magic number from http://dev.mysql.com/doc/refman/5.0/en/select.html
201201
}

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Compiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Visit(SqlDeclareCursor node)
3131
public override void Visit(SqlBinary node)
3232
{
3333
var right = node.Right as SqlArray;
34-
if (!right.IsNullReference() && (node.NodeType is SqlNodeType.In or SqlNodeType.NotIn)) {
34+
if (right is not null && (node.NodeType is SqlNodeType.In or SqlNodeType.NotIn)) {
3535
var row = SqlDml.Row(right.GetValues().Select(value => SqlDml.Literal(value)).ToArray());
3636
base.Visit(node.NodeType == SqlNodeType.In ? SqlDml.In(node.Left, row) : SqlDml.NotIn(node.Left, row));
3737
}

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Compiler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override void Visit(SqlUpdate node)
7575
/// <inheritdoc/>
7676
protected override void VisitUpdateLimit(SqlUpdate node)
7777
{
78-
if (!node.Limit.IsNullReference()) {
78+
if (node.Limit is not null) {
7979
if (!Driver.ServerInfo.Query.Features.Supports(QueryFeatures.UpdateLimit)) {
8080
throw new NotSupportedException(Strings.ExStorageDoesNotSupportLimitationOfRowCountToUpdate);
8181
}
@@ -104,7 +104,7 @@ public override void Visit(SqlDelete node)
104104
/// <inheritdoc/>
105105
protected override void VisitDeleteLimit(SqlDelete node)
106106
{
107-
if (!node.Limit.IsNullReference()) {
107+
if (node.Limit is not null) {
108108
if (!Driver.ServerInfo.Query.Features.Supports(QueryFeatures.DeleteLimit)) {
109109
throw new NotSupportedException(Strings.ExStorageDoesNotSupportLimitationOfRowCountToDelete);
110110
}
@@ -287,12 +287,12 @@ public override void Visit(SqlRound node)
287287
var shouldCastToDecimal = node.Type==TypeCode.Decimal;
288288
switch (node.Mode) {
289289
case MidpointRounding.ToEven:
290-
result = node.Length.IsNullReference()
290+
result = node.Length is null
291291
? BankersRound(node.Argument, shouldCastToDecimal)
292292
: BankersRound(node.Argument, node.Length, shouldCastToDecimal);
293293
break;
294294
case MidpointRounding.AwayFromZero:
295-
result = node.Length.IsNullReference()
295+
result = node.Length is null
296296
? RegularRound(node.Argument, shouldCastToDecimal)
297297
: RegularRound(node.Argument, node.Length, shouldCastToDecimal);
298298
break;

0 commit comments

Comments
 (0)