Also update TODO-NULLABLE comments to be more specific where appropriate.
int dwFlagsAndAttributes,
IntPtr hTemplateFile)
{
- lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
return CreateFilePrivate(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
}
FileMode dwCreationDisposition,
ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
{
- lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
return CreateFile2Private(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref pCreateExParams);
}
}
internal static SafeFindHandle FindFirstFile(string fileName, ref WIN32_FIND_DATA data)
{
- fileName = PathInternal.EnsureExtendedPrefixIfNeeded(fileName)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ fileName = PathInternal.EnsureExtendedPrefixIfNeeded(fileName)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
// use FindExInfoBasic since we don't care about short name and it has better perf
return FindFirstFileExPrivate(fileName, FINDEX_INFO_LEVELS.FindExInfoBasic, ref data, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, 0);
internal static bool GetFileAttributesEx(string name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation)
{
- name = PathInternal.EnsureExtendedPrefixIfNeeded(name)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ name = PathInternal.EnsureExtendedPrefixIfNeeded(name)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
return GetFileAttributesExPrivate(name, fileInfoLevel, ref lpFileInformation);
}
}
(Func<IPrincipal>)mi.CreateDelegate(typeof(Func<IPrincipal>)));
}
- principal = s_getUnauthenticatedPrincipal!(); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ principal = s_getUnauthenticatedPrincipal!(); // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
break;
case PrincipalPolicy.WindowsPrincipal:
(Func<IPrincipal>)mi.CreateDelegate(typeof(Func<IPrincipal>)));
}
- principal = s_getWindowsPrincipal!(); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ principal = s_getWindowsPrincipal!(); // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
break;
}
}
// If we're preserving, though, we don't zero out the slot, as we need it for
// enumerations, peeking, ToArray, etc. And we don't update the sequence number,
// so that an enqueuer will see it as full and be forced to move to a new segment.
- slots[slotsIndex].Item = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ slots[slotsIndex].Item = default;
Volatile.Write(ref slots[slotsIndex].SequenceNumber, currentHead + slots.Length);
}
return true;
_dictionary = dictionary;
_version = dictionary._version;
_index = 0;
- _currentKey = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentKey = default;
}
public void Dispose()
}
_index = _dictionary._count + 1;
- _currentKey = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentKey = default;
return false;
}
}
_index = 0;
- _currentKey = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentKey = default;
}
}
}
_dictionary = dictionary;
_version = dictionary._version;
_index = 0;
- _currentValue = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentValue = default;
}
public void Dispose()
}
}
_index = _dictionary._count + 1;
- _currentValue = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentValue = default;
return false;
}
ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
}
_index = 0;
- _currentValue = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _currentValue = default;
}
}
}
public abstract bool Equals([AllowNull] T x, [AllowNull] T y);
public abstract int GetHashCode([DisallowNull] T obj);
-#pragma warning disable CS8617 // TODO-NULLABLE: Covariance in interfaces (https://github.com/dotnet/roslyn/issues/35227)
int IEqualityComparer.GetHashCode(object? obj)
-#pragma warning restore CS8617
{
if (obj == null) return 0;
if (obj is T) return GetHashCode((T)obj);
_list = list;
_index = 0;
_version = list._version;
- _current = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _current = default;
}
public void Dispose()
}
_index = _list._size + 1;
- _current = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _current = default;
return false;
}
}
_index = 0;
- _current = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _current = default;
}
}
}
current = null;
}
-#pragma warning disable CS8612 // TODO-NULLABLE: Covariance in interfaces (https://github.com/dotnet/roslyn/issues/35227)
public object Current
-#pragma warning restore CS8612
{
get
{
{
foreach (string name in environmentKey.GetValueNames())
{
- string? value = environmentKey.GetValue(name, "")!.ToString(); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ string? value = environmentKey.GetValue(name, "")!.ToString(); // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
try
{
results.Add(name, value);
{
for (int i = 0; i < array.Length; i++)
{
- array[i] = ReescapeWin32String(array[i])!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ array[i] = ReescapeWin32String(array[i])!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
}
}
return true;
}
-#pragma warning disable CS8612 // TODO-NULLABLE: Covariance in interfaces (https://github.com/dotnet/roslyn/issues/35227)
public object Current => GetTextElement();
-#pragma warning restore CS8612
public string GetTextElement()
{
}
}
-#pragma warning disable CS8612 // TODO-NULLABLE: Covariance in interfaces (https://github.com/dotnet/roslyn/issues/35227)
public object Current => Entry;
-#pragma warning restore CS8612
// Warning: This requires that you call the Key or Entry property FIRST before calling it!
internal int DataPosition => _dataPosition;
{
#if !PROJECTN
/// <summary>A cached task for default(TResult).</summary>
- internal readonly static Task<TResult> s_defaultResultTask = AsyncTaskCache.CreateCacheableTask(default(TResult)!); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ internal readonly static Task<TResult> s_defaultResultTask = AsyncTaskCache.CreateCacheableTask<TResult>(default);
#endif
/// <summary>The lazily-initialized built task.</summary>
_currentIndex++;
if (c.TryGetEntry(_currentIndex, out TKey? key, out TValue value))
{
- _current = new KeyValuePair<TKey, TValue>(key!, value); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _current = new KeyValuePair<TKey, TValue>(key, value);
return true;
}
}
get
{
object? obj = ExecutionContext.GetLocalValue(this);
- return (obj == null) ? default! : (T)obj; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ return (obj == null) ? default : (T)obj;
}
set
{
}
}
- return target!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ return target!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
}
/// <summary>
public class Task<TResult> : Task
{
// The value itself, if set.
- [MaybeNull] internal TResult m_result = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ [MaybeNull] internal TResult m_result = default!;
private static readonly TaskFactory<TResult> s_Factory = new TaskFactory<TResult>();
{
TaskCreationOptions tco;
Task.CreationOptionsFromContinuationOptions(continuationOptions, out tco, out _);
- return new Task<TResult>(true, default!, tco, ct); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ return new Task<TResult>(true, default, tco, ct);
}
//
// Reset/update state for the next use/await of this instance.
_version++;
_completed = false;
- _result = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _result = default;
_error = null;
_executionContext = null;
_capturedContext = null;
{
if (!cancellationToken.IsCancellationRequested)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.cancellationToken);
- return new Task<TResult>(true, default!, TaskCreationOptions.None, cancellationToken); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ return new Task<TResult>(true, default, TaskCreationOptions.None, cancellationToken);
}
/// <summary>Creates a <see cref="Task"/> that's completed due to cancellation with the specified exception.</summary>
if (Task.s_asyncDebuggingEnabled)
RemoveFromActiveTasks(this);
- result = TrySetResult(taskTResult != null ? taskTResult.Result : default!); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ result = TrySetResult(taskTResult != null ? taskTResult.Result : default);
break;
}
return result;
_obj = task;
- _result = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _result = default;
_continueOnCapturedContext = true;
_token = 0;
}
_obj = source;
_token = token;
- _result = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _result = default;
_continueOnCapturedContext = true;
}
// And clear the references from the slot table to the linked slot and the value so that
// both can get garbage collected.
- slotArray[id].Value!._value = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ slotArray[id].Value!._value = default;
slotArray[id].Value = null;
}
}
internal volatile LinkedSlotVolatile[]? _slotArray;
// The value for this slot.
- [AllowNull, MaybeNull] internal T _value = default!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ [AllowNull, MaybeNull] internal T _value = default;
}
/// <summary>
if (symlinkPath != null)
{
// symlinkPath can be relative path, use Path to get the full absolute path.
- symlinkPath = Path.GetFullPath(symlinkPath, Path.GetDirectoryName(tzFilePath)!); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ symlinkPath = Path.GetFullPath(symlinkPath, Path.GetDirectoryName(tzFilePath)!);
string timeZoneDirectory = GetTimeZoneDirectory();
if (symlinkPath.StartsWith(timeZoneDirectory, StringComparison.Ordinal))
// read LastEntry {(yearN, 1, 1) - MaxValue }
// read the FirstEntry and LastEntry key values (ex: "1980", "2038")
- int first = (int)dynamicKey.GetValue(FirstEntryValue, -1)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
- int last = (int)dynamicKey.GetValue(LastEntryValue, -1)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ int first = (int)dynamicKey.GetValue(FirstEntryValue, -1)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
+ int last = (int)dynamicKey.GetValue(LastEntryValue, -1)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
if (first == -1 || last == -1 || first > last)
{
{
if (wrapper.Delegate.GetType() == d.GetType())
{
- wrapper.Delegate = Delegate.Combine(wrapper.Delegate, d)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ wrapper.Delegate = Delegate.Combine(wrapper.Delegate, d)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
return;
}
}
_assemblyPaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (string assemblyPath in assemblyPaths)
{
- _assemblyPaths.Add(Path.GetFileNameWithoutExtension(assemblyPath)!, assemblyPath); // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ _assemblyPaths.Add(Path.GetFileNameWithoutExtension(assemblyPath)!, assemblyPath); // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
}
_nativeSearchPaths = SplitPathsList(nativeSearchPathsList);
Utf8String newString = FastAllocate(value.Length);
Buffer.Memmove(ref newString.DangerousGetMutableReference(), ref MemoryMarshal.GetReference(value), (uint)value.Length);
- return Utf8Utility.ValidateAndFixupUtf8String(newString)!; // TODO-NULLABLE: Remove ! when nullable attributes are respected
+ return Utf8Utility.ValidateAndFixupUtf8String(newString)!; // TODO-NULLABLE: Remove ! when [NotNullIfNotNull] respected
}
/// <summary>