Skip to content

Commit 43dcb95

Browse files
committed
Remove most remaining analyzer and nullable warnings
1 parent 050c209 commit 43dcb95

43 files changed

Lines changed: 165 additions & 95 deletions

Some content is hidden

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

src/RepoDb.PostgreSql.BulkOperations/Compiler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private static Action<NpgsqlBinaryImporter, TEntity> GetFunc(string tableName,
159159

160160
// Check
161161
Action<NpgsqlBinaryImporter, TEntity> func;
162-
if (expressions.Any())
162+
if (expressions.Count > 0)
163163
{
164164
func = Expression
165165
.Lambda<Action<NpgsqlBinaryImporter, TEntity>>(Expression.Block(expressions), importerParameterExpression, entityParameterExpression)
@@ -328,7 +328,7 @@ private static Func<NpgsqlBinaryImporter, TEntity, CancellationToken, Task> GetF
328328

329329
// Check
330330
Func<NpgsqlBinaryImporter, TEntity, CancellationToken, Task> func;
331-
if (expressions.Any())
331+
if (expressions.Count > 0)
332332
{
333333
func = Expression
334334
.Lambda<Func<NpgsqlBinaryImporter, TEntity, CancellationToken, Task>>(Expression.Block(expressions),
@@ -490,7 +490,7 @@ private static Expression GetEntityPropertyExpressionForEnum(Expression property
490490
/// <param name="propertyExpression"></param>
491491
/// <returns></returns>
492492
/// <exception cref="InvalidOperationException"></exception>
493-
private static Expression ConvertEnumExpressionToString(Expression propertyExpression) =>
493+
private static MethodCallExpression ConvertEnumExpressionToString(Expression propertyExpression) =>
494494
Expression.Call(GetConvertToTypeMethod(typeof(string)),
495495
Expression.Convert(propertyExpression, typeof(object)));
496496

src/RepoDb/BaseRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public Task<int> ExecuteNonQueryAsync(string commandText,
554554
/// <param name="transaction">The transaction to be used.</param>
555555
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
556556
/// <returns>A first occurrence value (first column of first row) of the execution.</returns>
557-
public Task<TResult> ExecuteScalarAsync<TResult>(string commandText,
557+
public Task<TResult?> ExecuteScalarAsync<TResult>(string commandText,
558558
object? param = null,
559559
CommandType commandType = default,
560560
string? cacheKey = null,

src/RepoDb/Cachers/MemoryCache.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace RepoDb;
1010
/// </summary>
1111
#pragma warning disable CA1010 // Generic interface should also be implemented
1212
public class MemoryCache : ICache
13-
#pragma warning restore CA1010 // Generic interface should also be implemented
1413
{
1514
private readonly ConcurrentDictionary<string, IExpirable> _cache = new();
1615

src/RepoDb/Contexts/Cachers/MergeAllExecutionContextCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal static void Add(string key,
3030
/// </summary>
3131
/// <param name="key"></param>
3232
/// <returns></returns>
33-
internal static MergeAllExecutionContext Get(string key)
33+
internal static MergeAllExecutionContext? Get(string key)
3434
{
3535
if (cache.TryGetValue(key, out var result))
3636
{

src/RepoDb/Contexts/Providers/InsertExecutionContextProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private static InsertExecutionContext CreateInternal(Type entityType,
201201
ParametersSetterFunc = FunctionCache
202202
.GetDataEntityDbParameterSetterCompiledFunction(entityType,
203203
string.Concat(entityType.FullName, ".", tableName, ".Insert"),
204-
inputFields?.AsList(),
204+
inputFields,
205205
null,
206206
dbSetting,
207207
dbHelper),

src/RepoDb/Contexts/Providers/MergeExecutionContextProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private static MergeExecutionContext CreateInternal(Type entityType,
216216
ParametersSetterFunc = FunctionCache
217217
.GetDataEntityDbParameterSetterCompiledFunction(entityType,
218218
string.Concat(entityType.FullName, ".", tableName, ".Merge"),
219-
inputFields?.AsList(),
219+
inputFields,
220220
null,
221221
dbSetting,
222222
dbHelper),

src/RepoDb/Contexts/Providers/UpdateExecutionContextProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private static UpdateExecutionContext CreateInternal(Type entityType,
200200
InputFields = inputFields,
201201
ParametersSetterFunc = FunctionCache.GetDataEntityDbParameterSetterCompiledFunction(entityType,
202202
string.Concat(entityType.FullName, ".", tableName, ".Update"),
203-
inputFields?.AsList(),
203+
inputFields,
204204
null,
205205
dbSetting,
206206
dbHelper)

src/RepoDb/DataEntityDataReader.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace RepoDb;
1010
/// A data reader object that is used to manipulate the enumerable list of data entity objects.
1111
/// </summary>
1212
/// <typeparam name="TEntity">The type of the data entity</typeparam>
13+
#pragma warning disable CA1010 // Generic interface should also be implemented
1314
public class DataEntityDataReader<TEntity> : DbDataReader
1415
where TEntity : class
1516
{
@@ -680,7 +681,7 @@ private IEnumerable<ClassProperty> GetClassProperties()
680681
{
681682
if (isDictionaryStringObject)
682683
{
683-
return Enumerable.Empty<ClassProperty>();
684+
return [];
684685
}
685686
return PropertyCache.Get(EntityType);
686687
}

src/RepoDb/DbRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ public async Task<int> ExecuteNonQueryAsync(string commandText,
820820
/// <param name="transaction">The transaction to be used.</param>
821821
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
822822
/// <returns>A first occurrence value (first column of first row) of the execution.</returns>
823-
public async Task<TResult> ExecuteScalarAsync<TResult>(string commandText,
823+
public async Task<TResult?> ExecuteScalarAsync<TResult>(string commandText,
824824
object? param = null,
825825
CommandType commandType = default,
826826
string? cacheKey = null,

src/RepoDb/Extensions/DataEntityExtension.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,8 @@ internal static PropertyInfo GetPropertyOrThrow<TEntity>(string propertyName)
167167
private static PropertyInfo GetPropertyOrThrow(Type type,
168168
string propertyName)
169169
{
170-
var property = TypeExtension.GetProperty(type, propertyName);
171-
if (property == null)
172-
{
173-
throw new PropertyNotFoundException(nameof(propertyName), $"The property '{propertyName}' is not found from type '{type.FullName}'.");
174-
}
170+
var property = TypeExtension.GetProperty(type, propertyName) ?? throw new PropertyNotFoundException(nameof(propertyName), $"The property '{propertyName}' is not found from type '{type.FullName}'.");
171+
175172
return property;
176173
}
177174

@@ -181,7 +178,7 @@ private static PropertyInfo GetPropertyOrThrow(Type type,
181178
/// <typeparam name="TEntity"></typeparam>
182179
/// <param name="propertyName"></param>
183180
/// <returns></returns>
184-
internal static ClassProperty GetClassPropertyOrThrow<TEntity>(string propertyName)
181+
internal static ClassProperty GetClassPropertyOrThrow<TEntity>(string? propertyName)
185182
where TEntity : class =>
186183
GetClassPropertyOrThrow(typeof(TEntity), propertyName);
187184

@@ -192,7 +189,7 @@ internal static ClassProperty GetClassPropertyOrThrow<TEntity>(string propertyNa
192189
/// <param name="propertyName"></param>
193190
/// <returns></returns>
194191
private static ClassProperty GetClassPropertyOrThrow(Type type,
195-
string propertyName)
192+
string? propertyName)
196193
{
197194
return PropertyCache
198195
.Get(type)?

0 commit comments

Comments
 (0)