diff --git a/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs b/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs
index bd87017..9bd521e 100644
--- a/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs
+++ b/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs
@@ -468,7 +468,6 @@ public static bool IsDefined(string name, bool allowMatchingMetadataAttribute)
"""
- #if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -508,10 +507,10 @@ public static bool IsDefined(in global::System.ReadOnlySpan name, bool all
sb.Append(
"""
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(
""")
.Append(SymbolDisplay.FormatLiteral(dn, quote: true))
- .Append(", global::System.StringComparison.Ordinal) => true,");
+ .Append("), global::System.StringComparison.Ordinal) => true,");
}
}
@@ -541,10 +540,10 @@ public static bool IsDefined(in global::System.ReadOnlySpan name, bool all
sb.Append(
"""
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(
""").Append(fullyQualifiedName).Append('.')
.Append(member.Key)
- .Append("), global::System.StringComparison.Ordinal) => true,");
+ .Append(")), global::System.StringComparison.Ordinal) => true,");
}
sb.Append(
@@ -553,7 +552,6 @@ public static bool IsDefined(in global::System.ReadOnlySpan name, bool all
_ => false,
};
}
- #endif
""");
sb.Append(
@@ -949,7 +947,6 @@ private static bool TryParseWithCase(
}
}
- #if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an current when global::System.MemoryExtensions.Equals(current,
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(
""")
.Append(SymbolDisplay.FormatLiteral(dn, quote: true)).Append(
"""
- , global::System.StringComparison.OrdinalIgnoreCase):
+ ), global::System.StringComparison.OrdinalIgnoreCase):
result =
""").Append(fullyQualifiedName).Append('.').Append(member.Key).Append(
"""
@@ -1206,11 +1203,11 @@ private static bool TryParseIgnoreCase(
sb.Append(
"""
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(
""").Append(fullyQualifiedName).Append('.')
.Append(member.Key).Append(
"""
- ), global::System.StringComparison.OrdinalIgnoreCase):
+ )), global::System.StringComparison.OrdinalIgnoreCase):
result =
""").Append(fullyQualifiedName).Append('.').Append(member.Key).Append(
"""
@@ -1225,7 +1222,13 @@ private static bool TryParseIgnoreCase(
case global::System.ReadOnlySpan current when
""").Append(enumToGenerate.UnderlyingType).Append(
"""
- .TryParse(name, out var numericResult):
+ .TryParse(
+ name
+ #if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+ #endif
+ , out var numericResult):
result = (
""").Append(fullyQualifiedName).Append(
"""
@@ -1267,11 +1270,11 @@ private static bool TryParseWithCase(
sb.Append(
"""
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current,
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(
""")
.Append(SymbolDisplay.FormatLiteral(dn, quote: true)).Append(
"""
- , global::System.StringComparison.Ordinal):
+ ), global::System.StringComparison.Ordinal):
result =
""").Append(fullyQualifiedName).Append('.').Append(member.Key).Append(
"""
@@ -1303,11 +1306,11 @@ private static bool TryParseWithCase(
sb.Append(
"""
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(
""").Append(fullyQualifiedName).Append('.')
.Append(member.Key).Append(
"""
- ), global::System.StringComparison.Ordinal):
+ )), global::System.StringComparison.Ordinal):
result =
""").Append(fullyQualifiedName).Append('.').Append(member.Key).Append(
"""
@@ -1322,7 +1325,13 @@ private static bool TryParseWithCase(
case global::System.ReadOnlySpan current when
""").Append(enumToGenerate.UnderlyingType).Append(
"""
- .TryParse(name, out var numericResult):
+ .TryParse(
+ name
+ #if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+ #endif
+ , out var numericResult):
result = (
""").Append(fullyQualifiedName).Append(
"""
@@ -1333,7 +1342,6 @@ private static bool TryParseWithCase(
return false;
}
}
- #endif
""");
var orderedNames = GetNamesOrderedByValue(enumToGenerate);
diff --git a/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj b/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj
index 5b2ecdd..794d31a 100644
--- a/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj
+++ b/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj
@@ -18,5 +18,6 @@
+
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt
index 7023687..cb4be52 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt
@@ -120,7 +120,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -142,13 +141,12 @@ namespace MyTestNameSpace
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -332,7 +330,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -461,16 +458,22 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -489,16 +492,22 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -506,7 +515,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt
index 26db5d5..1e10de6 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt
@@ -105,7 +105,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -127,12 +126,11 @@ namespace MyTestNameSpace
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -310,7 +308,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -439,13 +436,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -464,13 +467,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -478,7 +487,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt
index af8f252..fb8c589 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt
@@ -103,7 +103,6 @@
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -125,12 +124,11 @@
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -308,7 +306,6 @@
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -437,13 +434,19 @@
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyEnum)numericResult;
return true;
default:
@@ -462,13 +465,19 @@
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyEnum)numericResult;
return true;
default:
@@ -476,7 +485,6 @@
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt
index a7fd3b4..cf4228e 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt
@@ -105,7 +105,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -127,12 +126,11 @@ namespace MyTestNameSpace
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -310,7 +308,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -439,13 +436,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.InnerClass.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.InnerClass.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.InnerClass.MyEnum)numericResult;
return true;
default:
@@ -464,13 +467,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.InnerClass.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.InnerClass.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.InnerClass.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.InnerClass.MyEnum)numericResult;
return true;
default:
@@ -478,7 +487,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt
index 5dab336..0a0c467 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt
@@ -1,4 +1,4 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by the NetEscapades.EnumGenerators source generator
//
@@ -105,7 +105,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -127,12 +126,11 @@ namespace MyTestNameSpace
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -310,7 +308,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -439,13 +436,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -464,13 +467,19 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -478,7 +487,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt
index 79fa5fa..9f49325 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt
@@ -134,7 +134,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -159,8 +158,8 @@ namespace MyTestNameSpace
{
isDefinedInDisplayAttribute = name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "4th", global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("4th"), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
@@ -172,14 +171,13 @@ namespace MyTestNameSpace
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -397,7 +395,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -528,10 +525,10 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "4th", global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("4th"), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
default:
@@ -541,19 +538,25 @@ namespace MyTestNameSpace
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -574,10 +577,10 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "4th", global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("4th"), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
default:
@@ -587,19 +590,25 @@ namespace MyTestNameSpace
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -607,7 +616,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt
index f570524..a3e3ceb 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt
@@ -1,4 +1,4 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by the NetEscapades.EnumGenerators source generator
//
@@ -105,7 +105,6 @@ namespace A.B
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -127,12 +126,11 @@ namespace A.B
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -310,7 +308,6 @@ namespace A.B
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -439,13 +436,19 @@ namespace A.B
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -464,13 +467,19 @@ namespace A.B
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -478,7 +487,6 @@ namespace A.B
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt
index fe48913..01d2196 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt
@@ -105,7 +105,6 @@ namespace A.B
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -127,12 +126,11 @@ namespace A.B
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -310,7 +308,6 @@ namespace A.B
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -439,13 +436,19 @@ namespace A.B
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -464,13 +467,19 @@ namespace A.B
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -478,7 +487,6 @@ namespace A.B
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt
index 1dec877..9a2a41d 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt
@@ -133,7 +133,6 @@ namespace MyTestNameSpace
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -158,7 +157,7 @@ namespace MyTestNameSpace
{
isDefinedInDisplayAttribute = name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
@@ -170,14 +169,13 @@ namespace MyTestNameSpace
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -389,7 +387,6 @@ namespace MyTestNameSpace
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -520,7 +517,7 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
default:
@@ -530,19 +527,25 @@ namespace MyTestNameSpace
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -563,7 +566,7 @@ namespace MyTestNameSpace
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, "2nd", global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan("2nd"), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
default:
@@ -573,19 +576,25 @@ namespace MyTestNameSpace
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.First), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.First)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.First;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Second), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Second)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Second;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Third), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Third)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Third;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.Ordinal):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::MyTestNameSpace.MyEnum.Fourth)), global::System.StringComparison.Ordinal):
result = global::MyTestNameSpace.MyEnum.Fourth;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan current when int.TryParse(
+ name
+#if !NETCOREAPP || NETCOREAPP2_0 || NETCOREAPP1_1 || NETCOREAPP1_0
+
+ .ToString()
+#endif
+ , out var numericResult):
result = (global::MyTestNameSpace.MyEnum)numericResult;
return true;
default:
@@ -593,7 +602,6 @@ namespace MyTestNameSpace
return false;
}
}
-#endif
///
/// Retrieves an array of the values of the members defined in
diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateExternalEnumExtensionsWithCustomName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateExternalEnumExtensionsWithCustomName.verified.txt
index f8fe225..70b419f 100644
--- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateExternalEnumExtensionsWithCustomName.verified.txt
+++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateExternalEnumExtensionsWithCustomName.verified.txt
@@ -108,7 +108,6 @@ namespace System
};
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Returns a boolean telling whether an enum with the given name exists in the enumeration
///
@@ -130,13 +129,12 @@ namespace System
{
return name switch
{
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Unspecified), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Utc), global::System.StringComparison.Ordinal) => true,
- global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Local), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Unspecified)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Utc)), global::System.StringComparison.Ordinal) => true,
+ global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Local)), global::System.StringComparison.Ordinal) => true,
_ => false,
};
}
-#endif
///
/// Converts the string representation of the name or numeric value of
@@ -320,7 +318,6 @@ namespace System
}
}
-#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0
///
/// Converts the string representation of the name or numeric value of
/// an to the equivalent instance.
@@ -449,16 +446,22 @@ namespace System
{
switch (name)
{
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Unspecified), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Unspecified)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::System.DateTimeKind.Unspecified;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Utc), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Utc)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::System.DateTimeKind.Utc;
return true;
- case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, nameof(global::System.DateTimeKind.Local), global::System.StringComparison.OrdinalIgnoreCase):
+ case global::System.ReadOnlySpan current when global::System.MemoryExtensions.Equals(current, global::System.MemoryExtensions.AsSpan(nameof(global::System.DateTimeKind.Local)), global::System.StringComparison.OrdinalIgnoreCase):
result = global::System.DateTimeKind.Local;
return true;
- case global::System.ReadOnlySpan current when int.TryParse(name, out var numericResult):
+ case global::System.ReadOnlySpan