Annotate System.IO.IsolatedStorage for nullable (#31835)
authorbuyaa-n <bunamnan@microsoft.com>
Fri, 7 Feb 2020 18:13:08 +0000 (10:13 -0800)
committerGitHub <noreply@github.com>
Fri, 7 Feb 2020 18:13:08 +0000 (10:13 -0800)
* Annotate System.IO.IsolatedStorage for nullable

src/libraries/Common/src/System/Security/IdentityHelper.cs
src/libraries/System.IO.IsolatedStorage/ref/System.IO.IsolatedStorage.cs
src/libraries/System.IO.IsolatedStorage/ref/System.IO.IsolatedStorage.csproj
src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFileStream.cs

index 73c7074..9f77861 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 using System.Diagnostics;
 using System.IO;
 using System.Reflection;
@@ -38,9 +39,9 @@ namespace System.Security
         /// Uses the AssemblyName's public key to generate a hash equivalent to what
         /// StrongName.Normalize() gives.
         /// </summary>
-        internal static string GetNormalizedStrongNameHash(AssemblyName name)
+        internal static string? GetNormalizedStrongNameHash(AssemblyName name)
         {
-            byte[] publicKey = name.GetPublicKey();
+            byte[]? publicKey = name.GetPublicKey();
 
             // If we don't have a key, we're not strong named
             if (publicKey == null || publicKey.Length == 0)
@@ -51,8 +52,8 @@ namespace System.Security
             using (BinaryWriter bw = new BinaryWriter(ms))
             {
                 bw.Write(publicKey);
-                bw.Write(name.Version.Major);
-                bw.Write(name.Name);
+                bw.Write(name.Version!.Major);
+                bw.Write(name.Name!);
 
                 ms.Position = 0;
                 return GetStrongHashSuitableForObjectName(ms);
index 74ac066..619471b 100644 (file)
@@ -31,15 +31,15 @@ namespace System.IO.IsolatedStorage
         public virtual long UsedSize { get { throw null; } }
         public virtual bool IncreaseQuotaTo(long newQuotaSize) { throw null; }
         protected void InitStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type appEvidenceType) { }
-        protected void InitStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type domainEvidenceType, System.Type assemblyEvidenceType) { }
+        protected void InitStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type? domainEvidenceType, System.Type? assemblyEvidenceType) { }
         public abstract void Remove();
     }
     public partial class IsolatedStorageException : System.Exception
     {
         public IsolatedStorageException() { }
         protected IsolatedStorageException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
-        public IsolatedStorageException(string message) { }
-        public IsolatedStorageException(string message, System.Exception inner) { }
+        public IsolatedStorageException(string? message) { }
+        public IsolatedStorageException(string? message, System.Exception? inner) { }
     }
     public sealed partial class IsolatedStorageFile : System.IO.IsolatedStorage.IsolatedStorage, System.IDisposable
     {
@@ -76,10 +76,10 @@ namespace System.IO.IsolatedStorage
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetMachineStoreForApplication() { throw null; }
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetMachineStoreForAssembly() { throw null; }
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetMachineStoreForDomain() { throw null; }
-        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object applicationIdentity) { throw null; }
-        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity) { throw null; }
-        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type applicationEvidenceType) { throw null; }
-        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type domainEvidenceType, System.Type assemblyEvidenceType) { throw null; }
+        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object? applicationIdentity) { throw null; }
+        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object? domainIdentity, object? assemblyIdentity) { throw null; }
+        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type? applicationEvidenceType) { throw null; }
+        public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Type? domainEvidenceType, System.Type? assemblyEvidenceType) { throw null; }
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetUserStoreForApplication() { throw null; }
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetUserStoreForAssembly() { throw null; }
         public static System.IO.IsolatedStorage.IsolatedStorageFile GetUserStoreForDomain() { throw null; }
@@ -99,10 +99,10 @@ namespace System.IO.IsolatedStorage
         public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
         public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
         public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
