From 7453881bb09a9af0fe2eb58f8ed61247d26524eb Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sun, 18 Aug 2024 21:02:57 -0400 Subject: [PATCH] Update --- .../WebSockets/GraphQLWs/SubscriptionServer.cs | 5 ++--- .../SubscriptionsTransportWs/SubscriptionServer.cs | 5 ++--- src/Tests/Middleware/WebSocketTests.cs | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs b/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs index 8e75172..d858588 100644 --- a/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs +++ b/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs @@ -182,10 +182,9 @@ await Connection.SendMessageAsync(new OperationMessage { /// protected override async Task ExecuteRequestAsync(OperationMessage message) { - var request = Serializer.ReadNode(message.Payload); #pragma warning disable CA2208 // Instantiate argument exceptions correctly - if (request == null) - throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload)); + var request = Serializer.ReadNode(message.Payload) + ?? throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload)); #pragma warning restore CA2208 // Instantiate argument exceptions correctly using var scope = ServiceScopeFactory.CreateScope(); try { diff --git a/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs b/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs index 4d41a11..2e72846 100644 --- a/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs +++ b/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs @@ -162,10 +162,9 @@ await Connection.SendMessageAsync(new OperationMessage { /// protected override async Task ExecuteRequestAsync(OperationMessage message) { - var request = Serializer.ReadNode(message.Payload); #pragma warning disable CA2208 // Instantiate argument exceptions correctly - if (request == null) - throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload)); + var request = Serializer.ReadNode(message.Payload) + ?? throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload)); #pragma warning restore CA2208 // Instantiate argument exceptions correctly using var scope = ServiceScopeFactory.CreateScope(); try { diff --git a/src/Tests/Middleware/WebSocketTests.cs b/src/Tests/Middleware/WebSocketTests.cs index 72c764c..90123e0 100644 --- a/src/Tests/Middleware/WebSocketTests.cs +++ b/src/Tests/Middleware/WebSocketTests.cs @@ -9,10 +9,8 @@ public class WebSocketTests : IDisposable private void Configure(Action? configureOptions = null, Action? configureServices = null) { - if (configureOptions == null) - configureOptions = _ => { }; - if (configureServices == null) - configureServices = _ => { }; + configureOptions ??= _ => { }; + configureServices ??= _ => { }; var hostBuilder = new WebHostBuilder(); hostBuilder.ConfigureServices(services => {