Skip to content

Commit 92b213e

Browse files
committed
update Nullable Reference Types VS 16.2
1 parent 99a38a2 commit 92b213e

34 files changed

+216
-116
lines changed

Signum.Engine/BulkInserter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static int BulkInsertQueryIds<T, K>(this IEnumerable<T> entities,
5959
int? timeout = null,
6060
string? message = null)
6161
where T : Entity
62-
where K : object
62+
where K : notnull
6363
{
6464
using (HeavyProfiler.Log(nameof(BulkInsertQueryIds), () => typeof(T).TypeName()))
6565
using (Transaction tr = new Transaction())

Signum.Engine/DynamicQuery/ExpressionContainer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public ExtensionDictionaryInfo<T, KVP, K, V> RegisterDictionary<T, KVP, K, V>(
108108
Expression<Func<KVP, V>> valueSelector,
109109
ResetLazy<HashSet<K>>? allKeys = null)
110110
where T : Entity
111-
where K : object
111+
where K : notnull
112112
{
113113
var mei = new ExtensionDictionaryInfo<T, KVP, K, V>(collectionSelector, keySelector, valueSelector,
114114
allKeys ?? GetAllKeysLazy<T, KVP, K>(collectionSelector, keySelector));
@@ -126,7 +126,7 @@ public ExtensionDictionaryInfo<M, KVP, K, V> RegisterDictionaryInEmbedded<T, M,
126126
ResetLazy<HashSet<K>>? allKeys = null)
127127
where T : Entity
128128
where M : ModifiableEntity
129-
where K : object
129+
where K : notnull
130130
{
131131
var mei = new ExtensionDictionaryInfo<M, KVP, K, V>(collectionSelector, keySelector, valueSelector,
132132
allKeys ?? GetAllKeysLazy<T, KVP, K>(CombineSelectors(embeddedSelector, collectionSelector), keySelector));
@@ -173,7 +173,7 @@ public interface IExtensionDictionaryInfo
173173
}
174174

175175
public class ExtensionDictionaryInfo<T, KVP, K, V> : IExtensionDictionaryInfo
176-
where K : object
176+
where K : notnull
177177
{
178178
public ResetLazy<HashSet<K>> AllKeys;
179179

Signum.Engine/Engine/Synchronizer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void Synchronize<K, N, O>(
1414
Action<K, N>? createNew,
1515
Action<K, O>? removeOld,
1616
Action<K, N, O>? merge)
17-
where K : object
17+
where K : notnull
1818
{
1919
HashSet<K> keys = new HashSet<K>();
2020
keys.UnionWith(oldDictionary.Keys);
@@ -48,7 +48,7 @@ public static void SynchronizeProgressForeach<K, N, O>(
4848
Action<K, N, O>? merge,
4949
bool showProgress = true,
5050
bool transactional = true)
51-
where K : object
51+
where K : notnull
5252
{
5353
HashSet<K> keys = new HashSet<K>();
5454
keys.UnionWith(oldDictionary.Keys);
@@ -120,7 +120,7 @@ public static void SynchronizeReplacing<N, O>(
120120
Func<K, N, O, SqlPreCommand?>? mergeBoth)
121121
where O : class
122122
where N : class
123-
where K : object
123+
where K : notnull
124124
{
125125
return newDictionary.OuterJoinDictionaryCC(oldDictionary, (key, newVal, oldVal) =>
126126
{

Signum.Engine/Linq/ExpressionVisitor/DbExpressionNominator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Collections.Generic;
99
using System.Collections.ObjectModel;
1010
using System.Data;
11+
using System.Diagnostics.CodeAnalysis;
1112
using System.Globalization;
1213
using System.Linq;
1314
using System.Linq.Expressions;
@@ -61,6 +62,7 @@ static internal HashSet<Expression> Nominate(Expression? expression, out Express
6162
return n.candidates;
6263
}
6364

65+
[return: NotNullIfNotNull("expression")]
6466
static internal Expression? FullNominate(Expression? expression)
6567
{
6668
DbExpressionNominator n = new DbExpressionNominator { isFullNominate = true };
@@ -69,6 +71,7 @@ static internal HashSet<Expression> Nominate(Expression? expression, out Express
6971
return result;
7072
}
7173

74+
[return: NotNullIfNotNull("expression")]
7275
static internal Expression? FullNominateNotNullable(Expression? expression)
7376
{
7477
DbExpressionNominator n = new DbExpressionNominator { isFullNominate = true, isNotNullRoot = expression };

Signum.Engine/Linq/ExpressionVisitor/DbExpressionVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected internal virtual Expression VisitTypeEntity(TypeEntityExpression typeF
9999

100100
[DebuggerStepThrough]
101101
protected static ReadOnlyDictionary<K, V> Visit<K, V>(ReadOnlyDictionary<K, V> dictionary, Func<V, V> newValue)
102-
where K : object
102+
where K : notnull
103103
where V : class
104104
{
105105
Dictionary<K, V>? alternate = null;

Signum.Engine/Linq/ExpressionVisitor/QueryBinder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ private ProjectionExpression GetTableValuedFunctionProjection(MethodCallExpressi
13241324

13251325
var functionName = mce.Method.GetCustomAttribute<SqlMethodAttribute>().Name ?? mce.Method.Name;
13261326

1327-
var argumens = mce.Arguments.Select(DbExpressionNominator.FullNominate).ToList();
1327+
var argumens = mce.Arguments.Select(a => DbExpressionNominator.FullNominate(a)!).ToList();
13281328

13291329
SqlTableValuedFunctionExpression tableExpression = new SqlTableValuedFunctionExpression(functionName, table, tableAlias, argumens);
13301330

@@ -2425,7 +2425,7 @@ public void FillColumnAssigments(List<ColumnAssignment> assignments, ParameterEx
24252425

24262426
private Exception InvalidBody()
24272427
{
2428-
throw new InvalidOperationException("The only allowed expressions on UnsafeInsert are: object initializers, calling method 'SetMixin', or or calling 'Administrator.SetReadonly'");
2428+
throw new InvalidOperationException("The only allowed expressions on UnsafeInsert are: notnull initializers, calling method 'SetMixin', or or calling 'Administrator.SetReadonly'");
24292429
}
24302430

24312431
private ColumnAssignment[] AdaptAssign(Expression colExpression, Expression exp)

Signum.Engine/Schema/SchemaBuilder/SchemaBuilderSettings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Collections.Concurrent;
1414
using Signum.Utilities.ExpressionTrees;
1515
using System.Runtime.CompilerServices;
16+
using Signum.Utilities.Reflection;
1617

1718
namespace Signum.Engine.Maps
1819
{
@@ -224,8 +225,8 @@ private IsNullable GetIsNullablePrivate(PropertyRoute propertyRoute)
224225
if (propertyRoute.Type.IsValueType)
225226
return propertyRoute.Type.IsNullable() ? IsNullable.Yes : IsNullable.No;
226227

227-
var nullable = FieldAttribute<NullableAttribute>(propertyRoute);
228-
if (nullable != null && nullable.IsNullableMain == true)
228+
var nullable = propertyRoute.FieldInfo?.IsNullable();
229+
if (nullable == true)
229230
return IsNullable.Yes;
230231

231232
return IsNullable.No;

Signum.Engine/Signum.Engine.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netcoreapp2.2</TargetFramework>
55
<LangVersion>preview</LangVersion>
66
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
7-
<NullableContextOptions>enable</NullableContextOptions>
7+
<Nullable>enable</Nullable>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
99
<Platforms>x64;x86;AnyCPU</Platforms>
1010
</PropertyGroup>

Signum.Entities/DynamicQuery/Tokens/ExtensionDictionaryToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Signum.Entities.DynamicQuery
88
{
99
[Serializable]
1010
public class ExtensionDictionaryToken<T, K, V> : QueryToken
11-
where K : object
11+
where K : notnull
1212
{
1313
QueryToken parent;
1414
public override QueryToken? Parent => parent;

Signum.Entities/Reflection/EntityStructuralEqualityComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public override int GetHashCode(T obj)
9797
}
9898

9999
public class ClassStructuralEqualityComparer<T> : EqualityComparer<T>, ICompletableComparer
100-
where T: object
100+
where T: notnull
101101
{
102102
public Dictionary<string, PropertyComparer<T>> Properties;
103103

0 commit comments

Comments
 (0)