-        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
-        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
-        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
-        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
+        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile? isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
+        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile? isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
+        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.IsolatedStorage.IsolatedStorageFile? isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
+        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile? isf) : base (default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
         public override bool CanRead { get { throw null; } }
         public override bool CanSeek { get { throw null; } }
         public override bool CanWrite { get { throw null; } }
@@ -112,8 +112,8 @@ namespace System.IO.IsolatedStorage
         public override long Length { get { throw null; } }
         public override long Position { get { throw null; } set { } }
         public override Microsoft.Win32.SafeHandles.SafeFileHandle SafeFileHandle { get { throw null; } }
-        public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int numBytes, System.AsyncCallback userCallback, object stateObject) { throw null; }
-        public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int numBytes, System.AsyncCallback userCallback, object stateObject) { throw null; }
+        public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int numBytes, System.AsyncCallback userCallback, object? stateObject) { throw null; }
+        public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int numBytes, System.AsyncCallback userCallback, object? stateObject) { throw null; }
         protected override void Dispose(bool disposing) { }
         public override System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
         public override int EndRead(System.IAsyncResult asyncResult) { throw null; }
index 62e8a6a..ab19b0d 100644 (file)
@@ -1,6 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
+    <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="System.IO.IsolatedStorage.cs" />
index 7b4cbf3..710b00e 100644 (file)
@@ -1,6 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix</TargetFrameworks>
+       <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="System\IO\IsolatedStorage\IsolatedStorageException.cs" />
index 15e0e91..9ba74ef 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 using System.Reflection;
 using System.Security;
 using System.Threading;
@@ -48,15 +49,15 @@ namespace System.IO.IsolatedStorage
             // to pull from we'd have to dig into the use case to try and find a reasonable solution should we
             // run into this in the wild.
 
-            Assembly assembly = Assembly.GetEntryAssembly();
+            Assembly? assembly = Assembly.GetEntryAssembly();
 
             if (assembly == null)
                 throw new IsolatedStorageException(SR.IsolatedStorage_Init);
 
             AssemblyName assemblyName = assembly.GetName();
-            Uri codeBase = new Uri(assembly.CodeBase);
+            Uri codeBase = new Uri(assembly.CodeBase!);
 
