Nullable annotation fixes (#82803)
authorJared Parsons <jaredpparsons@gmail.com>
Fri, 3 Mar 2023 16:01:43 +0000 (08:01 -0800)
committerGitHub <noreply@github.com>
Fri, 3 Mar 2023 16:01:43 +0000 (08:01 -0800)
* 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 <stoub@microsoft.com>
---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/VersionConverter.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/Ecma/EcmaFatMethodParameter.cs

index 0d7bf0e..e42d19b 100644 (file)
@@ -94,7 +94,7 @@ namespace System.ComponentModel
         {
             if (value is string version)
             {
-                return Version.TryParse(version, out Version _);
+                return Version.TryParse(version, out _);
             }
             return value is Version;
         }
index 47772a2..9bc1af9 100644 (file)
@@ -471,7 +471,7 @@ namespace System.Net.Http
             {
                 if (entry.Value.CleanCacheAndDisposeIfUnused())
                 {
-                    _pools.TryRemove(entry.Key, out HttpConnectionPool _);
+                    _pools.TryRemove(entry.Key, out _);
                 }
             }
 
index b3e8964..3c8f511 100644 (file)
@@ -891,7 +891,7 @@ namespace System
             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 @@ namespace System
                 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,
index 49ccece..1f1c04e 100644 (file)
@@ -650,7 +650,7 @@ namespace System.Runtime.Serialization.DataContracts
         public void ImportSchemaSet(XmlSchemaSet schemaSet, IEnumerable<XmlQualifiedName>? typeNames, bool importXmlDataType)
         {
             SchemaImporter importer = new SchemaImporter(schemaSet, typeNames, null, this, importXmlDataType);
-            importer.Import(out List<XmlQualifiedName> _);
+            importer.Import(out _);
         }
 
         [RequiresDynamicCode(DataContract.SerializerAOTWarning)]
index 099a41b..4684045 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Reflection.TypeLoading.Ecma
 
         protected sealed override IEnumerable<CustomAttributeData> 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
         {