diff --git a/src/HotChocolate/Core/src/Types.Scalars.Upload/UploadType.cs b/src/HotChocolate/Core/src/Types.Scalars.Upload/UploadType.cs index 4f52c5bbedc..0baa442e7e4 100644 --- a/src/HotChocolate/Core/src/Types.Scalars.Upload/UploadType.cs +++ b/src/HotChocolate/Core/src/Types.Scalars.Upload/UploadType.cs @@ -82,7 +82,7 @@ public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider /// The runtime value (not used). /// The result element (not used). /// Always thrown as output coercion is not supported. - public override void OnCoerceOutputValue(IFile runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(IFile runtimeValue, ResultElement resultValue) => throw new NotSupportedException(); /// @@ -91,7 +91,7 @@ public override void OnCoerceOutputValue(IFile runtimeValue, ResultElement resul /// The runtime value (not used). /// Never returns; always throws. /// Always thrown as value to literal conversion is not supported. - public override IValueNode OnValueToLiteral(IFile runtimeValue) + protected override IValueNode OnValueToLiteral(IFile runtimeValue) => throw new NotSupportedException(); /// diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/AnyType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/AnyType.cs index 1a959e3839d..23d59e6c77a 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/AnyType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/AnyType.cs @@ -74,7 +74,7 @@ public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider => inputValue.Clone(); /// - public override void OnCoerceOutputValue(JsonElement runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(JsonElement runtimeValue, ResultElement resultValue) { switch (runtimeValue.ValueKind) { @@ -145,7 +145,7 @@ public override void OnCoerceOutputValue(JsonElement runtimeValue, ResultElement } /// - public override IValueNode OnValueToLiteral(JsonElement runtimeValue) + protected override IValueNode OnValueToLiteral(JsonElement runtimeValue) => JsonParser.Parse(runtimeValue); private static class JsonParser diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/ByteType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/ByteType.cs index 617a207641a..8bd6755f875 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/ByteType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/ByteType.cs @@ -43,10 +43,10 @@ protected override sbyte OnCoerceInputValue(JsonElement inputValue) => inputValue.GetSByte(); /// - public override void OnCoerceOutputValue(sbyte runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(sbyte runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(sbyte runtimeValue) + protected override IValueNode OnValueToLiteral(sbyte runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/DecimalType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/DecimalType.cs index da630c6b5af..50b0ed1f704 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/DecimalType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/DecimalType.cs @@ -57,10 +57,10 @@ protected override decimal OnCoerceInputValue(JsonElement inputValue) => inputValue.GetDecimal(); /// - public override void OnCoerceOutputValue(decimal runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(decimal runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(decimal runtimeValue) + protected override IValueNode OnValueToLiteral(decimal runtimeValue) => new FloatValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/FloatType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/FloatType.cs index 55e954455bd..4c7f62e49c3 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/FloatType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/FloatType.cs @@ -60,10 +60,10 @@ protected override double OnCoerceInputValue(JsonElement inputValue) => inputValue.GetDouble(); /// - public override void OnCoerceOutputValue(double runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(double runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(double runtimeValue) + protected override IValueNode OnValueToLiteral(double runtimeValue) => new FloatValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/IdType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/IdType.cs index 39c44e16a07..d62a5cba393 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/IdType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/IdType.cs @@ -104,10 +104,10 @@ public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider } /// - public override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) => resultValue.SetStringValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(string runtimeValue) + protected override IValueNode OnValueToLiteral(string runtimeValue) => new StringValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/IntType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/IntType.cs index de484ec2cc2..b9b90374d3b 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/IntType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/IntType.cs @@ -60,10 +60,10 @@ protected override int OnCoerceInputValue(JsonElement inputValue) => inputValue.GetInt32(); /// - public override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(int runtimeValue) + protected override IValueNode OnValueToLiteral(int runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/LongType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/LongType.cs index 0725498de98..d84b257e345 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/LongType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/LongType.cs @@ -57,10 +57,10 @@ protected override long OnCoerceInputValue(JsonElement inputValue) => inputValue.GetInt64(); /// - public override void OnCoerceOutputValue(long runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(long runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(long runtimeValue) + protected override IValueNode OnValueToLiteral(long runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarType~1.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarType~1.cs index 1f724747c79..9a386ec93c4 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarType~1.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarType~1.cs @@ -48,7 +48,7 @@ public override void CoerceOutputValue(object runtimeValue, ResultElement result /// /// Unable to coerce the given into an output value. /// - public abstract void OnCoerceOutputValue(TRuntimeType runtimeValue, ResultElement resultValue); + protected abstract void OnCoerceOutputValue(TRuntimeType runtimeValue, ResultElement resultValue); /// public override IValueNode ValueToLiteral(object runtimeValue) @@ -74,7 +74,7 @@ public override IValueNode ValueToLiteral(object runtimeValue) /// /// Unable to convert the given into a literal. /// - public abstract IValueNode OnValueToLiteral(TRuntimeType runtimeValue); + protected abstract IValueNode OnValueToLiteral(TRuntimeType runtimeValue); /// /// Creates the exception to throw when diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/ShortType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/ShortType.cs index 82b64491247..7f995ddaeb8 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/ShortType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/ShortType.cs @@ -55,10 +55,10 @@ protected override short OnCoerceInputValue(JsonElement inputValue) => inputValue.GetInt16(); /// - public override void OnCoerceOutputValue(short runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(short runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(short runtimeValue) + protected override IValueNode OnValueToLiteral(short runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedByteType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedByteType.cs index 05caf3285b0..0f95f3703da 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedByteType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedByteType.cs @@ -53,9 +53,9 @@ protected override byte OnCoerceInputLiteral(IntValueNode valueLiteral) protected override byte OnCoerceInputValue(JsonElement inputValue) => inputValue.GetByte(); - public override void OnCoerceOutputValue(byte runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(byte runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); - public override IValueNode OnValueToLiteral(byte runtimeValue) + protected override IValueNode OnValueToLiteral(byte runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedIntType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedIntType.cs index d21b3de0874..8a9213b1401 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedIntType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedIntType.cs @@ -43,10 +43,10 @@ protected override uint OnCoerceInputValue(JsonElement inputValue) => inputValue.GetUInt32(); /// - public override void OnCoerceOutputValue(uint runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(uint runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(uint runtimeValue) + protected override IValueNode OnValueToLiteral(uint runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedLongType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedLongType.cs index ca042f01554..f1de154fdc3 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedLongType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedLongType.cs @@ -43,10 +43,10 @@ protected override ulong OnCoerceInputValue(JsonElement inputValue) => inputValue.GetUInt64(); /// - public override void OnCoerceOutputValue(ulong runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(ulong runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(ulong runtimeValue) + protected override IValueNode OnValueToLiteral(ulong runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedShortType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedShortType.cs index 88528b534c0..017ccee408d 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedShortType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/UnsignedShortType.cs @@ -43,10 +43,10 @@ protected override ushort OnCoerceInputValue(JsonElement inputValue) => inputValue.GetUInt16(); /// - public override void OnCoerceOutputValue(ushort runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(ushort runtimeValue, ResultElement resultValue) => resultValue.SetNumberValue(runtimeValue); /// - public override IValueNode OnValueToLiteral(ushort runtimeValue) + protected override IValueNode OnValueToLiteral(ushort runtimeValue) => new IntValueNode(runtimeValue); } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Composite/SerializeAsTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Composite/SerializeAsTests.cs index bef3b898f8b..a4e063ac46e 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Composite/SerializeAsTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Composite/SerializeAsTests.cs @@ -60,10 +60,10 @@ public override object CoerceInputLiteral(IValueNode valueLiteral) public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider context) => throw new NotImplementedException(); - public override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) => throw new NotImplementedException(); - public override IValueNode OnValueToLiteral(string runtimeValue) + protected override IValueNode OnValueToLiteral(string runtimeValue) => throw new NotImplementedException(); } @@ -105,10 +105,10 @@ public override object CoerceInputLiteral(IValueNode valueLiteral) public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider context) => throw new NotImplementedException(); - public override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) => throw new NotImplementedException(); - public override IValueNode OnValueToLiteral(string runtimeValue) + protected override IValueNode OnValueToLiteral(string runtimeValue) => throw new NotImplementedException(); } } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/ScalarBindingTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/ScalarBindingTests.cs index 8ffcbb62bc2..32bce68562c 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/ScalarBindingTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/ScalarBindingTests.cs @@ -72,12 +72,12 @@ public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider throw new NotImplementedException(); } - public override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) { throw new NotImplementedException(); } - public override IValueNode OnValueToLiteral(int runtimeValue) + protected override IValueNode OnValueToLiteral(int runtimeValue) { throw new NotImplementedException(); } @@ -102,12 +102,12 @@ public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider throw new NotImplementedException(); } - public override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(int runtimeValue, ResultElement resultValue) { throw new NotImplementedException(); } - public override IValueNode OnValueToLiteral(int runtimeValue) + protected override IValueNode OnValueToLiteral(int runtimeValue) { throw new NotImplementedException(); } diff --git a/src/HotChocolate/Core/test/Validation.Tests/Types/InvalidScalar.cs b/src/HotChocolate/Core/test/Validation.Tests/Types/InvalidScalar.cs index 8cc4f9a8f49..55e79fe16cd 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/Types/InvalidScalar.cs +++ b/src/HotChocolate/Core/test/Validation.Tests/Types/InvalidScalar.cs @@ -21,9 +21,9 @@ public override object CoerceInputLiteral(IValueNode valueLiteral) public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider context) => throw new InvalidOperationException(); - public override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) + protected override void OnCoerceOutputValue(string runtimeValue, ResultElement resultValue) => throw new InvalidOperationException(); - public override IValueNode OnValueToLiteral(string runtimeValue) + protected override IValueNode OnValueToLiteral(string runtimeValue) => throw new InvalidOperationException(); }