diff options
author | Santiago Fernandez Madero <safern@microsoft.com> | 2019-06-07 11:01:51 -0500 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2019-06-07 12:01:51 -0400 |
commit | b51993933c5f2f29b20d229cdb32bbcb41e76dd6 (patch) | |
tree | 2f1b00a96a42a09e516aed5e9f413ca4182bd03c | |
parent | 1fa758fbb4c6278cbf3ba72f1f98ba52d10b8265 (diff) | |
download | coreclr-b51993933c5f2f29b20d229cdb32bbcb41e76dd6.tar.gz coreclr-b51993933c5f2f29b20d229cdb32bbcb41e76dd6.tar.bz2 coreclr-b51993933c5f2f29b20d229cdb32bbcb41e76dd6.zip |
Address nullable feedback for System.Runtime and System.Runtime.Extensions (#25017)
* Address last nullable feedback from System.Runtime
* Address nullable feedback for System.Runtime.Extensions
* PR Feedback
20 files changed, 37 insertions, 34 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs index d79924cfdc..890b27927a 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs @@ -673,7 +673,7 @@ namespace System.Collections.Generic return true; } - public virtual void OnDeserialization(object sender) + public virtual void OnDeserialization(object? sender) { HashHelpers.SerializationInfoTable.TryGetValue(this, out SerializationInfo siInfo); diff --git a/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs b/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs index 06e57b7ada..f5a90e654e 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs @@ -1153,7 +1153,7 @@ namespace System.Collections // // DeserializationEvent Listener // - public virtual void OnDeserialization(object sender) + public virtual void OnDeserialization(object? sender) { if (_buckets != null) { @@ -1491,7 +1491,7 @@ namespace System.Collections } } - public override void OnDeserialization(object sender) + public override void OnDeserialization(object? sender) { // Does nothing. We have to implement this because our parent HT implements it, // but it doesn't do anything meaningful. The real work will be done when we diff --git a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs index e328726a40..20457028c2 100644 --- a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs +++ b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs @@ -591,7 +591,7 @@ namespace System // ----- SECTION: private serialization instance methods ----------------* - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { try { diff --git a/src/System.Private.CoreLib/shared/System/Decimal.cs b/src/System.Private.CoreLib/shared/System/Decimal.cs index 72ac754776..47bea857f0 100644 --- a/src/System.Private.CoreLib/shared/System/Decimal.cs +++ b/src/System.Private.CoreLib/shared/System/Decimal.cs @@ -276,7 +276,7 @@ namespace System flags |= SignMask; } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { // OnDeserialization is called after each instance of this class is deserialized. // This callback method performs decimal validation after being deserialized. diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs index dd4da0de06..03e130219b 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs @@ -175,7 +175,7 @@ namespace System.Globalization m_name = null!; } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { OnDeserialized(); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs index 38005a0c6b..e5553f7bc4 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs @@ -63,7 +63,7 @@ namespace System.Globalization FinishInitialization(); } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { throw new PlatformNotSupportedException(); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs index 3de53a1419..0687dcf994 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs @@ -245,7 +245,7 @@ namespace System.Reflection throw new PlatformNotSupportedException(); } - public void OnDeserialization(object sender) + public void OnDeserialization(object? sender) { throw new PlatformNotSupportedException(); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/StrongNameKeyPair.cs b/src/System.Private.CoreLib/shared/System/Reflection/StrongNameKeyPair.cs index a0ba97f835..52fa6147b6 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/StrongNameKeyPair.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/StrongNameKeyPair.cs @@ -50,7 +50,7 @@ namespace System.Reflection throw new PlatformNotSupportedException(); } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { throw new PlatformNotSupportedException(); } diff --git a/src/System.Private.CoreLib/shared/System/ResolveEventHandler.cs b/src/System.Private.CoreLib/shared/System/ResolveEventHandler.cs index 7cb2818dcf..a08be720c4 100644 --- a/src/System.Private.CoreLib/shared/System/ResolveEventHandler.cs +++ b/src/System.Private.CoreLib/shared/System/ResolveEventHandler.cs @@ -6,5 +6,5 @@ using System.Reflection; namespace System { - public delegate Assembly ResolveEventHandler(object? sender, ResolveEventArgs args); + public delegate Assembly? ResolveEventHandler(object? sender, ResolveEventArgs args); } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/IDeserializationCallback.cs b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/IDeserializationCallback.cs index a1c1671a8b..22b799c78f 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/IDeserializationCallback.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/IDeserializationCallback.cs @@ -6,6 +6,6 @@ namespace System.Runtime.Serialization { public interface IDeserializationCallback { - void OnDeserialization(object sender); + void OnDeserialization(object? sender); } } diff --git a/src/System.Private.CoreLib/shared/System/Security/PermissionSet.cs b/src/System.Private.CoreLib/shared/System/Security/PermissionSet.cs index 7d1327df0a..999d039419 100644 --- a/src/System.Private.CoreLib/shared/System/Security/PermissionSet.cs +++ b/src/System.Private.CoreLib/shared/System/Security/PermissionSet.cs @@ -48,7 +48,7 @@ namespace System.Security public static void RevertAssert() { } public IPermission? SetPermission(IPermission? perm) { return SetPermissionImpl(perm); } protected virtual IPermission? SetPermissionImpl(IPermission? perm) { return default(IPermission); } - void IDeserializationCallback.OnDeserialization(object sender) { } + void IDeserializationCallback.OnDeserialization(object? sender) { } public override string ToString() => base.ToString()!; public virtual SecurityElement? ToXml() { return default(SecurityElement); } public PermissionSet? Union(PermissionSet? other) { return default(PermissionSet); } diff --git a/src/System.Private.CoreLib/shared/System/Text/CodePageDataItem.cs b/src/System.Private.CoreLib/shared/System/Text/CodePageDataItem.cs index e2be2e3b78..e4b8d4d730 100644 --- a/src/System.Private.CoreLib/shared/System/Text/CodePageDataItem.cs +++ b/src/System.Private.CoreLib/shared/System/Text/CodePageDataItem.cs @@ -8,19 +8,19 @@ namespace System.Text { public int CodePage { get; } public int UIFamilyCodePage { get; } - public string? WebName { get; } - public string? HeaderName { get; } - public string? BodyName { get; } - public string? DisplayName { get; } + public string WebName { get; } + public string HeaderName { get; } + public string BodyName { get; } + public string DisplayName { get; } public uint Flags { get; } internal CodePageDataItem( int codePage, int uiFamilyCodePage, - string? webName, - string? headerName, - string? bodyName, - string? displayName, + string webName, + string headerName, + string bodyName, + string displayName, uint flags) { CodePage = codePage; diff --git a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs index a1180a189b..74f0b95cbc 100644 --- a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs @@ -370,7 +370,7 @@ namespace System.Text // Returns the name for this encoding that can be used with mail agent body tags. // If the encoding may not be used, the string is empty. - public virtual string? BodyName + public virtual string BodyName { get { @@ -383,7 +383,7 @@ namespace System.Text } // Returns the human-readable description of the encoding ( e.g. Hebrew (DOS)). - public virtual string? EncodingName + public virtual string EncodingName { get { @@ -399,7 +399,7 @@ namespace System.Text // Returns the name for this encoding that can be used with mail agent header // tags. If the encoding may not be used, the string is empty. - public virtual string? HeaderName + public virtual string HeaderName { get { @@ -412,7 +412,7 @@ namespace System.Text } // Returns the IANA preferred name for this encoding. - public virtual string? WebName + public virtual string WebName { get { diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index 225442c215..165ea4ee2f 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -1520,13 +1520,13 @@ namespace System.Text return AppendFormatHelper(null, format, new ParamsArray(args)); } - public StringBuilder AppendFormat(IFormatProvider provider, string format, object? arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); + public StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, object? arg0, object? arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); + public StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0, object? arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, object? arg0, object? arg1, object? arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); + public StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, params object?[] args) + public StringBuilder AppendFormat(IFormatProvider? provider, string format, params object?[] args) { if (args == null) { diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs index a3ffb1c6a3..e2e51884b4 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs @@ -211,7 +211,7 @@ namespace System "DaylightDelta should not ever be more than 24h"); } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { // OnDeserialization is called after each instance of this class is deserialized. // This callback method performs AdjustmentRule validation after being deserialized. diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.TransitionTime.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.TransitionTime.cs index 4b0abe8e6e..aa88a144b5 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.TransitionTime.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.TransitionTime.cs @@ -106,7 +106,7 @@ namespace System } } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { // OnDeserialization is called after each instance of this class is deserialized. // This callback method performs TransitionTime validation after being deserialized. diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs index 768385cfb2..589a605fcc 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs @@ -1005,7 +1005,7 @@ namespace System disableDaylightSavingTime); } - void IDeserializationCallback.OnDeserialization(object sender) + void IDeserializationCallback.OnDeserialization(object? sender) { try { diff --git a/src/System.Private.CoreLib/src/System/Environment.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Environment.CoreCLR.cs index b2d7f1165e..a296a1ca95 100644 --- a/src/System.Private.CoreLib/src/System/Environment.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Environment.CoreCLR.cs @@ -20,6 +20,7 @@ namespace System [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void _Exit(int exitCode); + [DoesNotReturn] public static void Exit(int exitCode) => _Exit(exitCode); public static extern int ExitCode diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs index 1c36377794..9047f5efa6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using Internal.Runtime.CompilerServices; @@ -27,7 +28,8 @@ namespace System.Runtime.CompilerServices // Of course, reference types are not cloned. // [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern object GetObjectValue(object obj); + [return: NotNullIfNotNull("obj")] + public static extern object? GetObjectValue(object? obj); // RunClassConstructor causes the class constructor for the given type to be triggered // in the current domain. After this call returns, the class constructor is guaranteed to diff --git a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs index 197a07e7ce..bd56e50d4d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs @@ -328,7 +328,7 @@ namespace System.Runtime.Loader foreach (ResolveEventHandler handler in eventHandler.GetInvocationList()) { - Assembly asm = handler(null /* AppDomain */, args); + Assembly? asm = handler(null /* AppDomain */, args); RuntimeAssembly? ret = GetRuntimeAssembly(asm); if (ret != null) return ret; @@ -337,7 +337,7 @@ namespace System.Runtime.Loader return null; } - private static RuntimeAssembly? GetRuntimeAssembly(Assembly asm) + private static RuntimeAssembly? GetRuntimeAssembly(Assembly? asm) { return asm == null ? null : |