From a6975e07ff56cbd7737445aca69aa3cb46d9b06b Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Fri, 3 Mar 2023 08:01:43 -0800 Subject: [PATCH] Nullable annotation fixes (#82803) * Nullable annotation fixes Once runtime merges to a Roslyn toolset that has the fix for [issue 50782](https://github.com/dotnet/roslyn/issues/50782) these annotations will be necessary. Front loading the work here with this change. * Apply suggestions from code review Co-authored-by: Stephen Toub --------- Co-authored-by: Stephen Toub --- .../src/System/ComponentModel/VersionConverter.cs | 2 +- .../Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs | 2 +- .../System.Private.CoreLib/src/System/TimeZoneInfo.cs | 4 ++-- .../src/System/Runtime/Serialization/DataContractSet.cs | 2 +- .../TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/VersionConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/VersionConverter.cs index 0d7bf0e2b672d..e42d19bc01b9f 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/VersionConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/VersionConverter.cs @@ -94,7 +94,7 @@ public override bool IsValid(ITypeDescriptorContext? context, object? value) { if (value is string version) { - return Version.TryParse(version, out Version _); + return Version.TryParse(version, out _); } return value is Version; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs index 47772a2b4a76b..9bc1af96d8835 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs @@ -471,7 +471,7 @@ private void RemoveStalePools() { if (entry.Value.CleanCacheAndDisposeIfUnused()) { - _pools.TryRemove(entry.Key, out HttpConnectionPool _); + _pools.TryRemove(entry.Key, out _); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs index b3e8964bdb529..3c8f5119b7d2a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs @@ -891,7 +891,7 @@ public static TimeZoneInfo CreateCustomTimeZone( string? displayName, string? standardDisplayName) { - bool hasIanaId = TimeZoneInfo.TryConvertIanaIdToWindowsId(id, allocate: false, out string _); + bool hasIanaId = TimeZoneInfo.TryConvertIanaIdToWindowsId(id, allocate: false, out _); return new TimeZoneInfo( id, @@ -942,7 +942,7 @@ public static TimeZoneInfo CreateCustomTimeZone( adjustmentRules = (AdjustmentRule[])adjustmentRules.Clone(); } - bool hasIanaId = TimeZoneInfo.TryConvertIanaIdToWindowsId(id, allocate: false, out string _); + bool hasIanaId = TimeZoneInfo.TryConvertIanaIdToWindowsId(id, allocate: false, out _); return new TimeZoneInfo( id, diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs index 49ccecede632e..1f1c04e5934d5 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs @@ -650,7 +650,7 @@ internal IEnumerator> GetEnumerator public void ImportSchemaSet(XmlSchemaSet schemaSet, IEnumerable? typeNames, bool importXmlDataType) { SchemaImporter importer = new SchemaImporter(schemaSet, typeNames, null, this, importXmlDataType); - importer.Import(out List _); + importer.Import(out _); } [RequiresDynamicCode(DataContract.SerializerAOTWarning)] diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs index 099a41b7e6d56..46840458ac2f1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs @@ -37,7 +37,7 @@ internal EcmaFatMethodParameter(IRoMethodBase roMethodBase, int position, Type p protected sealed override IEnumerable GetTrueCustomAttributes() => Parameter.GetCustomAttributes().ToTrueCustomAttributes(GetEcmaModule()); - public sealed override bool HasDefaultValue => TryGetRawDefaultValue(out object _); + public sealed override bool HasDefaultValue => TryGetRawDefaultValue(out _); public sealed override object? RawDefaultValue {