From 1998523590276ce8af34cf264b912f16feeee9b2 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 10 Apr 2019 19:12:26 -0400 Subject: [PATCH] Address follow-up PR feedback on System nullability annotations (#23878) --- src/System.Private.CoreLib/shared/System/AppDomain.cs | 8 ++++---- src/System.Private.CoreLib/shared/System/Array.cs | 11 ++++++----- src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/AppDomain.cs b/src/System.Private.CoreLib/shared/System/AppDomain.cs index be238e3..b1a2055 100644 --- a/src/System.Private.CoreLib/shared/System/AppDomain.cs +++ b/src/System.Private.CoreLib/shared/System/AppDomain.cs @@ -364,10 +364,10 @@ namespace System return Activator.CreateInstanceFrom(assemblyFile, typeName, activationAttributes); } - public object CreateInstanceFromAndUnwrap(string assemblyFile, string typeName) + public object? CreateInstanceFromAndUnwrap(string assemblyFile, string typeName) { ObjectHandle? oh = CreateInstanceFrom(assemblyFile, typeName); - return oh?.Unwrap()!; + return oh?.Unwrap(); } public object? CreateInstanceFromAndUnwrap(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder? binder, object?[]? args, System.Globalization.CultureInfo? culture, object?[]? activationAttributes) @@ -380,13 +380,13 @@ namespace System args, culture, activationAttributes); - return oh?.Unwrap()!; + return oh?.Unwrap(); } public object? CreateInstanceFromAndUnwrap(string assemblyFile, string typeName, object?[]? activationAttributes) { ObjectHandle? oh = CreateInstanceFrom(assemblyFile, typeName, activationAttributes); - return oh?.Unwrap()!; + return oh?.Unwrap(); } public IPrincipal? GetThreadPrincipal() diff --git a/src/System.Private.CoreLib/shared/System/Array.cs b/src/System.Private.CoreLib/shared/System/Array.cs index c851bb4..058f1ca 100644 --- a/src/System.Private.CoreLib/shared/System/Array.cs +++ b/src/System.Private.CoreLib/shared/System/Array.cs @@ -1582,10 +1582,10 @@ namespace System private readonly struct SorterObjectArray { private readonly object[] keys; - private readonly object[]? items; + private readonly object?[]? items; private readonly IComparer comparer; - internal SorterObjectArray(object[] keys, object[]? items, IComparer comparer) + internal SorterObjectArray(object[] keys, object?[]? items, IComparer comparer) { this.keys = keys; this.items = items; @@ -1737,7 +1737,7 @@ namespace System private void DownHeap(int i, int n, int lo) { object d = keys[lo + i - 1]; - object dt = (items != null) ? items[lo + i - 1] : null!; + object? dt = (items != null) ? items[lo + i - 1] : null; int child; while (i <= n / 2) { @@ -1761,12 +1761,13 @@ namespace System private void InsertionSort(int lo, int hi) { int i, j; - object t, ti; + object t; + object? ti; for (i = lo; i < hi; i++) { j = i; t = keys[i + 1]; - ti = (items != null) ? items[i + 1] : null!; + ti = (items != null) ? items[i + 1] : null; while (j >= lo && comparer.Compare(t, keys[j]) < 0) { keys[j + 1] = keys[j]; diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs index 9b12adb..3245845 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs @@ -961,10 +961,10 @@ namespace System public static TimeZoneInfo CreateCustomTimeZone( string id, TimeSpan baseUtcOffset, - string displayName, - string standardDisplayName, - string daylightDisplayName, - AdjustmentRule[] adjustmentRules) + string? displayName, + string? standardDisplayName, + string? daylightDisplayName, + AdjustmentRule[]? adjustmentRules) { return CreateCustomTimeZone( id, -- 2.7.4