Skip to content

Commit

Permalink
Merge branch 'main' into mst/fusion-spec-refac-1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Sep 1, 2023
2 parents d750e9e + de63bd0 commit a7a5773
Show file tree
Hide file tree
Showing 192 changed files with 1,360 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,4 @@ conferences.db-wal

.server/
.nuke/
.mono/
16 changes: 7 additions & 9 deletions src/HotChocolate/Core/src/Abstractions/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ namespace HotChocolate;
/// </summary>
public abstract class Path : IEquatable<Path>
{
private readonly Path? _parent;

protected Path()
{
Parent = this;
_parent = null;
Length = 0;
}

protected Path(Path parent)
{
Parent = parent ?? throw new ArgumentNullException(nameof(parent));
_parent = parent ?? throw new ArgumentNullException(nameof(parent));
Length = parent.Length + 1;
}

/// <summary>
/// Gets the parent path segment.
/// </summary>
public Path Parent { get; }
public Path Parent => _parent!;

/// <summary>
/// Gets the count of segments this path contains.
Expand Down Expand Up @@ -238,11 +240,7 @@ public override bool Equals(Path? other)

/// <inheritdoc />
public override int GetHashCode()
{
// ReSharper disable NonReadonlyMemberInGetHashCode
return HashCode.Combine(Parent, Length);
// ReSharper restore NonReadonlyMemberInGetHashCode
}
=> 0;

public static RootPathSegment Instance { get; } = new();
}
Expand Down
16 changes: 13 additions & 3 deletions src/HotChocolate/Core/src/Subscriptions.Postgres/ContinuousTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal sealed class ContinuousTask : IAsyncDisposable
private readonly CancellationTokenSource _completion = new();
private readonly Func<CancellationToken, Task> _handler;
private readonly Task _task;
private bool disposed;

public ContinuousTask(Func<CancellationToken, Task> handler)
{
Expand Down Expand Up @@ -46,13 +47,22 @@ private async Task RunContinuously()
/// <inheritdoc />
public async ValueTask DisposeAsync()
{
if(disposed)
{
return;
}

if(!_completion.IsCancellationRequested)
{
#if NET8_0_OR_GREATER
await _completion.CancelAsync();
await _completion.CancelAsync();
#else
_completion.Cancel();
_completion.Cancel();
#endif
}

_completion.Dispose();

await _task;
disposed = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void AddErrorType(
throw new ArgumentNullException(nameof(errorType));
}

if (descriptorContext.ContextData[MutationContextDataKeys.Options] == null)
if (!descriptorContext.ContextData.ContainsKey(MutationContextDataKeys.Options))
{
var richMessage = string.Format(
MutationConvention_ShouldBeEnabled_WhenAddingErrorType,
Expand Down
13 changes: 13 additions & 0 deletions src/HotChocolate/Core/test/Abstractions.Tests/PathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ namespace HotChocolate.Execution.Instrumentation;

public class PathExtensionsTests
{
[Fact]
public void GetHashCode_Test()
{
var path = Path.Root.Append("hero");
Assert.NotEqual(0, path.GetHashCode());
}

[Fact]
public void GetHashCode_Root_Test()
{
Assert.Equal(0, Path.Root.GetHashCode());
}

[Fact]
public void Path_ToString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "abc",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "abc",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "abc",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ public void OneOf_A_and_B_Are_Set()
new ObjectFieldNode("b", 123));

// act
void Fail()
=> parser.ParseLiteral(data, oneOfInput, Path.Root.Append("root"));
void Fail() => parser.ParseLiteral(data, oneOfInput, Path.Root.Append("root"));

// assert
Assert.Throws<SerializationException>(Fail).Errors.MatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "root",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "root",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "arguments",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "fieldWithArg",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Parent": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -66,6 +67,7 @@
"Parent": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -60,6 +61,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "fieldWithArg",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -60,6 +61,7 @@
"Path": {
"Name": "fieldWithArg",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -59,6 +60,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -60,6 +61,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -60,6 +61,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down Expand Up @@ -60,6 +61,7 @@
"Path": {
"Name": "dog",
"Parent": {
"Parent": null,
"Length": 0,
"IsRoot": true
},
Expand Down
Loading

0 comments on commit a7a5773

Please sign in to comment.