diff --git a/JsonApiDotnetCore.sln b/JsonApiDotnetCore.sln
index 69b9367d58..769230390d 100644
--- a/JsonApiDotnetCore.sln
+++ b/JsonApiDotnetCore.sln
@@ -108,6 +108,7 @@ Global
{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
diff --git a/benchmarks/BenchmarkResource.cs b/benchmarks/BenchmarkResource.cs
index 0d3ae2c8bf..6fe5eea7ca 100644
--- a/benchmarks/BenchmarkResource.cs
+++ b/benchmarks/BenchmarkResource.cs
@@ -2,7 +2,7 @@
namespace Benchmarks
{
- public class BenchmarkResource : Identifiable
+ public sealed class BenchmarkResource : Identifiable
{
[Attr(BenchmarkResourcePublicNames.NameAttr)]
public string Name { get; set; }
@@ -17,7 +17,7 @@ public class SubResource : Identifiable
public string Value { get; set; }
}
- public static class BenchmarkResourcePublicNames
+ internal static class BenchmarkResourcePublicNames
{
public const string NameAttr = "full-name";
public const string Type = "simple-types";
diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj
index 02bfbf378d..72ff3a78cf 100644
--- a/benchmarks/Benchmarks.csproj
+++ b/benchmarks/Benchmarks.csproj
@@ -6,7 +6,6 @@
-
diff --git a/benchmarks/Program.cs b/benchmarks/Program.cs
index 474bb5725c..396f8786cb 100644
--- a/benchmarks/Program.cs
+++ b/benchmarks/Program.cs
@@ -5,9 +5,9 @@
namespace Benchmarks
{
- class Program
+ internal class Program
{
- static void Main(string[] args)
+ private static void Main(string[] args)
{
var switcher = new BenchmarkSwitcher(new[]
{
diff --git a/src/Examples/GettingStarted/Controllers/ArticlesController.cs b/src/Examples/GettingStarted/Controllers/ArticlesController.cs
index fec9d3e38d..c25e740825 100644
--- a/src/Examples/GettingStarted/Controllers/ArticlesController.cs
+++ b/src/Examples/GettingStarted/Controllers/ArticlesController.cs
@@ -6,7 +6,7 @@
namespace GettingStarted
{
- public class ArticlesController : JsonApiController
+ public sealed class ArticlesController : JsonApiController
{
public ArticlesController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/GettingStarted/Controllers/PeopleController.cs b/src/Examples/GettingStarted/Controllers/PeopleController.cs
index 68ff5932ea..e6a9a2a4ff 100644
--- a/src/Examples/GettingStarted/Controllers/PeopleController.cs
+++ b/src/Examples/GettingStarted/Controllers/PeopleController.cs
@@ -6,7 +6,7 @@
namespace GettingStarted
{
- public class PeopleController : JsonApiController
+ public sealed class PeopleController : JsonApiController
{
public PeopleController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/GettingStarted/Models/Article.cs b/src/Examples/GettingStarted/Models/Article.cs
index f10c3b175f..e8bf99fcaf 100644
--- a/src/Examples/GettingStarted/Models/Article.cs
+++ b/src/Examples/GettingStarted/Models/Article.cs
@@ -2,7 +2,7 @@
namespace GettingStarted.Models
{
- public class Article : Identifiable
+ public sealed class Article : Identifiable
{
[Attr]
public string Title { get; set; }
@@ -10,4 +10,4 @@ public class Article : Identifiable
public Person Author { get; set; }
public int AuthorId { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Examples/GettingStarted/Models/Person.cs b/src/Examples/GettingStarted/Models/Person.cs
index 39b59a44bb..3c5cff596c 100644
--- a/src/Examples/GettingStarted/Models/Person.cs
+++ b/src/Examples/GettingStarted/Models/Person.cs
@@ -3,11 +3,11 @@
namespace GettingStarted.Models
{
- public class Person : Identifiable
+ public sealed class Person : Identifiable
{
[Attr]
public string Name { get; set; }
[HasMany]
public List Articles { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Examples/GettingStarted/ResourceDefinitionExample/Model.cs b/src/Examples/GettingStarted/ResourceDefinitionExample/Model.cs
index 44a421e112..c12d8946f8 100644
--- a/src/Examples/GettingStarted/ResourceDefinitionExample/Model.cs
+++ b/src/Examples/GettingStarted/ResourceDefinitionExample/Model.cs
@@ -2,7 +2,7 @@
namespace GettingStarted.ResourceDefinitionExample
{
- public class Model : Identifiable
+ public sealed class Model : Identifiable
{
[Attr]
public string DoNotExpose { get; set; }
diff --git a/src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs b/src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs
index 1948a13dd7..ac89fc97f2 100644
--- a/src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs
+++ b/src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using JsonApiDotNetCore.Internal.Contracts;
using JsonApiDotNetCore.Models;
diff --git a/src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs b/src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs
index 52478823f8..3b2d83e8c8 100644
--- a/src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs
+++ b/src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs
@@ -5,7 +5,7 @@
namespace GettingStarted.ResourceDefinitionExample
{
- public class ModelsController : JsonApiController
+ public sealed class ModelsController : JsonApiController
{
public ModelsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/GettingStarted/Startup.cs b/src/Examples/GettingStarted/Startup.cs
index c467b9cccd..6c46707d1d 100644
--- a/src/Examples/GettingStarted/Startup.cs
+++ b/src/Examples/GettingStarted/Startup.cs
@@ -5,7 +5,7 @@
namespace GettingStarted
{
- public class Startup
+ public sealed class Startup
{
public void ConfigureServices(IServiceCollection services)
{
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/ArticlesController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/ArticlesController.cs
index ab64bf2c45..4ae287c670 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/ArticlesController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/ArticlesController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class ArticlesController : JsonApiController
+ public sealed class ArticlesController : JsonApiController
{
public ArticlesController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/CamelCasedModelsController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/CamelCasedModelsController.cs
index 588b474c28..3f1ac5e2ed 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/CamelCasedModelsController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/CamelCasedModelsController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class KebabCasedModelsController : JsonApiController
+ public sealed class KebabCasedModelsController : JsonApiController
{
public KebabCasedModelsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/PassportsController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/PassportsController.cs
index 1f38c6aee6..d2268ac09e 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/PassportsController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/PassportsController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class PassportsController : JsonApiController
+ public sealed class PassportsController : JsonApiController
{
public PassportsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/PeopleController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/PeopleController.cs
index 85a00aaa02..eae404b7bc 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/PeopleController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/PeopleController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class PeopleController : JsonApiController
+ public sealed class PeopleController : JsonApiController
{
public PeopleController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/PersonRolesController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/PersonRolesController.cs
index f11e2cee5a..4dfb9232b0 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/PersonRolesController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/PersonRolesController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class PersonRolesController : JsonApiController
+ public sealed class PersonRolesController : JsonApiController
{
public PersonRolesController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TagsController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TagsController.cs
index 24a5de6931..d9e1382c33 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TagsController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TagsController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class TagsController : JsonApiController
+ public sealed class TagsController : JsonApiController
{
public TagsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TestValuesController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TestValuesController.cs
index a29295c426..29bb211cfd 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TestValuesController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TestValuesController.cs
@@ -8,7 +8,7 @@ public class TestValuesController : ControllerBase
[HttpGet]
public IActionResult Get()
{
- var result = new string[] { "value" };
+ var result = new[] { "value" };
return Ok(result);
}
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs
index 8bf3a95539..ccdcb088ca 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs
@@ -12,9 +12,9 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class TodoCollectionsController : JsonApiController
+ public sealed class TodoCollectionsController : JsonApiController
{
- readonly IDbContextResolver _dbResolver;
+ private readonly IDbContextResolver _dbResolver;
public TodoCollectionsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsController.cs
index ea8dbf8359..d21f6c016d 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class TodoItemsController : JsonApiController
+ public sealed class TodoItemsController : JsonApiController
{
public TodoItemsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs
index 19e16c26ea..476ae4860b 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs
@@ -28,7 +28,7 @@ public CustomJsonApiController(
IJsonApiOptions options,
IResourceService resourceService,
ILoggerFactory loggerFactory)
- : base(options, resourceService, loggerFactory)
+ : base(options, resourceService)
{
}
}
@@ -36,23 +36,20 @@ public CustomJsonApiController(
public class CustomJsonApiController
: ControllerBase where T : class, IIdentifiable
{
- private readonly ILogger _logger;
private readonly IJsonApiOptions _options;
private readonly IResourceService _resourceService;
- protected IActionResult Forbidden()
+ private IActionResult Forbidden()
{
return new StatusCodeResult(403);
}
public CustomJsonApiController(
IJsonApiOptions options,
- IResourceService resourceService,
- ILoggerFactory loggerFactory)
+ IResourceService resourceService)
{
_options = options;
_resourceService = resourceService;
- _logger = loggerFactory.CreateLogger>();
}
public CustomJsonApiController(
@@ -62,14 +59,14 @@ public CustomJsonApiController(
}
[HttpGet]
- public virtual async Task GetAsync()
+ public async Task GetAsync()
{
var entities = await _resourceService.GetAsync();
return Ok(entities);
}
[HttpGet("{id}")]
- public virtual async Task GetAsync(TId id)
+ public async Task GetAsync(TId id)
{
var entity = await _resourceService.GetAsync(id);
@@ -80,7 +77,7 @@ public virtual async Task GetAsync(TId id)
}
[HttpGet("{id}/relationships/{relationshipName}")]
- public virtual async Task GetRelationshipsAsync(TId id, string relationshipName)
+ public async Task GetRelationshipsAsync(TId id, string relationshipName)
{
var relationship = _resourceService.GetRelationshipAsync(id, relationshipName);
if (relationship == null)
@@ -90,14 +87,14 @@ public virtual async Task GetRelationshipsAsync(TId id, string re
}
[HttpGet("{id}/{relationshipName}")]
- public virtual async Task GetRelationshipAsync(TId id, string relationshipName)
+ public async Task GetRelationshipAsync(TId id, string relationshipName)
{
var relationship = await _resourceService.GetRelationshipAsync(id, relationshipName);
return Ok(relationship);
}
[HttpPost]
- public virtual async Task PostAsync([FromBody] T entity)
+ public async Task PostAsync([FromBody] T entity)
{
if (entity == null)
return UnprocessableEntity();
@@ -111,7 +108,7 @@ public virtual async Task PostAsync([FromBody] T entity)
}
[HttpPatch("{id}")]
- public virtual async Task PatchAsync(TId id, [FromBody] T entity)
+ public async Task PatchAsync(TId id, [FromBody] T entity)
{
if (entity == null)
return UnprocessableEntity();
@@ -125,14 +122,14 @@ public virtual async Task PatchAsync(TId id, [FromBody] T entity)
}
[HttpPatch("{id}/relationships/{relationshipName}")]
- public virtual async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships)
+ public async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships)
{
await _resourceService.UpdateRelationshipsAsync(id, relationshipName, relationships);
return Ok();
}
[HttpDelete("{id}")]
- public virtual async Task DeleteAsync(TId id)
+ public async Task DeleteAsync(TId id)
{
var wasDeleted = await _resourceService.DeleteAsync(id);
diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/UsersController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/UsersController.cs
index e96bed2517..e07456cc90 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Controllers/UsersController.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/UsersController.cs
@@ -6,7 +6,7 @@
namespace JsonApiDotNetCoreExample.Controllers
{
- public class UsersController : JsonApiController
+ public sealed class UsersController : JsonApiController
{
public UsersController(
IJsonApiOptions jsonApiOptions,
@@ -16,7 +16,7 @@ public UsersController(
{ }
}
- public class SuperUsersController : JsonApiController
+ public sealed class SuperUsersController : JsonApiController
{
public SuperUsersController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs b/src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs
index 17815f9778..cb8876b36a 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs
@@ -3,7 +3,7 @@
namespace JsonApiDotNetCoreExample.Data
{
- public class AppDbContext : DbContext
+ public sealed class AppDbContext : DbContext
{
public DbSet TodoItems { get; set; }
public DbSet Passports { get; set; }
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/Article.cs b/src/Examples/JsonApiDotNetCoreExample/Models/Article.cs
index d8fd68c886..7a4a3ca56b 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/Article.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/Article.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCoreExample.Models
{
- public class Article : Identifiable
+ public sealed class Article : Identifiable
{
[Attr]
public string Name { get; set; }
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/ArticleTag.cs b/src/Examples/JsonApiDotNetCoreExample/Models/ArticleTag.cs
index 22a63459c7..c1f8ebbf82 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/ArticleTag.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/ArticleTag.cs
@@ -2,7 +2,7 @@
namespace JsonApiDotNetCoreExample.Models
{
- public class ArticleTag
+ public sealed class ArticleTag
{
public int ArticleId { get; set; }
public Article Article { get; set; }
@@ -24,4 +24,4 @@ public class IdentifiableArticleTag : Identifiable
public string SomeMetaData { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/Author.cs b/src/Examples/JsonApiDotNetCoreExample/Models/Author.cs
index fce4e7f9c3..0696b037e3 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/Author.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/Author.cs
@@ -3,7 +3,7 @@
namespace JsonApiDotNetCoreExample.Models
{
- public class Author : Identifiable
+ public sealed class Author : Identifiable
{
[Attr]
public string Name { get; set; }
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/Passport.cs b/src/Examples/JsonApiDotNetCoreExample/Models/Passport.cs
index 8775ecbab5..e7d9336ac9 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/Passport.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/Passport.cs
@@ -2,12 +2,12 @@
namespace JsonApiDotNetCoreExample.Models
{
- public class Passport : Identifiable
+ public sealed class Passport : Identifiable
{
- public virtual int? SocialSecurityNumber { get; set; }
- public virtual bool IsLocked { get; set; }
+ public int? SocialSecurityNumber { get; set; }
+ public bool IsLocked { get; set; }
[HasOne]
- public virtual Person Person { get; set; }
+ public Person Person { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/Person.cs b/src/Examples/JsonApiDotNetCoreExample/Models/Person.cs
index c5182aeb9d..58e2c8c67b 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/Person.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/Person.cs
@@ -4,13 +4,13 @@
namespace JsonApiDotNetCoreExample.Models
{
- public class PersonRole : Identifiable
+ public sealed class PersonRole : Identifiable
{
[HasOne]
public Person Person { get; set; }
}
- public class Person : Identifiable, IIsLockable
+ public sealed class Person : Identifiable, IIsLockable
{
public bool IsLocked { get; set; }
@@ -24,30 +24,30 @@ public class Person : Identifiable, IIsLockable
public int Age { get; set; }
[HasMany]
- public virtual List TodoItems { get; set; }
+ public List TodoItems { get; set; }
[HasMany]
- public virtual List AssignedTodoItems { get; set; }
+ public List AssignedTodoItems { get; set; }
[HasMany]
- public virtual List todoCollections { get; set; }
+ public List todoCollections { get; set; }
[HasOne]
- public virtual PersonRole Role { get; set; }
+ public PersonRole Role { get; set; }
public int? PersonRoleId { get; set; }
[HasOne]
- public virtual TodoItem OneToOneTodoItem { get; set; }
+ public TodoItem OneToOneTodoItem { get; set; }
[HasOne]
- public virtual TodoItem StakeHolderTodoItem { get; set; }
- public virtual int? StakeHolderTodoItemId { get; set; }
+ public TodoItem StakeHolderTodoItem { get; set; }
+ public int? StakeHolderTodoItemId { get; set; }
[HasOne(links: Link.All, canInclude: false)]
- public virtual TodoItem UnIncludeableItem { get; set; }
+ public TodoItem UnIncludeableItem { get; set; }
[HasOne]
- public virtual Passport Passport { get; set; }
+ public Passport Passport { get; set; }
public int? PassportId { get; set; }
}
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/TodoItem.cs b/src/Examples/JsonApiDotNetCoreExample/Models/TodoItem.cs
index 815bc52675..5358d6cb11 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/TodoItem.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/TodoItem.cs
@@ -32,7 +32,7 @@ public TodoItem()
public DateTime? UpdatedDate { get; set; }
[Attr(isImmutable: true)]
- public string CalculatedValue { get => "calculated"; }
+ public string CalculatedValue => "calculated";
[Attr]
public DateTimeOffset? OffsetDate { get; set; }
@@ -44,35 +44,35 @@ public TodoItem()
public Guid? CollectionId { get; set; }
[HasOne]
- public virtual Person Owner { get; set; }
+ public Person Owner { get; set; }
[HasOne]
- public virtual Person Assignee { get; set; }
+ public Person Assignee { get; set; }
[HasOne]
- public virtual Person OneToOnePerson { get; set; }
+ public Person OneToOnePerson { get; set; }
- public virtual int? OneToOnePersonId { get; set; }
+ public int? OneToOnePersonId { get; set; }
[HasMany]
- public virtual List StakeHolders { get; set; }
+ public List StakeHolders { get; set; }
[HasOne]
- public virtual TodoItemCollection Collection { get; set; }
+ public TodoItemCollection Collection { get; set; }
// cyclical to-one structure
- public virtual int? DependentOnTodoId { get; set; }
+ public int? DependentOnTodoId { get; set; }
[HasOne]
- public virtual TodoItem DependentOnTodo { get; set; }
+ public TodoItem DependentOnTodo { get; set; }
// cyclical to-many structure
- public virtual int? ParentTodoId {get; set;}
+ public int? ParentTodoId {get; set;}
[HasOne]
- public virtual TodoItem ParentTodo { get; set; }
+ public TodoItem ParentTodo { get; set; }
[HasMany]
- public virtual List ChildrenTodos { get; set; }
+ public List ChildrenTodos { get; set; }
}
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/TodoItemCollection.cs b/src/Examples/JsonApiDotNetCoreExample/Models/TodoItemCollection.cs
index 2a251581d4..3b33a0fc1f 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/TodoItemCollection.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/TodoItemCollection.cs
@@ -5,16 +5,16 @@
namespace JsonApiDotNetCoreExample.Models
{
[Resource("todoCollections")]
- public class TodoItemCollection : Identifiable
+ public sealed class TodoItemCollection : Identifiable
{
[Attr]
public string Name { get; set; }
[HasMany]
- public virtual List TodoItems { get; set; }
+ public List TodoItems { get; set; }
[HasOne]
- public virtual Person Owner { get; set; }
+ public Person Owner { get; set; }
public int? OwnerId { get; set; }
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Models/User.cs b/src/Examples/JsonApiDotNetCoreExample/Models/User.cs
index d0e38b93e7..ef65054c89 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Models/User.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Models/User.cs
@@ -1,4 +1,3 @@
-using System;
using JsonApiDotNetCore.Models;
namespace JsonApiDotNetCoreExample.Models
@@ -9,7 +8,7 @@ public class User : Identifiable
[Attr] public string Password { get; set; }
}
- public class SuperUser : User
+ public sealed class SuperUser : User
{
[Attr] public int SecurityLevel { get; set; }
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs b/src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs
index 4c786b238c..c1969e9b19 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs
@@ -11,11 +11,6 @@ public class PersonResource : LockableResource, IHasMeta
{
public PersonResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
- public override IEnumerable BeforeUpdate(IDiffableEntityHashSet entities, ResourcePipeline pipeline)
- {
- return base.BeforeUpdate(entities, pipeline);
- }
-
public override IEnumerable BeforeUpdateRelationship(HashSet ids, IRelationshipsDictionary entitiesByRelationship, ResourcePipeline pipeline)
{
BeforeImplicitUpdateRelationship(entitiesByRelationship, pipeline);
@@ -31,7 +26,7 @@ public Dictionary GetMeta()
{
return new Dictionary {
{ "copyright", "Copyright 2015 Example Corp." },
- { "authors", new string[] { "Jared Nance", "Maurits Moeys", "Harro van der Kroft" } }
+ { "authors", new[] { "Jared Nance", "Maurits Moeys", "Harro van der Kroft" } }
};
}
}
diff --git a/src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs b/src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs
index 1999936e34..f65a0490d0 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs
@@ -3,7 +3,6 @@
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Hooks;
using JsonApiDotNetCoreExample.Models;
-using JsonApiDotNetCore.Internal;
using JsonApiDotNetCore.Internal.Contracts;
namespace JsonApiDotNetCoreExample.Resources
diff --git a/src/Examples/JsonApiDotNetCoreExample/Resources/UserResource.cs b/src/Examples/JsonApiDotNetCoreExample/Resources/UserResource.cs
index aa4552cae6..517e9137c0 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Resources/UserResource.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Resources/UserResource.cs
@@ -3,7 +3,6 @@
using JsonApiDotNetCoreExample.Models;
using JsonApiDotNetCore.Internal.Query;
using JsonApiDotNetCore.Internal.Contracts;
-using JsonApiDotNetCore.Services;
namespace JsonApiDotNetCoreExample.Resources
{
@@ -18,7 +17,7 @@ public override QueryFilters GetQueryFilters()
{
return new QueryFilters
{
- { "firstCharacter", (users, queryFilter) => FirstCharacterFilter(users, queryFilter) }
+ { "firstCharacter", FirstCharacterFilter }
};
}
@@ -26,8 +25,8 @@ private IQueryable FirstCharacterFilter(IQueryable users, FilterQuer
{
switch (filterQuery.Operation)
{
- /// In EF core >= 3.0 we need to explicitly evaluate the query first. This could probably be translated
- /// into a query by building expression trees.
+ // In EF core >= 3.0 we need to explicitly evaluate the query first. This could probably be translated
+ // into a query by building expression trees.
case "lt":
return users.ToList().Where(u => u.Username.First() < filterQuery.Value[0]).AsQueryable();
default:
diff --git a/src/Examples/JsonApiDotNetCoreExample/Startups/MetaStartup.cs b/src/Examples/JsonApiDotNetCoreExample/Startups/MetaStartup.cs
index 6cc0dd1e81..f074be15bc 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Startups/MetaStartup.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Startups/MetaStartup.cs
@@ -2,7 +2,6 @@
using Microsoft.Extensions.DependencyInjection;
using JsonApiDotNetCore.Services;
using System.Collections.Generic;
-using Microsoft.Extensions.Configuration;
namespace JsonApiDotNetCoreExample
{
@@ -10,7 +9,7 @@ namespace JsonApiDotNetCoreExample
/// This should be in JsonApiDotNetCoreExampleTests project but changes in .net core 3.0
/// do no longer allow that. See https://github.com/aspnet/AspNetCore/issues/15373.
///
- public class MetaStartup : Startup
+ public sealed class MetaStartup : Startup
{
public MetaStartup(IWebHostEnvironment env) : base(env) { }
@@ -21,7 +20,7 @@ public override void ConfigureServices(IServiceCollection services)
}
}
- public class MetaService : IRequestMeta
+ public sealed class MetaService : IRequestMeta
{
public Dictionary GetMeta()
{
diff --git a/src/Examples/JsonApiDotNetCoreExample/Startups/NoDefaultPageSizeStartup.cs b/src/Examples/JsonApiDotNetCoreExample/Startups/NoDefaultPageSizeStartup.cs
index facfd2bb42..2d990ce784 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Startups/NoDefaultPageSizeStartup.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Startups/NoDefaultPageSizeStartup.cs
@@ -11,7 +11,7 @@ namespace JsonApiDotNetCoreExample
/// This should be in JsonApiDotNetCoreExampleTests project but changes in .net core 3.0
/// do no longer allow that. See https://github.com/aspnet/AspNetCore/issues/15373.
///
- public class NoDefaultPageSizeStartup : Startup
+ public sealed class NoDefaultPageSizeStartup : Startup
{
public NoDefaultPageSizeStartup(IWebHostEnvironment env) : base(env) { }
diff --git a/src/Examples/JsonApiDotNetCoreExample/Startups/Startup.cs b/src/Examples/JsonApiDotNetCoreExample/Startups/Startup.cs
index cc5341026a..5c7a7164b2 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Startups/Startup.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Startups/Startup.cs
@@ -30,7 +30,7 @@ public virtual void ConfigureServices(IServiceCollection services)
{
options
.EnableSensitiveDataLogging()
- .UseNpgsql(GetDbConnectionString(), options => options.SetPostgresVersion(new Version(9,6)));
+ .UseNpgsql(GetDbConnectionString(), innerOptions => innerOptions.SetPostgresVersion(new Version(9,6)));
}, ServiceLifetime.Transient)
.AddJsonApi(options =>
{
@@ -44,7 +44,7 @@ public virtual void ConfigureServices(IServiceCollection services)
services.AddClientSerialization();
}
- public virtual void Configure(
+ public void Configure(
IApplicationBuilder app,
AppDbContext context)
{
diff --git a/src/Examples/NoEntityFrameworkExample/Controllers/TodoItemsController.cs b/src/Examples/NoEntityFrameworkExample/Controllers/TodoItemsController.cs
index c21ee5a837..79b487d721 100644
--- a/src/Examples/NoEntityFrameworkExample/Controllers/TodoItemsController.cs
+++ b/src/Examples/NoEntityFrameworkExample/Controllers/TodoItemsController.cs
@@ -6,7 +6,7 @@
namespace NoEntityFrameworkExample.Controllers
{
- public class TodoItemsController : JsonApiController
+ public sealed class TodoItemsController : JsonApiController
{
public TodoItemsController(
IJsonApiOptions jsonApiOptions,
diff --git a/src/Examples/NoEntityFrameworkExample/Data/AppDbContext.cs b/src/Examples/NoEntityFrameworkExample/Data/AppDbContext.cs
index e7247108dd..383041c6be 100644
--- a/src/Examples/NoEntityFrameworkExample/Data/AppDbContext.cs
+++ b/src/Examples/NoEntityFrameworkExample/Data/AppDbContext.cs
@@ -3,7 +3,7 @@
namespace NoEntityFrameworkExample.Data
{
- public class AppDbContext : DbContext
+ public sealed class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions options)
: base(options)
diff --git a/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs b/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs
index 7836ecdd58..8e9c7c8674 100644
--- a/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs
+++ b/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs
@@ -3,7 +3,7 @@
namespace NoEntityFrameworkExample.Models
{
- public class TodoItem : Identifiable
+ public sealed class TodoItem : Identifiable
{
public TodoItem()
{
diff --git a/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs b/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs
index 09078cda2c..bbf430060f 100644
--- a/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs
+++ b/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs
@@ -11,7 +11,7 @@
namespace NoEntityFrameworkExample.Services
{
- public class TodoItemService : IResourceService
+ public sealed class TodoItemService : IResourceService
{
private readonly string _connectionString;
@@ -20,37 +20,27 @@ public TodoItemService(IConfiguration config)
_connectionString = config.GetValue("Data:DefaultConnection");
}
- private IDbConnection Connection
- {
- get
- {
- return new NpgsqlConnection(_connectionString);
- }
- }
+ private IDbConnection Connection => new NpgsqlConnection(_connectionString);
private async Task> QueryAsync(Func>> query)
{
- using (IDbConnection dbConnection = Connection)
- {
- dbConnection.Open();
- return await query(dbConnection);
- }
+ using IDbConnection dbConnection = Connection;
+ dbConnection.Open();
+ return await query(dbConnection);
}
public async Task> GetAsync()
{
- return await QueryAsync(async connection =>
- {
- return await connection.QueryAsync("select * from \"TodoItems\"");
- });
+ return await QueryAsync(async connection =>
+ await connection.QueryAsync("select * from \"TodoItems\""));
}
public async Task GetAsync(int id)
{
- return (await QueryAsync(async connection =>
- {
- return await connection.QueryAsync("select * from \"TodoItems\" where \"Id\"= @id", new { id });
- })).SingleOrDefault();
+ var query = await QueryAsync(async connection =>
+ await connection.QueryAsync("select * from \"TodoItems\" where \"Id\"= @id", new {id}));
+
+ return query.SingleOrDefault();
}
public Task