From 749b2c80db9726f2a096462ed75f57fd99d21e7d Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Tue, 11 Jun 2019 16:52:22 -0500 Subject: [PATCH] Address System.Runtime and System.Runtime.Extensions nullable feedback (dotnet/corefx#38459) * Address System.Runtime and System.Runtime.Extensions nullable feedback * PR Feedback Commit migrated from https://github.com/dotnet/corefx/commit/e3dd986b1ba2ec80bba84aee5a4b4527db087ce2 --- .../System.Runtime.Extensions/src/System/IO/BufferedStream.cs | 5 +++-- .../System.Runtime/src/System/Runtime/NgenServicingAttributes.cs | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Runtime.Extensions/src/System/IO/BufferedStream.cs b/src/libraries/System.Runtime.Extensions/src/System/IO/BufferedStream.cs index 35a8fe9..a92a81a 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/IO/BufferedStream.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/IO/BufferedStream.cs @@ -145,11 +145,12 @@ namespace System.IO _buffer = new byte[_bufferSize]; } - public Stream? UnderlyingStream + public Stream UnderlyingStream { get { - return _stream; + // _stream can be null when disposed. However we don't want to make UnderlyingStream nullable just for that scenario, since doing operations after dispose is invalid anyway. + return _stream!; } } diff --git a/src/libraries/System.Runtime/src/System/Runtime/NgenServicingAttributes.cs b/src/libraries/System.Runtime/src/System/Runtime/NgenServicingAttributes.cs index 6d53595..303f6e3 100644 --- a/src/libraries/System.Runtime/src/System/Runtime/NgenServicingAttributes.cs +++ b/src/libraries/System.Runtime/src/System/Runtime/NgenServicingAttributes.cs @@ -7,9 +7,9 @@ namespace System.Runtime [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] public sealed class AssemblyTargetedPatchBandAttribute : Attribute { - public string? TargetedPatchBand { get; } + public string TargetedPatchBand { get; } - public AssemblyTargetedPatchBandAttribute(string? targetedPatchBand) + public AssemblyTargetedPatchBandAttribute(string targetedPatchBand) { TargetedPatchBand = targetedPatchBand; } @@ -18,9 +18,9 @@ namespace System.Runtime [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] public sealed class TargetedPatchingOptOutAttribute : Attribute { - public string? Reason { get; } + public string Reason { get; } - public TargetedPatchingOptOutAttribute(string? reason) + public TargetedPatchingOptOutAttribute(string reason) { Reason = reason; } -- 2.7.4