diff --git a/src/TypeNameInterpretation/FrameworkExtensions/SpanExtensions.cs b/src/TypeNameInterpretation/FrameworkExtensions/SpanExtensions.cs new file mode 100644 index 0000000..7996ec1 --- /dev/null +++ b/src/TypeNameInterpretation/FrameworkExtensions/SpanExtensions.cs @@ -0,0 +1,11 @@ +// Copyright (c) Brian Reichle. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information. + +#if !NET +namespace System; + +static class SpanExtensions +{ + public static bool ContainsAny(this ReadOnlySpan haystack, ReadOnlySpan needle) + => haystack.IndexOfAny(needle) >= 0; +} +#endif diff --git a/src/TypeNameInterpretation/InsFormatter.cs b/src/TypeNameInterpretation/InsFormatter.cs index 6aa54d6..67d8525 100644 --- a/src/TypeNameInterpretation/InsFormatter.cs +++ b/src/TypeNameInterpretation/InsFormatter.cs @@ -31,7 +31,7 @@ public static string Format(InsAssembly assembly) { ArgumentNullException.ThrowIfNull(assembly); - if (assembly.Qualifications.Length == 0 && assembly.Name.AsSpan().IndexOfAny(Delimiters.All) < 0) + if (assembly.Qualifications.Length == 0 && !assembly.Name.AsSpan().ContainsAny(Delimiters.All)) { return assembly.Name; } @@ -188,7 +188,7 @@ static void WriteWithEscapedDelimiters(StringBuilder builder, string identifier, } static bool RequiresQuoting(string identifier) - => string.IsNullOrEmpty(identifier) || identifier.AsSpan().IndexOfAny(Delimiters.All) >= 0; + => string.IsNullOrEmpty(identifier) || identifier.AsSpan().ContainsAny(Delimiters.All); } sealed class AssemblyLocator : IInsTypeVisitor