-            hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName);
+            hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!;
             if (hash != null)
             {
                 hash = "StrongName" + separator + hash;
@@ -71,7 +72,7 @@ namespace System.IO.IsolatedStorage
 
         internal static string GetRandomDirectory(string rootDirectory, IsolatedStorageScope scope)
         {
-            string randomDirectory = GetExistingRandomDirectory(rootDirectory);
+            string? randomDirectory = GetExistingRandomDirectory(rootDirectory);
             if (string.IsNullOrEmpty(randomDirectory))
             {
                 using (Mutex m = CreateMutexNotOwned(rootDirectory))
@@ -101,7 +102,7 @@ namespace System.IO.IsolatedStorage
             return randomDirectory;
         }
 
-        internal static string GetExistingRandomDirectory(string rootDirectory)
+        internal static string? GetExistingRandomDirectory(string rootDirectory)
         {
             // Look for an existing random directory at the given root
             // (a set of nested directories that were created via Path.GetRandomFileName())
index f48cd48..1c0b1b5 100644 (file)
@@ -2,15 +2,16 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.IO.IsolatedStorage
 {
     internal static partial class Helper
     {
         private const string IsolatedStorageDirectoryName = "IsolatedStorage";
 
-        private static string s_machineRootDirectory;
-        private static string s_roamingUserRootDirectory;
-        private static string s_userRootDirectory;
+        private static string? s_machineRootDirectory;
+        private static string? s_roamingUserRootDirectory;
+        private static string? s_userRootDirectory;
 
         /// <summary>
         /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus "IsolatedStorage"
index 968035f..ab44481 100644 (file)
@@ -11,9 +11,9 @@ namespace System.IO.IsolatedStorage
         private ulong _quota;
         private bool _validQuota;
 
-        private object _applicationIdentity;
-        private object _assemblyIdentity;
-        private object _domainIdentity;
+        private object? _applicationIdentity;
+        private object? _assemblyIdentity;
+        private object? _domainIdentity;
 
         protected IsolatedStorage() { }
 
@@ -22,7 +22,7 @@ namespace System.IO.IsolatedStorage
             get
             {
                 if (Helper.IsApplication(Scope))
-                    return _applicationIdentity;
+                    return _applicationIdentity!;
 
                 throw new InvalidOperationException(SR.IsolatedStorage_ApplicationUndefined);
             }
@@ -33,7 +33,7 @@ namespace System.IO.IsolatedStorage
             get
             {
                 if (Helper.IsAssembly(Scope))
-                    return _assemblyIdentity;
+                    return _assemblyIdentity!;
 
                 throw new InvalidOperationException(SR.IsolatedStorage_AssemblyUndefined);
             }
@@ -44,7 +44,7 @@ namespace System.IO.IsolatedStorage
             get
             {
                 if (Helper.IsDomain(Scope))
-                    return _domainIdentity;
+                    return _domainIdentity!;
 
                 throw new InvalidOperationException(SR.IsolatedStorage_AssemblyUndefined);
             }
@@ -128,7 +128,7 @@ namespace System.IO.IsolatedStorage
 
         public abstract void Remove();
 
-        internal string IdentityHash
+        internal string? IdentityHash
         {
             get; private set;
         }
@@ -138,14 +138,12 @@ namespace System.IO.IsolatedStorage
             InitStore(scope, null, appEvidenceType);
         }
 
-        protected void InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
+        protected void InitStore(IsolatedStorageScope scope, Type? domainEvidenceType, Type? assemblyEvidenceType)
         {
             VerifyScope(scope);
             Scope = scope;
 
-            object identity;
-            string hash;
-            Helper.GetDefaultIdentityAndHash(out identity, out hash, SeparatorInternal);
+            Helper.GetDefaultIdentityAndHash(out object identity, out string hash, SeparatorInternal);
 
             if (Helper.IsApplication(scope))
             {
index fbf2908..1af42ca 100644 (file)
@@ -15,7 +15,7 @@ namespace System.IO.IsolatedStorage
 
         // All the exceptions from IsolatedStorage are wrapped as IsolatedStorageException,
         // this field is used to provide the underlying exception under debugger.
-        internal Exception _underlyingException;
+        internal Exception? _underlyingException;
 
         public IsolatedStorageException()
             : base(SR.IsolatedStorage_Exception)
@@ -23,13 +23,13 @@ namespace System.IO.IsolatedStorage
             HResult = COR_E_ISOSTORE;
         }
 
-        public IsolatedStorageException(string message)
+        public IsolatedStorageException(string? message)
             : base(message)
         {
             HResult = COR_E_ISOSTORE;
         }
 
-        public IsolatedStorageException(string message, Exception inner)
+        public IsolatedStorageException(string? message, Exception? inner)
             : base(message, inner)
         {
             HResult = COR_E_ISOSTORE;
index 3bef2d8..ecd16d5 100644 (file)
@@ -14,7 +14,7 @@ namespace System.IO.IsolatedStorage
         internal const string s_files = "Files";
         internal const string s_assemFiles = "AssemFiles";
         internal const string s_appFiles = "AppFiles";
-        private string _rootDirectory;
+        private string _rootDirectory = null!; // Initialized in helper
 
         private bool _disposed;
         private bool _closed;
@@ -223,7 +223,7 @@ namespace System.IO.IsolatedStorage
             {
                 // FileSystem APIs return the complete path of the matching directories however Iso store only provided the directory name
                 // and hid the IsoStore root. Hence we find all the matching directories from the fileSystem and simply return their names.
-                return Directory.EnumerateDirectories(RootDirectory, searchPattern).Select(m => m.Substring(Path.GetDirectoryName(m).Length + 1)).ToArray();
+                return Directory.EnumerateDirectories(RootDirectory, searchPattern).Select(m => m.Substring(Path.GetDirectoryName(m)!.Length + 1)).ToArray();
             }
             catch (UnauthorizedAccessException e)
             {
@@ -609,25 +609,25 @@ namespace System.IO.IsolatedStorage
         //
         // "Known" types are Publisher, StrongName, Url, Site, and Zone.
 
-        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Type applicationEvidenceType)
+        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Type? applicationEvidenceType)
         {
             // Scope MUST be Application
             return (applicationEvidenceType == null) ? GetStore(scope) : throw new PlatformNotSupportedException(SR.PlatformNotSupported_CAS); // https://github.com/dotnet/corefx/issues/10935
         }
 
-        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, object applicationIdentity)
+        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, object? applicationIdentity)
         {
             // Scope MUST be Application
             return (applicationIdentity == null) ? GetStore(scope) : throw new PlatformNotSupportedException(SR.PlatformNotSupported_CAS); // https://github.com/dotnet/corefx/issues/10935
         }
 
-        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
+        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Type? domainEvidenceType, Type? assemblyEvidenceType)
         {
             // Scope MUST NOT be Application (assembly is assumed otherwise)
             return (domainEvidenceType == null && assemblyEvidenceType == null) ? GetStore(scope) : throw new PlatformNotSupportedException(SR.PlatformNotSupported_CAS); // https://github.com/dotnet/corefx/issues/10935
         }
 
-        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity)
+        public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, object? domainIdentity, object? assemblyIdentity)
         {
             // Scope MUST NOT be Application (assembly is assumed otherwise)
             return (domainIdentity == null && assemblyIdentity == null) ? GetStore(scope) : throw new PlatformNotSupportedException(SR.PlatformNotSupported_CAS); // https://github.com/dotnet/corefx/issues/10935
@@ -734,7 +734,8 @@ namespace System.IO.IsolatedStorage
 
             Close();
 
-            string parentDirectory = Path.GetDirectoryName(RootDirectory.TrimEnd(Path.DirectorySeparatorChar));
+            string? parentDirectory = Path.GetDirectoryName(RootDirectory.TrimEnd(Path.DirectorySeparatorChar));
+            Debug.Assert(parentDirectory != null);
 
             if (ContainsUnknownFiles(parentDirectory))
                 return;
@@ -753,6 +754,7 @@ namespace System.IO.IsolatedStorage
             if (Helper.IsDomain(Scope))
             {
                 parentDirectory = Path.GetDirectoryName(parentDirectory);
+                Debug.Assert(parentDirectory != null);
 
                 if (ContainsUnknownFiles(parentDirectory))
                     return;
index 829c32d..f403195 100644 (file)
@@ -23,7 +23,7 @@ namespace System.IO.IsolatedStorage
         {
         }
 
-        public IsolatedStorageFileStream(string path, FileMode mode, IsolatedStorageFile isf)
+        public IsolatedStorageFileStream(string path, FileMode mode, IsolatedStorageFile? isf)
             : this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.None, isf)
         {
         }
@@ -33,7 +33,7 @@ namespace System.IO.IsolatedStorage
         {
         }
 
-        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, IsolatedStorageFile isf)
+        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, IsolatedStorageFile? isf)
             : this(path, mode, access, access == FileAccess.Read ? FileShare.Read : FileShare.None, DefaultBufferSize, isf)
         {
         }
