Код: Выделить всё
public static string GetIpAddress(this HttpContext ctx)
{
// Try Cloudflare Header
if (ctx.Request.Headers.TryGetValue("CF-Connecting-IP", out var ip)
&& !string.IsNullOrEmpty(ip))
{
return ip; // Warning here
}
// Return from the connection
return ctx.Connection.RemoteIpAddress?.ToString() ?? "0.0.0.0";
}

Сначала я подумал, что это проблема IDE, но сборка dotnet возвращает то же предупреждение.
Я даже убедился, что определение платформы правильное, и это так (используя ссылку на источник VS ):
Код: Выделить всё
public static bool IsNullOrEmpty([NotNullWhen(false)] string? value)
{
return value == null || value.Length == 0;
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... -i-have-an