Repository: files-community/Files
File: src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs (C#)

Code before:
		}

		private JsonDocument? GetGoogleDriveRegValJson()
        {
            // This will be null if the key name is not found.
            using var googleDriveRegKey = Registry.CurrentUser.OpenSubKey(_googleDriveRegKeyName);

            if (googleDriveRegKey is null)
            {
                _logger.LogWarning(
                    "Google Drive registry key for key name `"
                        + _googleDriveRegKeyName
                        + "' not found."
                );
                return null;
            }

            var googleDriveRegVal = googleDriveRegKey.GetValue(_googleDriveRegValName);

            if (googleDriveRegVal is null)
            {
                _logger.LogWarning(
                    "Google Drive registry value for value name `"
                        + _googleDriveRegValName
                        + "' not found."
                );
                return null;
            }

            JsonDocument? googleDriveRegValueJson = null;
            try
            {
                googleDriveRegValueJson = JsonDocument.Parse(googleDriveRegVal.ToString() ?? "");
            }
            catch (JsonException je)
            {
                _logger.LogWarning(
                    je,
                    "Google Drive registry value for value name `"
                        + _googleDriveRegValName
                        + "' could not be parsed as a JsonDocument."
                );
            }

            return googleDriveRegValueJson;
        }

		private async IAsyncEnumerable<ICloudProvider> GetGoogleDriveProvidersFromRegistryAsync()
		{
            var googleDriveRegValJson = GetGoogleDriveRegValJson();


Review comment (suggestion):
```suggestion
                _logger.LogWarning($"Google Drive registry value for value name '{_googleDriveRegValName}' not found.");
```


Code after:
			}

			return googleDriveRegValueJson;
		}

		public static string? GetRegistryBasePath()
		{
			var googleDriveRegValJson = GetGoogleDriveRegValJson();

			if (googleDriveRegValJson is null)
				return null;

			var googleDriveRegValJsonProperty = googleDriveRegValJson
				.RootElement.EnumerateObject()
				.FirstOrDefault();

			// A default JsonProperty struct has an "Undefined" Value#ValueKind and throws an
			// error if you try to call EnumerateArray on its Value.
			if (googleDriveRegValJsonProperty.Value.ValueKind == JsonValueKind.Undefined)
			{
				_logger.LogWarning($"Root element of Google Drive registry value for value name '{_googleDriveRegValName}' was empty.");
				return null;
			}

			Debug.WriteLine("REGISTRY LOGGING");
			Debug.WriteLine(googleDriveRegValJsonProperty.ToString());

			var item = googleDriveRegValJsonProperty.Value.EnumerateArray().FirstOrDefault();
			if (item.ValueKind == JsonValueKind.Undefined)
			{
				_logger.LogWarning($"Array in the root element of Google Drive registry value for value name '{_googleDriveRegValName}' was empty.");
				return null;
			}

			if (!item.TryGetProperty(_googleDriveRegValPropName, out var googleDriveRegValProp))
			{
				_logger.LogWarning($"First element in the Google Drive Registry Root Array did not have property named {_googleDriveRegValPropName}");
				return null;
			}

			if (!googleDriveRegValProp.TryGetProperty(_googleDriveRegValPropPropName, out var googleDriveRegValPropProp))
			{
				_logger.LogWarning($"Value from {_googleDriveRegValPropName} did not have property named {_googleDriveRegValPropPropName}");
				return null;
			}

			var path = googleDriveRegValPropProp.GetString();
			if (path is not null) 
				return ConvertDriveLetterToPathAndValidate(ref path) ? path : null;

			_logger.LogWarning($"Could not get string from value from {_googleDriveRegValPropPropName}");