Skip to content

Commit 6556367

Browse files
committed
Addressing recently introduced warnings
1 parent c24aa32 commit 6556367

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/DotNetWorker.Core/Context/Features/InvocationFeatures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public InvocationFeatures(IEnumerable<IInvocationFeatureProvider> featureProvide
3131
}
3232
}
3333

34-
return (T)feature;
34+
return feature is null ? default : (T)feature;
3535
}
3636

3737
public IEnumerator<KeyValuePair<Type, object>> GetEnumerator()

src/DotNetWorker.Core/Context/FunctionContextLoggerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class FunctionContextLoggerExtensions
1818
/// <returns>The <see cref="ILogger{T}"/>.</returns>
1919
public static ILogger<T> GetLogger<T>(this FunctionContext context)
2020
{
21-
return context.InstanceServices.GetService<ILogger<T>>();
21+
return context.InstanceServices.GetService<ILogger<T>>()!;
2222
}
2323

2424
/// <summary>
@@ -30,7 +30,7 @@ public static ILogger<T> GetLogger<T>(this FunctionContext context)
3030
public static ILogger GetLogger(this FunctionContext context, string categoryName)
3131
{
3232
return context.InstanceServices
33-
.GetService<ILoggerFactory>()
33+
.GetService<ILoggerFactory>()!
3434
.CreateLogger(categoryName);
3535
}
3636
}

src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Threading.Channels;
56
using Grpc.Core;
67
using Grpc.Net.Client;
@@ -47,7 +48,9 @@ public static IServiceCollection AddGrpc(this IServiceCollection services)
4748
services.AddSingleton<IWorker, GrpcWorker>();
4849
services.AddSingleton<FunctionRpcClient>(p =>
4950
{
50-
IOptions<GrpcWorkerStartupOptions> argumentsOptions = p.GetService<IOptions<GrpcWorkerStartupOptions>>();
51+
IOptions<GrpcWorkerStartupOptions> argumentsOptions = p.GetService<IOptions<GrpcWorkerStartupOptions>>()
52+
?? throw new InvalidOperationException("gRPC Serivces are not correctly registered.");
53+
5154
GrpcWorkerStartupOptions arguments = argumentsOptions.Value;
5255

5356
GrpcChannel grpcChannel = GrpcChannel.ForAddress($"http://{arguments.Host}:{arguments.Port}", new GrpcChannelOptions()

0 commit comments

Comments
 (0)