From 24a2ef3a70611c450bb6ee32958005863d7d82de Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:04:39 +0200 Subject: [PATCH 01/12] merge: merge into correct email: --- .editorconfig | 6 +- Directory.Build.props | 2 +- JsonApiDotnetCore.sln | 361 +++++++++--------- src/Examples/GettingStarted/Program.cs | 26 +- .../JsonApiDotNetCoreExample/Program.cs | 11 +- .../JsonApiDotNetCoreExample/Startup.cs | 27 +- .../NoEntityFrameworkExample/Program.cs | 10 +- .../NoEntityFrameworkExample/Startup.cs | 25 +- src/Examples/ReportsExample/Program.cs | 10 +- .../Internal/ResourceGraph.cs | 4 +- .../Server/ResponseSerializer.cs | 2 +- test/DiscoveryTests/DiscoveryTests.csproj | 2 +- .../Acceptance/Spec/CreatingDataTests.cs | 14 +- .../Startups/ClientGeneratedIdsStartup.cs | 5 +- test/UnitTests/Builders/LinkBuilderTests.cs | 8 +- test/UnitTests/Graph/TypeLocator_Tests.cs | 39 +- .../Common/DocumentParserTests.cs | 8 +- .../Common/ResourceObjectBuilderTests.cs | 6 +- .../IncludedResourceObjectBuilderTests.cs | 4 +- 19 files changed, 285 insertions(+), 285 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3499a1f7a6..1cdb95b612 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,4 +22,8 @@ dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private dotnet_naming_style.prefix_underscore.capitalization = camel_case -dotnet_naming_style.prefix_underscore.required_prefix = _ \ No newline at end of file +dotnet_naming_style.prefix_underscore.required_prefix = _ +[*.cs] + +# CS0659: Type overrides Object.Equals(object o) but does not override Object.GetHashCode() +dotnet_diagnostic.CS0659.severity = silent diff --git a/Directory.Build.props b/Directory.Build.props index fcd668b5ba..61e8771fc0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 netstandard2.0 2.* diff --git a/JsonApiDotnetCore.sln b/JsonApiDotnetCore.sln index d582f7b921..7310cf2097 100644 --- a/JsonApiDotnetCore.sln +++ b/JsonApiDotnetCore.sln @@ -1,181 +1,180 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28606.126 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C5B4D998-CECB-454D-9F32-085A897577BE}" - ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore - .travis.yml = .travis.yml - appveyor.yml = appveyor.yml - Build.ps1 = Build.ps1 - build.sh = build.sh - Directory.Build.props = Directory.Build.props - README.md = README.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{026FBC6C-AF76-4568-9B87-EC73457899FD}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{076E1AE4-FD25-4684-B826-CAAE37FEA0AA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCoreExampleTests", "test\JsonApiDotNetCoreExampleTests\JsonApiDotNetCoreExampleTests.csproj", "{CAF331F8-9255-4D72-A1A8-A54141E99F1E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkTests", "test\NoEntityFrameworkTests\NoEntityFrameworkTests.csproj", "{4F15A8F8-5BC6-45A1-BC51-03F921B726A4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{8788FF65-C2B6-40B2-A3A0-1E3D91C02664}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscoveryTests", "test\DiscoveryTests\DiscoveryTests.csproj", "{03032A2F-664D-4DD8-A82F-AD8A482EDD85}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "benchmarks\Benchmarks.csproj", "{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCoreExample", "src\Examples\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj", "{C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkExample", "src\Examples\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{789085E1-048F-4996-B600-791B9CA3A663}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportsExample", "src\Examples\ReportsExample\ReportsExample.csproj", "{8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCore", "src\JsonApiDotNetCore\JsonApiDotNetCore.csproj", "{21D27239-138D-4604-8E49-DCBE41BCE4C8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GettingStarted", "src\Examples\GettingStarted\GettingStarted.csproj", "{067FFD7A-C66B-473D-8471-37F5C95DF61C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|x64.ActiveCfg = Debug|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|x86.ActiveCfg = Debug|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|Any CPU.Build.0 = Release|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|x64.ActiveCfg = Release|Any CPU - {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|x86.ActiveCfg = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x64.ActiveCfg = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x64.Build.0 = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x86.ActiveCfg = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x86.Build.0 = Debug|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|Any CPU.Build.0 = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x64.ActiveCfg = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x64.Build.0 = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x86.ActiveCfg = Release|Any CPU - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x86.Build.0 = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x64.ActiveCfg = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x64.Build.0 = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x86.ActiveCfg = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x86.Build.0 = Debug|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|Any CPU.Build.0 = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x64.ActiveCfg = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x64.Build.0 = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x86.ActiveCfg = Release|Any CPU - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x86.Build.0 = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|Any CPU.Build.0 = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x64.ActiveCfg = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x64.Build.0 = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x86.ActiveCfg = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x86.Build.0 = Debug|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|Any CPU.ActiveCfg = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|Any CPU.Build.0 = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x64.ActiveCfg = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x64.Build.0 = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x86.ActiveCfg = Release|Any CPU - {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x86.Build.0 = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x64.ActiveCfg = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x64.Build.0 = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.ActiveCfg = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.Build.0 = Debug|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.Build.0 = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.ActiveCfg = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.Build.0 = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.ActiveCfg = Release|Any CPU - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.Build.0 = Release|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|x64.ActiveCfg = Debug|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|x86.ActiveCfg = Debug|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|Any CPU.Build.0 = Release|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|x64.ActiveCfg = Release|Any CPU - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|x86.ActiveCfg = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|Any CPU.Build.0 = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x64.ActiveCfg = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x64.Build.0 = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x86.ActiveCfg = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x86.Build.0 = Debug|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|Any CPU.ActiveCfg = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|Any CPU.Build.0 = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|x64.ActiveCfg = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|x64.Build.0 = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|x86.ActiveCfg = Release|Any CPU - {789085E1-048F-4996-B600-791B9CA3A663}.Release|x86.Build.0 = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x64.ActiveCfg = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x64.Build.0 = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x86.ActiveCfg = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x86.Build.0 = Debug|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|Any CPU.Build.0 = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x64.ActiveCfg = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x64.Build.0 = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x86.ActiveCfg = Release|Any CPU - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x86.Build.0 = Release|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|x64.ActiveCfg = Debug|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|x86.ActiveCfg = Debug|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|Any CPU.Build.0 = Release|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|x64.ActiveCfg = Release|Any CPU - {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|x86.ActiveCfg = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x64.ActiveCfg = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x64.Build.0 = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x86.ActiveCfg = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x86.Build.0 = Debug|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|Any CPU.Build.0 = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x64.ActiveCfg = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x64.Build.0 = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.ActiveCfg = Release|Any CPU - {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {026FBC6C-AF76-4568-9B87-EC73457899FD} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} - {CAF331F8-9255-4D72-A1A8-A54141E99F1E} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} - {4F15A8F8-5BC6-45A1-BC51-03F921B726A4} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} - {8788FF65-C2B6-40B2-A3A0-1E3D91C02664} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} - {03032A2F-664D-4DD8-A82F-AD8A482EDD85} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} - {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C} = {076E1AE4-FD25-4684-B826-CAAE37FEA0AA} - {21D27239-138D-4604-8E49-DCBE41BCE4C8} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} - {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A} = {026FBC6C-AF76-4568-9B87-EC73457899FD} - {789085E1-048F-4996-B600-791B9CA3A663} = {026FBC6C-AF76-4568-9B87-EC73457899FD} - {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B} = {026FBC6C-AF76-4568-9B87-EC73457899FD} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4} - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28606.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C5B4D998-CECB-454D-9F32-085A897577BE}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + .travis.yml = .travis.yml + appveyor.yml = appveyor.yml + Build.ps1 = Build.ps1 + build.sh = build.sh + Directory.Build.props = Directory.Build.props + README.md = README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{026FBC6C-AF76-4568-9B87-EC73457899FD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{076E1AE4-FD25-4684-B826-CAAE37FEA0AA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExampleTests", "test\JsonApiDotNetCoreExampleTests\JsonApiDotNetCoreExampleTests.csproj", "{CAF331F8-9255-4D72-A1A8-A54141E99F1E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoEntityFrameworkTests", "test\NoEntityFrameworkTests\NoEntityFrameworkTests.csproj", "{4F15A8F8-5BC6-45A1-BC51-03F921B726A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{8788FF65-C2B6-40B2-A3A0-1E3D91C02664}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscoveryTests", "test\DiscoveryTests\DiscoveryTests.csproj", "{03032A2F-664D-4DD8-A82F-AD8A482EDD85}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "benchmarks\Benchmarks.csproj", "{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExample", "src\Examples\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj", "{C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoEntityFrameworkExample", "src\Examples\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{789085E1-048F-4996-B600-791B9CA3A663}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReportsExample", "src\Examples\ReportsExample\ReportsExample.csproj", "{8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore", "src\JsonApiDotNetCore\JsonApiDotNetCore.csproj", "{21D27239-138D-4604-8E49-DCBE41BCE4C8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStarted", "src\Examples\GettingStarted\GettingStarted.csproj", "{067FFD7A-C66B-473D-8471-37F5C95DF61C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Debug|x86.ActiveCfg = Debug|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|Any CPU.Build.0 = Release|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|x64.ActiveCfg = Release|Any CPU + {CAF331F8-9255-4D72-A1A8-A54141E99F1E}.Release|x86.ActiveCfg = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x64.Build.0 = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Debug|x86.Build.0 = Debug|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|Any CPU.Build.0 = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x64.ActiveCfg = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x64.Build.0 = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x86.ActiveCfg = Release|Any CPU + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4}.Release|x86.Build.0 = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x64.ActiveCfg = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x64.Build.0 = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x86.ActiveCfg = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Debug|x86.Build.0 = Debug|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|Any CPU.Build.0 = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x64.ActiveCfg = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x64.Build.0 = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x86.ActiveCfg = Release|Any CPU + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664}.Release|x86.Build.0 = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x64.ActiveCfg = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x64.Build.0 = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x86.ActiveCfg = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Debug|x86.Build.0 = Debug|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|Any CPU.Build.0 = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x64.ActiveCfg = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x64.Build.0 = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x86.ActiveCfg = Release|Any CPU + {03032A2F-664D-4DD8-A82F-AD8A482EDD85}.Release|x86.Build.0 = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x64.ActiveCfg = Debug|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x64.Build.0 = Debug|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.ActiveCfg = Debug|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.Build.0 = Debug|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.Build.0 = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.ActiveCfg = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.Build.0 = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.ActiveCfg = Release|Any CPU + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.Build.0 = Release|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|x64.ActiveCfg = Debug|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Debug|x86.ActiveCfg = Debug|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|Any CPU.Build.0 = Release|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|x64.ActiveCfg = Release|Any CPU + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A}.Release|x86.ActiveCfg = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|Any CPU.Build.0 = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x64.ActiveCfg = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x64.Build.0 = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x86.ActiveCfg = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Debug|x86.Build.0 = Debug|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|Any CPU.ActiveCfg = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|Any CPU.Build.0 = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|x64.ActiveCfg = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|x64.Build.0 = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|x86.ActiveCfg = Release|Any CPU + {789085E1-048F-4996-B600-791B9CA3A663}.Release|x86.Build.0 = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x64.ActiveCfg = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x64.Build.0 = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x86.ActiveCfg = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Debug|x86.Build.0 = Debug|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|Any CPU.Build.0 = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x64.ActiveCfg = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x64.Build.0 = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x86.ActiveCfg = Release|Any CPU + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B}.Release|x86.Build.0 = Release|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|x64.ActiveCfg = Debug|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Debug|x86.ActiveCfg = Debug|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|Any CPU.Build.0 = Release|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|x64.ActiveCfg = Release|Any CPU + {21D27239-138D-4604-8E49-DCBE41BCE4C8}.Release|x86.ActiveCfg = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x64.ActiveCfg = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x64.Build.0 = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x86.ActiveCfg = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Debug|x86.Build.0 = Debug|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|Any CPU.Build.0 = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x64.ActiveCfg = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x64.Build.0 = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.ActiveCfg = Release|Any CPU + {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {026FBC6C-AF76-4568-9B87-EC73457899FD} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} + {CAF331F8-9255-4D72-A1A8-A54141E99F1E} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} + {4F15A8F8-5BC6-45A1-BC51-03F921B726A4} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} + {8788FF65-C2B6-40B2-A3A0-1E3D91C02664} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} + {03032A2F-664D-4DD8-A82F-AD8A482EDD85} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} + {DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C} = {076E1AE4-FD25-4684-B826-CAAE37FEA0AA} + {C916EBDA-3429-4FEA-AFB3-DF7CA32A8C6A} = {026FBC6C-AF76-4568-9B87-EC73457899FD} + {789085E1-048F-4996-B600-791B9CA3A663} = {026FBC6C-AF76-4568-9B87-EC73457899FD} + {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B} = {026FBC6C-AF76-4568-9B87-EC73457899FD} + {21D27239-138D-4604-8E49-DCBE41BCE4C8} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4} + EndGlobalSection +EndGlobal diff --git a/src/Examples/GettingStarted/Program.cs b/src/Examples/GettingStarted/Program.cs index fdc5046542..04523dcf9c 100644 --- a/src/Examples/GettingStarted/Program.cs +++ b/src/Examples/GettingStarted/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,17 +10,17 @@ namespace GettingStarted { - public class Program - { - public static void Main(string[] args) - { - BuildWebHost(args).Run(); - } - - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://localhost:5001") - .Build(); + + + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .UseUrls("http://localhost:5001"); } } diff --git a/src/Examples/JsonApiDotNetCoreExample/Program.cs b/src/Examples/JsonApiDotNetCoreExample/Program.cs index b9bbe37b6a..f17228e167 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Program.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Program.cs @@ -5,11 +5,12 @@ namespace JsonApiDotNetCoreExample { public class Program { - public static void Main(string[] args) => BuildWebHost(args).Run(); - - public static IWebHost BuildWebHost(string[] args) => + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + .UseStartup(); } } diff --git a/src/Examples/JsonApiDotNetCoreExample/Startup.cs b/src/Examples/JsonApiDotNetCoreExample/Startup.cs index 2963a33ffa..4463ca98da 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Startup.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Startup.cs @@ -28,21 +28,23 @@ public Startup(IHostingEnvironment env) public virtual IServiceProvider ConfigureServices(IServiceCollection services) { var loggerFactory = new LoggerFactory(); - loggerFactory.AddConsole(LogLevel.Warning); services .AddSingleton(loggerFactory) + .AddLogging(builder => + { + builder.AddConsole(); + builder.AddConfiguration(Config.GetSection("Logging")); + }) .AddDbContext(options => options.UseNpgsql(GetDbConnectionString()), ServiceLifetime.Transient) - .AddJsonApi( - options => - { - options.Namespace = "api/v1"; - options.DefaultPageSize = 5; - options.IncludeTotalRecordCount = true; - options.EnableResourceHooks = true; - options.LoaDatabaseValues = true; - }, - discovery => discovery.AddCurrentAssembly()); - + .AddJsonApi(options => + { + options.Namespace = "api/v1"; + options.DefaultPageSize = 5; + options.IncludeTotalRecordCount = true; + options.EnableResourceHooks = true; + options.LoaDatabaseValues = true; + }, + discovery => discovery.AddCurrentAssembly()); return services.BuildServiceProvider(); } @@ -53,7 +55,6 @@ public virtual void Configure( AppDbContext context) { context.Database.EnsureCreated(); - loggerFactory.AddConsole(Config.GetSection("Logging")); app.UseJsonApi(); } diff --git a/src/Examples/NoEntityFrameworkExample/Program.cs b/src/Examples/NoEntityFrameworkExample/Program.cs index 76f3020c52..9cd9c3ce22 100755 --- a/src/Examples/NoEntityFrameworkExample/Program.cs +++ b/src/Examples/NoEntityFrameworkExample/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace NoEntityFrameworkExample @@ -7,12 +7,10 @@ public class Program { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateWebHostBuilder(args).Build().Run(); } - - public static IWebHost BuildWebHost(string[] args) => + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + .UseStartup(); } } diff --git a/src/Examples/NoEntityFrameworkExample/Startup.cs b/src/Examples/NoEntityFrameworkExample/Startup.cs index fe73537169..a438ff9336 100644 --- a/src/Examples/NoEntityFrameworkExample/Startup.cs +++ b/src/Examples/NoEntityFrameworkExample/Startup.cs @@ -32,31 +32,28 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. var mvcBuilder = services.AddMvcCore(); - - services.AddJsonApi( - options => options.Namespace = "api/v1", - resources: resources => resources.AddResource("custom-todo-items"), - mvcBuilder: mvcBuilder - ); - + services.AddLogging(builder => + { + builder.AddConfiguration(Configuration.GetSection("Logging")); + builder.AddConsole(); + }).AddJsonApi( + options => options.Namespace = "api/v1", + resources: resources => resources.AddResource("custom-todo-items"), + mvcBuilder: mvcBuilder + ); services.AddScoped, TodoItemService>(); - var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseNpgsql(Configuration.GetValue("Data:DefaultConnection")); services.AddSingleton(Configuration); - services.AddSingleton>(optionsBuilder.Options); + services.AddSingleton(optionsBuilder.Options); services.AddScoped(); - return services.BuildServiceProvider(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AppDbContext context) + public void Configure(IApplicationBuilder app, AppDbContext context) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - context.Database.EnsureCreated(); - app.UseJsonApi(); } } diff --git a/src/Examples/ReportsExample/Program.cs b/src/Examples/ReportsExample/Program.cs index f3ce6c81b0..3794a268c4 100644 --- a/src/Examples/ReportsExample/Program.cs +++ b/src/Examples/ReportsExample/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace ReportsExample @@ -7,12 +7,10 @@ public class Program { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateWebHostBuilder(args).Build().Run(); } - - public static IWebHost BuildWebHost(string[] args) => + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + .UseStartup(); } } diff --git a/src/JsonApiDotNetCore/Internal/ResourceGraph.cs b/src/JsonApiDotNetCore/Internal/ResourceGraph.cs index c9cfcd2b5d..2dc5dda57a 100644 --- a/src/JsonApiDotNetCore/Internal/ResourceGraph.cs +++ b/src/JsonApiDotNetCore/Internal/ResourceGraph.cs @@ -93,7 +93,7 @@ private IEnumerable Getter(Expression> selec targeted.Add(available.Single(f => f.ExposedInternalMemberName == memberExpression.Member.Name)); return targeted; } - catch (Exception ex) + catch (InvalidOperationException) { ThrowNotExposedError(memberExpression.Member.Name, type); } @@ -115,7 +115,7 @@ private IEnumerable Getter(Expression> selec } return targeted; } - catch (Exception ex) + catch (InvalidOperationException) { ThrowNotExposedError(memberName, type); } diff --git a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs index dd138d3697..e54a0abd0a 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using JsonApiDotNetCore.Internal.Contracts; diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index eeb13485f3..c1c13846a3 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -16,4 +16,4 @@ - + \ No newline at end of file diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs index f2b4b68596..96d3133b68 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs @@ -24,8 +24,8 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class CreatingDataTests : EndToEndTest { - private Faker _todoItemFaker; - private Faker _personFaker; + private readonly Faker _todoItemFaker; + private readonly Faker _personFaker; public CreatingDataTests(TestFixture fixture) : base(fixture) { @@ -155,9 +155,11 @@ public async Task CreateWithRelationship_HasManyAndInclude_IsCreatedAndIncludes( var serializer = GetSerializer(e => new { }, e => new { e.TodoItems, e.Owner }); var owner = new Person(); - var todoItem = new TodoItem(); - todoItem.Owner = owner; - todoItem.Description = "Description"; + var todoItem = new TodoItem + { + Owner = owner, + Description = "Description" + }; dbContext.People.Add(owner); dbContext.TodoItems.Add(todoItem); dbContext.SaveChanges(); @@ -340,7 +342,7 @@ public async Task CreateRelationship_ToManyWithImplicitRemove_IsCreated() var oldPersonDb = dbContext.People.AsNoTracking().Where(p => p.Id == currentPerson.Id).Include(e => e.TodoItems).Single(); AssertEqualStatusCode(HttpStatusCode.Created, response); Assert.Equal(2, newPersonDb.TodoItems.Count); - Assert.Equal(1, oldPersonDb.TodoItems.Count); + Assert.Single(oldPersonDb.TodoItems); Assert.NotNull(newPersonDb.TodoItems.SingleOrDefault(ti => ti.Id == firstTd.Id)); Assert.NotNull(newPersonDb.TodoItems.SingleOrDefault(ti => ti.Id == secondTd.Id)); Assert.NotNull(oldPersonDb.TodoItems.SingleOrDefault(ti => ti.Id == thirdTd.Id)); diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs index fb8920816b..64147e5460 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs @@ -19,10 +19,13 @@ public ClientGeneratedIdsStartup(IHostingEnvironment env) public override IServiceProvider ConfigureServices(IServiceCollection services) { var loggerFactory = new LoggerFactory(); - loggerFactory.AddConsole(LogLevel.Warning); var mvcBuilder = services.AddMvcCore(); services .AddSingleton(loggerFactory) + .AddLogging(builder => + { + builder.AddConsole(); + }) .AddDbContext(options => options.UseNpgsql(GetDbConnectionString()), ServiceLifetime.Transient) .AddJsonApi(options => { options.Namespace = "api/v1"; diff --git a/test/UnitTests/Builders/LinkBuilderTests.cs b/test/UnitTests/Builders/LinkBuilderTests.cs index b7c5f1a3fe..0d9ce1c98b 100644 --- a/test/UnitTests/Builders/LinkBuilderTests.cs +++ b/test/UnitTests/Builders/LinkBuilderTests.cs @@ -115,22 +115,22 @@ public void BuildRelationshipLinks_GlobalResourceAndAttrConfiguration_ExpectedLi [InlineData(Link.All, Link.All, _topSelf, true)] [InlineData(Link.All, Link.Self, _topSelf, false)] [InlineData(Link.All, Link.Paging, null, true)] - [InlineData(Link.All, Link.None, null, null)] + [InlineData(Link.All, Link.None, null, false)] [InlineData(Link.Self, Link.NotConfigured, _topSelf, false)] [InlineData(Link.Self, Link.All, _topSelf, true)] [InlineData(Link.Self, Link.Self, _topSelf, false)] [InlineData(Link.Self, Link.Paging, null, true)] - [InlineData(Link.Self, Link.None, null, null)] + [InlineData(Link.Self, Link.None, null, false)] [InlineData(Link.Paging, Link.NotConfigured, null, true)] [InlineData(Link.Paging, Link.All, _topSelf, true)] [InlineData(Link.Paging, Link.Self, _topSelf, false)] [InlineData(Link.Paging, Link.Paging, null, true)] - [InlineData(Link.Paging, Link.None, null, null)] + [InlineData(Link.Paging, Link.None, null, false)] [InlineData(Link.None, Link.NotConfigured, null, false)] [InlineData(Link.None, Link.All, _topSelf, true)] [InlineData(Link.None, Link.Self, _topSelf, false)] [InlineData(Link.None, Link.Paging, null, true)] - [InlineData(Link.None, Link.None, null, null)] + [InlineData(Link.None, Link.None, null, false)] public void BuildTopLevelLinks_GlobalAndResourceConfiguration_ExpectedLinks(Link global, Link resource, object expectedSelfLink, diff --git a/test/UnitTests/Graph/TypeLocator_Tests.cs b/test/UnitTests/Graph/TypeLocator_Tests.cs index 890994c340..860730857e 100644 --- a/test/UnitTests/Graph/TypeLocator_Tests.cs +++ b/test/UnitTests/Graph/TypeLocator_Tests.cs @@ -11,7 +11,7 @@ public class TypeLocator_Tests [Fact] public void GetGenericInterfaceImplementation_Gets_Implementation() { - // arrange + // Arrange var assembly = GetType().Assembly; var openGeneric = typeof(IGenericInterface<>); var genericArg = typeof(int); @@ -19,17 +19,16 @@ public void GetGenericInterfaceImplementation_Gets_Implementation() var expectedImplementation = typeof(Implementation); var expectedInterface = typeof(IGenericInterface); - // act - var result = TypeLocator.GetGenericInterfaceImplementation( + // Act + var (implementation, registrationInterface) = TypeLocator.GetGenericInterfaceImplementation( assembly, openGeneric, genericArg ); - // assert - Assert.NotNull(result); - Assert.Equal(expectedImplementation, result.implementation); - Assert.Equal(expectedInterface, result.registrationInterface); + // Assert + Assert.Equal(expectedImplementation, implementation); + Assert.Equal(expectedInterface, registrationInterface); } [Fact] @@ -58,17 +57,16 @@ public void GetDerivedGenericTypes_Gets_Implementation() [Fact] public void GetIdType_Correctly_Identifies_JsonApiResource() { - // arrange + // Arrange var type = typeof(Model); var exextedIdType = typeof(int); - // act - var result = TypeLocator.GetIdType(type); + // Act + var (isJsonApiResource, idType) = TypeLocator.GetIdType(type); - // assert - Assert.NotNull(result); - Assert.True(result.isJsonApiResource); - Assert.Equal(exextedIdType, result.idType); + // Assert + Assert.True(isJsonApiResource); + Assert.Equal(exextedIdType, idType); } [Fact] @@ -79,12 +77,11 @@ public void GetIdType_Correctly_Identifies_NonJsonApiResource() Type exextedIdType = null; // act - var result = TypeLocator.GetIdType(type); + var (isJsonApiResource, idType) = TypeLocator.GetIdType(type); - // assert - Assert.NotNull(result); - Assert.False(result.isJsonApiResource); - Assert.Equal(exextedIdType, result.idType); + // Assert + Assert.False(isJsonApiResource); + Assert.Equal(exextedIdType, idType); } [Fact] @@ -136,7 +133,7 @@ public void TryGetResourceDescriptor_Returns_False_If_Type_Is_IIdentfiable() var resourceType = typeof(String); // act - var isJsonApiResource = TypeLocator.TryGetResourceDescriptor(resourceType, out var descriptor); + var isJsonApiResource = TypeLocator.TryGetResourceDescriptor(resourceType, out var _); // assert Assert.False(isJsonApiResource); @@ -152,4 +149,4 @@ public class BaseType { } public class DerivedType : BaseType { } public class Model : Identifiable { } -} \ No newline at end of file +} diff --git a/test/UnitTests/Serialization/Common/DocumentParserTests.cs b/test/UnitTests/Serialization/Common/DocumentParserTests.cs index fa6e10ce01..ca718affcd 100644 --- a/test/UnitTests/Serialization/Common/DocumentParserTests.cs +++ b/test/UnitTests/Serialization/Common/DocumentParserTests.cs @@ -137,15 +137,15 @@ public void DeserializeAttributes_VariousDataTypes_CanDeserialize(string member, if (member == "int-field") { - Assert.Equal(deserializedValue, 1); + Assert.Equal(1, deserializedValue); } else if (member == "nullable-int-field" && value == null) { - Assert.Equal(deserializedValue, null); + Assert.Null(deserializedValue); } else if (member == "nullable-int-field" && (string)value == "1") { - Assert.Equal(deserializedValue, 1); + Assert.Equal(1, deserializedValue); } else if (member == "guid-field") { @@ -366,7 +366,7 @@ public void DeserializeRelationships_PopulatedOneToManyDependent_NavigationIsPop // assert Assert.Equal(1, result.Id); - Assert.Equal(1, result.Dependents.Count); + Assert.Single(result.Dependents); Assert.Equal(10, result.Dependents.First().Id); Assert.Null(result.AttributeMember); } diff --git a/test/UnitTests/Serialization/Common/ResourceObjectBuilderTests.cs b/test/UnitTests/Serialization/Common/ResourceObjectBuilderTests.cs index 06df8ab1e2..16e6519f3d 100644 --- a/test/UnitTests/Serialization/Common/ResourceObjectBuilderTests.cs +++ b/test/UnitTests/Serialization/Common/ResourceObjectBuilderTests.cs @@ -128,7 +128,7 @@ public void EntityWithRelationshipsToResourceObject_WithIncludedRelationshipsAtt Assert.Equal("10", populatedToOneData.Id); Assert.Equal("one-to-one-dependents", populatedToOneData.Type); var populatedToManiesData = (List)resourceObject.Relationships["populated-to-manies"].Data; - Assert.Equal(1, populatedToManiesData.Count); + Assert.Single(populatedToManiesData); Assert.Equal("20", populatedToManiesData.First().Id); Assert.Equal("one-to-many-dependents", populatedToManiesData.First().Type); } @@ -144,7 +144,7 @@ public void EntityWithRelationshipsToResourceObject_DeviatingForeignKeyWhileRela var resourceObject = _builder.Build(entity, relationships: relationships); // assert - Assert.Equal(1, resourceObject.Relationships.Count); + Assert.Single(resourceObject.Relationships); Assert.NotNull(resourceObject.Relationships["principal"].Data); var ro = (ResourceIdentifierObject)resourceObject.Relationships["principal"].Data; Assert.Equal("10", ro.Id); @@ -175,7 +175,7 @@ public void EntityWithRequiredRelationshipsToResourceObject_DeviatingForeignKeyW var resourceObject = _builder.Build(entity, relationships: relationships); // assert - Assert.Equal(1, resourceObject.Relationships.Count); + Assert.Single(resourceObject.Relationships); Assert.NotNull(resourceObject.Relationships["principal"].Data); var ro = (ResourceIdentifierObject)resourceObject.Relationships["principal"].Data; Assert.Equal("10", ro.Id); diff --git a/test/UnitTests/Serialization/Server/IncludedResourceObjectBuilderTests.cs b/test/UnitTests/Serialization/Server/IncludedResourceObjectBuilderTests.cs index e3b7798974..c0f0dd468d 100644 --- a/test/UnitTests/Serialization/Server/IncludedResourceObjectBuilderTests.cs +++ b/test/UnitTests/Serialization/Server/IncludedResourceObjectBuilderTests.cs @@ -79,7 +79,7 @@ public void BuildIncluded_OverlappingDeeplyNestedCirculairChains_CanBuild() var nonOverlappingBlogs = result.Where((ro) => ro.Type == "blogs" && ro.Id != sharedBlog.StringId).ToList(); foreach (var blog in nonOverlappingBlogs) - Assert.Equal(1, blog.Relationships.Keys.ToList().Count); + Assert.Single(blog.Relationships.Keys.ToList()); var sharedAuthorResourceObject = result.Single((ro) => ro.Type == "people" && ro.Id == sharedBlogAuthor.StringId); var sharedAuthorSongRelation = sharedAuthorResourceObject.Relationships["favorite-song"].SingleData; @@ -149,7 +149,7 @@ public void BuildIncluded_DuplicateChildrenMultipleChains_OnceInOutput() } var result = builder.Build(); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.Equal(person.Name, result[0].Attributes["name"]); Assert.Equal(person.Id.ToString(), result[0].Id); } From 4124aa9afe8d8b2858a4362dc4da3a945ee463d5 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:20:51 +0200 Subject: [PATCH 02/12] feat: upgrade to 2.2 --- Directory.Build.props | 17 ++++++++--------- .../JsonApiDotNetCoreExample.csproj | 1 + .../JsonApiDotNetCoreExample/web.config | 4 ++-- .../NoEntityFrameworkExample.csproj | 3 ++- .../ReportsExample/ReportsExample.csproj | 1 + test/DiscoveryTests/DiscoveryTests.csproj | 1 - 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 61e8771fc0..fbae083fe3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,17 +1,17 @@ - netcoreapp2.1 + netcoreapp2.2 netstandard2.0 - 2.* + 2.2.* - 2.* - 2.* - 2.* + 2.2.* + 2.2.* + 2.2.* - 2.* - 2.* + 2.2.* + 2.2.* 4.0.0 2.1.0 @@ -26,5 +26,4 @@ 22.1.2 4.8.3 - - + \ No newline at end of file diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index 92f1bf4fa0..b3d9610ed5 100644 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -5,6 +5,7 @@ JsonApiDotNetCoreExample Exe JsonApiDotNetCoreExample + InProcess diff --git a/src/Examples/JsonApiDotNetCoreExample/web.config b/src/Examples/JsonApiDotNetCoreExample/web.config index a8d6672758..cde57f2300 100644 --- a/src/Examples/JsonApiDotNetCoreExample/web.config +++ b/src/Examples/JsonApiDotNetCoreExample/web.config @@ -7,8 +7,8 @@ - + - + diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index efdaa68e5b..86825c5621 100755 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,6 +1,7 @@ - + $(NetCoreAppVersion) + InProcess diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index 24c01b9a8d..50e64df8f6 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -1,6 +1,7 @@ $(NetCoreAppVersion) + InProcess diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index c1c13846a3..d4458df6dd 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -15,5 +15,4 @@ - \ No newline at end of file From 17f0c8c5a946a44dd9d1e7e0c014c6a90d5e4601 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:42:11 +0200 Subject: [PATCH 03/12] chore: spacing fix --- src/Examples/GettingStarted/Program.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Examples/GettingStarted/Program.cs b/src/Examples/GettingStarted/Program.cs index 04523dcf9c..7da77fd0fa 100644 --- a/src/Examples/GettingStarted/Program.cs +++ b/src/Examples/GettingStarted/Program.cs @@ -10,17 +10,16 @@ namespace GettingStarted { - - - public class Program - { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build().Run(); - } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://localhost:5001"); + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .UseUrls("http://localhost:5001"); } -} +} \ No newline at end of file From 10ea6cb0e037d597383927c547584ad767a13a67 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:42:38 +0200 Subject: [PATCH 04/12] chore: revert silencing error --- .editorconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1cdb95b612..3499a1f7a6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,8 +22,4 @@ dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private dotnet_naming_style.prefix_underscore.capitalization = camel_case -dotnet_naming_style.prefix_underscore.required_prefix = _ -[*.cs] - -# CS0659: Type overrides Object.Equals(object o) but does not override Object.GetHashCode() -dotnet_diagnostic.CS0659.severity = silent +dotnet_naming_style.prefix_underscore.required_prefix = _ \ No newline at end of file From 0a4e32222676d8b4e14233ae165a93ad86298d87 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:45:49 +0200 Subject: [PATCH 05/12] chore: small spacing fix --- src/Examples/JsonApiDotNetCoreExample/web.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Examples/JsonApiDotNetCoreExample/web.config b/src/Examples/JsonApiDotNetCoreExample/web.config index cde57f2300..50d0b02786 100644 --- a/src/Examples/JsonApiDotNetCoreExample/web.config +++ b/src/Examples/JsonApiDotNetCoreExample/web.config @@ -9,6 +9,6 @@ - + From 9697449f4e787d268a3e0e0483460ec368121156 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 14:58:03 +0200 Subject: [PATCH 06/12] chore: remove unneeeded dependencies --- Directory.Build.props | 2 +- benchmarks/Benchmarks.csproj | 2 +- src/Examples/GettingStarted/GettingStarted.csproj | 1 - .../JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj | 4 +--- .../NoEntityFrameworkExample/NoEntityFrameworkExample.csproj | 5 +---- src/Examples/ReportsExample/ReportsExample.csproj | 5 +---- src/JsonApiDotNetCore/JsonApiDotNetCore.csproj | 2 -- test/DiscoveryTests/DiscoveryTests.csproj | 2 +- .../JsonApiDotNetCoreExampleTests.csproj | 2 +- test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj | 2 +- test/UnitTests/UnitTests.csproj | 2 +- 11 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 5b447710fc..545159e16c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - netcoreapp2.2 + netcoreapp3.0 netstandard2.0 2.2.* 2.2.* diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj index 60a9a8bf42..94f19fb579 100644 --- a/benchmarks/Benchmarks.csproj +++ b/benchmarks/Benchmarks.csproj @@ -1,7 +1,7 @@ Exe - $(NetCoreAppVersion) + $(NetCoreAppVersion) Benchmarks diff --git a/src/Examples/GettingStarted/GettingStarted.csproj b/src/Examples/GettingStarted/GettingStarted.csproj index e29e94ce6a..3574e80bc1 100644 --- a/src/Examples/GettingStarted/GettingStarted.csproj +++ b/src/Examples/GettingStarted/GettingStarted.csproj @@ -14,7 +14,6 @@ - diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index b3d9610ed5..deced2745a 100644 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -1,11 +1,10 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) true JsonApiDotNetCoreExample Exe JsonApiDotNetCoreExample - InProcess @@ -13,7 +12,6 @@ - diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index 86825c5621..c5b4c2b785 100755 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,7 +1,6 @@ - $(NetCoreAppVersion) - InProcess + $(NetCoreAppVersion) @@ -14,8 +13,6 @@ - - diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index 50e64df8f6..233d277b9c 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -1,7 +1,6 @@ - $(NetCoreAppVersion) - InProcess + $(NetCoreAppVersion) @@ -13,8 +12,6 @@ - - diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 00ecf71759..aa3e3673be 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -22,8 +22,6 @@ - - diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index d4458df6dd..055afe6da9 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) false diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 5b4231b027..47b14c3bbb 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) false diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 6e2fe18abd..2f5cfe8dcc 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) true NoEntityFrameworkTests Exe diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index 4897b8ae60..3bb001bf2c 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) false From 931c97cfd7cc3a39a2d96612ae6f794c40035433 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 15:10:58 +0200 Subject: [PATCH 07/12] chore: fix framework dependencies --- Directory.Build.props | 4 ++-- benchmarks/Benchmarks.csproj | 2 +- src/Examples/GettingStarted/GettingStarted.csproj | 2 +- .../JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj | 2 +- .../NoEntityFrameworkExample/NoEntityFrameworkExample.csproj | 2 +- src/Examples/ReportsExample/ReportsExample.csproj | 2 +- src/JsonApiDotNetCore/JsonApiDotNetCore.csproj | 3 +-- test/DiscoveryTests/DiscoveryTests.csproj | 2 +- .../JsonApiDotNetCoreExampleTests.csproj | 2 +- test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj | 2 +- test/UnitTests/UnitTests.csproj | 2 +- 11 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 545159e16c..227b894a5f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - netcoreapp3.0 - netstandard2.0 + netcoreapp3.0 + netstandard2.1 2.2.* 2.2.* 2.2.* diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj index 94f19fb579..60a9a8bf42 100644 --- a/benchmarks/Benchmarks.csproj +++ b/benchmarks/Benchmarks.csproj @@ -1,7 +1,7 @@ Exe - $(NetCoreAppVersion) + $(NetCoreAppVersion) Benchmarks diff --git a/src/Examples/GettingStarted/GettingStarted.csproj b/src/Examples/GettingStarted/GettingStarted.csproj index 3574e80bc1..9e2d0beb46 100644 --- a/src/Examples/GettingStarted/GettingStarted.csproj +++ b/src/Examples/GettingStarted/GettingStarted.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + $(NetCoreAppVersion) diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index deced2745a..6fe5336a64 100644 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) true JsonApiDotNetCoreExample Exe diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index c5b4c2b785..502f982880 100755 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index 233d277b9c..d9610da570 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index aa3e3673be..9cba42549e 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,4 +1,4 @@ - + 4.0.0 $(NetStandardVersion) @@ -25,7 +25,6 @@ - diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index 055afe6da9..d4458df6dd 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppVersion) + $(NetCoreAppVersion) false diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 47b14c3bbb..5b4231b027 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) false diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 2f5cfe8dcc..6e2fe18abd 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) true NoEntityFrameworkTests Exe diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index 3bb001bf2c..4897b8ae60 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppVersion) + $(NetCoreAppVersion) false From dd37d8ed56e3be81513aa6a6c70591abefb7626e Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 15:19:18 +0200 Subject: [PATCH 08/12] chore: updates --- .../JsonApiDotNetCore.csproj | 2 +- .../Properties/launchSettings.json | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/JsonApiDotNetCore/Properties/launchSettings.json diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 9cba42549e..919ca5717d 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,4 +1,4 @@ - + 4.0.0 $(NetStandardVersion) diff --git a/src/JsonApiDotNetCore/Properties/launchSettings.json b/src/JsonApiDotNetCore/Properties/launchSettings.json new file mode 100644 index 0000000000..d0f3094262 --- /dev/null +++ b/src/JsonApiDotNetCore/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63521/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "JsonApiDotNetCore": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:63522/" + } + } +} \ No newline at end of file From 13bfdebf58e54db5e8ed62ba2cce124569fd2bbf Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 16:42:14 +0200 Subject: [PATCH 09/12] chore: test fixes --- Directory.Build.props | 12 +++--- .../Data/DefaultResourceRepository.cs | 21 +++++++--- .../Extensions/DbContextExtensions.cs | 16 ++++++++ .../Extensions/ModelStateExtensions.cs | 2 +- .../Formatters/JsonApiOutputFormatter.cs | 1 - .../JsonApiDotNetCore.csproj | 3 +- .../Acceptance/Spec/SparseFieldSetTests.cs | 33 +++++++-------- .../Extensions/IQueryableExtensions.cs | 41 ------------------- .../JsonApiDotNetCoreExampleTests.csproj | 6 ++- .../Data/DefaultEntityRepository_Tests.cs | 16 ++++---- test/UnitTests/DbSetMock.cs | 32 +++++++++++++-- 11 files changed, 96 insertions(+), 87 deletions(-) delete mode 100644 test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs diff --git a/Directory.Build.props b/Directory.Build.props index 143bf8dcd3..900d8801e8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,12 +2,12 @@ netcoreapp3.0 netstandard2.1 - 2.2.* - 2.2.* - 2.2.* - 2.2.* - 2.2.* - 2.2.* + 3.* + 3.* + 3.* + 3.* + 3.* + 3.* 4.0.0 2.1.0 4.5.0 diff --git a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs index 12eba8f6d0..41f3bd2cd3 100644 --- a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs +++ b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs @@ -321,9 +321,14 @@ public virtual async Task> PageAsync(IQueryable public async Task CountAsync(IQueryable entities) { - return (entities is IAsyncEnumerable) - ? await entities.CountAsync() - : entities.Count(); + if (entities is IAsyncEnumerable) + { + return await entities.CountAsync(); + } + else + { + return entities.Count(); + } } /// @@ -337,9 +342,13 @@ public async Task FirstOrDefaultAsync(IQueryable entities) /// public async Task> ToListAsync(IQueryable entities) { - return (entities is IAsyncEnumerable) - ? await entities.ToListAsync() - : entities.ToList(); + if(entities is IAsyncEnumerable) + { + return await entities.ToListAsync(); + } else + { + return entities.ToList(); + } } /// diff --git a/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs b/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs index ebe89815f8..31ba185125 100644 --- a/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs +++ b/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using JsonApiDotNetCore.Models; using Microsoft.EntityFrameworkCore; @@ -108,5 +109,20 @@ private void Proxy(Action func) if(_shouldExecute) func(_transaction); } + + public Task CommitAsync(CancellationToken cancellationToken = default) + { + return _transaction.CommitAsync(cancellationToken); + } + + public Task RollbackAsync(CancellationToken cancellationToken = default) + { + return _transaction.RollbackAsync(cancellationToken); + } + + public ValueTask DisposeAsync() + { + return _transaction.DisposeAsync(); + } } } diff --git a/src/JsonApiDotNetCore/Extensions/ModelStateExtensions.cs b/src/JsonApiDotNetCore/Extensions/ModelStateExtensions.cs index 3bbfbbb09d..1c0e233ebb 100644 --- a/src/JsonApiDotNetCore/Extensions/ModelStateExtensions.cs +++ b/src/JsonApiDotNetCore/Extensions/ModelStateExtensions.cs @@ -1,9 +1,9 @@ using System; +using System.Linq; using System.Reflection; using JsonApiDotNetCore.Internal; using JsonApiDotNetCore.Models; using Microsoft.AspNetCore.Mvc.ModelBinding; -using Microsoft.EntityFrameworkCore.Internal; namespace JsonApiDotNetCore.Extensions { diff --git a/src/JsonApiDotNetCore/Formatters/JsonApiOutputFormatter.cs b/src/JsonApiDotNetCore/Formatters/JsonApiOutputFormatter.cs index b456932fc5..6facec6a6a 100644 --- a/src/JsonApiDotNetCore/Formatters/JsonApiOutputFormatter.cs +++ b/src/JsonApiDotNetCore/Formatters/JsonApiOutputFormatter.cs @@ -17,7 +17,6 @@ public bool CanWriteResult(OutputFormatterCanWriteContext context) return string.IsNullOrEmpty(contentTypeString) || contentTypeString == Constants.ContentType; } - public async Task WriteAsync(OutputFormatterWriteContext context) { var writer = context.HttpContext.RequestServices.GetService(); diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 919ca5717d..25b446f41e 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,4 +1,4 @@ - + 4.0.0 $(NetStandardVersion) @@ -22,6 +22,7 @@ + diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs index 5b9ea5ea57..2981009adc 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs @@ -29,15 +29,13 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class SparseFieldSetTests { - private TestFixture _fixture; private readonly AppDbContext _dbContext; - private IResourceGraph _resourceGraph; - private Faker _personFaker; - private Faker _todoItemFaker; + private readonly IResourceGraph _resourceGraph; + private readonly Faker _personFaker; + private readonly Faker _todoItemFaker; public SparseFieldSetTests(TestFixture fixture) { - _fixture = fixture; _dbContext = fixture.GetService(); _resourceGraph = fixture.GetService(); _personFaker = new Faker() @@ -47,7 +45,7 @@ public SparseFieldSetTests(TestFixture fixture) _todoItemFaker = new Faker() .RuleFor(t => t.Description, f => f.Lorem.Sentence()) - .RuleFor(t => t.Ordinal, f => f.Random.Number(1,10)) + .RuleFor(t => t.Ordinal, f => f.Random.Number(1, 10)) .RuleFor(t => t.CreatedDate, f => f.Date.Past()); } @@ -73,9 +71,8 @@ public async Task Can_Select_Sparse_Fieldsets() var query = _dbContext .TodoItems .Where(t => t.Id == todoItem.Id) - .Select(_resourceGraph.GetAttributes(e => new { e.Id, e.Description, e.CreatedDate, e.AchievedDate } )); + .Select(_resourceGraph.GetAttributes(e => new { e.Id, e.Description, e.CreatedDate, e.AchievedDate })); - var resultSql = StringExtensions.Normalize(query.ToSql()); var result = await query.FirstAsync(); // assert @@ -83,7 +80,6 @@ public async Task Can_Select_Sparse_Fieldsets() Assert.Equal(todoItem.Description, result.Description); Assert.Equal(todoItem.CreatedDate.ToString("G"), result.CreatedDate.ToString("G")); Assert.Equal(todoItem.AchievedDate.GetValueOrDefault().ToString("G"), result.AchievedDate.GetValueOrDefault().ToString("G")); - Assert.Equal(expectedSql, resultSql); } [Fact] @@ -102,7 +98,7 @@ public async Task Fields_Query_Selects_Sparse_Field_Sets() var builder = new WebHostBuilder() .UseStartup(); var httpMethod = new HttpMethod("GET"); - var server = new TestServer(builder); + using var server = new TestServer(builder); var client = server.CreateClient(); var route = $"/api/v1/todo-items/{todoItem.Id}?fields=description,created-date"; @@ -136,7 +132,7 @@ public async Task Fields_Query_Selects_Sparse_Field_Sets_With_Type_As_Navigation var builder = new WebHostBuilder() .UseStartup(); var httpMethod = new HttpMethod("GET"); - var server = new TestServer(builder); + using var server = new TestServer(builder); var client = server.CreateClient(); var route = $"/api/v1/todo-items/{todoItem.Id}?fields[todo-items]=description,created-date"; var request = new HttpRequestMessage(httpMethod, route); @@ -148,6 +144,7 @@ public async Task Fields_Query_Selects_Sparse_Field_Sets_With_Type_As_Navigation // assert Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Contains("relationships only", body); + } [Fact] @@ -170,7 +167,7 @@ public async Task Fields_Query_Selects_All_Fieldset_With_HasOne() var builder = new WebHostBuilder() .UseStartup(); var httpMethod = new HttpMethod("GET"); - var server = new TestServer(builder); + using var server = new TestServer(builder); var client = server.CreateClient(); var route = $"/api/v1/todo-items?include=owner&fields[owner]=first-name,age"; @@ -212,23 +209,23 @@ public async Task Fields_Query_Selects_Fieldset_With_HasOne() var builder = new WebHostBuilder() .UseStartup(); var httpMethod = new HttpMethod("GET"); - var server = new TestServer(builder); + using var server = new TestServer(builder); var client = server.CreateClient(); var route = $"/api/v1/todo-items/{todoItem.Id}?include=owner&fields[owner]=first-name,age"; var request = new HttpRequestMessage(httpMethod, route); - // act + // Act var response = await client.SendAsync(request); - // assert + // Assert - check statusc ode Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadAsStringAsync(); var deserializeBody = JsonConvert.DeserializeObject(body); - // check owner attributes + // Assert - check owner attributes var included = deserializeBody.Included.First(); - Assert.Equal(owner.StringId, included.Id); + Assert.Equal(owner.StringId, included.Id); Assert.Equal(owner.FirstName, included.Attributes["first-name"]); Assert.Equal((long)owner.Age, included.Attributes["age"]); Assert.DoesNotContain("last-name", included.Attributes.Keys); @@ -249,7 +246,7 @@ public async Task Fields_Query_Selects_Fieldset_With_HasMany() var builder = new WebHostBuilder() .UseStartup(); var httpMethod = new HttpMethod("GET"); - var server = new TestServer(builder); + using var server = new TestServer(builder); var client = server.CreateClient(); var route = $"/api/v1/people/{owner.Id}?include=todo-items&fields[todo-items]=description"; diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs deleted file mode 100644 index f9558e9e86..0000000000 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Query.Internal; -using Microsoft.EntityFrameworkCore.Storage; -using Database = Microsoft.EntityFrameworkCore.Storage.Database; - -namespace JsonApiDotNetCoreExampleTests.Helpers.Extensions -{ - public static class IQueryableExtensions - { - private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.Single(x => x.Name == "_queryCompiler"); - - private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo(); - - private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_queryModelGenerator"); - - private static readonly FieldInfo DatabaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database"); - - private static readonly PropertyInfo DependenciesProperty = typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies"); - - public static string ToSql(this IQueryable queryable) - where TResource : class - { - if (!(queryable is EntityQueryable) && !(queryable is InternalDbSet)) - throw new ArgumentException(); - - var queryCompiler = (IQueryCompiler)QueryCompilerField.GetValue(queryable.Provider); - var queryModelGenerator = (IQueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler); - var queryModel = queryModelGenerator.ParseQuery(queryable.Expression); - var database = DatabaseField.GetValue(queryCompiler); - var queryCompilationContextFactory = ((DatabaseDependencies)DependenciesProperty.GetValue(database)).QueryCompilationContextFactory; - var queryCompilationContext = queryCompilationContextFactory.Create(false); - var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor(); - modelVisitor.CreateQueryExecutor(queryModel); - return modelVisitor.Queries.Join(Environment.NewLine + Environment.NewLine); - } - } -} diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 5b4231b027..35080f950d 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -1,4 +1,4 @@ - + $(NetCoreAppVersion) false @@ -17,6 +17,8 @@ + + @@ -24,7 +26,7 @@ - + diff --git a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs b/test/UnitTests/Data/DefaultEntityRepository_Tests.cs index 8b2410dbbb..d4e6adec10 100644 --- a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs +++ b/test/UnitTests/Data/DefaultEntityRepository_Tests.cs @@ -16,16 +16,15 @@ namespace UnitTests.Data { - public class DefaultResourceRepository_Tests : JsonApiControllerMixin + public class DefaultResourceRepositoryTests : JsonApiControllerMixin { - private readonly Mock _currentRequestMock; private readonly Mock> _dbSetMock; private readonly Mock _contextMock; private readonly Mock _targetedFieldsMock; private readonly Mock _contextResolverMock; private readonly TodoItem _todoItem; - public DefaultResourceRepository_Tests() + public DefaultResourceRepositoryTests() { _todoItem = new TodoItem { @@ -33,7 +32,6 @@ public DefaultResourceRepository_Tests() Description = Guid.NewGuid().ToString(), Ordinal = 10 }; - _currentRequestMock = new Mock(); _dbSetMock = DbSetMock.Create(new[] { _todoItem }); _contextMock = new Mock(); _contextResolverMock = new Mock(); @@ -50,8 +48,10 @@ public async Task UpdateAsync_Updates_Attributes_In_AttributesToUpdate() Description = Guid.NewGuid().ToString() }; - var descAttr = new AttrAttribute("description", "Description"); - descAttr.PropertyInfo = typeof(TodoItem).GetProperty(nameof(TodoItem.Description)); + var descAttr = new AttrAttribute("description", "Description") + { + PropertyInfo = typeof(TodoItem).GetProperty(nameof(TodoItem.Description)) + }; _targetedFieldsMock.Setup(m => m.Attributes).Returns(new List { descAttr }); _targetedFieldsMock.Setup(m => m.Relationships).Returns(new List()); @@ -139,8 +139,8 @@ public async Task Page_When_PageNumber_Is_Positive_Returns_PageNumberTh_Page_Of_ [Theory] [InlineData(6, -1, new[] { 4, 5, 6, 7, 8, 9 })] [InlineData(6, -2, new[] { 1, 2, 3 })] - [InlineData(20, -1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 })] - public async Task Page_When_PageNumber_Is_Negative_Returns_PageNumberTh_Page_From_End(int pageSize, int pageNumber, int[] expectedIds) + [InlineData(20, -1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 })] + public async Task Paging_PageNumberIsNegative_PageCorrectIds(int pageSize, int pageNumber, int[] expectedIds) { var todoItems = DbSetMock.Create(TodoItems(1, 2, 3, 4, 5, 6, 7, 8, 9)).Object; var repository = GetRepository(); diff --git a/test/UnitTests/DbSetMock.cs b/test/UnitTests/DbSetMock.cs index fc87757815..f6ad7a2915 100644 --- a/test/UnitTests/DbSetMock.cs +++ b/test/UnitTests/DbSetMock.cs @@ -25,8 +25,13 @@ public static Mock> AsDbSetMock(this List list) where T : class dbSetMock.As>().Setup(x => x.Expression).Returns(queryableList.Expression); dbSetMock.As>().Setup(x => x.ElementType).Returns(queryableList.ElementType); dbSetMock.As>().Setup(x => x.GetEnumerator()).Returns(queryableList.GetEnumerator()); - - dbSetMock.As>().Setup(m => m.GetEnumerator()).Returns(new TestAsyncEnumerator(queryableList.GetEnumerator())); + + var toReturn = new TestAsyncEnumerator(queryableList.GetEnumerator()); + + + dbSetMock.As>() + .Setup(m => m.GetAsyncEnumerator(It.IsAny())) + .Returns(toReturn); dbSetMock.As>().Setup(m => m.Provider).Returns(new TestAsyncQueryProvider(queryableList.Provider)); return dbSetMock; } @@ -70,6 +75,12 @@ public Task ExecuteAsync(Expression expression, CancellationTo { return Task.FromResult(Execute(expression)); } + + TResult IAsyncQueryProvider.ExecuteAsync(Expression expression, CancellationToken cancellationToken) + { + + return Execute(expression); + } } internal class TestAsyncEnumerable : EnumerableQuery, IAsyncEnumerable, IQueryable @@ -87,6 +98,11 @@ public IAsyncEnumerator GetEnumerator() return new TestAsyncEnumerator(this.AsEnumerable().GetEnumerator()); } + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + { + throw new System.NotImplementedException(); + } + IQueryProvider IQueryable.Provider { get { return new TestAsyncQueryProvider(this); } @@ -119,4 +135,14 @@ public Task MoveNext(CancellationToken cancellationToken) { return Task.FromResult(_inner.MoveNext()); } -} \ No newline at end of file + + public ValueTask MoveNextAsync() + { + throw new System.NotImplementedException(); + } + + public ValueTask DisposeAsync() + { + throw new System.NotImplementedException(); + } +} From 5b10565325162cc2d12e64e036c8a43440fa8ae7 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 16:48:34 +0200 Subject: [PATCH 10/12] chore: start integration tests --- JsonApiDotnetCore.sln | 15 +++++++++++ .../Data/DefaultResourceRepository.cs | 7 +++-- .../Data/EntityRepositoryTests.cs | 27 +++++++++++++++++++ test/IntegrationTests/IntegrationTests.csproj | 16 +++++++++++ test/IntegrationTests/UnitTest1.cs | 14 ++++++++++ .../Data/DefaultEntityRepository_Tests.cs | 12 --------- 6 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 test/IntegrationTests/Data/EntityRepositoryTests.cs create mode 100644 test/IntegrationTests/IntegrationTests.csproj create mode 100644 test/IntegrationTests/UnitTest1.cs diff --git a/JsonApiDotnetCore.sln b/JsonApiDotnetCore.sln index 7310cf2097..ad130ce4b1 100644 --- a/JsonApiDotnetCore.sln +++ b/JsonApiDotnetCore.sln @@ -41,6 +41,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore", "src\Js EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStarted", "src\Examples\GettingStarted\GettingStarted.csproj", "{067FFD7A-C66B-473D-8471-37F5C95DF61C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "test\IntegrationTests\IntegrationTests.csproj", "{CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -158,6 +160,18 @@ Global {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x64.Build.0 = Release|Any CPU {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.ActiveCfg = Release|Any CPU {067FFD7A-C66B-473D-8471-37F5C95DF61C}.Release|x86.Build.0 = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|x64.ActiveCfg = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|x64.Build.0 = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|x86.ActiveCfg = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Debug|x86.Build.0 = Debug|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|Any CPU.Build.0 = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|x64.ActiveCfg = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|x64.Build.0 = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|x86.ActiveCfg = Release|Any CPU + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -173,6 +187,7 @@ Global {789085E1-048F-4996-B600-791B9CA3A663} = {026FBC6C-AF76-4568-9B87-EC73457899FD} {8BCFF95F-4850-427C-AEDB-B5B4F62B2C7B} = {026FBC6C-AF76-4568-9B87-EC73457899FD} {21D27239-138D-4604-8E49-DCBE41BCE4C8} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} + {CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4} diff --git a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs index 41f3bd2cd3..6275087761 100644 --- a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs +++ b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs @@ -307,10 +307,13 @@ public virtual async Task> PageAsync(IQueryable()); + } + } +} diff --git a/test/IntegrationTests/IntegrationTests.csproj b/test/IntegrationTests/IntegrationTests.csproj new file mode 100644 index 0000000000..efead13897 --- /dev/null +++ b/test/IntegrationTests/IntegrationTests.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp3.0 + + false + + + + + + + + + + diff --git a/test/IntegrationTests/UnitTest1.cs b/test/IntegrationTests/UnitTest1.cs new file mode 100644 index 0000000000..d90a7ba820 --- /dev/null +++ b/test/IntegrationTests/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace IntegrationTests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} diff --git a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs b/test/UnitTests/Data/DefaultEntityRepository_Tests.cs index d4e6adec10..9584ec7cab 100644 --- a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs +++ b/test/UnitTests/Data/DefaultEntityRepository_Tests.cs @@ -136,19 +136,7 @@ public async Task Page_When_PageNumber_Is_Positive_Returns_PageNumberTh_Page_Of_ Assert.Equal(TodoItems(expectedResult), result, new IdComparer()); } - [Theory] - [InlineData(6, -1, new[] { 4, 5, 6, 7, 8, 9 })] - [InlineData(6, -2, new[] { 1, 2, 3 })] - [InlineData(20, -1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 })] - public async Task Paging_PageNumberIsNegative_PageCorrectIds(int pageSize, int pageNumber, int[] expectedIds) - { - var todoItems = DbSetMock.Create(TodoItems(1, 2, 3, 4, 5, 6, 7, 8, 9)).Object; - var repository = GetRepository(); - var result = await repository.PageAsync(todoItems, pageSize, pageNumber); - - Assert.Equal(TodoItems(expectedIds), result, new IdComparer()); - } private static TodoItem[] TodoItems(params int[] ids) { From 487728ea1ced53fcb43a414dab033dacdff3ac7b Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 16:49:39 +0200 Subject: [PATCH 11/12] chore: cleanup name of dertest --- test/IntegrationTests/Data/EntityRepositoryTests.cs | 2 ++ ...tityRepository_Tests.cs => DefaultEntityRepositoryTests.cs} | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) rename test/UnitTests/Data/{DefaultEntityRepository_Tests.cs => DefaultEntityRepositoryTests.cs} (97%) diff --git a/test/IntegrationTests/Data/EntityRepositoryTests.cs b/test/IntegrationTests/Data/EntityRepositoryTests.cs index 334c243a7b..8141c9891f 100644 --- a/test/IntegrationTests/Data/EntityRepositoryTests.cs +++ b/test/IntegrationTests/Data/EntityRepositoryTests.cs @@ -19,8 +19,10 @@ public async Task Paging_PageNumberIsNegative_PageCorrectIds(int pageSize, int p var todoItems = DbSetMock.Create(TodoItems(1, 2, 3, 4, 5, 6, 7, 8, 9)).Object; var repository = GetRepository(); + // Act var result = await repository.PageAsync(todoItems, pageSize, pageNumber); + // Assert Assert.Equal(TodoItems(expectedIds), result, new IdComparer()); } } diff --git a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs b/test/UnitTests/Data/DefaultEntityRepositoryTests.cs similarity index 97% rename from test/UnitTests/Data/DefaultEntityRepository_Tests.cs rename to test/UnitTests/Data/DefaultEntityRepositoryTests.cs index 9584ec7cab..c54eb62a29 100644 --- a/test/UnitTests/Data/DefaultEntityRepository_Tests.cs +++ b/test/UnitTests/Data/DefaultEntityRepositoryTests.cs @@ -135,9 +135,6 @@ public async Task Page_When_PageNumber_Is_Positive_Returns_PageNumberTh_Page_Of_ Assert.Equal(TodoItems(expectedResult), result, new IdComparer()); } - - - private static TodoItem[] TodoItems(params int[] ids) { return ids.Select(id => new TodoItem { Id = id }).ToArray(); From 80ea1416fe6e7a06f146cc50c4569054453a6222 Mon Sep 17 00:00:00 2001 From: Harro van der Kroft Date: Wed, 23 Oct 2019 16:55:44 +0200 Subject: [PATCH 12/12] chore: start of getRepostory --- .../Data/EntityRepositoryTests.cs | 33 ++++++++++++++++++- test/IntegrationTests/IntegrationTests.csproj | 10 ++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/test/IntegrationTests/Data/EntityRepositoryTests.cs b/test/IntegrationTests/Data/EntityRepositoryTests.cs index 8141c9891f..99ac4e2116 100644 --- a/test/IntegrationTests/Data/EntityRepositoryTests.cs +++ b/test/IntegrationTests/Data/EntityRepositoryTests.cs @@ -1,14 +1,23 @@ +using JsonApiDotNetCore.Builders; +using JsonApiDotNetCore.Data; +using JsonApiDotNetCoreExample.Models; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Xunit; -namespace IntegrationTests.Data +namespace JADNC.IntegrationTests.Data { public class EntityRepositoryTests { + + public EntityRepositoryTests() + { + // setup database + services + // seed + } [Theory] [InlineData(6, -1, new[] { 4, 5, 6, 7, 8, 9 })] [InlineData(6, -2, new[] { 1, 2, 3 })] @@ -25,5 +34,27 @@ public async Task Paging_PageNumberIsNegative_PageCorrectIds(int pageSize, int p // Assert Assert.Equal(TodoItems(expectedIds), result, new IdComparer()); } + + + private DefaultResourceRepository GetRepository() + { + + var contextResolverMock = new Mock(); + _contextMock + .Setup(m => m.Set()) + .Returns(_dbSetMock.Object); + + contextResolverMock + .Setup(m => m.GetContext()) + .Returns(_contextMock.Object); + + var resourceGraph = new ResourceGraphBuilder().AddResource().Build(); + + + return new DefaultResourceRepository( + _targetedFieldsMock.Object, + _contextResolverMock.Object, + resourceGraph, null, null); + } } } diff --git a/test/IntegrationTests/IntegrationTests.csproj b/test/IntegrationTests/IntegrationTests.csproj index efead13897..ac3be5a51d 100644 --- a/test/IntegrationTests/IntegrationTests.csproj +++ b/test/IntegrationTests/IntegrationTests.csproj @@ -4,6 +4,8 @@ netcoreapp3.0 false + + JADNC.IntegrationTests @@ -13,4 +15,12 @@ + + + + + + + +