// 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.Buffers;
using System.Collections.Generic;
private const int MaxKeyLength = 255;
private const int MaxValueLength = 16383;
- private SafeRegistryHandle _hkey = null;
+ private SafeRegistryHandle _hkey;
private RegistryKey(SafeRegistryHandle hkey)
{
return new RegistryKey(new SafeRegistryHandle(hKey, false));
}
- public RegistryKey OpenSubKey(string name)
+ public RegistryKey? OpenSubKey(string name)
{
return OpenSubKey(name, false);
}
- public RegistryKey OpenSubKey(string name, bool writable)
+ public RegistryKey? OpenSubKey(string name, bool writable)
{
// Make sure that the name does not contain double slahes
Debug.Assert(name.IndexOf("\\\\") == -1);
// add up quickly- we'll try to keep the memory pressure low and grow the buffer
// only if needed.
- char[] name = ArrayPool<char>.Shared.Rent(100);
+ char[]? name = ArrayPool<char>.Shared.Rent(100);
try
{
return names.ToArray();
}
- public object GetValue(string name)
+ public object? GetValue(string name)
{
return GetValue(name, null);
}
- public object GetValue(string name, object defaultValue)
+ public object? GetValue(string name, object? defaultValue) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
{
- object data = defaultValue;
+ object? data = defaultValue;
int type = 0;
int datasize = 0;
- int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
+ int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[]?)null, ref datasize);
if (ret != 0)
{
// make sure the string is null terminated before processing the data
if (blob.Length > 0 && blob[blob.Length - 1] != (char)0)
{
- Array.Resize(ref blob, blob.Length + 1);
+ Array.Resize(ref blob!, blob.Length + 1); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
string[] strings = Array.Empty<string>();
nextNull++;
}
- string toAdd = null;
+ string? toAdd = null;
if (nextNull < len)
{
Debug.Assert(blob[nextNull] == (char)0, "blob[nextNull] should be 0");
{
if (strings.Length == stringsCount)
{
- Array.Resize(ref strings, stringsCount > 0 ? stringsCount * 2 : 4);
+ Array.Resize(ref strings!, stringsCount > 0 ? stringsCount * 2 : 4); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
- strings[stringsCount++] = toAdd;
+ strings![stringsCount++] = toAdd; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
}
- Array.Resize(ref strings, stringsCount);
+ Array.Resize(ref strings!, stringsCount); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
data = strings;
}
break;
}
}
- internal void Win32Error(int errorCode, string str)
+ internal void Win32Error(int errorCode, string? str)
{
switch (errorCode)
{