diff --git a/Directory.Build.props b/Directory.Build.props index 0b51f53d6d..7160a70dc2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,6 +13,11 @@ 4.5.0 + + $(NoWarn);1591 + true + + 16.3.0 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 diff --git a/README.md b/README.md index 3c91c6492e..a547f360f9 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,10 @@ 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 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/Configuration/ILinksConfiguration.cs b/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs index cc782f79ab..7d1c1b38d8 100644 --- a/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs +++ b/src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs @@ -1,3 +1,4 @@ +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/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/Data/DefaultResourceRepository.cs b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs index b1e37885a5..56814db547 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/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/Extensions/EntityFrameworkCoreExtension.cs b/src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs index af9272f48c..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 8a3c19b41e..1b0b6d455d 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/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 2e58f0d3ea..d2a5bf1840 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) { @@ -127,7 +127,7 @@ public static IEnumerable GetDerivedGenericTypes(Assembly assembly, Type o /// Get all derivatives of the specified type. /// /// The assembly to search - /// The inherited type + /// The inherited type /// /// /// GetDerivedGenericTypes(assembly, typeof(DbContext)) diff --git a/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs b/src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs index b47d1e47db..d619eacd58 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/IResourceHookContainer.cs b/src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs index cffc1371c9..0c712f516f 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. @@ -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 6d74313804..399f98bc69 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; @@ -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; } @@ -92,8 +94,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 +168,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/Hooks/ResourceHookExecutor.cs b/src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs index 73c811e7e8..549704d908 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 currentEntitiesGrouped = node.RelationshipsFromPreviousLayer.GetRightEntities(); currentEntitiesGroupedInverse = ReplaceKeysWithInverseRelationships(currentEntitiesGrouped); @@ -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. currentEntitiesGrouped = node.RelationshipsFromPreviousLayer.GetRightEntities(); if (currentEntitiesGrouped.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(currentEntitiesGrouped); - /// 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 = currentEntitiesGrouped.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 currentEntitiesGrouped = 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(currentEntitiesGrouped)); CallHook(container, ResourceHook.AfterUpdateRelationship, new object[] { resourcesByRelationship, pipeline }); } @@ -462,4 +462,3 @@ HashSet GetIds(IEnumerable entities) } } } - diff --git a/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs b/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs index a8c69f4d96..14423e6007 100644 --- a/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs +++ b/src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs @@ -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/Hooks/Traversal/TraversalHelper.cs b/src/JsonApiDotNetCore/Hooks/Traversal/TraversalHelper.cs index 0539226091..13591fd926 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/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 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/Internal/TypeHelper.cs b/src/JsonApiDotNetCore/Internal/TypeHelper.cs index 47b6a8a1cb..ec3954b069 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); @@ -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/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 7fadf92c6f..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 @@ -23,7 +24,7 @@ - + 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 - /// + /// /// /// /// diff --git a/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/HasOneAttribute.cs index dd4c483165..183f5b46c3 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 @@ -14,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: /// diff --git a/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs b/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs index 44a67396e0..00e348f8c0 100644 --- a/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs +++ b/src/JsonApiDotNetCore/Models/Annotation/RelationshipAttribute.cs @@ -60,13 +60,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/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/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 { diff --git a/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs b/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs index b47bfca5c4..21815794f2 100644 --- a/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs @@ -88,9 +88,9 @@ 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); diff --git a/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs b/src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs index 750434b4aa..62cbf096c7 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; @@ -170,14 +172,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/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 +} 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/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/IncludedResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs index 2dd9219a25..5e1608fd3f 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/IncludedResourceObjectBuilder.cs @@ -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/LinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs index 7307d6438e..5d81048988 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs @@ -51,8 +51,6 @@ public TopLevelLinks GetTopLevelLinks() /// configuration on the , and if not configured, by checking with the /// global configuration in . /// - /// - /// private bool ShouldAddTopLevelLink(ResourceContext resourceContext, Link link) { if (resourceContext.TopLevelLinks != Link.NotConfigured) @@ -170,7 +168,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) @@ -186,7 +183,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/Builders/ResponseResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs index 230aed4372..2291610391 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Builders/ResponseResourceObjectBuilder.cs @@ -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/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 diff --git a/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs index 7e3224969e..6a0b59042f 100644 --- a/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Server/Contracts/ILinkBuilder.cs @@ -15,7 +15,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/Serialization/Server/ResponseSerializer.cs b/src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs index dc2ef0264b..4c86f29e2e 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; @@ -119,7 +118,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 +138,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..95eeb00e72 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."); } @@ -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(); 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/Acceptance/Spec/UpdatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs index e3d8b10714..ea9ea6004c 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/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index b95b3dced5..919ccc48ac 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -24,8 +24,8 @@ - - + + diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 12c372c22d..548cb6b048 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -24,7 +24,7 @@ - + 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(); 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 @@ - - + +