From c6fe32c50a0331efa72ba66d824b0eae9687914e Mon Sep 17 00:00:00 2001 From: Glen Date: Tue, 7 Jan 2025 16:20:25 +0200 Subject: [PATCH] Renamed "EnumTypesInconsistentRule" to "EnumValuesMismatchRule" (#7906) --- .../src/Fusion.Composition/Logging/LogEntryCodes.cs | 2 +- .../src/Fusion.Composition/Logging/LogEntryHelper.cs | 6 +++--- ...mTypesInconsistentRule.cs => EnumValuesMismatchRule.cs} | 7 +++---- .../Properties/CompositionResources.Designer.cs | 4 ++-- .../Properties/CompositionResources.resx | 2 +- .../src/Fusion.Composition/SourceSchemaMerger.cs | 2 +- ...nsistentRuleTests.cs => EnumValuesMismatchRuleTests.cs} | 6 +++--- 7 files changed, 14 insertions(+), 15 deletions(-) rename src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/{EnumTypesInconsistentRule.cs => EnumValuesMismatchRule.cs} (87%) rename src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/{EnumTypesInconsistentRuleTests.cs => EnumValuesMismatchRuleTests.cs} (95%) diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryCodes.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryCodes.cs index a37f8b4d3a9..1e4f9c46b21 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryCodes.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryCodes.cs @@ -3,7 +3,7 @@ namespace HotChocolate.Fusion.Logging; public static class LogEntryCodes { public const string DisallowedInaccessible = "DISALLOWED_INACCESSIBLE"; - public const string EnumTypesInconsistent = "ENUM_TYPES_INCONSISTENT"; + public const string EnumValuesMismatch = "ENUM_VALUES_MISMATCH"; public const string ExternalArgumentDefaultMismatch = "EXTERNAL_ARGUMENT_DEFAULT_MISMATCH"; public const string ExternalMissingOnBase = "EXTERNAL_MISSING_ON_BASE"; public const string ExternalOnInterface = "EXTERNAL_ON_INTERFACE"; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryHelper.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryHelper.cs index 269559d545d..8a3f6f36088 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryHelper.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryHelper.cs @@ -100,18 +100,18 @@ public static LogEntry DisallowedInaccessibleDirectiveArgument( schema); } - public static LogEntry EnumTypesInconsistent( + public static LogEntry EnumValuesMismatch( EnumTypeDefinition enumType, string enumValue, SchemaDefinition schema) { return new LogEntry( string.Format( - LogEntryHelper_EnumTypesInconsistent, + LogEntryHelper_EnumValuesMismatch, enumType.Name, schema.Name, enumValue), - LogEntryCodes.EnumTypesInconsistent, + LogEntryCodes.EnumValuesMismatch, LogSeverity.Error, new SchemaCoordinate(enumType.Name), enumType, diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumTypesInconsistentRule.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumValuesMismatchRule.cs similarity index 87% rename from src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumTypesInconsistentRule.cs rename to src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumValuesMismatchRule.cs index 85944355fa4..d2b4dcdbd16 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumTypesInconsistentRule.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/EnumValuesMismatchRule.cs @@ -18,10 +18,10 @@ namespace HotChocolate.Fusion.PreMergeValidation.Rules; /// exact match in their values. /// /// -/// +/// /// Specification /// -internal sealed class EnumTypesInconsistentRule : IEventHandler +internal sealed class EnumValuesMismatchRule : IEventHandler { public void Handle(EnumTypeGroupEvent @event, CompositionContext context) { @@ -44,8 +44,7 @@ public void Handle(EnumTypeGroupEvent @event, CompositionContext context) { if (!enumType.Values.ContainsName(enumValue)) { - context.Log.Write( - EnumTypesInconsistent(enumType, enumValue, schema)); + context.Log.Write(EnumValuesMismatch(enumType, enumValue, schema)); } } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs index 1e7f11d4fa0..b00df7d1465 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs @@ -116,9 +116,9 @@ internal static string LogEntryHelper_DisallowedInaccessibleIntrospectionType { /// /// Looks up a localized string similar to The enum type '{0}' in schema '{1}' must define the value '{2}'.. /// - internal static string LogEntryHelper_EnumTypesInconsistent { + internal static string LogEntryHelper_EnumValuesMismatch { get { - return ResourceManager.GetString("LogEntryHelper_EnumTypesInconsistent", resourceCulture); + return ResourceManager.GetString("LogEntryHelper_EnumValuesMismatch", resourceCulture); } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.resx b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.resx index fd7394c6db5..74c59613533 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.resx +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.resx @@ -36,7 +36,7 @@ The built-in directive argument '{0}' in schema '{1}' is not accessible. - + The enum type '{0}' in schema '{1}' must define the value '{2}'. diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaMerger.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaMerger.cs index ba89727622d..cee7c6b5bd3 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaMerger.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaMerger.cs @@ -47,7 +47,7 @@ private CompositionResult MergeSchemaDefinitions(CompositionCo private static readonly List _preMergeValidationRules = [ new DisallowedInaccessibleElementsRule(), - new EnumTypesInconsistentRule(), + new EnumValuesMismatchRule(), new ExternalArgumentDefaultMismatchRule(), new ExternalMissingOnBaseRule(), new ExternalOnInterfaceRule(), diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumTypesInconsistentRuleTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumValuesMismatchRuleTests.cs similarity index 95% rename from src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumTypesInconsistentRuleTests.cs rename to src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumValuesMismatchRuleTests.cs index 0b59e5bc9fa..2be30e48fc3 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumTypesInconsistentRuleTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/PreMergeValidation/Rules/EnumValuesMismatchRuleTests.cs @@ -4,9 +4,9 @@ namespace HotChocolate.Composition.PreMergeValidation.Rules; -public sealed class EnumTypesInconsistentRuleTests : CompositionTestBase +public sealed class EnumValuesMismatchRuleTests : CompositionTestBase { - private readonly PreMergeValidator _preMergeValidator = new([new EnumTypesInconsistentRule()]); + private readonly PreMergeValidator _preMergeValidator = new([new EnumValuesMismatchRule()]); [Theory] [MemberData(nameof(ValidExamplesData))] @@ -36,7 +36,7 @@ public void Examples_Invalid(string[] sdl, string[] errorMessages) // assert Assert.True(result.IsFailure); Assert.Equal(errorMessages, context.Log.Select(e => e.Message).ToArray()); - Assert.True(context.Log.All(e => e.Code == "ENUM_TYPES_INCONSISTENT")); + Assert.True(context.Log.All(e => e.Code == "ENUM_VALUES_MISMATCH")); Assert.True(context.Log.All(e => e.Severity == LogSeverity.Error)); }