Skip to content

Fixed all compiler warnings #675

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2cea812
Fixed all compiler warnings
Jan 24, 2020
1f9d461
Suppress warning-as-error "CS1591: Missing XML comment for publicly v…
Jan 27, 2020
d3af5f6
Fix CS1570: XML comment has badly formed XML
Jan 27, 2020
a9552a0
Fix CS1584: XML comment has syntactically incorrect cref attribute
Jan 27, 2020
68e5e76
Fix CS1587: XML comment is not placed on a valid language element
Jan 27, 2020
ae1f960
Fix CS1574: XML comment has cref attribute that could not be resolved
Jan 27, 2020
fdba1c9
Fix CS1572: XML comment has a param tag, but there is no parameter by…
Jan 27, 2020
c320d43
CS1711: XML comment has a typeparam tag, but there is no type paramet…
Jan 27, 2020
2c1a71f
CS1573: Parameter has no matching param tag in the XML comment (but o…
Jan 27, 2020
a0480f8
Fix CS1723: XML comment has cref attribute that refers to a type para…
Jan 27, 2020
7a8494d
Fix CS1734: XML comment has a paramref tag, but there is no parameter…
Jan 27, 2020
e9d477b
Updated fixed package versions with placeholders in project files
Jan 30, 2020
2ed49be
Disabled building benchmarks project in Release mode (was already dis…
Jan 30, 2020
50ce3ca
Fix for NU5125: The 'licenseUrl' element will be deprecated.
Feb 5, 2020
b404dad
Merge branch 'master' into fix-compile-errors
Feb 11, 2020
32a1cd1
Merge branch 'master' into fix-compile-errors
maurei Feb 12, 2020
019eba5
Update HasManyAttribute.cs
maurei Feb 12, 2020
ecff246
Update HasOneAttribute.cs
maurei Feb 12, 2020
82846f4
docs: add compiler warning instructions
maurei Feb 12, 2020
16ed340
docs: spacing
maurei Feb 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<TuplesVersion>4.5.0</TuplesVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<NoWarn>$(NoWarn);1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<!-- Test Project Dependencies -->
<PropertyGroup>
<TestSdkVersion>16.3.0</TestSdkVersion>
Expand Down
3 changes: 1 addition & 2 deletions JsonApiDotnetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ protected virtual List<AttrAttribute> 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()
Expand Down
3 changes: 2 additions & 1 deletion src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Models.Links;

namespace JsonApiDotNetCore.Configuration
Expand Down Expand Up @@ -68,4 +69,4 @@ public interface ILinksConfiguration
Link RelationshipLinks { get; }

}
}
}
1 change: 0 additions & 1 deletion src/JsonApiDotNetCore/Controllers/JsonApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class JsonApiController<T> : JsonApiController<T, int> where T : class, I
/// Base constructor with int as default
/// </summary>
/// <param name="jsonApiOptions"></param>
/// <param name="resourceGraph"></param>
/// <param name="resourceService"></param>
/// <param name="loggerFactory"></param>
public JsonApiController(
Expand Down
52 changes: 26 additions & 26 deletions src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public virtual async Task<TResource> 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);
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -192,16 +192,16 @@ public virtual async Task<TResource> 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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static async Task<IDbContextTransaction> 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.
/// <summary>
/// </summary>
internal struct SafeTransactionProxy : IDbContextTransaction
{
private readonly bool _shouldExecute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ public static class IServiceCollectionExtensions
/// <summary>
/// Enabling JsonApiDotNetCore using the EF Core DbContext to build the ResourceGraph.
/// </summary>
/// <typeparam name="TContext"></typeparam>
/// <param name="services"></param>
/// <param name="options"></param>
/// <param name="resources"></param>
/// <returns></returns>
public static IServiceCollection AddJsonApi<TDbContext>(this IServiceCollection services,
Action<JsonApiOptions> options = null,
Action<IServiceDiscoveryFacade> discovery = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public static class IServiceCollectionExtensions
/// <summary>
/// Enabling JsonApiDotNetCore using manual declaration to build the ResourceGraph.
/// </summary>
/// <param name="services"></param>
/// <param name="options"></param>
/// <param name="resources"></param>
/// <returns></returns>
public static IServiceCollection AddJsonApi(this IServiceCollection services,
Action<JsonApiOptions> options = null,
Action<IServiceDiscoveryFacade> discovery = null,
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/Formatters/JsonApiReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task<InputFormatterResult> ReadAsync(InputFormatterContext context
}
}

/// <summary> Checks if the deserialized payload has an ID included </summary
/// <summary> Checks if the deserialized payload has an ID included </summary>
private bool CheckForId(object model)
{
if (model == null) return false;
Expand All @@ -84,7 +84,7 @@ private bool CheckForId(object model)
return false;
}

/// <summary> Checks if the elements in the deserialized payload have an ID included </summary
/// <summary> Checks if the elements in the deserialized payload have an ID included </summary>
private bool CheckForId(IList modelList)
{
foreach (var model in modelList)
Expand Down
6 changes: 3 additions & 3 deletions src/JsonApiDotNetCore/Graph/TypeLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public static (Type implementation, Type registrationInterface) GetGenericInterf
/// <param name="openGenericType">The open generic type, e.g. `typeof(ResourceDefinition&lt;&gt;)`</param>
/// <param name="genericArguments">Parameters to the generic type</param>
/// <example>
/// <code>
/// <code><![CDATA[
/// GetDerivedGenericTypes(assembly, typeof(ResourceDefinition<>), typeof(Article))
/// </code>
/// ]]></code>
/// </example>
public static IEnumerable<Type> GetDerivedGenericTypes(Assembly assembly, Type openGenericType, params Type[] genericArguments)
{
Expand All @@ -127,7 +127,7 @@ public static IEnumerable<Type> GetDerivedGenericTypes(Assembly assembly, Type o
/// Get all derivatives of the specified type.
/// </summary>
/// <param name="assembly">The assembly to search</param>
/// <param name="openGenericType">The inherited type</param>
/// <param name="inheritedType">The inherited type</param>
/// <example>
/// <code>
/// GetDerivedGenericTypes(assembly, typeof(DbContext))
Expand Down
12 changes: 6 additions & 6 deletions src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public HookExecutorHelper(IGenericServiceFactory genericProcessorFactory,
/// <inheritdoc/>
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<IResourceHookContainer>(typeof(ResourceDefinition<>), rightType));
_hookContainers[rightType] = container;
}
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<ResourceHook> targetHooks;
if (hook == ResourceHook.None)
{
Expand Down
6 changes: 3 additions & 3 deletions src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;

Expand Down Expand Up @@ -143,7 +143,7 @@ public interface IUpdateHookContainer<TResource> where TResource : class, IIdent
/// <para />
/// If relationships were updated with the updated entities, this will
/// be reflected by the corresponding NavigationProperty being set.
/// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline"/>
/// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline)"/>
/// hook is fired after the execution of this hook.
/// </summary>
/// <param name="entities">The unique set of affected entities.</param>
Expand Down Expand Up @@ -211,7 +211,7 @@ public interface IDeleteHookContainer<TResource> where TResource : class, IIdent
/// </summary>
/// <param name="entities">The unique set of affected entities.</param>
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
/// <param name="succeeded">If set to <c>true</c> if the deletion was succeeded in the repository layer.</param>
/// <param name="succeeded">If set to <c>true</c> the deletion succeeded in the repository layer.</param>
void AfterDelete(HashSet<TResource> entities, ResourcePipeline pipeline, bool succeeded);
}

Expand Down
10 changes: 6 additions & 4 deletions src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;

Expand Down Expand Up @@ -67,6 +67,7 @@ public interface IDeleteHookExecutor
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
/// <typeparam name="TResource">The type of the root entities</typeparam>
IEnumerable<TResource> BeforeDelete<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable;

/// <summary>
/// Executes the After Cycle by firing the appropriate hooks if they are implemented.
/// <para />
Expand All @@ -75,6 +76,7 @@ public interface IDeleteHookExecutor
/// </summary>
/// <param name="entities">Target entities for the Before cycle.</param>
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
/// <param name="succeeded">If set to <c>true</c> the deletion succeeded.</param>
/// <typeparam name="TResource">The type of the root entities</typeparam>
void AfterDelete<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline, bool succeeded) where TResource : class, IIdentifiable;
}
Expand All @@ -92,8 +94,8 @@ public interface IReadHookExecutor
/// entities as well as any related relationship.
/// </summary>
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
/// <param name="stringId">StringId of the requested entity in the case of
/// <see cref="DefaultResourceService{X, Y, Z}.GetAsync(Z)"/>.</param>
/// <param name="stringId">StringId of the requested entity in the case of
/// <see cref="DefaultResourceService{TResource,TId}.GetAsync(TId)"/>.</param>
/// <typeparam name="TResource">The type of the request entity</typeparam>
void BeforeRead<TResource>(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable;
/// <summary>
Expand Down Expand Up @@ -166,4 +168,4 @@ public interface IOnReturnHookExecutor
/// <typeparam name="TResource">The type of the root entities</typeparam>
IEnumerable<TResource> OnReturn<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable;
}
}
}
Loading