// 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;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
/// <param name="assemblyPath">The path to the assembly (as a pointer to a UTF-16 C string).</param>
public static unsafe void LoadInMemoryAssembly(IntPtr moduleHandle, IntPtr assemblyPath)
{
+ string? assemblyPathString = Marshal.PtrToStringUni(assemblyPath);
+ if (assemblyPathString == null)
+ {
+ throw new ArgumentOutOfRangeException(nameof(assemblyPath));
+ }
+
// We don't cache the ALCs here since each IJW assembly will call this method at most once
// (the load process rewrites the stubs that call here to call the actual methods they're supposed to)
- AssemblyLoadContext context = new IsolatedComponentLoadContext(Marshal.PtrToStringUni(assemblyPath));
+ AssemblyLoadContext context = new IsolatedComponentLoadContext(assemblyPathString);
context.LoadFromInMemoryModule(moduleHandle);
}
}
// 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;
using System.Reflection;
using System.Runtime.Loader;
/// or IJW components loaded from native. It provides a load context that uses an <see cref="AssemblyDependencyResolver" /> to resolve the component's
/// dependencies within the ALC and not pollute the default ALC.
///</summary>
- internal class IsolatedComponentLoadContext : AssemblyLoadContext
+ internal sealed class IsolatedComponentLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;
_resolver = new AssemblyDependencyResolver(componentAssemblyPath);
}
- protected override Assembly Load(AssemblyName assemblyName)
+ protected override Assembly? Load(AssemblyName assemblyName)
{
- string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
+ string? assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
return LoadFromAssemblyPath(assemblyPath);
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
- string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
+ string? libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
if (libraryPath != null)
{
return LoadUnmanagedDllFromPath(libraryPath);
// 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;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Loader;
public unsafe static int GetActivationFactory(
char* componentPath,
[MarshalAs(UnmanagedType.HString)] string typeName,
- [MarshalAs(UnmanagedType.Interface)] out IActivationFactory activationFactory)
+ [MarshalAs(UnmanagedType.Interface)] out IActivationFactory? activationFactory)
{
activationFactory = null;
try
throw new ArgumentNullException(nameof(typeName));
}
- AssemblyLoadContext context = GetALC(Marshal.PtrToStringUni((IntPtr)componentPath));
+ AssemblyLoadContext context = GetALC(Marshal.PtrToStringUni((IntPtr)componentPath)!);
Type winRTType = context.LoadTypeForWinRTTypeNameInContext(typeName);
// 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
internal static partial class Interop
{
internal static partial class Libraries
// We use the no throw version since we could be deserializing a pre-V4
// exception object that may not have this entry. In such a case, we would
// get null.
- _watsonBuckets = (object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization)
+ _watsonBuckets = info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization)
// If we are constructing a new exception after a cross-appdomain call...
if (context.State == StreamingContextStates.CrossAppDomain)
// 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.Globalization
{
internal sealed partial class GlobalizationMode
// 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.Globalization
{
internal sealed partial class GlobalizationMode
// 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.Globalization
{
internal sealed partial class GlobalizationMode
if (!exist)
{
// Linux doesn't support environment variable names include dots
- string switchValue = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
+ string? switchValue = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
if (switchValue != null)
{
ret = bool.IsTrueStringIgnoreCase(switchValue) || switchValue.Equals("1");
// 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.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Security;
namespace System.Reflection.Metadata
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Text;
-
+#nullable enable
namespace System.Runtime.InteropServices.CustomMarshalers
{
internal static class ComDataHelpers
managedView = createCallback((T)comObject);
if (!Marshal.SetComObjectData(comObject, key, managedView))
{
- managedView = (TView)Marshal.GetComObjectData(comObject, key);
+ managedView = (TView)Marshal.GetComObjectData(comObject, key)!;
}
return managedView;
}
// 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.Collections;
namespace System.Runtime.InteropServices.CustomMarshalers
// Licensed to the .NET Foundation under one or more agreements.
// 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.Collections.Generic;
using System.IO;
using System.Reflection;
public AssemblyDependencyResolver(string componentAssemblyPath)
{
- string assemblyPathsList = null;
- string nativeSearchPathsList = null;
- string resourceSearchPathsList = null;
+ if (componentAssemblyPath == null)
+ {
+ throw new ArgumentNullException(nameof(componentAssemblyPath));
+ }
+
+ string? assemblyPathsList = null;
+ string? nativeSearchPathsList = null;
+ string? resourceSearchPathsList = null;
int returnCode = 0;
StringBuilder errorMessage = new StringBuilder();
_assemblyPaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (string assemblyPath in assemblyPaths)
{
- _assemblyPaths.Add(Path.GetFileNameWithoutExtension(assemblyPath), assemblyPath);
+ _assemblyPaths.Add(Path.GetFileNameWithoutExtension(assemblyPath)!, assemblyPath); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
_nativeSearchPaths = SplitPathsList(nativeSearchPathsList);
_resourceSearchPaths = SplitPathsList(resourceSearchPathsList);
- _assemblyDirectorySearchPaths = new string[1] { Path.GetDirectoryName(componentAssemblyPath) };
+ _assemblyDirectorySearchPaths = new string[1] { Path.GetDirectoryName(componentAssemblyPath)! }; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
- public string ResolveAssemblyToPath(AssemblyName assemblyName)
+ public string? ResolveAssemblyToPath(AssemblyName assemblyName)
{
+ if (assemblyName == null)
+ {
+ throw new ArgumentNullException(nameof(assemblyName));
+ }
+
// Determine if the assembly name is for a satellite assembly or not
// This is the same logic as in AssemblyBinder::BindByTpaList in CoreCLR
// - If the culture name is non-empty and it's not 'neutral'
}
}
}
- else
+ else if (assemblyName.Name != null)
{
// Load code assembly - simply look it up in the dictionary by its simple name.
if (_assemblyPaths.TryGetValue(assemblyName.Name, out string assemblyPath))
return null;
}
- public string ResolveUnmanagedDllToPath(string unmanagedDllName)
+ public string? ResolveUnmanagedDllToPath(string unmanagedDllName)
{
+ if (unmanagedDllName == null)
+ {
+ throw new ArgumentNullException(nameof(unmanagedDllName));
+ }
+
string[] searchPaths;
if (unmanagedDllName.Contains(Path.DirectorySeparatorChar))
{
return null;
}
- private static string[] SplitPathsList(string pathsList)
+ private static string[] SplitPathsList(string? pathsList)
{
if (pathsList == null)
{
throw new ArgumentNullException(nameof(info));
}
- object target = info.GetValue("TrackedObject", typeof(object)); // Do not rename (binary serialization)
+ object? target = info.GetValue("TrackedObject", typeof(object)); // Do not rename (binary serialization)
bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization)
Create(target, trackResurrection);
throw new ArgumentNullException(nameof(info));
}
- T target = (T)info.GetValue("TrackedObject", typeof(T)); // Do not rename (binary serialization)
+ T target = (T)info.GetValue("TrackedObject", typeof(T))!; // Do not rename (binary serialization) // TODO-NULLABLE-GENERIC
bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization)
Create(target, trackResurrection);
// 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.Runtime.InteropServices;
namespace Internal
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
+#nullable enable
using System.Globalization;
namespace Internal.Resources
// allowing us to ask for a WinRT-specific ResourceManager.
public abstract class WindowsRuntimeResourceManagerBase
{
- public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo);
+ public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo? exceptionInfo);
- public abstract string GetString(string stringName, string startingCulture, string neutralResourcesCulture);
+ public abstract string GetString(string stringName, string? startingCulture, string? neutralResourcesCulture);
- public abstract CultureInfo GlobalResourceContextBestFitCultureInfo
+ public abstract CultureInfo? GlobalResourceContextBestFitCultureInfo
{
get;
}
/// Check whether CultureData exists for specified cultureName
/// This API is used for WindowsRuntimeResourceManager in System.Runtime.WindowsRuntime
/// </summary>
- public static bool IsValidCulture(string cultureName)
+ public static bool IsValidCulture(string? cultureName)
{
return CultureData.GetCultureData(cultureName, /* useUserOverride */ true) != null;
}
// 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.Threading.Tasks;
using System.Runtime.CompilerServices;
// 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;
using System.Runtime.InteropServices;
message = buffer;
}
- return Marshal.PtrToStringAnsi((IntPtr)message);
+ return Marshal.PtrToStringAnsi((IntPtr)message)!;
}
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")]
// 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;
using System.Diagnostics;
using System.IO;
internal static partial class Interop
{
- private static void ThrowExceptionForIoErrno(ErrorInfo errorInfo, string path, bool isDirectory, Func<ErrorInfo, ErrorInfo> errorRewriter)
+ private static void ThrowExceptionForIoErrno(ErrorInfo errorInfo, string? path, bool isDirectory, Func<ErrorInfo, ErrorInfo>? errorRewriter)
{
Debug.Assert(errorInfo.Error != Error.SUCCESS);
Debug.Assert(errorInfo.Error != Error.EINTR, "EINTR errors should be handled by the native shim and never bubble up to managed code");
throw Interop.GetExceptionForIoErrno(errorInfo, path, isDirectory);
}
- internal static void CheckIo(Error error, string path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo> errorRewriter = null)
+ internal static void CheckIo(Error error, string? path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo>? errorRewriter = null)
{
if (error != Interop.Error.SUCCESS)
{
/// <returns>
/// On success, returns the non-negative result long that was validated.
/// </returns>
- internal static long CheckIo(long result, string path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo> errorRewriter = null)
+ internal static long CheckIo(long result, string? path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo>? errorRewriter = null)
{
if (result < 0)
{
/// <returns>
/// On success, returns the non-negative result int that was validated.
/// </returns>
- internal static int CheckIo(int result, string path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo> errorRewriter = null)
+ internal static int CheckIo(int result, string? path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo>? errorRewriter = null)
{
CheckIo((long)result, path, isDirectory, errorRewriter);
/// <returns>
/// On success, returns the non-negative result IntPtr that was validated.
/// </returns>
- internal static IntPtr CheckIo(IntPtr result, string path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo> errorRewriter = null)
+ internal static IntPtr CheckIo(IntPtr result, string? path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo>? errorRewriter = null)
{
CheckIo((long)result, path, isDirectory, errorRewriter);
/// <returns>
/// On success, returns the valid SafeFileHandle that was validated.
/// </returns>
- internal static TSafeHandle CheckIo<TSafeHandle>(TSafeHandle handle, string path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo> errorRewriter = null)
+ internal static TSafeHandle CheckIo<TSafeHandle>(TSafeHandle handle, string? path = null, bool isDirectory = false, Func<ErrorInfo, ErrorInfo>? errorRewriter = null)
where TSafeHandle : SafeHandle
{
if (handle.IsInvalid)
/// <param name="path">The path with which this error is associated. This may be null.</param>
/// <param name="isDirectory">true if the <paramref name="path"/> is known to be a directory; otherwise, false.</param>
/// <returns></returns>
- internal static Exception GetExceptionForIoErrno(ErrorInfo errorInfo, string path = null, bool isDirectory = false)
+ internal static Exception GetExceptionForIoErrno(ErrorInfo errorInfo, string? path = null, bool isDirectory = false)
{
// Translate the errno into a known set of exception types. For cases where multiple errnos map
// to the same exception type, include an inner exception with the details.
// 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
internal static partial class Interop
{
internal static partial class Libraries
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-
+#nullable enable
namespace System.Collections.Generic
{
// Implement this interface if you need to support foreach semantics.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
+#nullable enable
using System.Runtime.InteropServices;
namespace System.Collections
{
using (var reader = new StreamReader(userDirsPath))
{
- string line;
+ string? line;
while ((line = reader.ReadLine()) != null)
{
// Example lines:
throw new ArgumentNullException(nameof(info));
_message = info.GetString("Message"); // Do not rename (binary serialization)
- _data = (IDictionary)(info.GetValueNoThrow("Data", typeof(IDictionary))); // Do not rename (binary serialization)
- _innerException = (Exception)(info.GetValue("InnerException", typeof(Exception))); // Do not rename (binary serialization)
+ _data = (IDictionary?)(info.GetValueNoThrow("Data", typeof(IDictionary))); // Do not rename (binary serialization)
+ _innerException = (Exception?)(info.GetValue("InnerException", typeof(Exception))); // Do not rename (binary serialization)
_helpURL = info.GetString("HelpURL"); // Do not rename (binary serialization)
_stackTraceString = info.GetString("StackTraceString"); // Do not rename (binary serialization)
_HResult = info.GetInt32("HResult"); // Do not rename (binary serialization)
return null;
}
- CultureInfo toReturn;
+ CultureInfo? toReturn;
try
{
: base(info, context)
{
_invalidCultureId = (int?)info.GetValue("InvalidCultureId", typeof(int?));
- _invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string));
+ _invalidCultureName = (string?)info.GetValue("InvalidCultureName", typeof(string));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
**
============================================================*/
+#nullable enable
using System.Buffers.Binary;
using System.Diagnostics;
using System.Runtime.CompilerServices;
private readonly Stream _stream;
private readonly byte[] _buffer;
private readonly Decoder _decoder;
- private byte[] _charBytes;
- private char[] _charBuffer;
+ private byte[]? _charBytes;
+ private char[]? _charBuffer;
private int _maxCharsSize; // From MaxCharBytesSize & Encoding
// Performance optimization for Read() w/ Unicode. Speeds us up by ~40%
_charBuffer = new char[_maxCharsSize];
}
- StringBuilder sb = null;
+ StringBuilder? sb = null;
do
{
readLength = ((stringLength - currPos) > MaxCharBytesSize) ? MaxCharBytesSize : (stringLength - currPos);
}
int position = 0;
- byte[] byteBuffer = null;
+ byte[]? byteBuffer = null;
if (_isMemoryStream)
{
Debug.Assert(_stream is MemoryStream);
// reasons. More about the subject in: https://github.com/dotnet/coreclr/pull/22102
protected virtual void FillBuffer(int numBytes)
{
- if (_buffer != null && (numBytes < 0 || numBytes > _buffer.Length))
+ if (numBytes < 0 || numBytes > _buffer.Length)
{
throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_BinaryReaderFillBuffer);
}
// 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.Text;
using System.Diagnostics;
using System.Buffers;
private bool _leaveOpen;
// Perf optimization stuff
- private byte[] _largeByteBuffer; // temp space for writing chars.
+ private byte[]? _largeByteBuffer; // temp space for writing chars.
private int _maxChars; // max # of chars we can put in _largeByteBuffer
// Size should be around the max number of chars/string * Encoding's max bytes/char
private const int LargeByteBufferSize = 256;
// 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.Diagnostics.CodeAnalysis;
using System.Text;
private const int MinBufferSize = 128;
private readonly Stream _stream;
- private Encoding _encoding;
- private Decoder _decoder;
- private readonly byte[] _byteBuffer;
- private char[] _charBuffer;
+ private Encoding _encoding = null!; // only null in NullStreamReader where this is never used
+ private Decoder _decoder = null!; // only null in NullStreamReader where this is never used
+ private readonly byte[] _byteBuffer = null!; // only null in NullStreamReader where this is never used
+ private char[] _charBuffer = null!; // only null in NullStreamReader where this is never used
private int _charPos;
private int _charLen;
// Record the number of valid bytes in the byteBuffer, for a few checks.
private StreamReader()
{
+ Debug.Assert(this is NullStreamReader);
_stream = Stream.Null;
_closable = true;
}
// contain the terminating carriage return and/or line feed. The returned
// value is null if the end of the input stream has been reached.
//
- public override string ReadLine()
+ public override string? ReadLine()
{
ThrowIfDisposed();
CheckAsyncTaskInProgress();
}
}
- StringBuilder sb = null;
+ StringBuilder? sb = null;
do
{
int i = _charPos;
return sb.ToString();
}
- public override Task<string> ReadLineAsync()
+ public override Task<string?> ReadLineAsync()
{
// If we have been inherited into a subclass, the following implementation could be incorrect
// since it does not call through to Read() which a subclass might have overridden.
ThrowIfDisposed();
CheckAsyncTaskInProgress();
- Task<string> task = ReadLineAsyncInternal();
+ Task<string?> task = ReadLineAsyncInternal();
_asyncReadTask = task;
return task;
}
- private async Task<string> ReadLineAsyncInternal()
+ private async Task<string?> ReadLineAsyncInternal()
{
if (_charPos == _charLen && (await ReadBufferAsync().ConfigureAwait(false)) == 0)
{
return null;
}
- StringBuilder sb = null;
+ StringBuilder? sb = null;
do
{
return 0;
}
- public override string ReadLine()
+ public override string? ReadLine()
{
return null;
}
// 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.Runtime.CompilerServices;
using System.Runtime.InteropServices;
}
[MethodImpl(MethodImplOptions.NoInlining)] // prevent WriteSpan from bloating call sites
- public override void Write(char[] buffer)
+ public override void Write(char[]? buffer)
{
WriteSpan(buffer, appendNewLine: false);
}
}
[MethodImpl(MethodImplOptions.NoInlining)] // prevent WriteSpan from bloating call sites
- public override void Write(string value)
+ public override void Write(string? value)
{
WriteSpan(value, appendNewLine: false);
}
[MethodImpl(MethodImplOptions.NoInlining)] // prevent WriteSpan from bloating call sites
- public override void WriteLine(string value)
+ public override void WriteLine(string? value)
{
CheckAsyncTaskInProgress();
WriteSpan(value, appendNewLine: true);
private void WriteFormatHelper(string format, ParamsArray args, bool appendNewLine)
{
StringBuilder sb =
- StringBuilderCache.Acquire(format.Length + args.Length * 8)
- .AppendFormatHelper(null, format, args);
+ StringBuilderCache.Acquire((format?.Length ?? 0) + args.Length * 8)
+ .AppendFormatHelper(null, format!, args); // AppendFormatHelper will appropriately throw ArgumentNullException for a null format
StringBuilder.ChunkEnumerator chunks = sb.GetChunks();
StringBuilderCache.Release(sb);
}
- public override void Write(string format, object arg0)
+ public override void Write(string format, object? arg0)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void Write(string format, object arg0, object arg1)
+ public override void Write(string format, object? arg0, object? arg1)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void Write(string format, object arg0, object arg1, object arg2)
+ public override void Write(string format, object? arg0, object? arg1, object? arg2)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void Write(string format, params object[] arg)
+ public override void Write(string format, params object?[] arg)
{
if (GetType() == typeof(StreamWriter))
{
+ if (arg == null)
+ {
+ throw new ArgumentNullException((format == null) ? nameof(format) : nameof(arg)); // same as base logic
+ }
WriteFormatHelper(format, new ParamsArray(arg), appendNewLine: false);
}
else
}
}
- public override void WriteLine(string format, object arg0)
+ public override void WriteLine(string format, object? arg0)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void WriteLine(string format, object arg0, object arg1)
+ public override void WriteLine(string format, object? arg0, object? arg1)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void WriteLine(string format, object arg0, object arg1, object arg2)
+ public override void WriteLine(string format, object? arg0, object? arg1, object? arg2)
{
if (GetType() == typeof(StreamWriter))
{
}
}
- public override void WriteLine(string format, params object[] arg)
+ public override void WriteLine(string format, params object?[] arg)
{
if (GetType() == typeof(StreamWriter))
{
+ if (arg == null)
+ {
+ throw new ArgumentNullException(nameof(arg));
+ }
WriteFormatHelper(format, new ParamsArray(arg), appendNewLine: true);
}
else
_this.CharPos_Prop = charPos;
}
- public override Task WriteAsync(string value)
+ public override Task WriteAsync(string? value)
{
// If we have been inherited into a subclass, the following implementation could be incorrect
// since it does not call through to Write() which a subclass might have overridden.
}
- public override Task WriteLineAsync(string value)
+ public override Task WriteLineAsync(string? value)
{
if (value == null)
{
// Write(char) for each of the characters in the character array.
// If the character array is null, nothing is written.
//
- public virtual void Write(char[] buffer)
+ public virtual void Write(char[]? buffer)
{
if (buffer != null)
{
// Writes an array of characters followed by a line terminator to the text
// stream.
//
- public virtual void WriteLine(char[] buffer)
+ public virtual void WriteLine(char[]? buffer)
{
Write(buffer);
WriteLine();
}
}
- public Task WriteAsync(char[] buffer)
+ public Task WriteAsync(char[]? buffer)
{
if (buffer == null)
{
}
}
- public Task WriteLineAsync(char[] buffer)
+ public Task WriteLineAsync(char[]? buffer)
{
if (buffer == null)
{
public override void Write(char value) => _out.Write(value);
[MethodImpl(MethodImplOptions.Synchronized)]
- public override void Write(char[] buffer) => _out.Write(buffer);
+ public override void Write(char[]? buffer) => _out.Write(buffer);
[MethodImpl(MethodImplOptions.Synchronized)]
public override void Write(char[] buffer, int index, int count) => _out.Write(buffer, index, count);
public override void WriteLine(decimal value) => _out.WriteLine(value);
[MethodImpl(MethodImplOptions.Synchronized)]
- public override void WriteLine(char[] buffer) => _out.WriteLine(buffer);
+ public override void WriteLine(char[]? buffer) => _out.WriteLine(buffer);
[MethodImpl(MethodImplOptions.Synchronized)]
public override void WriteLine(char[] buffer, int index, int count) => _out.WriteLine(buffer, index, count);
{
ClassName = info.GetString("MMClassName");
MemberName = info.GetString("MMMemberName");
- Signature = (byte[])info.GetValue("MMSignature", typeof(byte[]));
+ Signature = (byte[]?)info.GetValue("MMSignature", typeof(byte[]));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
// 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.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// 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.Runtime.CompilerServices;
namespace System.Numerics
return value;
}
}
-}
+}
\ No newline at end of file
<#@ import namespace="System.Runtime.InteropServices" #>
<#@ include file="GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
+#nullable enable
using System.Runtime.CompilerServices;
namespace System.Numerics
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// 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.Runtime.InteropServices;
namespace System.Numerics
<#@ import namespace="System.Diagnostics" #>
<#@ include file="GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
+#nullable enable
using System.Runtime.InteropServices;
namespace System.Numerics
}
#> #endregion Internal Storage Fields
}
-}
\ No newline at end of file
+}
// 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
#if netcoreapp
using Internal.Runtime.CompilerServices;
#endif
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this vector; False otherwise.</returns>
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is Vector<T>))
{
/// </summary>
/// <param name="format">The format of individual elements.</param>
/// <returns>The string representation.</returns>
- public string ToString(string format)
+ public string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <param name="format">The format of individual elements.</param>
/// <param name="formatProvider">The format provider to use when formatting elements.</param>
/// <returns>The string representation.</returns>
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string? format, IFormatProvider? formatProvider)
{
StringBuilder sb = new StringBuilder();
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
<#@ import namespace="System.Runtime.InteropServices" #>
<#@ include file="GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
+#nullable enable
#if netcoreapp
using Internal.Runtime.CompilerServices;
#endif
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this vector; False otherwise.</returns>
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is Vector<T>))
{
/// </summary>
/// <param name="format">The format of individual elements.</param>
/// <returns>The string representation.</returns>
- public string ToString(string format)
+ public string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <param name="format">The format of individual elements.</param>
/// <param name="formatProvider">The format provider to use when formatting elements.</param>
/// <returns>The string representation.</returns>
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string? format, IFormatProvider? formatProvider)
{
StringBuilder sb = new StringBuilder();
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
private ReflectionTypeLoadException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- LoaderExceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[])));
+ LoaderExceptions = (Exception[]?)(info.GetValue("Exceptions", typeof(Exception[])));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
private RuntimeWrappedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _wrappedException = info.GetValue("WrappedException", typeof(object));
+ _wrappedException = info.GetValue("WrappedException", typeof(object))!;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
**
===========================================================*/
+#nullable enable
namespace System.Runtime.ConstrainedExecution
{
public abstract class CriticalFinalizerObject
// 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.Runtime.InteropServices.ComTypes
{
[StructLayout(LayoutKind.Sequential)]
void ReleaseBoundObjects();
void SetBindOptions([In()] ref BIND_OPTS pbindopts);
void GetBindOptions(ref BIND_OPTS pbindopts);
- void GetRunningObjectTable(out IRunningObjectTable pprot);
+ void GetRunningObjectTable(out IRunningObjectTable? pprot);
void RegisterObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey, [MarshalAs(UnmanagedType.Interface)] object punk);
- void GetObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey, [MarshalAs(UnmanagedType.Interface)] out object ppunk);
- void EnumObjectParam(out IEnumString ppenum);
+ void GetObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey, [MarshalAs(UnmanagedType.Interface)] out object? ppunk);
+ void EnumObjectParam(out IEnumString? ppenum);
[PreserveSig]
int RevokeObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey);
}
// 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.Runtime.InteropServices.ComTypes
{
[Guid("B196B286-BAB4-101A-B69C-00AA00341D07")]
// 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.Runtime.InteropServices.ComTypes
{
[Guid("B196B284-BAB4-101A-B69C-00AA00341D07")]
public interface IConnectionPointContainer
{
void EnumConnectionPoints(out IEnumConnectionPoints ppEnum);
- void FindConnectionPoint([In] ref Guid riid, out IConnectionPoint ppCP);
+ void FindConnectionPoint([In] ref Guid riid, out IConnectionPoint? ppCP);
}
}
// 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.Runtime.InteropServices.ComTypes
{
[Guid("B196B285-BAB4-101A-B69C-00AA00341D07")]
using System.Diagnostics;
using System.IO;
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
// 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.Runtime
{
public sealed partial class MemoryFailPoint
// 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.IO;
using System.Runtime.InteropServices;
**
===========================================================*/
-using System.IO;
+#nullable enable
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Runtime.CompilerServices;
-using System.Threading;
-
+#nullable enable
namespace System.Runtime.Serialization
{
// Tracks whether deserialization is currently in progress
public readonly struct DeserializationToken : IDisposable
{
- private readonly DeserializationTracker _tracker;
+ private readonly DeserializationTracker? _tracker;
- internal DeserializationToken(DeserializationTracker tracker)
+ internal DeserializationToken(DeserializationTracker? tracker)
{
_tracker = tracker;
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Runtime.CompilerServices;
-
+#nullable enable
namespace System.Runtime.Serialization
{
// Tracks whether deserialization is currently in progress
// 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.Runtime.Serialization
{
public interface IDeserializationCallback
// 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.Runtime.Serialization
{
[CLSCompliant(false)]
double ToDouble(object value);
decimal ToDecimal(object value);
DateTime ToDateTime(object value);
- string ToString(object value);
+ string? ToString(object value);
}
}
// 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.Runtime.Serialization
{
public interface IObjectReference
// 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.Runtime.Serialization
{
//
// 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.Runtime.Serialization
{
public interface ISerializable
// 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.Collections.Generic;
namespace System.Runtime.Serialization
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections;
+#nullable enable
using System.Collections.Generic;
using System.Diagnostics;
using System.Security;
// Even though we have a dictionary, we're still keeping all the arrays around for back-compat.
// Otherwise we may run into potentially breaking behaviors like GetEnumerator() not returning entries in the same order they were added.
private string[] _names;
- private object[] _values;
+ private object?[] _values;
private Type[] _types;
private int _count;
private Dictionary<string, int> _nameToIndex;
_types = newTypes;
}
- public void AddValue(string name, object value, Type type)
+ public void AddValue(string name, object? value, Type type)
{
if (null == name)
{
AddValueInternal(name, value, type);
}
- public void AddValue(string name, object value)
+ public void AddValue(string name, object? value)
{
if (null == value)
{
AddValue(name, (object)value, typeof(DateTime));
}
- internal void AddValueInternal(string name, object value, Type type)
+ internal void AddValueInternal(string name, object? value, Type type)
{
if (_nameToIndex.ContainsKey(name))
{
/// <param name="name"> The name of the element to find.</param>
/// <param name="foundType"> The type of the element associated with the given name.</param>
/// <returns>The value of the element at the position associated with name.</returns>
- private object GetElement(string name, out Type foundType)
+ private object? GetElement(string name, out Type foundType)
{
int index = FindElement(name);
if (index == -1)
return _values[index];
}
- private object GetElementNoThrow(string name, out Type foundType)
+ private object? GetElementNoThrow(string name, out Type? foundType)
{
int index = FindElement(name);
if (index == -1)
return _values[index];
}
- public object GetValue(string name, Type type)
+ public object? GetValue(string name, Type type)
{
if ((object)type == null)
{
if (!type.IsRuntimeImplemented())
throw new ArgumentException(SR.Argument_MustBeRuntimeType);
- Type foundType;
- object value;
- value = GetElement(name, out foundType);
+ Type foundType;
+ object? value = GetElement(name, out foundType);
if (ReferenceEquals(foundType, type) || type.IsAssignableFrom(foundType) || value == null)
{
return _converter.Convert(value, type);
}
- internal object GetValueNoThrow(string name, Type type)
+ internal object? GetValueNoThrow(string name, Type type)
{
- Type foundType;
- object value;
-
Debug.Assert((object)type != null, "[SerializationInfo.GetValue]type ==null");
Debug.Assert(type.IsRuntimeImplemented(), "[SerializationInfo.GetValue]type is not a runtime type");
- value = GetElementNoThrow(name, out foundType);
+ Type? foundType;
+ object? value = GetElementNoThrow(name, out foundType);
if (value == null)
return null;
public bool GetBoolean(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(bool)) ? (bool)value : _converter.ToBoolean(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(bool)) ? (bool)value : _converter.ToBoolean(value!); // if value is null To* method will either deal with it or throw
}
public char GetChar(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(char)) ? (char)value : _converter.ToChar(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(char)) ? (char)value : _converter.ToChar(value!);
}
[CLSCompliant(false)]
public sbyte GetSByte(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(sbyte)) ? (sbyte)value : _converter.ToSByte(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(sbyte)) ? (sbyte)value : _converter.ToSByte(value!);
}
public byte GetByte(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(byte)) ? (byte)value : _converter.ToByte(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(byte)) ? (byte)value : _converter.ToByte(value!);
}
public short GetInt16(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(short)) ? (short)value : _converter.ToInt16(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(short)) ? (short)value : _converter.ToInt16(value!);
}
[CLSCompliant(false)]
public ushort GetUInt16(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(ushort)) ? (ushort)value : _converter.ToUInt16(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(ushort)) ? (ushort)value : _converter.ToUInt16(value!);
}
public int GetInt32(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(int)) ? (int)value : _converter.ToInt32(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(int)) ? (int)value : _converter.ToInt32(value!);
}
[CLSCompliant(false)]
public uint GetUInt32(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(uint)) ? (uint)value : _converter.ToUInt32(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(uint)) ? (uint)value : _converter.ToUInt32(value!);
}
public long GetInt64(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(long)) ? (long)value : _converter.ToInt64(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(long)) ? (long)value : _converter.ToInt64(value!);
}
[CLSCompliant(false)]
public ulong GetUInt64(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(ulong)) ? (ulong)value : _converter.ToUInt64(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(ulong)) ? (ulong)value : _converter.ToUInt64(value!);
}
public float GetSingle(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(float)) ? (float)value : _converter.ToSingle(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(float)) ? (float)value : _converter.ToSingle(value!);
}
public double GetDouble(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(double)) ? (double)value : _converter.ToDouble(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(double)) ? (double)value : _converter.ToDouble(value!);
}
public decimal GetDecimal(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(decimal)) ? (decimal)value : _converter.ToDecimal(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(decimal)) ? (decimal)value : _converter.ToDecimal(value!);
}
public DateTime GetDateTime(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(DateTime)) ? (DateTime)value : _converter.ToDateTime(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(DateTime)) ? (DateTime)value : _converter.ToDateTime(value!);
}
- public string GetString(string name)
+ public string? GetString(string name)
{
Type foundType;
- object value = GetElement(name, out foundType);
- return ReferenceEquals(foundType, typeof(string)) || value == null ? (string)value : _converter.ToString(value);
+ object? value = GetElement(name, out foundType);
+ return ReferenceEquals(foundType, typeof(string)) || value == null ? (string?)value : _converter.ToString(value);
}
}
}
// 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.Collections;
using System.Diagnostics;
public readonly struct SerializationEntry
{
private readonly string _name;
- private readonly object _value;
+ private readonly object? _value;
private readonly Type _type;
- internal SerializationEntry(string entryName, object entryValue, Type entryType)
+ internal SerializationEntry(string entryName, object? entryValue, Type entryType)
{
_name = entryName;
_value = entryValue;
_type = entryType;
}
- public object Value => _value;
+ public object? Value => _value;
public string Name => _name;
public Type ObjectType => _type;
}
public sealed class SerializationInfoEnumerator : IEnumerator
{
private readonly string[] _members;
- private readonly object[] _data;
+ private readonly object?[] _data;
private readonly Type[] _types;
private readonly int _numItems;
private int _currItem;
private bool _current;
- internal SerializationInfoEnumerator(string[] members, object[] info, Type[] types, int numItems)
+ internal SerializationInfoEnumerator(string[] members, object?[] info, Type[] types, int numItems)
{
Debug.Assert(members != null, "[SerializationInfoEnumerator.ctor]members!=null");
Debug.Assert(info != null, "[SerializationInfoEnumerator.ctor]info!=null");
return _current;
}
- object IEnumerator.Current => Current;
+ object? IEnumerator.Current => Current; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/23268
public SerializationEntry Current
{
return _members[_currItem];
}
}
- public object Value
+ public object? Value
{
get
{
// 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.Runtime.Serialization
{
public readonly struct StreamingContext
{
- private readonly object _additionalContext;
+ private readonly object? _additionalContext;
private readonly StreamingContextStates _state;
public StreamingContext(StreamingContextStates state) : this(state, null)
{
}
- public StreamingContext(StreamingContextStates state, object additional)
+ public StreamingContext(StreamingContextStates state, object? additional)
{
_state = state;
_additionalContext = additional;
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is StreamingContext))
{
public StreamingContextStates State => _state;
- public object Context => _additionalContext;
+ public object? Context => _additionalContext;
}
[Flags]
protected SecurityException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- Demanded = (string)info.GetValueNoThrow(DemandedName, typeof(string));
- GrantedSet = (string)info.GetValueNoThrow(GrantedSetName, typeof(string));
- RefusedSet = (string)info.GetValueNoThrow(RefusedSetName, typeof(string));
- DenySetInstance = (string)info.GetValueNoThrow(DeniedName, typeof(string));
- PermitOnlySetInstance = (string)info.GetValueNoThrow(PermitOnlyName, typeof(string));
- Url = (string)info.GetValueNoThrow(UrlName, typeof(string));
+ Demanded = (string?)info.GetValueNoThrow(DemandedName, typeof(string));
+ GrantedSet = (string?)info.GetValueNoThrow(GrantedSetName, typeof(string));
+ RefusedSet = (string?)info.GetValueNoThrow(RefusedSetName, typeof(string));
+ DenySetInstance = (string?)info.GetValueNoThrow(DeniedName, typeof(string));
+ PermitOnlySetInstance = (string?)info.GetValueNoThrow(PermitOnlyName, typeof(string));
+ Url = (string?)info.GetValueNoThrow(UrlName, typeof(string));
}
public override string ToString() => base.ToString();
private CultureAwareComparer(SerializationInfo info, StreamingContext context)
{
- _compareInfo = (CompareInfo)info.GetValue("_compareInfo", typeof(CompareInfo));
+ _compareInfo = (CompareInfo)info.GetValue("_compareInfo", typeof(CompareInfo))!;
bool ignoreCase = info.GetBoolean("_ignoreCase");
var obj = info.GetValueNoThrow("_options", typeof(CompareOptions));
_daylightTransitionStart = (TransitionTime)info.GetValue("DaylightTransitionStart", typeof(TransitionTime)); // Do not rename (binary serialization)
_daylightTransitionEnd = (TransitionTime)info.GetValue("DaylightTransitionEnd", typeof(TransitionTime)); // Do not rename (binary serialization)
- object o = info.GetValueNoThrow("BaseUtcOffsetDelta", typeof(TimeSpan)); // Do not rename (binary serialization)
+ object? o = info.GetValueNoThrow("BaseUtcOffsetDelta", typeof(TimeSpan)); // Do not rename (binary serialization)
if (o != null)
{
_baseUtcOffsetDelta = (TimeSpan)o;
{
using (StreamReader sr = new StreamReader(Path.Combine(timeZoneDirectory, ZoneTabFileName), Encoding.UTF8))
{
- string zoneTabFileLine;
+ string? zoneTabFileLine;
while ((zoneTabFileLine = sr.ReadLine()) != null)
{
if (!string.IsNullOrEmpty(zoneTabFileLine) && zoneTabFileLine[0] != '#')
throw new ArgumentNullException(nameof(info));\r
}\r
\r
- _id = (string)info.GetValue("Id", typeof(string)); // Do not rename (binary serialization)\r
- _displayName = (string)info.GetValue("DisplayName", typeof(string)); // Do not rename (binary serialization)\r
- _standardDisplayName = (string)info.GetValue("StandardName", typeof(string)); // Do not rename (binary serialization)\r
- _daylightDisplayName = (string)info.GetValue("DaylightName", typeof(string)); // Do not rename (binary serialization)\r
+ _id = (string)info.GetValue("Id", typeof(string))!; // Do not rename (binary serialization)\r
+ _displayName = (string?)info.GetValue("DisplayName", typeof(string)); // Do not rename (binary serialization)\r
+ _standardDisplayName = (string?)info.GetValue("StandardName", typeof(string)); // Do not rename (binary serialization)\r
+ _daylightDisplayName = (string?)info.GetValue("DaylightName", typeof(string)); // Do not rename (binary serialization)\r
_baseUtcOffset = (TimeSpan)info.GetValue("BaseUtcOffset", typeof(TimeSpan)); // Do not rename (binary serialization)\r
- _adjustmentRules = (AdjustmentRule[])info.GetValue("AdjustmentRules", typeof(AdjustmentRule[])); // Do not rename (binary serialization)\r
+ _adjustmentRules = (AdjustmentRule[]?)info.GetValue("AdjustmentRules", typeof(AdjustmentRule[])); // Do not rename (binary serialization)\r
_supportsDaylightSavingTime = (bool)info.GetValue("SupportsDaylightSavingTime", typeof(bool)); // Do not rename (binary serialization)\r
}\r
\r
{
internal const int NullUnity = 0x0002;
private readonly int _unityType;
- private readonly string _data;
+ private readonly string? _data;
/// <summary>
/// A helper method that returns the SerializationInfo that a class utilizing