Skip to content

Update master with dev-v4 #591

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
446cba4
Feat/context decoupling (#557)
maurei Sep 27, 2019
343912e
Feat/serializer context decoupling (#558)
maurei Oct 10, 2019
6204a16
chore: remove example projects
maurei Oct 10, 2019
54ff111
chore: remove bulk related code
maurei Oct 10, 2019
e4a4d9c
chore: remove bulk related tests
maurei Oct 10, 2019
3b5a12c
chore: remove logic related to ER splitting
maurei Oct 10, 2019
4c321fb
chore: remove split test project
maurei Oct 10, 2019
40c9203
chore: update other test projects to pass again
maurei Oct 10, 2019
622875a
chore: fix typo
maurei Oct 10, 2019
d7c6353
Added value types support to the filters isnull & isnotnull. (#549) (…
maurei Oct 10, 2019
e9980c2
fix: missing reference'
maurei Oct 10, 2019
82766b5
chore: fix spacing
maurei Oct 10, 2019
2790843
Merge pull request #571 from json-api-dotnet/chore/remove-bulk-and-split
wisepotato Oct 10, 2019
54942de
feat: draft of reflectively retrieving all query parameters
maurei Oct 10, 2019
0180c5d
Merge branch 'dev-v4' into feat/562
maurei Oct 10, 2019
44eb2c4
chore: scaffolded required query parameter service
maurei Oct 10, 2019
a33fdac
chore: migrate parsing logic sparsefields
maurei Oct 10, 2019
32b3c64
chore: reorganising test models in unit test project
maurei Oct 10, 2019
b9c03b0
tests: add includeservicetests
maurei Oct 10, 2019
9e6b004
chore: migrate parsing logic of filter to filter service
maurei Oct 10, 2019
3812189
chore: prefix private variables underscore in editorconfig
maurei Oct 11, 2019
72a289a
feat: common query parameter base service
maurei Oct 14, 2019
e27d56d
feat: interfaces of query parameter services
maurei Oct 14, 2019
90ab4cf
feat: sort service and filter service
maurei Oct 14, 2019
40cd129
feat: wired up filter and sort service with refactored data and repo …
maurei Oct 14, 2019
5925a29
feat: new omit default and null value services, wired them up in seri…
maurei Oct 14, 2019
bd24e04
feat: refactored remaining query services, introduced new queryparser…
maurei Oct 14, 2019
eec6de4
feat: wired up new query parser in action filter, slimmed down curren…
maurei Oct 14, 2019
0e74d79
chores: various test fixes, minor fixes
maurei Oct 14, 2019
db7157b
chores: various test fixes, minor fixes
maurei Oct 14, 2019
b88d8e7
chore: add more unit tests
maurei Oct 15, 2019
7f59641
docs: query parameters wiki
maurei Oct 15, 2019
73221db
fix: typo
maurei Oct 15, 2019
f78a188
chore: rename, update wiki
maurei Oct 15, 2019
d1af7cc
chore: various minor fixes, PR self review
maurei Oct 15, 2019
8d90ac9
Merge pull request #574 from json-api-dotnet/feat/queryparams
wisepotato Oct 15, 2019
ee7b2c8
feat: added new overload in query controllers (#580)
maurei Oct 17, 2019
4c067db
Cleaning repository of remaining business logic (#579)
maurei Oct 17, 2019
a94f318
Allow for multiple naming conventions (camelCase vs kebab-case) (#581)
maurei Oct 17, 2019
b02445c
fix: #583
maurei Oct 17, 2019
f5d0e8f
feat: throw error on deeply nested selections
maurei Oct 18, 2019
b8e628d
docs: add extra comment
maurei Oct 22, 2019
b24bb60
chore: processed Wisepotatos review
maurei Oct 22, 2019
928ac1e
Merge pull request #584 from json-api-dotnet/fix/sparse-field-navigation
wisepotato Oct 22, 2019
d6c403c
Separation of concerns ResourceGraph (#586)
maurei Oct 22, 2019
811f8ee
Update variable / class naming conventions (#589)
maurei Oct 22, 2019
97d94d2
chore: merge master into dev-v4
maurei Oct 23, 2019
34cffeb
Fix DiscoveryTests and NoEntityFrameworkExample project/tests (#590)
maurei Oct 23, 2019
a2331cb
Simplify DefaultResourceService constructor (#592)
maurei Oct 23, 2019
0a330cb
fix: fix build.sh
maurei Oct 23, 2019
76771d9
fix: appveyor build
maurei Oct 23, 2019
6c83bd8
fix: hotfix constructor ServiceDiscoveryFacadeTests
maurei Oct 23, 2019
b6fccd3
upgrade to .net core 2.1
wisepotato Oct 23, 2019
8a26a2d
.NET core 2.1 -> 2.2 (#594)
wisepotato Oct 23, 2019
f0a0625
chore: rm whitespace
maurei Oct 24, 2019
1be2236
Merge branch 'dev-v4' of https://github.com/json-api-dotnet/JsonApiDo…
maurei Oct 24, 2019
5281350
fix: public setters to allow testing
maurei Oct 24, 2019
c885de2
.NET Core 2.2 -> 3.0 (#597)
wisepotato Oct 29, 2019
d4de3c4
chore: update travis.yml
maurei Oct 29, 2019
504bf20
chore: retry travis.yml
maurei Oct 29, 2019
b3635b2
chore: retry .travis.yml
maurei Oct 29, 2019
40218ce
chore: appveyor.yml
maurei Oct 29, 2019
0bf496b
fix: CI builds
maurei Oct 29, 2019
58253a3
chore: attempt to fix travis.yml
maurei Oct 29, 2019
8ab07de
chore: spacing
wisepotato Oct 30, 2019
b28dc48
chore: postgres version bump
wisepotato Oct 30, 2019
966e606
chore: fix readme + downgrade postgres
wisepotato Oct 30, 2019
6412284
chore: revert
wisepotato Oct 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ charset = utf-8

[*.{csproj,props}]
indent_size = 2

[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion

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 = _
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: csharp
dist: trusty
sudo: required
services:
- postgresql
before_script:
- psql -c 'create database JsonApiDotNetCoreExample;' -U postgres
mono: none
dotnet: 2.1.300 # https://www.microsoft.com/net/download/linux
dotnet: 3.0.100 # https://www.microsoft.com/net/download/linux
branches:
only:
- master
Expand Down
6 changes: 0 additions & 6 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ CheckLastExitCode
dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
CheckLastExitCode

dotnet test ./test/OperationsExampleTests/OperationsExampleTests.csproj
CheckLastExitCode

dotnet test ./test/ResourceEntitySeparationExampleTests/ResourceEntitySeparationExampleTests.csproj
CheckLastExitCode

dotnet test ./test/DiscoveryTests/DiscoveryTests.csproj
CheckLastExitCode

Expand Down
37 changes: 15 additions & 22 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
<Project>

<PropertyGroup>
<NetCoreAppVersion>netcoreapp2.0</NetCoreAppVersion>
<NetStandardVersion>netstandard2.0</NetStandardVersion>

<AspNetCoreVersion>2.1.0</AspNetCoreVersion>

<MicrosoftLoggingVersion>2.1.0</MicrosoftLoggingVersion>
<MicrosoftConfigurationVersion>2.1.0</MicrosoftConfigurationVersion>
<MicrosoftOptionsVersion>2.1.0</MicrosoftOptionsVersion>

<EFCoreVersion>2.1.0</EFCoreVersion>
<EFCoreToolsVersion>2.1.0</EFCoreToolsVersion>

<NpgsqlVersion>4.0.0</NpgsqlVersion>
<NpgsqlPostgreSQLVersion>2.1.0</NpgsqlPostgreSQLVersion>

<NetCoreAppVersion>netcoreapp3.0</NetCoreAppVersion>
<NetStandardVersion>netstandard2.1</NetStandardVersion>
<AspNetCoreVersion>3.*</AspNetCoreVersion>
<MicrosoftLoggingVersion>3.*</MicrosoftLoggingVersion>
<MicrosoftConfigurationVersion>3.*</MicrosoftConfigurationVersion>
<MicrosoftOptionsVersion>3.*</MicrosoftOptionsVersion>
<EFCoreVersion>3.*</EFCoreVersion>
<EFCoreToolsVersion>3.*</EFCoreToolsVersion>
<NpgsqlVersion>4.1.1</NpgsqlVersion>
<NpgsqlPostgreSQLVersion>3.0.1</NpgsqlPostgreSQLVersion>
<TuplesVersion>4.5.0</TuplesVersion>
</PropertyGroup>

<!-- Test Project Dependencies -->
<PropertyGroup>
<TestSdkVersion>15.7.2</TestSdkVersion>
<XUnitVersion>2.3.1</XUnitVersion>
<BogusVersion>22.1.2</BogusVersion>
<MoqVersion>4.8.3</MoqVersion>
<TestSdkVersion>16.3.0</TestSdkVersion>
<XUnitVersion>2.4.1</XUnitVersion>
<BogusVersion>28.4.1</BogusVersion>
<MoqVersion>4.13.1</MoqVersion>
</PropertyGroup>

</Project>
</Project>
436 changes: 195 additions & 241 deletions JsonApiDotnetCore.sln

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See [the documentation](https://json-api-dotnet.github.io/#/) for detailed usage

```csharp
public class Article : Identifiable
{
{
[Attr("name")]
public string Name { get; set; }
}
Expand All @@ -53,10 +53,12 @@ public class Article : Identifiable
```csharp
public class ArticlesController : JsonApiController<Article>
{
public ArticlesController(
IJsonApiContext jsonApiContext,
IResourceService<Article> resourceService)
: base(jsonApiContext, resourceService) { }
public ArticlesController(
IJsonApiOptions jsonApiOptions,
IResourceService<Article> resourceService,
ILoggerFactory loggerFactory)
: base(jsonApiOptions, resourceService, loggerFactory)
{ }
}
```

Expand All @@ -79,19 +81,18 @@ public class Startup

### Development

Restore all nuget packages with:
Restore all NuGet packages with:

```bash
dotnet restore
```

#### Testing

Running tests locally requires access to a postgresql database.
If you have docker installed, this can be propped up via:
Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:

```bash
docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:12.0
```

And then to run the tests:
Expand All @@ -107,3 +108,14 @@ Sometimes the compiled files can be dirty / corrupt from other branches / failed
```bash
dotnet clean
```

## Compatibility

A lot of changes were introduced in v4.0.0, the following chart should help you with compatibility issues between .NET Core versions

| .NET Core Version | JADNC Version |
| ----------------- | ------------- |
| 2.* | v3.* |
| 3.* | v4.* |


2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '{build}'
os: Visual Studio 2017
os: Visual Studio 2019

environment:
POSTGRES_PORT: tcp://localhost:5432
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Attributes.Jobs;
using System;

namespace Benchmarks.LinkBuilder
{
[MarkdownExporter, SimpleJob(launchCount : 3, warmupCount : 10, targetCount : 20), MemoryDiagnoser]
[MarkdownExporter, SimpleJob(launchCount: 3, warmupCount: 10, targetCount: 20), MemoryDiagnoser]
public class LinkBuilder_GetNamespaceFromPath_Benchmarks
{
private const string PATH = "/api/some-really-long-namespace-path/resources/current/articles";
Expand All @@ -14,7 +15,7 @@ public class LinkBuilder_GetNamespaceFromPath_Benchmarks
public void UsingSplit() => GetNamespaceFromPath_BySplitting(PATH, ENTITY_NAME);

[Benchmark]
public void Current() => GetNameSpaceFromPath_Current(PATH, ENTITY_NAME);
public void Current() => GetNameSpaceFromPathCurrent(PATH, ENTITY_NAME);

public static string GetNamespaceFromPath_BySplitting(string path, string entityName)
{
Expand All @@ -32,7 +33,38 @@ public static string GetNamespaceFromPath_BySplitting(string path, string entity
return nSpace;
}

public static string GetNameSpaceFromPath_Current(string path, string entityName)
=> JsonApiDotNetCore.Builders.LinkBuilder.GetNamespaceFromPath(path, entityName);
public static string GetNameSpaceFromPathCurrent(string path, string entityName)
{

var entityNameSpan = entityName.AsSpan();
var pathSpan = path.AsSpan();
const char delimiter = '/';
for (var i = 0; i < pathSpan.Length; i++)
{
if (pathSpan[i].Equals(delimiter))
{
var nextPosition = i + 1;
if (pathSpan.Length > i + entityNameSpan.Length)
{
var possiblePathSegment = pathSpan.Slice(nextPosition, entityNameSpan.Length);
if (entityNameSpan.SequenceEqual(possiblePathSegment))
{
// check to see if it's the last position in the string
// or if the next character is a /
var lastCharacterPosition = nextPosition + entityNameSpan.Length;

if (lastCharacterPosition == pathSpan.Length || pathSpan.Length >= lastCharacterPosition + 2 && pathSpan[lastCharacterPosition].Equals(delimiter))
{
return pathSpan.Slice(0, i).ToString();
}
}
}
}
}

return string.Empty;


}
}
}
6 changes: 3 additions & 3 deletions benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Running;
using Benchmarks.JsonApiContext;
using Benchmarks.LinkBuilder;
using Benchmarks.Query;
Expand All @@ -9,8 +9,8 @@ namespace Benchmarks {
class Program {
static void Main(string[] args) {
var switcher = new BenchmarkSwitcher(new[] {
typeof(JsonApiDeserializer_Benchmarks),
typeof(JsonApiSerializer_Benchmarks),
typeof(JsonApideserializer_Benchmarks),
//typeof(JsonApiSerializer_Benchmarks),
typeof(QueryParser_Benchmarks),
typeof(LinkBuilder_GetNamespaceFromPath_Benchmarks),
typeof(ContainsMediaTypeParameters_Benchmarks),
Expand Down
13 changes: 7 additions & 6 deletions benchmarks/Query/QueryParser_Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using BenchmarkDotNet.Attributes.Jobs;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Internal;
using JsonApiDotNetCore.Managers.Contracts;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;
using Microsoft.AspNetCore.Http.Internal;
Expand All @@ -21,14 +22,14 @@ public class QueryParser_Benchmarks {
private const string DESCENDING_SORT = "-" + ATTRIBUTE;

public QueryParser_Benchmarks() {
var controllerContextMock = new Mock<IControllerContext>();
controllerContextMock.Setup(m => m.RequestEntity).Returns(new ContextEntity {
var requestMock = new Mock<IRequestContext>();
requestMock.Setup(m => m.GetRequestResource()).Returns(new ResourceContext {
Attributes = new List<AttrAttribute> {
new AttrAttribute(ATTRIBUTE, ATTRIBUTE)
}
});
var options = new JsonApiOptions();
_queryParser = new BenchmarkFacade(controllerContextMock.Object, options);
_queryParser = new BenchmarkFacade(requestMock.Object, options);
}

[Benchmark]
Expand Down Expand Up @@ -56,10 +57,10 @@ private void Run(int iterations, Action action) {
}

// this facade allows us to expose and micro-benchmark protected methods
private class BenchmarkFacade : QueryParser {
private class BenchmarkFacade : QueryParameterDiscovery {
public BenchmarkFacade(
IControllerContext controllerContext,
JsonApiOptions options) : base(controllerContext, options) { }
IRequestContext currentRequest,
JsonApiOptions options) : base(currentRequest, options) { }

public void _ParseSortParameters(string value) => base.ParseSortParameters(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ContainsMediaTypeParameters_Benchmarks

[Benchmark]
public void Current()
=> JsonApiDotNetCore.Middleware.RequestMiddleware.ContainsMediaTypeParameters(MEDIA_TYPE);
=> JsonApiDotNetCore.Middleware.CurrentRequestMiddleware.ContainsMediaTypeParameters(MEDIA_TYPE);

private bool UsingSplitImpl(string mediaType)
{
Expand Down
23 changes: 14 additions & 9 deletions benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
using BenchmarkDotNet.Attributes.Exporters;
using JsonApiDotNetCore.Builders;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Internal.Generics;
using JsonApiDotNetCore.Managers.Contracts;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Contracts;

using JsonApiDotNetCore.Services;
using Moq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Benchmarks.Serialization {
namespace Benchmarks.Serialization
{
[MarkdownExporter]
public class JsonApiDeserializer_Benchmarks {
public class JsonApideserializer_Benchmarks {
private const string TYPE_NAME = "simple-types";
private static readonly string Content = JsonConvert.SerializeObject(new Document {
Data = new ResourceObject {
Expand All @@ -29,28 +31,31 @@ public class JsonApiDeserializer_Benchmarks {
}
});

private readonly JsonApiDeSerializer _jsonApiDeSerializer;
private readonly JsonApideserializer _jsonApideserializer;

public JsonApiDeserializer_Benchmarks() {
public JsonApideserializer_Benchmarks() {
var resourceGraphBuilder = new ResourceGraphBuilder();
resourceGraphBuilder.AddResource<SimpleType>(TYPE_NAME);
var resourceGraph = resourceGraphBuilder.Build();
var currentRequestMock = new Mock<IRequestContext>();

currentRequestMock.Setup(m => m.GetUpdatedAttributes()).Returns(new Dictionary<AttrAttribute, object>());

var jsonApiContextMock = new Mock<IJsonApiContext>();
jsonApiContextMock.SetupAllProperties();
jsonApiContextMock.Setup(m => m.ResourceGraph).Returns(resourceGraph);
jsonApiContextMock.Setup(m => m.AttributesToUpdate).Returns(new Dictionary<AttrAttribute, object>());
jsonApiContextMock.Setup(m => m.RequestManager.GetUpdatedAttributes()).Returns(new Dictionary<AttrAttribute, object>());

var jsonApiOptions = new JsonApiOptions();
jsonApiOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
jsonApiContextMock.Setup(m => m.Options).Returns(jsonApiOptions);


_jsonApiDeSerializer = new JsonApiDeSerializer(jsonApiContextMock.Object);
_jsonApideserializer = new JsonApideserializer(jsonApiContextMock.Object, currentRequestMock.Object);
}

[Benchmark]
public object DeserializeSimpleObject() => _jsonApiDeSerializer.Deserialize<SimpleType>(Content);
public object DeserializeSimpleObject() => _jsonApideserializer.Deserialize<SimpleType>(Content);

private class SimpleType : Identifiable {
[Attr("name")]
Expand Down
Loading