Skip to content

Commit

Permalink
v8.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Abraham committed Oct 28, 2024
1 parent c7e828f commit d248801
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Types/OutputGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public FieldType AddField<ITEM>(MethodInfo methodInfo)
/// whose result objects are reduced by <paramref name="getResult"/> based on state data from <see cref="IResolveFieldContext"/>.<br/>
/// The name of the field is the name or <see cref="GraphQLNameAttribute"/> of the <paramref name="methodInfo"/>.
/// </summary>
/// <param name="methodInfo">The method that loads data for all result items (<see cref="ITEM[]"/>). This method can contain user input query parameters.</param>
/// <param name="methodInfo">The method that loads data for all result items (<typeparamref name="ITEM"/>[]). This method can contain user input query parameters.</param>
/// <param name="getResult">Reduces the data returned by <paramref name="methodInfo"/>.</param>
public FieldType AddField<ITEM>(MethodInfo methodInfo, Func<T, ITEM[], ITEM> getResult)
where ITEM : notnull
Expand Down
14 changes: 12 additions & 2 deletions src/TypeCache/Converters/BigIntegerJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@
using System.Numerics;
using System.Text.Json;
using System.Text.Json.Serialization;
using TypeCache.Extensions;

namespace TypeCache.Converters;

public sealed class BigIntegerJsonConverter : JsonConverter<BigInteger>
{
public override BigInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> new(reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan);
{
reader.TokenType.ThrowIfNotEqual(JsonTokenType.Number);

using var doc = JsonDocument.ParseValue(ref reader);
return BigInteger.Parse(doc.RootElement.GetRawText(), NumberFormatInfo.InvariantInfo);
}

public override void Write(Utf8JsonWriter writer, BigInteger value, JsonSerializerOptions options)
=> writer.WriteRawValue(value.ToString(NumberFormatInfo.InvariantInfo), false);
{
var text = value.ToString(NumberFormatInfo.InvariantInfo);
using var doc = JsonDocument.Parse(text);
doc.WriteTo(writer);
}
}
7 changes: 5 additions & 2 deletions src/TypeCache/Extensions/NumericExtensions.Int32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public static ulong Factorial(this int @this)
{
(@this < 0).ThrowIfTrue();

var result = 1UL;
while (@this > 0)
if (@this is 0)
return 1UL;

var result = (ulong)@this;
while (@this > 1)
result *= (ulong)(--@this);

return result;
Expand Down

0 comments on commit d248801

Please sign in to comment.