From 2cea812844309df6630561f9b0fc9743ad10eed1 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Fri, 24 Jan 2020 17:27:35 +0100 Subject: [PATCH 01/18] Fixed all compiler warnings Also corrected Equals implementation and set builds to fail on compiler warnings in release mode. --- Directory.Build.props | 4 ++++ .../Annotation/RelationshipAttribute.cs | 13 +++++++++--- .../Server/ResponseSerializer.cs | 1 - .../Acceptance/Spec/UpdatingDataTests.cs | 2 -- .../Services/EntityResourceService_Tests.cs | 20 ++++++++++++++++--- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0b51f53d6d..e60f4535ad 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,6 +13,10 @@ 4.5.0 + + true + + 16.3.0 diff --git a/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs index 4eb8d2bbfc..5cb8c7c449 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs @@ -62,13 +62,20 @@ public override string ToString() public override bool Equals(object obj) { - if (!(obj is RelationshipAttribute attr)) + if (obj == null || GetType() != obj.GetType()) { return false; } - bool equalRelationshipName = PublicRelationshipName.Equals(attr.PublicRelationshipName); - return IsHasMany == attr.IsHasMany && equalRelationshipName; + var other = (RelationshipAttribute) obj; + + return PublicRelationshipName == other.PublicRelationshipName && LeftType == other.LeftType && + RightType == other.RightType; + } + + public override int GetHashCode() + { + return HashCode.Combine(PublicRelationshipName, LeftType, RightType); } /// diff --git a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs index e54a0abd0a..0584a9b90c 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs @@ -29,7 +29,6 @@ public class ResponseSerializer : BaseDocumentBuilder, IJsonApiSerial public RelationshipAttribute RequestRelationship { get; set; } private readonly Dictionary> _attributesToSerializeCache = new Dictionary>(); private readonly Dictionary> _relationshipsToSerializeCache = new Dictionary>(); - private readonly IIncludeService _includeService; private readonly IFieldsToSerialize _fieldsToSerialize; private readonly IMetaBuilder _metaBuilder; private readonly Type _primaryResourceType; diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs index 1e9a3d1643..4943bbde1e 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs @@ -22,14 +22,12 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class UpdatingDataTests : EndToEndTest { - private TestFixture _fixture; private AppDbContext _context; private Faker _todoItemFaker; private Faker _personFaker; public UpdatingDataTests(TestFixture fixture) : base(fixture) { - _fixture = fixture; _context = fixture.GetService(); _todoItemFaker = new Faker() diff --git a/test/UnitTests/Services/EntityResourceService_Tests.cs b/test/UnitTests/Services/EntityResourceService_Tests.cs index 4fb8565927..e3bf3128eb 100644 --- a/test/UnitTests/Services/EntityResourceService_Tests.cs +++ b/test/UnitTests/Services/EntityResourceService_Tests.cs @@ -47,7 +47,14 @@ public async Task GetRelationshipAsync_Passes_Public_ResourceName_To_Repository( // Arrange const int id = 1; const string relationshipName = "collection"; - var relationship = new RelationshipAttribute[] { new HasOneAttribute(relationshipName) }; + var relationship = new RelationshipAttribute[] + { + new HasOneAttribute(relationshipName) + { + LeftType = typeof(TodoItem), + RightType = typeof(TodoItemCollection) + } + }; var todoItem = new TodoItem(); var query = new List { todoItem }.AsQueryable(); @@ -73,7 +80,14 @@ public async Task GetRelationshipAsync_Returns_Relationship_Value() // Arrange const int id = 1; const string relationshipName = "collection"; - var relationship = new RelationshipAttribute[] { new HasOneAttribute(relationshipName) }; + var relationships = new RelationshipAttribute[] + { + new HasOneAttribute(relationshipName) + { + LeftType = typeof(TodoItem), + RightType = typeof(TodoItemCollection) + } + }; var todoItem = new TodoItem { @@ -83,7 +97,7 @@ public async Task GetRelationshipAsync_Returns_Relationship_Value() var query = new List { todoItem }.AsQueryable(); _repositoryMock.Setup(m => m.Get(id)).Returns(query); - _repositoryMock.Setup(m => m.Include(query, relationship)).Returns(query); + _repositoryMock.Setup(m => m.Include(query, relationships)).Returns(query); _repositoryMock.Setup(m => m.FirstOrDefaultAsync(query)).ReturnsAsync(todoItem); var repository = GetService(); From 1f9d461d32b9647916d50ab614f70068f25a57cc Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 10:54:39 +0100 Subject: [PATCH 02/18] Suppress warning-as-error "CS1591: Missing XML comment for publicly visible type or member" because it is a massive amount of work to fix all of those. --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index e60f4535ad..7160a70dc2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,7 @@ + $(NoWarn);1591 true From d3af5f630e3b4b30b38329e4dd2860b088aee930 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:00:53 +0100 Subject: [PATCH 03/18] Fix CS1570: XML comment has badly formed XML --- src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs | 2 +- src/JsonApiDotNetCore/Formatters/JsonApiReader.cs | 4 ++-- src/JsonApiDotNetCore/Graph/TypeLocator.cs | 4 ++-- src/JsonApiDotNetCore/Internal/TypeHelper.cs | 3 +-- .../QueryParameterServices/Contracts/IPageService.cs | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs b/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs index 31ba185125..bbcb635b81 100644 --- a/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs +++ b/src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs @@ -75,7 +75,7 @@ public static async Task GetCurrentOrCreateTransactionAsy /// If a transaction already exists, commit, rollback and dispose /// will not be called. It is assumed the creator of the original /// transaction should be responsible for disposal. - /// + /// internal struct SafeTransactionProxy : IDbContextTransaction { private readonly bool _shouldExecute; diff --git a/src/JsonApiDotNetCore/Formatters/JsonApiReader.cs b/src/JsonApiDotNetCore/Formatters/JsonApiReader.cs index 69d04ed3cc..0bc1e79440 100644 --- a/src/JsonApiDotNetCore/Formatters/JsonApiReader.cs +++ b/src/JsonApiDotNetCore/Formatters/JsonApiReader.cs @@ -69,7 +69,7 @@ public async Task ReadAsync(InputFormatterContext context } } - /// Checks if the deserialized payload has an ID included Checks if the deserialized payload has an ID included private bool CheckForId(object model) { if (model == null) return false; @@ -84,7 +84,7 @@ private bool CheckForId(object model) return false; } - /// Checks if the elements in the deserialized payload have an ID included Checks if the elements in the deserialized payload have an ID included private bool CheckForId(IList modelList) { foreach (var model in modelList) diff --git a/src/JsonApiDotNetCore/Graph/TypeLocator.cs b/src/JsonApiDotNetCore/Graph/TypeLocator.cs index de5a2cd82f..7bc7898f18 100644 --- a/src/JsonApiDotNetCore/Graph/TypeLocator.cs +++ b/src/JsonApiDotNetCore/Graph/TypeLocator.cs @@ -113,9 +113,9 @@ public static (Type implementation, Type registrationInterface) GetGenericInterf /// The open generic type, e.g. `typeof(ResourceDefinition<>)` /// Parameters to the generic type /// - /// + /// ), typeof(Article)) - /// + /// ]]> /// public static IEnumerable GetDerivedGenericTypes(Assembly assembly, Type openGenericType, params Type[] genericArguments) { diff --git a/src/JsonApiDotNetCore/Internal/TypeHelper.cs b/src/JsonApiDotNetCore/Internal/TypeHelper.cs index e5938472c1..cb709c3ff3 100644 --- a/src/JsonApiDotNetCore/Internal/TypeHelper.cs +++ b/src/JsonApiDotNetCore/Internal/TypeHelper.cs @@ -215,7 +215,6 @@ public static IList CreateListFor(Type type) /// /// Reflectively instantiates a hashset of a certain type. /// - /// public static IEnumerable CreateHashSetFor(Type type, object elements = null) { return (IEnumerable)CreateInstanceOfOpenType(typeof(HashSet<>), type, elements ?? new object()); @@ -225,7 +224,7 @@ public static IEnumerable CreateHashSetFor(Type type, object elements = null) /// Gets the generic argument T of List{T} /// /// The type of the list - /// The list to be inspected/param> + /// The list to be inspected public static Type GetListInnerType(IEnumerable list) { return list.GetType().GetGenericArguments()[0]; diff --git a/src/JsonApiDotNetCore/QueryParameterServices/Contracts/IPageService.cs b/src/JsonApiDotNetCore/QueryParameterServices/Contracts/IPageService.cs index 64f4a9f965..ed840d5694 100644 --- a/src/JsonApiDotNetCore/QueryParameterServices/Contracts/IPageService.cs +++ b/src/JsonApiDotNetCore/QueryParameterServices/Contracts/IPageService.cs @@ -1,7 +1,7 @@ namespace JsonApiDotNetCore.Query { /// - /// Query parameter service responsible for url queries of the form ?page[size]=X&page[number]=Y + /// Query parameter service responsible for url queries of the form ?page[size]=X&page[number]=Y /// public interface IPageService : IQueryParameterService { From a9552a0f569f36a71d1ea5217793568f4267e8e6 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:02:29 +0100 Subject: [PATCH 04/18] Fix CS1584: XML comment has syntactically incorrect cref attribute --- src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs b/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs index cffc1371c9..bb8990d62e 100644 --- a/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs +++ b/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using JsonApiDotNetCore.Models; using JsonApiDotNetCore.Services; @@ -143,7 +143,7 @@ public interface IUpdateHookContainer where TResource : class, IIdent /// /// If relationships were updated with the updated entities, this will /// be reflected by the corresponding NavigationProperty being set. - /// For each of these relationships, the + /// For each of these relationships, the /// hook is fired after the execution of this hook. /// /// The unique set of affected entities. From 68e5e76c8c5e3bedfe90bb660e2463b15f729efc Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:09:52 +0100 Subject: [PATCH 05/18] Fix CS1587: XML comment is not placed on a valid language element --- .../Builders/ResourceGraphBuilder.cs | 6 +- .../Data/DefaultResourceRepository.cs | 52 ++++++------ .../Hooks/Execution/HookExecutorHelper.cs | 12 +-- .../Hooks/ResourceHookExecutor.cs | 82 +++++++++---------- .../Hooks/Traversal/TraversalHelper.cs | 14 ++-- .../Serialization/Client/RequestSerializer.cs | 10 +-- .../Common/BaseDocumentParser.cs | 10 +-- .../Builders/IncludedResourceObjectBuilder.cs | 10 +-- .../Builders/ResponseResourceObjectBuilder.cs | 6 +- .../Server/ResponseSerializer.cs | 4 +- .../Services/DefaultResourceService.cs | 4 +- 11 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs b/src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs index 414be55944..f9d8c9da13 100644 --- a/src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs +++ b/src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs @@ -91,9 +91,9 @@ protected virtual List GetAttributes(Type entityType) foreach (var prop in properties) { - /// todo: investigate why this is added in the exposed attributes list - /// because it is not really defined attribute considered from the json:api - /// spec point of view. + // todo: investigate why this is added in the exposed attributes list + // because it is not really defined attribute considered from the json:api + // spec point of view. if (prop.Name == nameof(Identifiable.Id)) { var idAttr = new AttrAttribute() diff --git a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs index 079115d378..0ace8de160 100644 --- a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs +++ b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs @@ -89,11 +89,11 @@ public virtual async Task CreateAsync(TResource entity) object trackedRelationshipValue = GetTrackedRelationshipValue(relationshipAttr, entity, out bool relationshipWasAlreadyTracked); LoadInverseRelationships(trackedRelationshipValue, relationshipAttr); if (relationshipWasAlreadyTracked || relationshipAttr is HasManyThroughAttribute) - /// We only need to reassign the relationship value to the to-be-added - /// entity when we're using a different instance of the relationship (because this different one - /// was already tracked) than the one assigned to the to-be-created entity. - /// Alternatively, even if we don't have to reassign anything because of already tracked - /// entities, we still need to assign the "through" entities in the case of many-to-many. + // We only need to reassign the relationship value to the to-be-added + // entity when we're using a different instance of the relationship (because this different one + // was already tracked) than the one assigned to the to-be-created entity. + // Alternatively, even if we don't have to reassign anything because of already tracked + // entities, we still need to assign the "through" entities in the case of many-to-many. relationshipAttr.SetValue(entity, trackedRelationshipValue); } _dbSet.Add(entity); @@ -163,18 +163,18 @@ private void DetachRelationships(TResource entity) { foreach (IIdentifiable single in collection.ToList()) _context.Entry(single).State = EntityState.Detached; - /// detaching has many relationships is not sufficient to - /// trigger a full reload of relationships: the navigation - /// property actually needs to be nulled out, otherwise - /// EF will still add duplicate instances to the collection + // detaching has many relationships is not sufficient to + // trigger a full reload of relationships: the navigation + // property actually needs to be nulled out, otherwise + // EF will still add duplicate instances to the collection relationship.SetValue(entity, null); } else { _context.Entry(value).State = EntityState.Detached; - /// temporary work around for https://github.com/aspnet/EntityFrameworkCore/issues/18621 - /// as soon as ef core 3.1 lands we can get rid of this again. + // temporary work around for https://github.com/aspnet/EntityFrameworkCore/issues/18621 + // as soon as ef core 3.1 lands we can get rid of this again. _context.Entry(entity).State = EntityState.Detached; } } @@ -192,16 +192,16 @@ public virtual async Task UpdateAsync(TResource updatedEntity) foreach (var relationshipAttr in _targetedFields.Relationships) { - /// loads databasePerson.todoItems + // loads databasePerson.todoItems LoadCurrentRelationships(databaseEntity, relationshipAttr); - /// trackedRelationshipValue is either equal to updatedPerson.todoItems, - /// or replaced with the same set (same ids) of todoItems from the EF Core change tracker, - /// which is the case if they were already tracked + // trackedRelationshipValue is either equal to updatedPerson.todoItems, + // or replaced with the same set (same ids) of todoItems from the EF Core change tracker, + // which is the case if they were already tracked object trackedRelationshipValue = GetTrackedRelationshipValue(relationshipAttr, updatedEntity, out _); - /// loads into the db context any persons currently related - /// to the todoItems in trackedRelationshipValue + // loads into the db context any persons currently related + // to the todoItems in trackedRelationshipValue LoadInverseRelationships(trackedRelationshipValue, relationshipAttr); - /// assigns the updated relationship to the database entity + // assigns the updated relationship to the database entity //AssignRelationshipValue(databaseEntity, trackedRelationshipValue, relationshipAttr); relationshipAttr.SetValue(databaseEntity, trackedRelationshipValue); } @@ -395,17 +395,17 @@ private IIdentifiable AttachOrGetTracked(IIdentifiable relationshipValue) if (trackedEntity != null) { - /// there already was an instance of this type and ID tracked - /// by EF Core. Reattaching will produce a conflict, so from now on we - /// will use the already attached instance instead. This entry might - /// contain updated fields as a result of business logic elsewhere in the application + // there already was an instance of this type and ID tracked + // by EF Core. Reattaching will produce a conflict, so from now on we + // will use the already attached instance instead. This entry might + // contain updated fields as a result of business logic elsewhere in the application return trackedEntity; } - /// the relationship pointer is new to EF Core, but we are sure - /// it exists in the database, so we attach it. In this case, as per - /// the json:api spec, we can also safely assume that no fields of - /// this entity were updated. + // the relationship pointer is new to EF Core, but we are sure + // it exists in the database, so we attach it. In this case, as per + // the json:api spec, we can also safely assume that no fields of + // this entity were updated. _context.Entry(relationshipValue).State = EntityState.Unchanged; return null; } diff --git a/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs b/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs index c52e64bd37..27f0a34dce 100644 --- a/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs +++ b/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs @@ -37,10 +37,10 @@ public HookExecutorHelper(IGenericServiceFactory genericProcessorFactory, /// public IResourceHookContainer GetResourceHookContainer(RightType rightType, ResourceHook hook = ResourceHook.None) { - /// checking the cache if we have a reference for the requested container, - /// regardless of the hook we will use it for. If the value is null, - /// it means there was no implementation IResourceHookContainer at all, - /// so we need not even bother. + // checking the cache if we have a reference for the requested container, + // regardless of the hook we will use it for. If the value is null, + // it means there was no implementation IResourceHookContainer at all, + // so we need not even bother. if (!_hookContainers.TryGetValue(rightType, out IResourceHookContainer container)) { container = (_genericProcessorFactory.Get(typeof(ResourceDefinition<>), rightType)); @@ -48,8 +48,8 @@ public IResourceHookContainer GetResourceHookContainer(RightType rightType, Reso } if (container == null) return container; - /// if there was a container, first check if it implements the hook we - /// want to use it for. + // if there was a container, first check if it implements the hook we + // want to use it for. List targetHooks; if (hook == ResourceHook.None) { diff --git a/src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs b/src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs index f8e4dad3ac..e8687e66bf 100644 --- a/src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs +++ b/src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs @@ -91,10 +91,10 @@ public virtual IEnumerable BeforeDelete(IEnumerable p.Attribute).ToArray(); var dbValues = LoadDbValues(entityType, uniqueEntities, ResourceHook.BeforeUpdateRelationship, relationships); - /// these are the entities of the current node grouped by - /// RelationshipAttributes that occured in the previous layer - /// so it looks like { HasOneAttribute:owner => owner_new }. - /// Note that in the BeforeUpdateRelationship hook of Person, - /// we want want inverse relationship attribute: - /// we now have the one pointing from article -> person, ] - /// but we require the the one that points from person -> article + // these are the entities of the current node grouped by + // RelationshipAttributes that occured in the previous layer + // so it looks like { HasOneAttribute:owner => owner_new }. + // Note that in the BeforeUpdateRelationship hook of Person, + // we want want inverse relationship attribute: + // we now have the one pointing from article -> person, ] + // but we require the the one that points from person -> article currenEntitiesGrouped = node.RelationshipsFromPreviousLayer.GetRightEntities(); currentEntitiesGroupedInverse = ReplaceKeysWithInverseRelationships(currenEntitiesGrouped); @@ -273,39 +273,39 @@ void FireNestedBeforeUpdateHooks(ResourcePipeline pipeline, NodeLayer layer) } } - /// Fire the BeforeImplicitUpdateRelationship hook for owner_old. - /// Note: if the pipeline is Post it means we just created article1, - /// which means we are sure that it isn't related to any other entities yet. + // Fire the BeforeImplicitUpdateRelationship hook for owner_old. + // Note: if the pipeline is Post it means we just created article1, + // which means we are sure that it isn't related to any other entities yet. if (pipeline != ResourcePipeline.Post) { - /// To fire a hook for owner_old, we need to first get a reference to it. - /// For this, we need to query the database for the HasOneAttribute:owner - /// relationship of article1, which is referred to as the - /// left side of the HasOneAttribute:owner relationship. + // To fire a hook for owner_old, we need to first get a reference to it. + // For this, we need to query the database for the HasOneAttribute:owner + // relationship of article1, which is referred to as the + // left side of the HasOneAttribute:owner relationship. var leftEntities = node.RelationshipsFromPreviousLayer.GetLeftEntities(); if (leftEntities.Any()) { - /// owner_old is loaded, which is an "implicitly affected entity" + // owner_old is loaded, which is an "implicitly affected entity" FireForAffectedImplicits(entityType, leftEntities, pipeline, uniqueEntities); } } - /// Fire the BeforeImplicitUpdateRelationship hook for article2 - /// For this, we need to query the database for the current owner - /// relationship value of owner_new. + // Fire the BeforeImplicitUpdateRelationship hook for article2 + // For this, we need to query the database for the current owner + // relationship value of owner_new. currenEntitiesGrouped = node.RelationshipsFromPreviousLayer.GetRightEntities(); if (currenEntitiesGrouped.Any()) { - /// rightEntities is grouped by relationships from previous - /// layer, ie { HasOneAttribute:owner => owner_new }. But - /// to load article2 onto owner_new, we need to have the - /// RelationshipAttribute from owner to article, which is the - /// inverse of HasOneAttribute:owner + // rightEntities is grouped by relationships from previous + // layer, ie { HasOneAttribute:owner => owner_new }. But + // to load article2 onto owner_new, we need to have the + // RelationshipAttribute from owner to article, which is the + // inverse of HasOneAttribute:owner currentEntitiesGroupedInverse = ReplaceKeysWithInverseRelationships(currenEntitiesGrouped); - /// Note that currently in the JADNC implementation of hooks, - /// the root layer is ALWAYS homogenous, so we safely assume - /// that for every relationship to the previous layer, the - /// left type is the same. + // Note that currently in the JADNC implementation of hooks, + // the root layer is ALWAYS homogenous, so we safely assume + // that for every relationship to the previous layer, the + // left type is the same. LeftType leftType = currenEntitiesGrouped.First().Key.LeftType; FireForAffectedImplicits(leftType, currentEntitiesGroupedInverse, pipeline); } @@ -319,10 +319,10 @@ void FireNestedBeforeUpdateHooks(ResourcePipeline pipeline, NodeLayer layer) /// Entities grouped by relationship attribute Dictionary ReplaceKeysWithInverseRelationships(Dictionary entitiesByRelationship) { - /// when Article has one Owner (HasOneAttribute:owner) is set, there is no guarantee - /// that the inverse attribute was also set (Owner has one Article: HasOneAttr:article). - /// If it isn't, JADNC currently knows nothing about this relationship pointing back, and it - /// currently cannot fire hooks for entities resolved through inverse relationships. + // when Article has one Owner (HasOneAttribute:owner) is set, there is no guarantee + // that the inverse attribute was also set (Owner has one Article: HasOneAttr:article). + // If it isn't, JADNC currently knows nothing about this relationship pointing back, and it + // currently cannot fire hooks for entities resolved through inverse relationships. var inversableRelationshipAttributes = entitiesByRelationship.Where(kvp => kvp.Key.InverseNavigation != null); return inversableRelationshipAttributes.ToDictionary(kvp => _resourceGraph.GetInverse(kvp.Key), kvp => kvp.Value); } @@ -430,8 +430,8 @@ HashSet GetAllowedEntities(IEnumerable source, IEnumerable. IEnumerable LoadDbValues(Type entityType, IEnumerable uniqueEntities, ResourceHook targetHook, RelationshipAttribute[] relationshipsToNextLayer) { - /// We only need to load database values if the target hook of this hook execution - /// cycle is compatible with displaying database values and has this option enabled. + // We only need to load database values if the target hook of this hook execution + // cycle is compatible with displaying database values and has this option enabled. if (!_executorHelper.ShouldLoadDbValues(entityType, targetHook)) return null; return _executorHelper.LoadDbValues(entityType, uniqueEntities, targetHook, relationshipsToNextLayer); } @@ -443,10 +443,10 @@ void FireAfterUpdateRelationship(IResourceHookContainer container, INode node, R { Dictionary currenEntitiesGrouped = node.RelationshipsFromPreviousLayer.GetRightEntities(); - /// the relationships attributes in currenEntitiesGrouped will be pointing from a - /// resource in the previouslayer to a resource in the current (nested) layer. - /// For the nested hook we need to replace these attributes with their inverse. - /// See the FireNestedBeforeUpdateHooks method for a more detailed example. + // the relationships attributes in currenEntitiesGrouped will be pointing from a + // resource in the previouslayer to a resource in the current (nested) layer. + // For the nested hook we need to replace these attributes with their inverse. + // See the FireNestedBeforeUpdateHooks method for a more detailed example. var resourcesByRelationship = CreateRelationshipHelper(node.ResourceType, ReplaceKeysWithInverseRelationships(currenEntitiesGrouped)); CallHook(container, ResourceHook.AfterUpdateRelationship, new object[] { resourcesByRelationship, pipeline }); } diff --git a/src/JsonApiDotNetCore/Hooks/Traversal/TraversalHelper.cs b/src/JsonApiDotNetCore/Hooks/Traversal/TraversalHelper.cs index 1b8fb9c935..8bba4150ed 100644 --- a/src/JsonApiDotNetCore/Hooks/Traversal/TraversalHelper.cs +++ b/src/JsonApiDotNetCore/Hooks/Traversal/TraversalHelper.cs @@ -79,16 +79,16 @@ public NodeLayer CreateNextLayer(INode rootNode) /// Nodes. public NodeLayer CreateNextLayer(IEnumerable nodes) { - /// first extract entities by parsing populated relationships in the entities - /// of previous layer + // first extract entities by parsing populated relationships in the entities + // of previous layer (var lefts, var rights) = ExtractEntities(nodes); - /// group them conveniently so we can make ChildNodes of them: - /// there might be several relationship attributes in rights dictionary - /// that point to the same right type. + // group them conveniently so we can make ChildNodes of them: + // there might be several relationship attributes in rights dictionary + // that point to the same right type. var leftsGrouped = GroupByRightTypeOfRelationship(lefts); - /// convert the groups into child nodes + // convert the groups into child nodes var nextNodes = leftsGrouped.Select(entry => { var nextNodeType = entry.Key; @@ -105,7 +105,7 @@ public NodeLayer CreateNextLayer(IEnumerable nodes) return CreateNodeInstance(nextNodeType, populatedRelationships.ToArray(), relationshipsToPreviousLayer); }).ToList(); - /// wrap the child nodes in a EntityChildLayer + // wrap the child nodes in a EntityChildLayer return new NodeLayer(nextNodes); } diff --git a/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs b/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs index 178fb7c2d4..504d507a79 100644 --- a/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -87,13 +87,13 @@ private List GetAttributesToSerialize(IIdentifiable entity) private List GetRelationshipsToSerialize(IIdentifiable entity) { var currentResourceType = entity.GetType(); - /// only allow relationship attributes to be serialized if they were set using - /// - /// and the current is a main entry in the primary data. + // only allow relationship attributes to be serialized if they were set using + // + // and the current is a main entry in the primary data. if (RelationshipsToSerialize == null) return _resourceGraph.GetRelationships(currentResourceType); return RelationshipsToSerialize.ToList(); } } -} \ No newline at end of file +} diff --git a/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs b/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs index ede8418eed..5b8afc1fa4 100644 --- a/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs +++ b/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -170,14 +170,14 @@ private object SetHasOneRelationship(IIdentifiable entity, var foreignKeyProperty = entityProperties.FirstOrDefault(p => p.Name == attr.IdentifiablePropertyName); if (foreignKeyProperty != null) - /// there is a FK from the current entity pointing to the related object, - /// i.e. we're populating the relationship from the dependent side. + // there is a FK from the current entity pointing to the related object, + // i.e. we're populating the relationship from the dependent side. SetForeignKey(entity, foreignKeyProperty, attr, relatedId); SetNavigation(entity, attr, relatedId); - /// depending on if this base parser is used client-side or server-side, - /// different additional processing per field needs to be executed. + // depending on if this base parser is used client-side or server-side, + // different additional processing per field needs to be executed. AfterProcessField(entity, attr, relationshipData); return entity; diff --git a/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs index 4ce2aa5f94..5e1608fd3f 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Linq; using JsonApiDotNetCore.Builders; @@ -34,7 +34,7 @@ public List Build() foreach (var resourceObject in _included) { if (resourceObject.Relationships != null) - { /// removes relationship entries (s) if they're completely empty. + { // removes relationship entries (s) if they're completely empty. var pruned = resourceObject.Relationships.Where(p => p.Value.IsPopulated || p.Value.Links != null).ToDictionary(p => p.Key, p => p.Value); if (!pruned.Any()) pruned = null; resourceObject.Relationships = pruned; @@ -49,9 +49,9 @@ public List Build() /// public void IncludeRelationshipChain(List inclusionChain, IIdentifiable rootEntity) { - /// We dont have to build a resource object for the root entity because - /// this one is already encoded in the documents primary data, so we process the chain - /// starting from the first related entity. + // We dont have to build a resource object for the root entity because + // this one is already encoded in the documents primary data, so we process the chain + // starting from the first related entity. var relationship = inclusionChain.First(); var chainRemainder = ShiftChain(inclusionChain); var related = relationship.GetValue(rootEntity); diff --git a/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs index fadc819581..23d85fec0d 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using JsonApiDotNetCore.Internal.Contracts; using JsonApiDotNetCore.Models; @@ -57,8 +57,8 @@ protected override RelationshipEntry GetRelationshipData(RelationshipAttribute r // if links relationshiplinks should be built for this entry, populate the "links" field. (relationshipEntry = relationshipEntry ?? new RelationshipEntry()).Links = links; - /// if neither "links" nor "data" was popupated, return null, which will omit this entry from the output. - /// (see the NullValueHandling settings on ) + // if neither "links" nor "data" was popupated, return null, which will omit this entry from the output. + // (see the NullValueHandling settings on ) return relationshipEntry; } diff --git a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs index 0584a9b90c..f4d4274551 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs @@ -119,7 +119,7 @@ internal string SerializeMany(IEnumerable entities) /// List of allowed attributes in the serialized result private List GetAttributesToSerialize(Type resourceType) { - /// Check the attributes cache to see if the allowed attrs for this resource type were determined before. + // Check the attributes cache to see if the allowed attrs for this resource type were determined before. if (_attributesToSerializeCache.TryGetValue(resourceType, out List allowedAttributes)) return allowedAttributes; @@ -139,7 +139,7 @@ private List GetAttributesToSerialize(Type resourceType) /// List of allowed relationships in the serialized result private List GetRelationshipsToSerialize(Type resourceType) { - /// Check the relationships cache to see if the allowed attrs for this resource type were determined before. + // Check the relationships cache to see if the allowed attrs for this resource type were determined before. if (_relationshipsToSerializeCache.TryGetValue(resourceType, out List allowedRelations)) return allowedRelations; diff --git a/src/JsonApiDotNetCore/Services/DefaultResourceService.cs b/src/JsonApiDotNetCore/Services/DefaultResourceService.cs index cb4328947a..e775f0bd2b 100644 --- a/src/JsonApiDotNetCore/Services/DefaultResourceService.cs +++ b/src/JsonApiDotNetCore/Services/DefaultResourceService.cs @@ -139,8 +139,8 @@ public virtual async Task GetRelationshipsAsync(TId id, string relati var entity = await _repository.FirstOrDefaultAsync(entityQuery); if (entity == null) { - /// TODO: this does not make sense. If the **parent** entity is not found, this error is thrown? - /// this error should be thrown when the relationship is not found. + // TODO: this does not make sense. If the **parent** entity is not found, this error is thrown? + // this error should be thrown when the relationship is not found. throw new JsonApiException(404, $"Relationship '{relationshipName}' not found."); } From ae1f96058ff2b4c7cca38c00fce7c3258f248aa8 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:32:43 +0100 Subject: [PATCH 06/18] Fix CS1574: XML comment has cref attribute that could not be resolved --- .../Configuration/ILinksConfiguration.cs | 5 +++-- src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs | 8 ++++---- src/JsonApiDotNetCore/Internal/ResourceContext.cs | 7 ++++--- .../Models/Annotation/HasOneAttribute.cs | 1 + .../Common/IQueryParameterParser.cs | 3 ++- .../Serialization/Common/BaseDocumentParser.cs | 2 ++ .../Serialization/Common/ResourceObjectBuilder.cs | 2 +- .../Server/Contracts/IJsonApiDeserializer.cs | 3 ++- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs b/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs index a372d61e67..03eaf62422 100644 --- a/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs +++ b/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs @@ -1,4 +1,5 @@ -using JsonApiDotNetCore.Models.Links; +using JsonApiDotNetCore.Models; +using JsonApiDotNetCore.Models.Links; namespace JsonApiDotNetCore.Configuration { @@ -68,4 +69,4 @@ public interface ILinksConfiguration Link RelationshipLinks { get; } } -} \ No newline at end of file +} diff --git a/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs b/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs index 6d74313804..06f4dfaeb4 100644 --- a/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs +++ b/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using JsonApiDotNetCore.Models; using JsonApiDotNetCore.Services; @@ -92,8 +92,8 @@ public interface IReadHookExecutor /// entities as well as any related relationship. /// /// An enum indicating from where the hook was triggered. - /// StringId of the requested entity in the case of - /// . + /// StringId of the requested entity in the case of + /// . /// The type of the request entity void BeforeRead(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable; /// @@ -166,4 +166,4 @@ public interface IOnReturnHookExecutor /// The type of the root entities IEnumerable OnReturn(IEnumerable entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable; } -} \ No newline at end of file +} diff --git a/src/JsonApiDotNetCore/Internal/ResourceContext.cs b/src/JsonApiDotNetCore/Internal/ResourceContext.cs index 91934ca070..15ab4b4c7a 100644 --- a/src/JsonApiDotNetCore/Internal/ResourceContext.cs +++ b/src/JsonApiDotNetCore/Internal/ResourceContext.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Models; using JsonApiDotNetCore.Models.Links; @@ -47,7 +48,7 @@ public class ResourceContext /// /// Configures which links to show in the /// object for this resource. If set to , - /// the configuration will be read from . + /// the configuration will be read from . /// Defaults to . /// public Link TopLevelLinks { get; internal set; } = Link.NotConfigured; @@ -55,7 +56,7 @@ public class ResourceContext /// /// Configures which links to show in the /// object for this resource. If set to , - /// the configuration will be read from . + /// the configuration will be read from . /// Defaults to . /// public Link ResourceLinks { get; internal set; } = Link.NotConfigured; @@ -65,7 +66,7 @@ public class ResourceContext /// for all relationships of the resource for which this attribute was instantiated. /// If set to , the configuration will /// be read from or - /// . Defaults to . + /// . Defaults to . /// public Link RelationshipLinks { get; internal set; } = Link.NotConfigured; diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs index 772eb32457..07f9d8668e 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs @@ -1,4 +1,5 @@ using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Internal; using JsonApiDotNetCore.Models.Links; namespace JsonApiDotNetCore.Models diff --git a/src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterParser.cs b/src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterParser.cs index 69163e37f4..9a0c0b49a5 100644 --- a/src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterParser.cs +++ b/src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterParser.cs @@ -1,4 +1,5 @@ -using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Query; using Microsoft.AspNetCore.Http; namespace JsonApiDotNetCore.Services diff --git a/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs b/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs index 5b8afc1fa4..0875856548 100644 --- a/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs +++ b/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs @@ -7,6 +7,8 @@ using JsonApiDotNetCore.Internal; using JsonApiDotNetCore.Internal.Contracts; using JsonApiDotNetCore.Models; +using JsonApiDotNetCore.Serialization.Client; +using JsonApiDotNetCore.Serialization.Server; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilder.cs index 784f2902a6..21aa663844 100644 --- a/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilder.cs @@ -54,7 +54,7 @@ protected virtual RelationshipEntry GetRelationshipData(RelationshipAttribute re } /// - /// Gets the value for the property. + /// Gets the value for the property. /// protected object GetRelatedResourceLinkage(RelationshipAttribute relationship, IIdentifiable entity) { diff --git a/src/JsonApiDotNetCore/Serialization/Server/Contracts/IJsonApiDeserializer.cs b/src/JsonApiDotNetCore/Serialization/Server/Contracts/IJsonApiDeserializer.cs index 3767aae6ca..680391a755 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Contracts/IJsonApiDeserializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Contracts/IJsonApiDeserializer.cs @@ -1,4 +1,5 @@ using JsonApiDotNetCore.Models; + namespace JsonApiDotNetCore.Serialization.Server { /// @@ -8,7 +9,7 @@ public interface IJsonApiDeserializer { /// /// Deserializes JSON in to a and constructs entities - /// from + /// from . /// /// The JSON to be deserialized /// The entities constructed from the content From fdba1c9a6c845b1e62b1ef76bd48a5c3caa2bf4f Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:33:49 +0100 Subject: [PATCH 07/18] Fix CS1572: XML comment has a param tag, but there is no parameter by that name --- src/JsonApiDotNetCore/Controllers/JsonApiController.cs | 1 - src/JsonApiDotNetCore/Graph/TypeLocator.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/JsonApiDotNetCore/Controllers/JsonApiController.cs b/src/JsonApiDotNetCore/Controllers/JsonApiController.cs index b61284ac0b..ed40928d1d 100644 --- a/src/JsonApiDotNetCore/Controllers/JsonApiController.cs +++ b/src/JsonApiDotNetCore/Controllers/JsonApiController.cs @@ -74,7 +74,6 @@ public class JsonApiController : JsonApiController where T : class, I /// Base constructor with int as default /// /// - /// /// /// public JsonApiController( diff --git a/src/JsonApiDotNetCore/Graph/TypeLocator.cs b/src/JsonApiDotNetCore/Graph/TypeLocator.cs index 7bc7898f18..5e77c166b3 100644 --- a/src/JsonApiDotNetCore/Graph/TypeLocator.cs +++ b/src/JsonApiDotNetCore/Graph/TypeLocator.cs @@ -127,7 +127,7 @@ public static IEnumerable GetDerivedGenericTypes(Assembly assembly, Type o /// Get all derivitives of the specified type. /// /// The assembly to search - /// The inherited type + /// The inherited type /// /// /// GetDerivedGenericTypes(assembly, typeof(DbContext)) From c320d43f29e9c195b8cb54b9abb50492ed68c199 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:35:08 +0100 Subject: [PATCH 08/18] CS1711: XML comment has a typeparam tag, but there is no type parameter by that name --- .../Extensions/EntityFrameworkCoreExtension.cs | 2 +- src/JsonApiDotNetCore/Internal/TypeHelper.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs b/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs index af9272f48c..f3b5215d2b 100644 --- a/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs +++ b/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs @@ -67,7 +67,7 @@ public static class IServiceCollectionExtensions /// /// Enabling JsonApiDotNetCore using the EF Core DbContext to build the ResourceGraph. /// - /// + /// /// /// /// diff --git a/src/JsonApiDotNetCore/Internal/TypeHelper.cs b/src/JsonApiDotNetCore/Internal/TypeHelper.cs index cb709c3ff3..31774eff06 100644 --- a/src/JsonApiDotNetCore/Internal/TypeHelper.cs +++ b/src/JsonApiDotNetCore/Internal/TypeHelper.cs @@ -143,7 +143,7 @@ public static IList ConvertListType(IEnumerable values, Type type) /// The instance of the parameterized generic type /// Generic type parameters to be used in open type. /// Constructor arguments to be provided in instantiation. - /// Open generic type + /// Open generic type public static object CreateInstanceOfOpenType(Type openType, Type[] parameters, params object[] constructorArguments) { var parameterizedType = openType.MakeGenericType(parameters); @@ -186,7 +186,7 @@ public static object CreateInstanceOfOpenType(Type openType, Type[] parameters, /// The instance of the parameterized generic type /// Generic type parameter to be used in open type. /// Constructor arguments to be provided in instantiation. - /// Open generic type + /// Open generic type public static object CreateInstanceOfOpenType(Type openType, Type parameter, params object[] constructorArguments) { return CreateInstanceOfOpenType(openType, new Type[] { parameter }, constructorArguments); From 2c1a71fac9041d56e061397bde3561664958cbf6 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:43:14 +0100 Subject: [PATCH 09/18] CS1573: Parameter has no matching param tag in the XML comment (but other parameters do) --- .../Extensions/EntityFrameworkCoreExtension.cs | 5 ----- .../Extensions/IServiceCollectionExtensions.cs | 4 ---- src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs | 2 +- src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs | 2 ++ src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs | 4 ++-- src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs | 1 + src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs | 1 + .../Serialization/Common/ResourceObjectBuilderSettings.cs | 1 + .../Serialization/Server/Builders/LinkBuilder.cs | 3 --- .../Serialization/Server/Contracts/ILinkBuilder.cs | 1 - src/JsonApiDotNetCore/Services/DefaultResourceService.cs | 2 -- 11 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs b/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs index f3b5215d2b..f2b731694c 100644 --- a/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs +++ b/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs @@ -67,11 +67,6 @@ public static class IServiceCollectionExtensions /// /// Enabling JsonApiDotNetCore using the EF Core DbContext to build the ResourceGraph. /// - /// - /// - /// - /// - /// public static IServiceCollection AddJsonApi(this IServiceCollection services, Action options = null, Action discovery = null, diff --git a/src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs b/src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs index eb30283428..bcf5b657ca 100644 --- a/src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs +++ b/src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs @@ -21,10 +21,6 @@ public static class IServiceCollectionExtensions /// /// Enabling JsonApiDotNetCore using manual declaration to build the ResourceGraph. /// - /// - /// - /// - /// public static IServiceCollection AddJsonApi(this IServiceCollection services, Action options = null, Action discovery = null, diff --git a/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs b/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs index bb8990d62e..0c712f516f 100644 --- a/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs +++ b/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs @@ -211,7 +211,7 @@ public interface IDeleteHookContainer where TResource : class, IIdent /// /// The unique set of affected entities. /// An enum indicating from where the hook was triggered. - /// If set to true if the deletion was succeeded in the repository layer. + /// If set to true the deletion succeeded in the repository layer. void AfterDelete(HashSet entities, ResourcePipeline pipeline, bool succeeded); } diff --git a/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs b/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs index 06f4dfaeb4..399f98bc69 100644 --- a/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs +++ b/src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs @@ -67,6 +67,7 @@ public interface IDeleteHookExecutor /// An enum indicating from where the hook was triggered. /// The type of the root entities IEnumerable BeforeDelete(IEnumerable entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable; + /// /// Executes the After Cycle by firing the appropriate hooks if they are implemented. /// @@ -75,6 +76,7 @@ public interface IDeleteHookExecutor /// /// Target entities for the Before cycle. /// An enum indicating from where the hook was triggered. + /// If set to true the deletion succeeded. /// The type of the root entities void AfterDelete(IEnumerable entities, ResourcePipeline pipeline, bool succeeded) where TResource : class, IIdentifiable; } diff --git a/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs b/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs index 427dbaf2eb..3d35517b57 100644 --- a/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs +++ b/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using JsonApiDotNetCore.Extensions; @@ -81,8 +81,8 @@ public object GetValue(IIdentifiable entity) /// Internally knows how to do this depending on the type of RelationshipAttribute /// that this RelationshipProxy encapsulates. /// - /// The relationship value. /// Parent entity. + /// The relationship value. public void SetValue(IIdentifiable entity, object value) { if (_isHasManyThrough) diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs index 7a05dd8fe4..15726a31a2 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs @@ -13,6 +13,7 @@ public class HasManyAttribute : RelationshipAttribute /// Which links are available. Defaults to /// Whether or not this relationship can be included using the ?include=public-name query string /// The name of the entity mapped property, defaults to null + /// /// /// /// diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs index 07f9d8668e..cd4043223a 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs @@ -16,6 +16,7 @@ public class HasOneAttribute : RelationshipAttribute /// Whether or not this relationship can be included using the ?include=public-name query string /// The foreign key property name. Defaults to "{RelationshipName}Id" /// The name of the entity mapped property, defaults to null + /// /// /// /// Using an alternative foreign key: diff --git a/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilderSettings.cs b/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilderSettings.cs index 3b910e3e97..e64578e333 100644 --- a/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilderSettings.cs +++ b/src/JsonApiDotNetCore/Serialization/Common/ResourceObjectBuilderSettings.cs @@ -9,6 +9,7 @@ namespace JsonApiDotNetCore.Serialization public class ResourceObjectBuilderSettings { /// Omit null values from attributes + /// Omit default values from attributes public ResourceObjectBuilderSettings(bool omitNullValuedAttributes = false, bool omitDefaultValuedAttributes = false) { OmitNullValuedAttributes = omitNullValuedAttributes; diff --git a/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs index 8fe73a289d..3fe2d329d3 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs @@ -48,7 +48,6 @@ public TopLevelLinks GetTopLevelLinks(ResourceContext primaryResource) /// configuration on the , and if not configured, by checking with the /// global configuration in . /// - /// private bool ShouldAddTopLevelLink(ResourceContext primaryResource, Link link) { if (primaryResource.TopLevelLinks != Link.NotConfigured) @@ -148,7 +147,6 @@ private string GetRelatedRelationshipLink(string parent, string parentId, string /// configuration on the , and if not configured, by checking with the /// global configuration in . /// - /// private bool ShouldAddResourceLink(ResourceContext resourceContext, Link link) { if (resourceContext.ResourceLinks != Link.NotConfigured) @@ -164,7 +162,6 @@ private bool ShouldAddResourceLink(ResourceContext resourceContext, Link link) /// the , and if not configured by checking with the /// global configuration in . /// - /// private bool ShouldAddRelationshipLink(ResourceContext resourceContext, RelationshipAttribute relationship, Link link) { if (relationship.RelationshipLinks != Link.NotConfigured) diff --git a/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs index a4bd87195a..bdb56ff216 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs @@ -17,7 +17,6 @@ public interface ILinkBuilder /// /// Builds the links object for resources in the primary data. /// - /// ResourceLinks GetResourceLinks(string resourceName, string id); /// /// Builds the links object that is included in the values of the . diff --git a/src/JsonApiDotNetCore/Services/DefaultResourceService.cs b/src/JsonApiDotNetCore/Services/DefaultResourceService.cs index e775f0bd2b..95eeb00e72 100644 --- a/src/JsonApiDotNetCore/Services/DefaultResourceService.cs +++ b/src/JsonApiDotNetCore/Services/DefaultResourceService.cs @@ -254,8 +254,6 @@ protected virtual IQueryable ApplyFilter(IQueryable entiti /// /// Applies include queries /// - /// - /// protected virtual IQueryable ApplyInclude(IQueryable entities, IEnumerable chainPrefix = null) { var chains = _includeService.Get(); From a0480f824ad250927e7dcd8f314bbdc2bba12209 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:44:35 +0100 Subject: [PATCH 10/18] Fix CS1723: XML comment has cref attribute that refers to a type parameter --- src/JsonApiDotNetCore/Internal/Query/BaseQueryContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/Internal/Query/BaseQueryContext.cs b/src/JsonApiDotNetCore/Internal/Query/BaseQueryContext.cs index 13a0e68c0e..c35dd64c88 100644 --- a/src/JsonApiDotNetCore/Internal/Query/BaseQueryContext.cs +++ b/src/JsonApiDotNetCore/Internal/Query/BaseQueryContext.cs @@ -3,7 +3,7 @@ namespace JsonApiDotNetCore.Internal.Query { /// - /// A context class that provides extra meta data for a + /// A context class that provides extra meta data for a /// that is used when applying url queries internally. /// public abstract class BaseQueryContext where TQuery : BaseQuery From 7a8494d0dd56d3921cbbbdb6a3a21d934f7846fc Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Mon, 27 Jan 2020 11:45:44 +0100 Subject: [PATCH 11/18] Fix CS1734: XML comment has a paramref tag, but there is no parameter by that name --- .../Serialization/Common/IResourceObjectBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JsonApiDotNetCore/Serialization/Common/IResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Common/IResourceObjectBuilder.cs index 8c314d1ddc..2575a1caf8 100644 --- a/src/JsonApiDotNetCore/Serialization/Common/IResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Common/IResourceObjectBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using JsonApiDotNetCore.Models; namespace JsonApiDotNetCore.Serialization @@ -11,7 +11,7 @@ public interface IResourceObjectBuilder { /// /// Converts into a . - /// Adds the attributes and relationships that are enlisted in and + /// Adds the attributes and relationships that are enlisted in and /// /// Entity to build a Resource Object for /// Attributes to include in the building process @@ -19,4 +19,4 @@ public interface IResourceObjectBuilder /// The resource object that was built ResourceObject Build(IIdentifiable entity, IEnumerable attributes, IEnumerable relationships); } -} \ No newline at end of file +} From e9d477b16bc119f3bc9575ba6ba7866ea3c06bba Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Thu, 30 Jan 2020 14:30:28 +0100 Subject: [PATCH 12/18] Updated fixed package versions with placeholders in project files --- src/JsonApiDotNetCore/JsonApiDotNetCore.csproj | 2 +- test/DiscoveryTests/DiscoveryTests.csproj | 2 +- test/IntegrationTests/IntegrationTests.csproj | 2 +- .../JsonApiDotNetCoreExampleTests.csproj | 4 ++-- test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj | 2 +- test/UnitTests/UnitTests.csproj | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 7fadf92c6f..2c1bb7c25a 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -23,7 +23,7 @@ - + diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index d4458df6dd..1be010a233 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/IntegrationTests/IntegrationTests.csproj b/test/IntegrationTests/IntegrationTests.csproj index 23141edea5..ef508b1d82 100644 --- a/test/IntegrationTests/IntegrationTests.csproj +++ b/test/IntegrationTests/IntegrationTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0 + $(NetCoreAppVersion) false diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index d68923e892..3c7bf2fbd6 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -25,8 +25,8 @@ - - + + diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index a53c1e90ce..a0bfc234d0 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -24,7 +24,7 @@ - + diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index 7374a96ae6..f3bd3ca0c0 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -8,8 +8,8 @@ - - + + From 2ed49bef90f583fe6876fad171a160775b8cedfa Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Thu, 30 Jan 2020 14:40:21 +0100 Subject: [PATCH 13/18] Disabled building benchmarks project in Release mode (was already disabled for Debug) The project type GUID was changed by VS 2019 v16.4.3 automatically. According to https://stackoverflow.com/questions/47312163/dotnet-sln-add-wrong-project-type-guid, this seems like a good thing. --- JsonApiDotnetCore.sln | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/JsonApiDotnetCore.sln b/JsonApiDotnetCore.sln index ad130ce4b1..7283612dcb 100644 --- a/JsonApiDotnetCore.sln +++ b/JsonApiDotnetCore.sln @@ -41,7 +41,7 @@ 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}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "test\IntegrationTests\IntegrationTests.csproj", "{CEB08B86-6BF1-4227-B20F-45AE9C1CC6D9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -103,7 +103,6 @@ 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 From 50ce3caba3bbe692f3a20f826f89dc67c1c344ac Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 5 Feb 2020 15:26:14 +0100 Subject: [PATCH 14/18] Fix for NU5125: The 'licenseUrl' element will be deprecated. --- src/JsonApiDotNetCore/JsonApiDotNetCore.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 2c1bb7c25a..3faf239f51 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -5,12 +5,13 @@ JsonApiDotNetCore JsonApiDotNetCore 8.0 + true jsonapi;dotnet core;emberjs;ember https://github.com/json-api-dotnet/JsonApiDotNetCore - https://github.com/json-api-dotnet/JsonApiDotNetCore/master/LICENSE + MIT false git https://github.com/json-api-dotnet/JsonApiDotNetCore From 019eba5d3d181697b144c49a1738412fa5b4d5aa Mon Sep 17 00:00:00 2001 From: Maurits Moeys Date: Tue, 11 Feb 2020 17:20:52 -0800 Subject: [PATCH 15/18] Update HasManyAttribute.cs --- src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs index b72e8f5af4..a6b33bb12e 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/HasManyAttribute.cs @@ -12,7 +12,7 @@ public class HasManyAttribute : RelationshipAttribute /// The relationship name as exposed by the API /// Which links are available. Defaults to /// Whether or not this relationship can be included using the ?include=public-name query string - /// + /// /// /// /// From ecff246458e2d18510d4cd7d99f94e560d9c9fe4 Mon Sep 17 00:00:00 2001 From: Maurits Moeys Date: Tue, 11 Feb 2020 17:21:40 -0800 Subject: [PATCH 16/18] Update HasOneAttribute.cs --- src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs index 22ee41cec9..183f5b46c3 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs @@ -15,7 +15,7 @@ public class HasOneAttribute : RelationshipAttribute /// or is used. /// Whether or not this relationship can be included using the ?include=public-name query string /// The foreign key property name. Defaults to "{RelationshipName}Id" - /// + /// /// /// Using an alternative foreign key: /// From 82846f4e002a1f8373488de7693f0198fce740d4 Mon Sep 17 00:00:00 2001 From: Maurits Moeys Date: Wed, 12 Feb 2020 11:03:20 -0800 Subject: [PATCH 17/18] docs: add compiler warning instructions --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3c91c6492e..2493d69e7c 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,9 @@ Sometimes the compiled files can be dirty / corrupt from other branches / failed dotnet clean ``` +#### Compiler warnings +The `Release` build configuration is set to fail on warnings. That means when submitting a PR there shouldn't be any compiler warnings because the CI build it set to `Release`. + ## Compatibility A lot of changes were introduced in v4.0.0, the following chart should help you with compatibility issues between .NET Core versions From 16ed34021651ef0d48cf7f140640b0aacc4057d1 Mon Sep 17 00:00:00 2001 From: Maurits Moeys Date: Wed, 12 Feb 2020 11:58:56 -0800 Subject: [PATCH 18/18] docs: spacing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2493d69e7c..a547f360f9 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ dotnet clean #### Compiler warnings The `Release` build configuration is set to fail on warnings. That means when submitting a PR there shouldn't be any compiler warnings because the CI build it set to `Release`. + ## Compatibility A lot of changes were introduced in v4.0.0, the following chart should help you with compatibility issues between .NET Core versions