Future-proof conditional compilation

* Invert `#if NET5_0` conditions so that when adding net6.0 target framework, the _new_ APIs are used.
* Use `NET5_0_OR_GREATER` instead of `NET5_0` to ensure consistent behaviour on future target frameworks.
This commit is contained in:
Cédric Luthi
2021-09-29 09:40:58 +02:00
committed by Patrik Svensson
parent 644fb76d61
commit a5716a35e2
5 changed files with 19 additions and 28 deletions

View File

@ -177,19 +177,19 @@ namespace Spectre.Console
internal static string ReplaceExact(this string text, string oldValue, string? newValue)
{
#if NET5_0
return text.Replace(oldValue, newValue, StringComparison.Ordinal);
#else
#if NETSTANDARD2_0
return text.Replace(oldValue, newValue);
#else
return text.Replace(oldValue, newValue, StringComparison.Ordinal);
#endif
}
internal static bool ContainsExact(this string text, string value)
{
#if NET5_0
return text.Contains(value, StringComparison.Ordinal);
#else
#if NETSTANDARD2_0
return text.Contains(value);
#else
return text.Contains(value, StringComparison.Ordinal);
#endif
}
}