@@ -43,7 +43,7 @@ namespace System.IO.IsolatedStorage
         {
         }
 
-        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)
+        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile? isf)
             : this(path, mode, access, share, DefaultBufferSize, isf)
         {
         }
@@ -53,7 +53,7 @@ namespace System.IO.IsolatedStorage
         {
         }
 
-        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile isf)
+        public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile? isf)
             : this(path, mode, access, share, bufferSize, InitializeFileStream(path, mode, access, share, bufferSize, isf))
         {
         }
@@ -81,7 +81,7 @@ namespace System.IO.IsolatedStorage
         }
 
         // If IsolatedStorageFile is null, then we default to using a file that is scoped by user, appdomain, and assembly.
-        private static InitialiationData InitializeFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile isf)
+        private static InitialiationData InitializeFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile? isf)
         {
             if (path == null)
                 throw new ArgumentNullException(nameof(path));
@@ -302,12 +302,12 @@ namespace System.IO.IsolatedStorage
             _fs.WriteByte(value);
         }
 
-        public override IAsyncResult BeginRead(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject)
+        public override IAsyncResult BeginRead(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object? stateObject)
         {
             return _fs.BeginRead(array, offset, numBytes, userCallback, stateObject);
         }
 
-        public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject)
+        public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object? stateObject)
         {
             return _fs.BeginWrite(array, offset, numBytes, userCallback, stateObject);
         }