From 566de97e5860bb1d9e4583945f0173070396098d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 19 Jun 2022 09:08:59 -0400 Subject: [PATCH] Enable IDE0030 (Use coalesce expression) (#70948) --- eng/CodeAnalysis.src.globalconfig | 2 +- src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index a3cf7c9..bef564cc 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -1386,7 +1386,7 @@ dotnet_diagnostic.IDE0028.severity = suggestion dotnet_diagnostic.IDE0029.severity = warning # IDE0030: Use coalesce expression -dotnet_diagnostic.IDE0030.severity = suggestion +dotnet_diagnostic.IDE0030.severity = warning # IDE0031: Use null propagation dotnet_diagnostic.IDE0031.severity = silent diff --git a/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs b/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs index bfd7aab..8e6fdea 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs @@ -80,8 +80,7 @@ namespace System.Net get { CheckDisposed(); - long? length = _httpResponseMessage.Content?.Headers.ContentLength; - return length.HasValue ? length.Value : -1; + return _httpResponseMessage.Content?.Headers.ContentLength ?? -1; } } -- 2.7.4