logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: String Equality Comparison, Broken Tests and .NET-1.x
Date Tue, 23 Aug 2016 04:14:32 GMT
On 2016-08-22, <Jonas.Baehr@rohde-schwarz.com> wrote:

> A recent commit [1] changed, among other things, some string equality
> comparisons from `SomeComparer.Compare(a, "B", IgnoreCase) == 0` to
> `a.ToUpperInvariant() == "B"`, see also [2].
> Unfortunately, this doesn't work if `a` is allowed to be null. Currently a
> lot of log4net.Tests are broken because of such a null reference exception
> in `NewLinePatternConverter.ActivateOptions` (apparently "%newline" is
> quite common in pattern layouts ;-).

Oh, I'm sorry. I must admit I glanced over the PR and applied it without
running the tests. My fault.

> For new code I tend to opt for `String.Equals(Option, "DOS",
> StringComparison.OrdinalIgnoreCase)` for a fast, case-insensitive
> comparison with fixed ASCII-only patterns, but static
> `String.Equals(String, String, StringComparison)` is not awailable on
> .NET-1.x [3].

This is what the original code before PR #16 looked like, but it doesn't
seem to be available for .NET Core, see the discussion around

> Should we create some helper in SystemInfo that provides null-aware,
> ordinal, casing-agnostic string equality comparison, with some #if's
> .NET-1.x?



View raw message