Skip to content

Commit bd254ad

Browse files
committed
add dotnet9 target and format code and update deps
1 parent c520bd8 commit bd254ad

225 files changed

Lines changed: 10498 additions & 10862 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.config/dotnet-tools.json‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"isRoot": true,
44
"tools": {
55
"csharpier": {
6-
"version": "0.27.3",
7-
"commands": [
8-
"dotnet-csharpier"
9-
]
6+
"version": "0.29.2",
7+
"commands": ["dotnet-csharpier"]
108
}
119
}
12-
}
10+
}

‎.editorconfig‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
[*.cs]
22
indent_style = space
33
indent_size = 4
4-
max_line_length = 180
4+
max_line_length = 180
5+
6+
# csharpier doesn't indent
7+
csharp_indent_case_contents_when_block = false
8+
9+
# adopt net9 defaults but soften to none for IDE0007/IDE0008
10+
csharp_style_var_for_built_in_types = false:none
11+
csharp_style_var_when_type_is_apparent = false:none
12+
csharp_style_var_elsewhere = false:none
13+
14+
csharp_style_namespace_declarations = file_scoped
15+
16+
# silent will remove the warnings but still show the suggestions in IDE
17+
18+
# prefer braces on all if statements
19+
csharp_prefer_braces = true:silent
20+
dotnet_style_prefer_conditional_expression_over_return = true:silent
21+
csharp_style_prefer_primary_constructors = true:silent
22+
csharp_style_expression_bodied_methods = false:silent
23+
dotnet_style_prefer_collection_expression = true:silent
24+
csharp_style_prefer_pattern_matching = true:silent
25+
csharp_style_pattern_matching_over_as_with_null_check = true:silent
26+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
27+
dotnet_style_namespace_match_folder = true:silent
28+
29+
# We enable EnforceCodeStyleInBuild = true to enable IDE0005 (Remove unnecessary usings/imports)
30+
# warnings but we dont' want the warnings on XML comments
31+
# Should work on cleaning this up in the future
32+
dotnet_diagnostic.CS1591.severity = none
33+
dotnet_diagnostic.CS1570.severity = none
34+
dotnet_diagnostic.CS1573.severity = none
35+
dotnet_diagnostic.CS1587.severity = none

‎.github/workflows/dotnet.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v4
15-
- name: Setup .NET 8.0.x
15+
- name: Setup .NET 9.0.x
1616
uses: actions/setup-dotnet@v4
1717
with:
18-
dotnet-version: 8.0.x
18+
dotnet-version: 9.0.x
1919
- name: Restore dependencies
2020
run: dotnet restore
2121
- name: Build

