Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #6818

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public readonly struct AcceptMediaType
/// <exception cref="ArgumentNullException">
/// Type or subtype are empty.
/// </exception>
internal AcceptMediaType(
public AcceptMediaType(
StringSegment type,
StringSegment subType,
double? quality,
Expand Down
4 changes: 2 additions & 2 deletions src/HotChocolate/AspNetCore/src/AspNetCore/HeaderUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace HotChocolate.AspNetCore;
/// <summary>
/// Utilities for handling HTTP headers.
/// </summary>
internal static class HeaderUtilities
public static class HeaderUtilities
{
private static readonly ConcurrentDictionary<string, CacheEntry> _cache =
new(StringComparer.Ordinal);
Expand Down Expand Up @@ -147,7 +147,7 @@ public CacheEntry(string key, MediaTypeHeaderValue value)
public DateTime CreatedAt { get; }
}

internal readonly struct AcceptHeaderResult
public readonly struct AcceptHeaderResult
{
public AcceptHeaderResult(AcceptMediaType[] acceptMediaTypes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public class MockInvocationFeatures : Dictionary<Type, object>, IInvocationFeatu
public void Set<T>(T instance)
{
if (instance == null)
{
return;
}

TryAdd(typeof(T), instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public MockHttpRequestData(
Method = requestHttpMethod ?? throw new ArgumentNullException(nameof(requestHttpMethod));
Url = requestUri ?? throw new ArgumentNullException(nameof(requestUri));

if(claimsIdentities != null)
if (claimsIdentities != null)
{
Identities = claimsIdentities;
}

if (!string.IsNullOrEmpty(requestBody))
{
Expand Down
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public interface IReadOnlySchemaOptions
DirectiveVisibility DefaultDirectiveVisibility { get; }

/// <summary>
/// Defines that the default resolver execution strategy.
/// Defines the default resolver execution strategy.
/// </summary>
ExecutionStrategy DefaultResolverStrategy { get; }

/// <summary>
/// Defines if the order of important middleware components shall be validated.
/// </summary>
bool ValidatePipelineOrder { get; }

/// <summary>
/// Defines if the runtime types of types shall be validated.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void OnAfterCompleteName(
ITypeCompletionContext completionContext,
DefinitionBase definition)
{
if(completionContext.Type is ObjectType && definition is ObjectTypeDefinition typeDef)
if (completionContext.Type is ObjectType && definition is ObjectTypeDefinition typeDef)
{
_objectTypeDefinitions.Add(typeDef);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,12 @@ namespace HotChocolate.Language;
public ref partial struct Utf8GraphQLRequestParser
{
private const byte _o = (byte)'o';
private const byte _n = (byte)'n';
private const byte _q = (byte)'q';
private const byte _v = (byte)'v';
private const byte _e = (byte)'e';
private const byte _t = (byte)'t';
private const byte _i = (byte)'i';
private const byte _p = (byte)'p';

// This uses C# compiler's ability to refer to static data directly. For more information see https://vcsjones.dev/2019/02/01/csharp-readonly-span-bytes-static
private static ReadOnlySpan<byte> OperationName => new[]
{
(byte)'o',
(byte)'p',
(byte)'e',
(byte)'r',
(byte)'a',
(byte)'t',
(byte)'i',
(byte)'o',
(byte)'n',
(byte)'N',
(byte)'a',
(byte)'m',
(byte)'e',
};

private static ReadOnlySpan<byte> Query => new[]
{
(byte)'q',
(byte)'u',
(byte)'e',
(byte)'r',
(byte)'y',
};

private static ReadOnlySpan<byte> Variables => new[]
{
(byte)'v',
(byte)'a',
(byte)'r',
(byte)'i',
(byte)'a',
(byte)'b',
(byte)'l',
(byte)'e',
(byte)'s',
};

private static ReadOnlySpan<byte> Extensions => new[]
{
(byte)'e',
(byte)'x',
(byte)'t',
(byte)'e',
(byte)'n',
(byte)'s',
(byte)'i',
(byte)'o',
(byte)'n',
(byte)'s',
};

private static ReadOnlySpan<byte> Type => new[]
{
(byte)'t',
(byte)'y',
(byte)'p',
(byte)'e',
};

private static ReadOnlySpan<byte> Id => new[]
{
(byte)'i',
(byte)'d',
};

private static ReadOnlySpan<byte> Payload => new[]
{
(byte)'p',
(byte)'a',
(byte)'y',
(byte)'l',
(byte)'o',
(byte)'a',
(byte)'d',
};
private static ReadOnlySpan<byte> Id => "id"u8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void ParseRequestProperty(ref Request request)
switch (fieldName[0])
{
case _o:
if (fieldName.SequenceEqual(OperationName))
if (fieldName.SequenceEqual("operationName"u8))
{
request.OperationName = ParseStringOrNull();
}
Expand All @@ -156,7 +156,7 @@ private void ParseRequestProperty(ref Request request)
break;

case _q:
if (fieldName.SequenceEqual(Query))
if (fieldName.SequenceEqual("query"u8))
{
request.HasQuery = !IsNullToken();

Expand All @@ -171,14 +171,14 @@ private void ParseRequestProperty(ref Request request)
break;

case _v:
if (fieldName.SequenceEqual(Variables))
if (fieldName.SequenceEqual("variables"u8))
{
request.Variables = ParseVariables();
}
break;

case _e:
if (fieldName.SequenceEqual(Extensions))
if (fieldName.SequenceEqual("extensions"u8))
{
request.Extensions = ParseObjectOrNull();
}
Expand All @@ -198,7 +198,7 @@ private void ParseMessageProperty(ref Message message)
switch (fieldName[0])
{
case _t:
if (fieldName.SequenceEqual(Type))
if (fieldName.SequenceEqual("type"u8))
{
message.Type = ParseStringOrNull();
}
Expand All @@ -212,7 +212,7 @@ private void ParseMessageProperty(ref Message message)
break;

case _p:
if (fieldName.SequenceEqual(Payload))
if (fieldName.SequenceEqual("payload"u8))
{
var start = _reader.Start;
var hasPayload = !IsNullToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ private OpenApiWrapperPipelineBuilder()
public OpenApiWrapperDelegate Build()
{
OpenApiWrapperDelegate next = _ => { };
for (var i = _pipeline.Count - 1; i >= 0; i--) next = _pipeline[i].Invoke(next);
for (var i = _pipeline.Count - 1; i >= 0; i--)
{
next = _pipeline[i].Invoke(next);
}

return next;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ private static void AddInputType(OpenApiWrapperContext context, Operation operat

private static void AddIfNecessary(OpenApiWrapperContext context, InputObjectType inputObjectType)
{
if (context.MutableSchema.Types.ContainsName(inputObjectType.Name)) return;
if (context.MutableSchema.Types.ContainsName(inputObjectType.Name))
{
return;
}

context.MutableSchema.Types.Add(inputObjectType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ private static void CreateMutationType(OpenApiWrapperContext context)
{
var operations = context.GetMutationOperations();

if (operations.Count == 0) return;
if (operations.Count == 0)
{
return;
}

var mutationType = new ObjectType(OpenApiResources.RootTypeMutation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public void Invoke(OpenApiWrapperContext context, OpenApiWrapperDelegate next)
resultOperation.AddParameter(openApiParameter);
}

if (context.Operations.ContainsKey(resultOperation.OperationId)) continue;
if (context.Operations.ContainsKey(resultOperation.OperationId))
{
continue;
}

context.Operations.Add(resultOperation.OperationId, resultOperation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public IActionResult DeletePet([FromRoute] [Required] long? id)
{
var toDelete = _pets.FirstOrDefault(p => p.Id == id);

if (toDelete is null) return BadRequest("Pet not found");
if (toDelete is null)
{
return BadRequest("Pet not found");
}

_pets.Remove(toDelete);
return Ok();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,14 @@

// Normalize to nanosecond intervals
for (; numDigits > 9; numDigits--)
{

Check warning on line 308 in src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs

View check run for this annotation

Codecov / codecov/patch

src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs#L308

Added line #L308 was not covered by tests
value /= 10;
}

for (; numDigits < 9; numDigits++)
{
value *= 10;
}

nanoseconds |= (uint)value;

Expand Down
Loading