// 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;
/// 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)
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);
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
{
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; }
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; } }
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; }
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.IO.IsolatedStorage.cs" />
<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" />
// 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;
// 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;
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))
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())
// 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"
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() { }
get
{
if (Helper.IsApplication(Scope))
- return _applicationIdentity;
+ return _applicationIdentity!;
throw new InvalidOperationException(SR.IsolatedStorage_ApplicationUndefined);
}
get
{
if (Helper.IsAssembly(Scope))
- return _assemblyIdentity;
+ return _assemblyIdentity!;
throw new InvalidOperationException(SR.IsolatedStorage_AssemblyUndefined);
}
get
{
if (Helper.IsDomain(Scope))
- return _domainIdentity;
+ return _domainIdentity!;
throw new InvalidOperationException(SR.IsolatedStorage_AssemblyUndefined);
}
public abstract void Remove();
- internal string IdentityHash
+ internal string? IdentityHash
{
get; private set;
}
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))
{
// 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)
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;
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;
{
// 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)
{
//
// "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
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;
if (Helper.IsDomain(Scope))
{
parentDirectory = Path.GetDirectoryName(parentDirectory);
+ Debug.Assert(parentDirectory != null);
if (ContainsUnknownFiles(parentDirectory))
return;
{
}
- 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)
{
}
{
}
- 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)
{
}
{
}
- 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)
{
}
{
}
- 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))
{
}
}
// 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));
_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);
}