‎.vscode/launch.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"type": "coreclr",
4545
"request": "launch",
4646
"preLaunchTask": "build",
47-
"program": "${workspaceFolder}/src/Benchmarks/bin/Debug/net8.0/Benchmarks.dll",
47+
"program": "${workspaceFolder}/src/Benchmarks/bin/Debug/net9.0/Benchmarks.dll",
4848
"args": [
4949
"--filter",
5050
"*QueryBenchmarks*"

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 5.6.0
2+
3+
## Changes
4+
5+
- Added additional framework target `net9.0`
6+
- `ResolveWithService` and `ResolveWithServices` methods are now obsolete. Please just use `Resolve` in the same way
7+
18
# 5.5.3
29

310
## Fixes

‎EntityGraphQL.sln‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFunctionApp", "src\exa
2727
EndProject
2828
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityGraphQL.EF.Tests", "src\tests\EntityGraphQL.EF.Tests\EntityGraphQL.EF.Tests.csproj", "{D5087AB2-C96F-42F4-9F34-5C8747846908}"
2929
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityGraphQL.Tests.Util", "src\tests\EntityGraphQL.Tests.Util\EntityGraphQL.Tests.Util.csproj", "{FBFD1928-D1F3-4975-AD77-C63576572B9B}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3234
Debug|Any CPU = Debug|Any CPU
@@ -145,6 +147,18 @@ Global
145147
{D5087AB2-C96F-42F4-9F34-5C8747846908}.Release|x64.Build.0 = Release|Any CPU
146148
{D5087AB2-C96F-42F4-9F34-5C8747846908}.Release|x86.ActiveCfg = Release|Any CPU
147149
{D5087AB2-C96F-42F4-9F34-5C8747846908}.Release|x86.Build.0 = Release|Any CPU
150+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
151+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
152+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|x64.ActiveCfg = Debug|Any CPU
153+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|x64.Build.0 = Debug|Any CPU
154+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|x86.ActiveCfg = Debug|Any CPU
155+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Debug|x86.Build.0 = Debug|Any CPU
156+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
157+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|Any CPU.Build.0 = Release|Any CPU
158+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|x64.ActiveCfg = Release|Any CPU
159+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|x64.Build.0 = Release|Any CPU
160+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|x86.ActiveCfg = Release|Any CPU
161+
{FBFD1928-D1F3-4975-AD77-C63576572B9B}.Release|x86.Build.0 = Release|Any CPU
148162
EndGlobalSection
149163
GlobalSection(SolutionProperties) = preSolution
150164
HideSolutionNode = FALSE
@@ -161,6 +175,7 @@ Global
161175
{55645B0C-88D1-4060-AB5A-C444B36E815A} = {D8AA6BD5-5945-4997-887E-491A25378303}
162176
{37B1BF94-489C-4C7E-9A1C-C1A9FC9CC9A4} = {D8AA6BD5-5945-4997-887E-491A25378303}
163177
{D5087AB2-C96F-42F4-9F34-5C8747846908} = {5F132C01-AA1F-4241-B90F-BE4B2275B34E}
178+
{FBFD1928-D1F3-4975-AD77-C63576572B9B} = {5F132C01-AA1F-4241-B90F-BE4B2275B34E}
164179
EndGlobalSection
165180
GlobalSection(ExtensibilityGlobals) = postSolution
166181
SolutionGuid = {74156BCF-DABB-4919-A8AC-90629FB4565E}

‎src/Benchmarks/ArgumentsBenchmarks.cs‎

Lines changed: 73 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,93 @@
33
using EntityGraphQL;
44
using EntityGraphQL.Compiler.Util;
55

6-
namespace Benchmarks
6+
namespace Benchmarks;
7+
8+
/// <summary>
9+
/// Was testing the performance of using reflection to build the correct types from variables or using System.Text.Json
10+
///
11+
/// Reflection wins
12+
/// | Method | Job | Toolchain | IterationCount | LaunchCount | WarmupCount | Mean | Error | StdDev |
13+
/// |---------------------------- |----------- |----------------------- |--------------- |------------ |------------ |------------:|-------------:|-----------:|
14+
/// | ObjectWithJsonSerialization | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 7,524.18 ms | 146.326 ms | 227.812 ms |
15+
/// | ObjectWithReflection | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 21.77 ms | 0.355 ms | 0.332 ms |
16+
/// | ListWithJsonSerialization | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 9,686.72 ms | 193.058 ms | 327.827 ms |
17+
/// | ListWithReflection | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 44.22 ms | 0.202 ms | 0.189 ms |
18+
/// | ObjectWithJsonSerialization | ShortRun | Default | 3 | 1 | 3 | 7,278.49 ms | 5,676.616 ms | 311.154 ms |
19+
/// | ObjectWithReflection | ShortRun | Default | 3 | 1 | 3 | 20.41 ms | 1.685 ms | 0.092 ms |
20+
/// | ListWithJsonSerialization | ShortRun | Default | 3 | 1 | 3 | 9,877.59 ms | 2,168.229 ms | 118.848 ms |
21+
/// | ListWithReflection | ShortRun | Default | 3 | 1 | 3 | 43.14 ms | 36.734 ms | 2.013 ms |
22+
/// </summary>
23+
[ShortRunJob]
24+
public class ArgumentsBenchmarks
725
{
8-
/// <summary>
9-
/// Was testing the performance of using reflection to build the correct types from variables or using System.Text.Json
10-
///
11-
/// Reflection wins
12-
/// | Method | Job | Toolchain | IterationCount | LaunchCount | WarmupCount | Mean | Error | StdDev |
13-
/// |---------------------------- |----------- |----------------------- |--------------- |------------ |------------ |------------:|-------------:|-----------:|
14-
/// | ObjectWithJsonSerialization | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 7,524.18 ms | 146.326 ms | 227.812 ms |
15-
/// | ObjectWithReflection | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 21.77 ms | 0.355 ms | 0.332 ms |
16-
/// | ListWithJsonSerialization | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 9,686.72 ms | 193.058 ms | 327.827 ms |
17-
/// | ListWithReflection | Job-DOGPPG | InProcessEmitToolchain | Default | Default | Default | 44.22 ms | 0.202 ms | 0.189 ms |
18-
/// | ObjectWithJsonSerialization | ShortRun | Default | 3 | 1 | 3 | 7,278.49 ms | 5,676.616 ms | 311.154 ms |
19-
/// | ObjectWithReflection | ShortRun | Default | 3 | 1 | 3 | 20.41 ms | 1.685 ms | 0.092 ms |
20-
/// | ListWithJsonSerialization | ShortRun | Default | 3 | 1 | 3 | 9,877.59 ms | 2,168.229 ms | 118.848 ms |
21-
/// | ListWithReflection | ShortRun | Default | 3 | 1 | 3 | 43.14 ms | 36.734 ms | 2.013 ms |
22-
/// </summary>
23-
[ShortRunJob]
24-
public class ArgumentsBenchmarks
25-
{
26-
// [Benchmark]
27-
// public void ObjectWithJsonSerialization()
28-
// {
29-
// var variables = new QueryVariables {
30-
// { "names", new { Name = "Lisa", LastName = "Simpson" } }
31-
// };
26+
// [Benchmark]
27+
// public void ObjectWithJsonSerialization()
28+
// {
29+
// var variables = new QueryVariables {
30+
// { "names", new { Name = "Lisa", LastName = "Simpson" } }
31+
// };
3232

33-
// for (int i = 0; i < 10000; i++)
34-
// {
35-
// var val = ExpressionUtil.ChangeType(variables["names"], typeof(InputType), true);
36-
// }
37-
// }
38-
// [Benchmark]
39-
// public void ListWithJsonSerialization()
40-
// {
41-
// var variables = new QueryVariables {
42-
// { "names", new List<InputType2>{new InputType2{ Name = "Lisa", LastName = "Simpson" } }}
43-
// };
33+
// for (int i = 0; i < 10000; i++)
34+
// {
35+
// var val = ExpressionUtil.ChangeType(variables["names"], typeof(InputType), true);
36+
// }
37+
// }
38+
// [Benchmark]
39+
// public void ListWithJsonSerialization()
40+
// {
41+
// var variables = new QueryVariables {
42+
// { "names", new List<InputType2>{new InputType2{ Name = "Lisa", LastName = "Simpson" } }}
43+
// };
4444

45-
// for (int i = 0; i < 10000; i++)
46-
// {
47-
// var val = ExpressionUtil.ChangeType(variables["names"], typeof(List<InputType>), true);
48-
// }
49-
// }
45+
// for (int i = 0; i < 10000; i++)
46+
// {
47+
// var val = ExpressionUtil.ChangeType(variables["names"], typeof(List<InputType>), true);
48+
// }
49+
// }
5050

51-
[Benchmark]
52-
public static void ObjectWithReflection()
53-
{
54-
var variables = new QueryVariables { { "names", new { Name = "Lisa", LastName = "Simpson" } } };
51+
[Benchmark]
52+
public static void ObjectWithReflection()
53+
{
54+
var variables = new QueryVariables { { "names", new { Name = "Lisa", LastName = "Simpson" } } };
5555

56-
for (int i = 0; i < 10000; i++)
57-
{
58-
ExpressionUtil.ConvertObjectType(variables["names"], typeof(InputType), null, null);
59-
}
56+
for (int i = 0; i < 10000; i++)
57+
{
58+
ExpressionUtil.ConvertObjectType(variables["names"], typeof(InputType), null, null);
6059
}
60+
}
6161

62-
[Benchmark]
63-
public static void ListWithReflection()
62+
[Benchmark]
63+
public static void ListWithReflection()
64+
{
65+
var variables = new QueryVariables
6466
{
65-
var variables = new QueryVariables
6667
{
68+
"names",
69+
new List<InputType2>
6770
{
68-
"names",
69-
new List<InputType2>
70-
{
71-
new InputType2 { Name = "Lisa", LastName = "Simpson" }
72-
}
71+
new InputType2 { Name = "Lisa", LastName = "Simpson" },
7372
}
74-
};
73+
},
74+
};
7575

76-
for (int i = 0; i < 10000; i++)
77-
{
78-
ExpressionUtil.ConvertObjectType(variables["names"], typeof(List<InputType>), null, null);
79-
}
76+
for (int i = 0; i < 10000; i++)
77+
{
78+
ExpressionUtil.ConvertObjectType(variables["names"], typeof(List<InputType>), null, null);
8079
}
8180
}
81+
}
8282

83-
// this would be the anonymous class created in compiling the query
84-
internal class InputType
85-
{
86-
public string name = string.Empty;
87-
public string lastName = string.Empty;
88-
}
83+
// this would be the anonymous class created in compiling the query
84+
internal class InputType
85+
{
86+
public string name = string.Empty;
87+
public string lastName = string.Empty;
88+
}
8989

90-
// This would be the class they pass in that matches the schema but is different from the anonymous class
91-
internal class InputType2
92-
{
93-
public string Name = string.Empty;
94-
public string LastName = string.Empty;
95-
}
90+
// This would be the class they pass in that matches the schema but is different from the anonymous class
91+
internal class InputType2
92+
{
93+
public string Name = string.Empty;
94+
public string LastName = string.Empty;
9695
}

‎src/Benchmarks/BaseBenchmark.cs‎

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,54 @@
44
using EntityGraphQL.Schema;
55
using Microsoft.Extensions.DependencyInjection;
66

7-
namespace Benchmarks
7+
namespace Benchmarks;
8+
9+
public abstract class BaseBenchmark
810
{
9-
public abstract class BaseBenchmark
11+
protected ServiceProvider Services { get; }
12+
protected SchemaProvider<BenchmarkContext> Schema { get; }
13+
14+
public BaseBenchmark()
1015
{
11-
protected ServiceProvider Services { get; }
12-
protected SchemaProvider<BenchmarkContext> Schema { get; }
16+
var servicesCollection = new ServiceCollection();
17+
ConfigureServices(servicesCollection);
18+
Services = servicesCollection.BuildServiceProvider();
19+
Schema = Services.GetRequiredService<SchemaProvider<BenchmarkContext>>();
20+
21+
DataLoader.EnsureDbCreated(Services.GetRequiredService<BenchmarkContext>());
22+
}
1323

14-
public BaseBenchmark()
24+
protected virtual SchemaProvider<BenchmarkContext> BuildSchema()
25+
{
26+
var schema = SchemaBuilder.FromObject<BenchmarkContext>();
27+
schema.UpdateType<Person>(type =>
1528
{
16-
var servicesCollection = new ServiceCollection();
17-
ConfigureServices(servicesCollection);
18-
Services = servicesCollection.BuildServiceProvider();
19-
Schema = Services.GetRequiredService<SchemaProvider<BenchmarkContext>>();
29+
type.AddField("name", person => $"{person.FirstName} {person.LastName}", "Person's full name");
30+
});
31+
return schema;
32+
}
2033

21-
DataLoader.EnsureDbCreated(Services.GetRequiredService<BenchmarkContext>());
22-
}
34+
private void ConfigureServices(IServiceCollection services)
35+
{
36+
services.AddDbContext<BenchmarkContext>().AddSingleton(BuildSchema());
37+
}
2338

24-
protected virtual SchemaProvider<BenchmarkContext> BuildSchema()
25-
{
26-
var schema = SchemaBuilder.FromObject<BenchmarkContext>();
27-
schema.UpdateType<Person>(type =>
28-
{
29-
type.AddField("name", person => $"{person.FirstName} {person.LastName}", "Person's full name");
30-
});
31-
return schema;
32-
}
33-
34-
private void ConfigureServices(IServiceCollection services)
35-
{
36-
services.AddDbContext<BenchmarkContext>().AddSingleton(BuildSchema());
37-
}
39+
protected BenchmarkContext GetContext()
40+
{
41+
return Services.GetRequiredService<BenchmarkContext>();
42+
}
3843

39-
protected BenchmarkContext GetContext()
40-
{
41-
return Services.GetRequiredService<BenchmarkContext>();
42-
}
43-
44-
/// <summary>
45-
/// Run query
46-
/// </summary>
47-
/// <param name="context"></param>
48-
/// <param name="query"></param>
49-
/// <param name="options"></param>
50-
/// <exception cref="InvalidOperationException"></exception>
51-
protected void RunQuery(BenchmarkContext context, QueryRequest query, ExecutionOptions? options = null)
52-
{
53-
var result = Schema.ExecuteRequestWithContext(query, context, Services, null, options);
54-
if (result.Errors != null)
55-
throw new InvalidOperationException("query failed: " + string.Join("\n", result.Errors.Select(m => m.Message)));
56-
}
44+
/// <summary>
45+
/// Run query
46+
/// </summary>
47+
/// <param name="context"></param>
48+
/// <param name="query"></param>
49+
/// <param name="options"></param>
50+
/// <exception cref="InvalidOperationException"></exception>
51+
protected void RunQuery(BenchmarkContext context, QueryRequest query, ExecutionOptions? options = null)
52+
{
53+
var result = Schema.ExecuteRequestWithContext(query, context, Services, null, options);
54+
if (result.Errors != null)
55+
throw new InvalidOperationException("query failed: " + string.Join("\n", result.Errors.Select(m => m.Message)));
5756
}
5857
}

0 commit comments

Comments
 (0)