From c8ecb0082480b4a91b79df940f2c55ebfe40ffe1 Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Thu, 9 Mar 2023 21:36:50 +0000 Subject: [PATCH] Add global alias prefix to disambiguate System namespace (#55) --- .../SourceGenerationHelper.cs | 38 ++++++------ .../Enums.cs | 13 ++++ ...ExtensionsForFlagsEnum_Params.verified.txt | 40 ++++++------- ...numExtensionsInChildNamespace.verified.txt | 28 ++++----- ...umExtensionsInGlobalNamespace.verified.txt | 28 ++++----- ...teEnumExtensionsInNestedClass.verified.txt | 28 ++++----- ...eEnumExtensionsWithCustomName.verified.txt | 28 ++++----- ...EnumExtensionsWithCustomNames.verified.txt | 60 +++++++++---------- ...ExtensionsWithCustomNamespace.verified.txt | 28 ++++----- ...onsWithCustomNamespaceAndName.verified.txt | 28 ++++----- ...ExtensionsWithSameDisplayName.verified.txt | 52 ++++++++-------- ...tTests.GeneratesEnumCorrectly.verified.txt | 28 ++++----- ...s.GeneratesFlagsEnumCorrectly.verified.txt | 32 +++++----- 13 files changed, 222 insertions(+), 209 deletions(-) diff --git a/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs b/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs index 784caee..ef5de60 100644 --- a/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs +++ b/src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs @@ -23,9 +23,9 @@ namespace NetEscapades.EnumGenerators /// /// Add to enums to indicate that extension methods should be generated for the type /// - [System.AttributeUsage(System.AttributeTargets.Enum)] - [System.Diagnostics.Conditional(""NETESCAPADES_ENUMGENERATORS_USAGES"")] - public class EnumExtensionsAttribute : System.Attribute + [global::System.AttributeUsage(global::System.AttributeTargets.Enum)] + [global::System.Diagnostics.Conditional(""NETESCAPADES_ENUMGENERATORS_USAGES"")] + public class EnumExtensionsAttribute : global::System.Attribute { /// /// The namespace to generate the extension class. @@ -110,13 +110,13 @@ public static string ToStringFast(this ").Append(enumToGenerate.FullyQualifiedNa /// /// Determines whether one or more bit fields are set in the current instance. - /// Equivalent to calling on . + /// Equivalent to calling on . /// /// The value of the instance to investigate /// The flag to check for /// true if the fields set in the flag are also set in the current instance; otherwise false. /// If the underlying value of is zero, the method returns true. - /// This is consistent with the behaviour of + /// This is consistent with the behaviour of public static bool HasFlagFast(this ").Append(enumToGenerate.FullyQualifiedName).Append(@" value, ").Append(enumToGenerate.FullyQualifiedName).Append(@" flag) => flag == 0 ? true : (value & flag) == flag;"); } @@ -242,7 +242,7 @@ public static bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetad if (member.Value.DisplayName is not null && member.Value.IsDisplayNameTheFirstPresence) { sb.Append(@" - ReadOnlySpan current when current.Equals(""").Append(member.Value.DisplayName).Append(@""".AsSpan(), System.StringComparison.Ordinal) => true,"); + ReadOnlySpan current when current.Equals(""").Append(member.Value.DisplayName).Append(@""".AsSpan(), global::System.StringComparison.Ordinal) => true,"); } } @@ -265,7 +265,7 @@ public static bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetad { sb.Append(@" ReadOnlySpan current when current.Equals(nameof(").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key) - .Append(@").AsSpan(), System.StringComparison.Ordinal) => true,"); + .Append(@").AsSpan(), global::System.StringComparison.Ordinal) => true,"); } sb.Append(@" @@ -290,7 +290,7 @@ ReadOnlySpan current when current.Equals(nameof(").Append(enumToGenerate.F /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" value) @@ -312,7 +312,7 @@ public static bool TryParse( /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" value, @@ -337,7 +337,7 @@ public static bool TryParse( /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" value, @@ -359,7 +359,7 @@ public static bool TryParse( if (member.Value.DisplayName is not null && member.Value.IsDisplayNameTheFirstPresence) { sb.Append(@" - case string s when s.Equals(""").Append(member.Value.DisplayName).Append(@""", System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(""").Append(member.Value.DisplayName).Append(@""", global::System.StringComparison.OrdinalIgnoreCase): value = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } @@ -403,7 +403,7 @@ public static bool TryParse( { sb.Append(@" case string s when s.Equals(nameof(").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append( - @"), System.StringComparison.OrdinalIgnoreCase): + @"), global::System.StringComparison.OrdinalIgnoreCase): value = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } @@ -457,7 +457,7 @@ public static bool TryParse( /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" value) @@ -479,7 +479,7 @@ public static bool TryParse( /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" value, @@ -505,7 +505,7 @@ public static bool TryParse( /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out ").Append(enumToGenerate.FullyQualifiedName).Append(@" result, @@ -528,7 +528,7 @@ public static bool TryParse( { sb.Append(@" case ReadOnlySpan current when current.Equals(""").Append(member.Value.DisplayName).Append( - @""".AsSpan(), System.StringComparison.OrdinalIgnoreCase): + @""".AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } @@ -548,7 +548,7 @@ public static bool TryParse( if (member.Value.DisplayName is not null && member.Value.IsDisplayNameTheFirstPresence) { sb.Append(@" - case ReadOnlySpan current when current.Equals(""").Append(member.Value.DisplayName).Append(@""".AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(""").Append(member.Value.DisplayName).Append(@""".AsSpan(), global::System.StringComparison.Ordinal): result = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } @@ -572,7 +572,7 @@ public static bool TryParse( { sb.Append(@" case ReadOnlySpan current when current.Equals(nameof(").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append( - @").AsSpan(), System.StringComparison.OrdinalIgnoreCase): + @").AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } @@ -594,7 +594,7 @@ public static bool TryParse( { sb.Append(@" case ReadOnlySpan current when current.Equals(nameof(").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append( - @").AsSpan(), System.StringComparison.Ordinal): + @").AsSpan(), global::System.StringComparison.Ordinal): result = ").Append(enumToGenerate.FullyQualifiedName).Append('.').Append(member.Key).Append(@"; return true;"); } diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/Enums.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/Enums.cs index 57373c2..4406b19 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/Enums.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/Enums.cs @@ -2,6 +2,19 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; +namespace System +{ + using NetEscapades.EnumGenerators; + + [EnumExtensions] + public enum EnumInSystem + { + First = 0, + Second = 1, + Third = 2, + } +} + namespace NetEscapades.EnumGenerators.IntegrationTests { [EnumExtensions] 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 446953a..1fa8294 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt @@ -44,13 +44,13 @@ namespace MyTestNameSpace /// /// Determines whether one or more bit fields are set in the current instance. - /// Equivalent to calling on . + /// Equivalent to calling on . /// /// The value of the instance to investigate /// The flag to check for /// true if the fields set in the flag are also set in the current instance; otherwise false. /// If the underlying value of is zero, the method returns true. - /// This is consistent with the behaviour of + /// This is consistent with the behaviour of public static bool HasFlagFast(this MyTestNameSpace.MyEnum value, MyTestNameSpace.MyEnum flag) => flag == 0 ? true : (value & flag) == flag; @@ -117,9 +117,9 @@ namespace MyTestNameSpace { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -139,7 +139,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -160,7 +160,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -184,7 +184,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -195,13 +195,13 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Third; return true; case string s when int.TryParse(name, out var val): @@ -250,7 +250,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -271,7 +271,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -295,7 +295,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -306,13 +306,13 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Third; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -327,13 +327,13 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Third; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt index 27bd277..cd11f81 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt @@ -102,8 +102,8 @@ namespace MyTestNameSpace { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -144,7 +144,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -168,7 +168,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -179,10 +179,10 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -249,7 +249,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -273,7 +273,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -284,10 +284,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt index c66ee4f..9fd10f3 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt @@ -100,8 +100,8 @@ using System; { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -121,7 +121,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyEnum value) @@ -142,7 +142,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyEnum value, @@ -166,7 +166,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyEnum value, @@ -177,10 +177,10 @@ using System; { switch (name) { - case string s when s.Equals(nameof(MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyEnum.First; return true; - case string s when s.Equals(nameof(MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -226,7 +226,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyEnum value) @@ -247,7 +247,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyEnum value, @@ -271,7 +271,7 @@ using System; /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyEnum result, @@ -282,10 +282,10 @@ using System; { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -300,10 +300,10 @@ using System; { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt index 4a7c620..d539c23 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt @@ -102,8 +102,8 @@ namespace MyTestNameSpace { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.InnerClass.MyEnum value) @@ -144,7 +144,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.InnerClass.MyEnum value, @@ -168,7 +168,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.InnerClass.MyEnum value, @@ -179,10 +179,10 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.InnerClass.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.InnerClass.MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.InnerClass.MyEnum value) @@ -249,7 +249,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.InnerClass.MyEnum value, @@ -273,7 +273,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.InnerClass.MyEnum result, @@ -284,10 +284,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.InnerClass.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.InnerClass.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.InnerClass.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.InnerClass.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.InnerClass.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt index b60996a..0573669 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt @@ -102,8 +102,8 @@ namespace MyTestNameSpace { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -144,7 +144,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -168,7 +168,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -179,10 +179,10 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -249,7 +249,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -273,7 +273,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -284,10 +284,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt index 2964528..084533c 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt @@ -128,8 +128,8 @@ namespace MyTestNameSpace { isDefinedInDisplayAttribute = name switch { - ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals("4th".AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals("4th".AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -141,10 +141,10 @@ namespace MyTestNameSpace return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -164,7 +164,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -185,7 +185,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -209,7 +209,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -222,10 +222,10 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals("2nd", System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals("2nd", global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; - case string s when s.Equals("4th", System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals("4th", global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Fourth; return true; default: @@ -252,16 +252,16 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Third; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Fourth), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Fourth; return true; case string s when int.TryParse(name, out var val): @@ -313,7 +313,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -334,7 +334,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -358,7 +358,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -371,10 +371,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals("4th".AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals("4th".AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Fourth; return true; default: @@ -385,10 +385,10 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals("4th".AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals("4th".AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Fourth; return true; default: @@ -401,16 +401,16 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Third; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Fourth; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -425,16 +425,16 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Third; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Fourth; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt index 2c69ba4..f934615 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt @@ -102,8 +102,8 @@ namespace A.B { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -144,7 +144,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -168,7 +168,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -179,10 +179,10 @@ namespace A.B { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -249,7 +249,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -273,7 +273,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -284,10 +284,10 @@ namespace A.B { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace A.B { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt index 42e05ff..b93a3ec 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt @@ -102,8 +102,8 @@ namespace A.B { return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -144,7 +144,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -168,7 +168,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -179,10 +179,10 @@ namespace A.B { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -249,7 +249,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -273,7 +273,7 @@ namespace A.B /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -284,10 +284,10 @@ namespace A.B { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace A.B { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt index b1289f2..179d252 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithSameDisplayName.verified.txt @@ -127,7 +127,7 @@ namespace MyTestNameSpace { isDefinedInDisplayAttribute = name switch { - ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -139,10 +139,10 @@ namespace MyTestNameSpace return name switch { - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -162,7 +162,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value) @@ -183,7 +183,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -207,7 +207,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out MyTestNameSpace.MyEnum value, @@ -220,7 +220,7 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals("2nd", System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals("2nd", global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; default: @@ -244,16 +244,16 @@ namespace MyTestNameSpace { switch (name) { - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.First), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.First; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Second), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Second; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Third), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Third; return true; - case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Fourth), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(MyTestNameSpace.MyEnum.Fourth), global::System.StringComparison.OrdinalIgnoreCase): value = MyTestNameSpace.MyEnum.Fourth; return true; case string s when int.TryParse(name, out var val): @@ -305,7 +305,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value) @@ -326,7 +326,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum value, @@ -350,7 +350,7 @@ namespace MyTestNameSpace /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out MyTestNameSpace.MyEnum result, @@ -363,7 +363,7 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; default: @@ -374,7 +374,7 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals("2nd".AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals("2nd".AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; default: @@ -387,16 +387,16 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Third; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = MyTestNameSpace.MyEnum.Fourth; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -411,16 +411,16 @@ namespace MyTestNameSpace { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.First).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.First; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Second).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Second; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Third).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Third; return true; - case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(MyTestNameSpace.MyEnum.Fourth).AsSpan(), global::System.StringComparison.Ordinal): result = MyTestNameSpace.MyEnum.Fourth; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesEnumCorrectly.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesEnumCorrectly.verified.txt index 2de0f90..a65cdb9 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesEnumCorrectly.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesEnumCorrectly.verified.txt @@ -102,8 +102,8 @@ namespace Something.Blah { return name switch { - ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -123,7 +123,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value) @@ -144,7 +144,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value, @@ -168,7 +168,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value, @@ -179,10 +179,10 @@ namespace Something.Blah { switch (name) { - case string s when s.Equals(nameof(Something.Blah.ShortName.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(Something.Blah.ShortName.First), global::System.StringComparison.OrdinalIgnoreCase): value = Something.Blah.ShortName.First; return true; - case string s when s.Equals(nameof(Something.Blah.ShortName.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(Something.Blah.ShortName.Second), global::System.StringComparison.OrdinalIgnoreCase): value = Something.Blah.ShortName.Second; return true; case string s when int.TryParse(name, out var val): @@ -228,7 +228,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName value) @@ -249,7 +249,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName value, @@ -273,7 +273,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName result, @@ -284,10 +284,10 @@ namespace Something.Blah { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = Something.Blah.ShortName.First; return true; - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = Something.Blah.ShortName.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -302,10 +302,10 @@ namespace Something.Blah { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.Ordinal): result = Something.Blah.ShortName.First; return true; - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.Ordinal): result = Something.Blah.ShortName.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): diff --git a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesFlagsEnumCorrectly.verified.txt b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesFlagsEnumCorrectly.verified.txt index e739b0e..34c617a 100644 --- a/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesFlagsEnumCorrectly.verified.txt +++ b/tests/NetEscapades.EnumGenerators.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesFlagsEnumCorrectly.verified.txt @@ -43,13 +43,13 @@ namespace Something.Blah /// /// Determines whether one or more bit fields are set in the current instance. - /// Equivalent to calling on . + /// Equivalent to calling on . /// /// The value of the instance to investigate /// The flag to check for /// true if the fields set in the flag are also set in the current instance; otherwise false. /// If the underlying value of is zero, the method returns true. - /// This is consistent with the behaviour of + /// This is consistent with the behaviour of public static bool HasFlagFast(this Something.Blah.ShortName value, Something.Blah.ShortName flag) => flag == 0 ? true : (value & flag) == flag; @@ -114,8 +114,8 @@ namespace Something.Blah { return name switch { - ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.Ordinal) => true, - ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.Ordinal) => true, + ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.Ordinal) => true, _ => false, }; } @@ -135,7 +135,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value) @@ -156,7 +156,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value, @@ -180,7 +180,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif string? name, out Something.Blah.ShortName value, @@ -191,10 +191,10 @@ namespace Something.Blah { switch (name) { - case string s when s.Equals(nameof(Something.Blah.ShortName.First), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(Something.Blah.ShortName.First), global::System.StringComparison.OrdinalIgnoreCase): value = Something.Blah.ShortName.First; return true; - case string s when s.Equals(nameof(Something.Blah.ShortName.Second), System.StringComparison.OrdinalIgnoreCase): + case string s when s.Equals(nameof(Something.Blah.ShortName.Second), global::System.StringComparison.OrdinalIgnoreCase): value = Something.Blah.ShortName.Second; return true; case string s when int.TryParse(name, out var val): @@ -240,7 +240,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName value) @@ -261,7 +261,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName value, @@ -285,7 +285,7 @@ namespace Something.Blah /// true if the value parameter was converted successfully; otherwise, false. public static bool TryParse( #if NETCOREAPP3_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] #endif in ReadOnlySpan name, out Something.Blah.ShortName result, @@ -296,10 +296,10 @@ namespace Something.Blah { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = Something.Blah.ShortName.First; return true; - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.OrdinalIgnoreCase): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.OrdinalIgnoreCase): result = Something.Blah.ShortName.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult): @@ -314,10 +314,10 @@ namespace Something.Blah { switch (name) { - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.First).AsSpan(), global::System.StringComparison.Ordinal): result = Something.Blah.ShortName.First; return true; - case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), System.StringComparison.Ordinal): + case ReadOnlySpan current when current.Equals(nameof(Something.Blah.ShortName.Second).AsSpan(), global::System.StringComparison.Ordinal): result = Something.Blah.ShortName.Second; return true; case ReadOnlySpan current when int.TryParse(name, out var numericResult):