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

Type System Update #669

Merged
merged 6 commits into from
Apr 5, 2019
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/Core/Abstractions.Tests/Abstractions.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="ChilliCream.Testing.Utilities" Version="0.2.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>

Expand Down
7 changes: 3 additions & 4 deletions src/Core/Abstractions.Tests/ErrorBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Specialized;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand All @@ -17,7 +16,7 @@ public void FromError()
IError error = new Error { Message = "123" };

// act
ErrorBuilder builder = ErrorBuilder.FromError(error);
var builder = ErrorBuilder.FromError(error);
error = builder.Build();

// assert
Expand All @@ -38,7 +37,7 @@ public void FromError_WithExtensions()
};

// act
ErrorBuilder builder = ErrorBuilder.FromError(error);
var builder = ErrorBuilder.FromError(error);
error = builder.Build();

// assert
Expand Down Expand Up @@ -106,7 +105,7 @@ public void FromError_WithLocations()
};

// act
ErrorBuilder builder = ErrorBuilder.FromError(error);
var builder = ErrorBuilder.FromError(error);
error = builder.Build();

// assert
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Abstractions.Tests/NameStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void EqualsOp_SameInstance_True()
{
// arrange
var a = new NameString("Foo");
var b = a;
NameString b = a;

// act
bool result = a == b;
Expand Down Expand Up @@ -319,7 +319,7 @@ public void NotEqualsOp_SameInstance_False()
{
// arrange
var a = new NameString("Foo");
var b = a;
NameString b = a;

// act
bool result = a != b;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Abstractions/AttributeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static string GetGraphQLDescription(
typeof(GraphQLDescriptionAttribute),
false))
{
var attribute = attributeProvider.GetCustomAttributes(
GraphQLDescriptionAttribute attribute = attributeProvider.GetCustomAttributes(
typeof(GraphQLDescriptionAttribute),
false)
.OfType<GraphQLDescriptionAttribute>()
Expand Down
1 change: 0 additions & 1 deletion src/Core/Abstractions/Error.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Specialized;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Abstractions/Execution/OrderedDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Security.Cryptography;
using System.Collections;
using System.Collections;
using System.Collections.Generic;

namespace HotChocolate.Execution
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Abstractions/NameString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace HotChocolate
[TypeConverter(typeof(NameStringConverter))]
public struct NameString
: IEquatable<NameString>
, IComparable<NameString>
{

/// <summary>
Expand Down Expand Up @@ -128,6 +129,11 @@ public override bool Equals(object obj)
return obj is NameString n && Equals(n);
}

public int CompareTo(NameString other)
{
return Value.CompareTo(other.Value);
}

/// <summary>
/// Serves as a hash function for a <see cref="NameString"/> object.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0" />
<PackageReference Include="ChilliCream.Testing.Utilities" Version="0.2.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0" />
<PackageReference Include="ChilliCream.Testing.Utilities" Version="0.2.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>

Expand Down
8 changes: 7 additions & 1 deletion src/Core/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0" />
<PackageReference Include="ChilliCream.Testing.Utilities" Version="0.2.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.0" />
<PackageReference Include="Snapshooter.Xunit" Version="0.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>

Expand All @@ -44,4 +44,10 @@
</None>
</ItemGroup>

<ItemGroup>
<Folder Include="Execution\Errors\__snapshots__\__mismatch__\" />
<Folder Include="Execution\__snapshots__\__mismatch__\" />
<Folder Include="Integration\TypeConversion\__snapshots__\__mismatch__\" />
</ItemGroup>

</Project>
20 changes: 10 additions & 10 deletions src/Core/Core.Tests/Execution/ArgumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ArgumentTests
public async Task ListOfInt()
{
// arrange
Schema schema = Schema.Create(c =>
var schema = Schema.Create(c =>
{
c.Options.StrictValidation = true;

Expand All @@ -29,7 +29,7 @@ public async Task ListOfInt()
c.RegisterType(new ObjectType<Bar>());
});

ListValueNode list = new ListValueNode(new List<IValueNode>
var list = new ListValueNode(new List<IValueNode>
{
new IntValueNode(1),
new IntValueNode(2),
Expand All @@ -51,7 +51,7 @@ await schema.MakeExecutable().ExecuteAsync(
public async Task ListOfFoo()
{
// arrange
Schema schema = Schema.Create(c =>
var schema = Schema.Create(c =>
{
c.RegisterQueryType(new ObjectType<Query>(d =>
{
Expand All @@ -67,7 +67,7 @@ public async Task ListOfFoo()
c.RegisterType(new InputObjectType<Foo>());
});

ListValueNode list = new ListValueNode(new List<IValueNode>
var list = new ListValueNode(new List<IValueNode>
{
new ObjectValueNode(new[] {
new ObjectFieldNode("bar", new StringValueNode("123")) }),
Expand All @@ -92,7 +92,7 @@ await schema.MakeExecutable().ExecuteAsync(
public async Task SingleInt()
{
// arrange
Schema schema = Schema.Create(c =>
var schema = Schema.Create(c =>
{
c.RegisterQueryType(new ObjectType<Query>(d =>
{
Expand All @@ -106,7 +106,7 @@ public async Task SingleInt()
c.RegisterType(new ObjectType<Bar>());
});

IntValueNode value = new IntValueNode(123);
var value = new IntValueNode(123);

// act
IExecutionResult result =
Expand All @@ -123,7 +123,7 @@ await schema.MakeExecutable().ExecuteAsync(
public async Task SingleFoo()
{
// arrange
Schema schema = Schema.Create(c =>
var schema = Schema.Create(c =>
{
c.RegisterQueryType(new ObjectType<Query>(d =>
{
Expand All @@ -138,7 +138,7 @@ public async Task SingleFoo()
c.RegisterType(new InputObjectType<Foo>());
});

ObjectValueNode obj = new ObjectValueNode(new List<ObjectFieldNode>
var obj = new ObjectValueNode(new List<ObjectFieldNode>
{
new ObjectFieldNode("bar", new StringValueNode("123"))
});
Expand Down Expand Up @@ -169,7 +169,7 @@ public Bar SingleInt(int foo)

public List<Bar> ListOfFoo(List<Foo> foo)
{
List<Bar> bar = new List<Bar>();
var bar = new List<Bar>();
foreach (Foo f in foo)
{
bar.Add(SingleFoo(f));
Expand All @@ -179,7 +179,7 @@ public List<Bar> ListOfFoo(List<Foo> foo)

public List<Bar> ListOfInt(List<int> foo)
{
List<Bar> bar = new List<Bar>();
var bar = new List<Bar>();
foreach (int f in foo)
{
bar.Add(SingleInt(f));
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Core.Tests/Execution/Errors/ErrorBehaviourTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using HotChocolate.Execution.Configuration;
using HotChocolate.Types;
Expand Down Expand Up @@ -272,7 +272,7 @@ public async Task RootFieldNotDefined()
string query = "mutation { foo }";

var schema = Schema.Create(
"type Mutation { bar: String }",
"type Query { a: String } type Mutation { bar: String }",
c => c.Use(next => context => Task.CompletedTask));
IQueryExecutor executor = schema.MakeExecutable();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"Data": {
"error5": null
},
Expand All @@ -16,7 +16,20 @@
"column": 3
}
],
"Exception": null,
"Exception": {
"ClassName": "System.Exception",
"Message": "query error 5",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at HotChocolate.Execution.ErrorBehaviourTests.Query.Error5() in /Users/michael/local/hotchocolate/src/Core/Core.Tests/Execution/Errors/ErrorBehaviourTests.cs:line 378\n at HotChocolate.Resolvers.CodeGeneration.___CompiledResolvers__0c1cd93e56814a31b80a3e0c1a1f0810.<>c.<<-cctor>b__32_24>d.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n at HotChocolate.Types.FieldMiddlewareCompiler.<>c__DisplayClass3_0.<<CreateResolverMiddleware>b__0>d.MoveNext() in /Users/michael/local/hotchocolate/src/Core/Types/Types/Helpers/FieldMiddlewareCompiler.cs:line 75\n--- End of stack trace from previous location where exception was thrown ---\n at HotChocolate.Execution.ExecutionStrategyBase.ExecuteFieldMiddlewareAsync(ResolverTask resolverTask) in /Users/michael/local/hotchocolate/src/Core/Core/Execution/ExecutionStrategyBase.Resolver.cs:line 98\n at HotChocolate.Execution.ExecutionStrategyBase.ExecuteMiddlewareAsync(ResolverTask resolverTask, IErrorHandler errorHandler) in /Users/michael/local/hotchocolate/src/Core/Core/Execution/ExecutionStrategyBase.Resolver.cs:line 58",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233088,
"Source": "HotChocolate.Core.Tests",
"WatsonBuckets": null
},
"Extensions": {}
}
]
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Core.Tests/Execution/FieldResolverTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types;
Expand Down Expand Up @@ -529,7 +530,8 @@ interface IFoo {
union FooUnion = Foo | Fa

type Query { a: String }
", c => { c.Options.StrictValidation = false; });
",
c => c.Use(next => context => Task.CompletedTask));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void BuildTracingResult()
StartTimestamp = 1113752464890200,
EndTimestamp = 1113752484850000
};
TimeSpan duration = TimeSpan.FromMilliseconds(122);
var duration = TimeSpan.FromMilliseconds(122);

builder.SetRequestStartTime(startTime, startTimestamp);
builder.SetParsingResult(1113752394890300, 1113752402820700);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task UseDelegateMiddleware()
.To("Query", "a");
});

var executor = QueryExecutionBuilder
IQueryExecutor executor = QueryExecutionBuilder
.New()
.Use(next => context =>
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public async Task UseClassMiddleware()
.To("Query", "a");
});

var executor = QueryExecutionBuilder
IQueryExecutor executor = QueryExecutionBuilder
.New()
.Use<TestMiddleware>()
.Build(schema);
Expand All @@ -74,7 +74,7 @@ public async Task UseClassMiddlewareWithFactory()
.To("Query", "a");
});

var executor = QueryExecutionBuilder
IQueryExecutor executor = QueryExecutionBuilder
.New()
.Use((services, next) => new TestMiddleware(next))
.Build(schema);
Expand Down
16 changes: 8 additions & 8 deletions src/Core/Core.Tests/Execution/Middleware/QueryExecuterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task ExecuteWithNonNullVariableNull_Error()
};

Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query x($a: String!) { b(a: $a) }")
{
Expand All @@ -95,7 +95,7 @@ public async Task ExecuteWithNonNullVariableInvalidType_Error()
};

Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query x($a: String!) { b(a: $a) }")
{
Expand All @@ -121,7 +121,7 @@ public async Task ExecuteWithNonNullVariableValidValue_NoErrors()
};

Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query x($a: String!) { b(a: $a) }")
{
Expand All @@ -141,7 +141,7 @@ public async Task ExecuteQueryWith2OperationsAndNoOperationName_Error()
{
// arrange
Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query a { a } query b { a }");

Expand All @@ -158,7 +158,7 @@ public async Task ExecuteQueryWith2OperationsAndOperationName_NoErrors()
{
// arrange
Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query a { a } query b { a }", "a");

Expand All @@ -175,7 +175,7 @@ public async Task ExecuteQueryWith2OperationsAndInvalidOpName_Error()
{
// arrange
Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest(
"query a { a } query b { a }", "c");

Expand All @@ -195,7 +195,7 @@ public async Task ExecuteFieldWithResolverResult()
new Dictionary<string, IValueNode>();

Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest("{ x xasync }");

// act
Expand All @@ -214,7 +214,7 @@ public async Task ExecuteFieldWithResolverResultError()
new Dictionary<string, IValueNode>();

Schema schema = CreateSchema();
var executor = QueryExecutionBuilder.BuildDefault(schema);
IQueryExecutor executor = QueryExecutionBuilder.BuildDefault(schema);
var request = new QueryRequest("{ y yasync }");

// act
Expand Down
Loading