Skip to content

Commit

Permalink
Make amendments following feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielreynolds1 committed Dec 19, 2024
1 parent 9f23c56 commit 7701ff1
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using HotChocolate.Fusion.Events;
using HotChocolate.Language;
using static HotChocolate.Fusion.Logging.LogEntryHelper;

namespace HotChocolate.Fusion.PreMergeValidation.Rules;
Expand Down Expand Up @@ -29,28 +30,19 @@ public void Handle(OutputFieldGroupEvent @event, CompositionContext context)

var argumentNames = fieldGroup
.SelectMany(i => i.Field.Arguments, (_, arg) => arg.Name)
.ToHashSet();
.ToImmutableHashSet();

foreach (var argumentName in argumentNames)
{
var arguments = fieldGroup
.Select(i => i.Field.Arguments[argumentName])
.SelectMany(i => i.Field.Arguments.Where(a => a.Name == argumentName))
.ToImmutableArray();

var defaultValue = arguments[0].DefaultValue;

foreach (var argument in arguments)
{
var currentDefaultValue = argument.DefaultValue;
var match = (currentDefaultValue, defaultValue) switch
{
(null, null) => true,
(not null, null) => false,
(null, not null) => false,
_ => currentDefaultValue.Value!.Equals(defaultValue.Value)
};

if (!match)
if (!SyntaxComparer.BySyntax.Equals(argument.DefaultValue, defaultValue))
{
context.Log.Write(
ExternalArgumentDefaultMismatch(argumentName, fieldName, typeName));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
Expand All @@ -14,14 +13,10 @@
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ErrorHelper_PreMergeValidationFailed" xml:space="preserve">
<value>Pre-merge validation failed. View the composition log for details.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private CompositionResult<SchemaDefinition> MergeSchemaDefinitions(CompositionCo
private static readonly List<object> _preMergeValidationRules =
[
new DisallowedInaccessibleElementsRule(),
new ExternalArgumentDefaultMismatchRule(),
new ExternalMissingOnBaseRule(),
new OutputFieldTypesMergeableRule()
];
Expand Down

0 comments on commit 7701ff1

Please sign in to comment.