Skip to content

Commit 33cf4a6

Browse files
Bart Koelmanmaurei
Bart Koelman
andauthored
Fixed all compiler warnings (#675)
* Fixed all compiler warnings Also corrected Equals implementation and set builds to fail on compiler warnings in release mode. * 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. * Fix CS1570: XML comment has badly formed XML * Fix CS1584: XML comment has syntactically incorrect cref attribute * Fix CS1587: XML comment is not placed on a valid language element * Fix CS1574: XML comment has cref attribute that could not be resolved * Fix CS1572: XML comment has a param tag, but there is no parameter by that name * CS1711: XML comment has a typeparam tag, but there is no type parameter by that name * CS1573: Parameter has no matching param tag in the XML comment (but other parameters do) * Fix CS1723: XML comment has cref attribute that refers to a type parameter * Fix CS1734: XML comment has a paramref tag, but there is no parameter by that name * Updated fixed package versions with placeholders in project files * 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. * Fix for NU5125: The 'licenseUrl' element will be deprecated. * Update HasManyAttribute.cs * Update HasOneAttribute.cs * docs: add compiler warning instructions * docs: spacing Co-authored-by: Maurits Moeys <maurei@users.noreply.github.com>
1 parent 9778788 commit 33cf4a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+187
-169
lines changed

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<TuplesVersion>4.5.0</TuplesVersion>
1414
</PropertyGroup>
1515

16+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
17+
<NoWarn>$(NoWarn);1591</NoWarn>
18+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
19+
</PropertyGroup>
20+
1621
<!-- Test Project Dependencies -->
1722
<PropertyGroup>
1823
<TestSdkVersion>16.3.0</TestSdkVersion>

JsonApiDotnetCore.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ Global
108108
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.ActiveCfg = Debug|Any CPU
109109
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Debug|x86.Build.0 = Debug|Any CPU
110110
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.ActiveCfg = Release|Any CPU
111-
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|Any CPU.Build.0 = Release|Any CPU
112111
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.ActiveCfg = Release|Any CPU
113112
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.Build.0 = Release|Any CPU
114113
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.ActiveCfg = Release|Any CPU

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ Sometimes the compiled files can be dirty / corrupt from other branches / failed
109109
dotnet clean
110110
```
111111

112+
#### Compiler warnings
113+
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`.
114+
115+
112116
## Compatibility
113117

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

src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ protected virtual List<AttrAttribute> GetAttributes(Type entityType)
9191

9292
foreach (var prop in properties)
9393
{
94-
/// todo: investigate why this is added in the exposed attributes list
95-
/// because it is not really defined attribute considered from the json:api
96-
/// spec point of view.
94+
// todo: investigate why this is added in the exposed attributes list
95+
// because it is not really defined attribute considered from the json:api
96+
// spec point of view.
9797
if (prop.Name == nameof(Identifiable.Id))
9898
{
9999
var idAttr = new AttrAttribute()

src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using JsonApiDotNetCore.Models;
12
using JsonApiDotNetCore.Models.Links;
23

34
namespace JsonApiDotNetCore.Configuration
@@ -68,4 +69,4 @@ public interface ILinksConfiguration
6869
Link RelationshipLinks { get; }
6970

7071
}
71-
}
72+
}

src/JsonApiDotNetCore/Controllers/JsonApiController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public class JsonApiController<T> : JsonApiController<T, int> where T : class, I
7474
/// Base constructor with int as default
7575
/// </summary>
7676
/// <param name="jsonApiOptions"></param>
77-
/// <param name="resourceGraph"></param>
7877
/// <param name="resourceService"></param>
7978
/// <param name="loggerFactory"></param>
8079
public JsonApiController(

src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ public virtual async Task<TResource> CreateAsync(TResource entity)
8989
object trackedRelationshipValue = GetTrackedRelationshipValue(relationshipAttr, entity, out bool relationshipWasAlreadyTracked);
9090
LoadInverseRelationships(trackedRelationshipValue, relationshipAttr);
9191
if (relationshipWasAlreadyTracked || relationshipAttr is HasManyThroughAttribute)
92-
/// We only need to reassign the relationship value to the to-be-added
93-
/// entity when we're using a different instance of the relationship (because this different one
94-
/// was already tracked) than the one assigned to the to-be-created entity.
95-
/// Alternatively, even if we don't have to reassign anything because of already tracked
96-
/// entities, we still need to assign the "through" entities in the case of many-to-many.
92+
// We only need to reassign the relationship value to the to-be-added
93+
// entity when we're using a different instance of the relationship (because this different one
94+
// was already tracked) than the one assigned to the to-be-created entity.
95+
// Alternatively, even if we don't have to reassign anything because of already tracked
96+
// entities, we still need to assign the "through" entities in the case of many-to-many.
9797
relationshipAttr.SetValue(entity, trackedRelationshipValue);
9898
}
9999
_dbSet.Add(entity);
@@ -163,18 +163,18 @@ private void DetachRelationships(TResource entity)
163163
{
164164
foreach (IIdentifiable single in collection.ToList())
165165
_context.Entry(single).State = EntityState.Detached;
166-
/// detaching has many relationships is not sufficient to
167-
/// trigger a full reload of relationships: the navigation
168-
/// property actually needs to be nulled out, otherwise
169-
/// EF will still add duplicate instances to the collection
166+
// detaching has many relationships is not sufficient to
167+
// trigger a full reload of relationships: the navigation
168+
// property actually needs to be nulled out, otherwise
169+
// EF will still add duplicate instances to the collection
170170
relationship.SetValue(entity, null);
171171
}
172172
else
173173
{
174174
_context.Entry(value).State = EntityState.Detached;
175175

176-
/// temporary work around for https://github.com/aspnet/EntityFrameworkCore/issues/18621
177-
/// as soon as ef core 3.1 lands we can get rid of this again.
176+
// temporary work around for https://github.com/aspnet/EntityFrameworkCore/issues/18621
177+
// as soon as ef core 3.1 lands we can get rid of this again.
178178
_context.Entry(entity).State = EntityState.Detached;
179179
}
180180
}
@@ -192,16 +192,16 @@ public virtual async Task<TResource> UpdateAsync(TResource updatedEntity)
192192

193193
foreach (var relationshipAttr in _targetedFields.Relationships)
194194
{
195-
/// loads databasePerson.todoItems
195+
// loads databasePerson.todoItems
196196
LoadCurrentRelationships(databaseEntity, relationshipAttr);
197-
/// trackedRelationshipValue is either equal to updatedPerson.todoItems,
198-
/// or replaced with the same set (same ids) of todoItems from the EF Core change tracker,
199-
/// which is the case if they were already tracked
197+
// trackedRelationshipValue is either equal to updatedPerson.todoItems,
198+
// or replaced with the same set (same ids) of todoItems from the EF Core change tracker,
199+
// which is the case if they were already tracked
200200
object trackedRelationshipValue = GetTrackedRelationshipValue(relationshipAttr, updatedEntity, out _);
201-
/// loads into the db context any persons currently related
202-
/// to the todoItems in trackedRelationshipValue
201+
// loads into the db context any persons currently related
202+
// to the todoItems in trackedRelationshipValue
203203
LoadInverseRelationships(trackedRelationshipValue, relationshipAttr);
204-
/// assigns the updated relationship to the database entity
204+
// assigns the updated relationship to the database entity
205205
//AssignRelationshipValue(databaseEntity, trackedRelationshipValue, relationshipAttr);
206206
relationshipAttr.SetValue(databaseEntity, trackedRelationshipValue);
207207
}
@@ -395,17 +395,17 @@ private IIdentifiable AttachOrGetTracked(IIdentifiable relationshipValue)
395395

396396
if (trackedEntity != null)
397397
{
398-
/// there already was an instance of this type and ID tracked
399-
/// by EF Core. Reattaching will produce a conflict, so from now on we
400-
/// will use the already attached instance instead. This entry might
401-
/// contain updated fields as a result of business logic elsewhere in the application
398+
// there already was an instance of this type and ID tracked
399+
// by EF Core. Reattaching will produce a conflict, so from now on we
400+
// will use the already attached instance instead. This entry might
401+
// contain updated fields as a result of business logic elsewhere in the application
402402
return trackedEntity;
403403
}
404404

405-
/// the relationship pointer is new to EF Core, but we are sure
406-
/// it exists in the database, so we attach it. In this case, as per
407-
/// the json:api spec, we can also safely assume that no fields of
408-
/// this entity were updated.
405+
// the relationship pointer is new to EF Core, but we are sure
406+
// it exists in the database, so we attach it. In this case, as per
407+
// the json:api spec, we can also safely assume that no fields of
408+
// this entity were updated.
409409
_context.Entry(relationshipValue).State = EntityState.Unchanged;
410410
return null;
411411
}

src/JsonApiDotNetCore/Extensions/DbContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static async Task<IDbContextTransaction> GetCurrentOrCreateTransactionAsy
7575
/// If a transaction already exists, commit, rollback and dispose
7676
/// will not be called. It is assumed the creator of the original
7777
/// transaction should be responsible for disposal.
78-
/// <summary>
78+
/// </summary>
7979
internal struct SafeTransactionProxy : IDbContextTransaction
8080
{
8181
private readonly bool _shouldExecute;

src/JsonApiDotNetCore/Extensions/EntityFrameworkCoreExtension.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ public static class IServiceCollectionExtensions
6767
/// <summary>
6868
/// Enabling JsonApiDotNetCore using the EF Core DbContext to build the ResourceGraph.
6969
/// </summary>
70-
/// <typeparam name="TContext"></typeparam>
71-
/// <param name="services"></param>
72-
/// <param name="options"></param>
73-
/// <param name="resources"></param>
74-
/// <returns></returns>
7570
public static IServiceCollection AddJsonApi<TDbContext>(this IServiceCollection services,
7671
Action<JsonApiOptions> options = null,
7772
Action<IServiceDiscoveryFacade> discovery = null,

src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public static class IServiceCollectionExtensions
2121
/// <summary>
2222
/// Enabling JsonApiDotNetCore using manual declaration to build the ResourceGraph.
2323
/// </summary>
24-
/// <param name="services"></param>
25-
/// <param name="options"></param>
26-
/// <param name="resources"></param>
27-
/// <returns></returns>
2824
public static IServiceCollection AddJsonApi(this IServiceCollection services,
2925
Action<JsonApiOptions> options = null,
3026
Action<IServiceDiscoveryFacade> discovery = null,

src/JsonApiDotNetCore/Formatters/JsonApiReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task<InputFormatterResult> ReadAsync(InputFormatterContext context
6969
}
7070
}
7171

72-
/// <summary> Checks if the deserialized payload has an ID included </summary
72+
/// <summary> Checks if the deserialized payload has an ID included </summary>
7373
private bool CheckForId(object model)
7474
{
7575
if (model == null) return false;
@@ -84,7 +84,7 @@ private bool CheckForId(object model)
8484
return false;
8585
}
8686

87-
/// <summary> Checks if the elements in the deserialized payload have an ID included </summary
87+
/// <summary> Checks if the elements in the deserialized payload have an ID included </summary>
8888
private bool CheckForId(IList modelList)
8989
{
9090
foreach (var model in modelList)

src/JsonApiDotNetCore/Graph/TypeLocator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public static (Type implementation, Type registrationInterface) GetGenericInterf
113113
/// <param name="openGenericType">The open generic type, e.g. `typeof(ResourceDefinition&lt;&gt;)`</param>
114114
/// <param name="genericArguments">Parameters to the generic type</param>
115115
/// <example>
116-
/// <code>
116+
/// <code><![CDATA[
117117
/// GetDerivedGenericTypes(assembly, typeof(ResourceDefinition<>), typeof(Article))
118-
/// </code>
118+
/// ]]></code>
119119
/// </example>
120120
public static IEnumerable<Type> GetDerivedGenericTypes(Assembly assembly, Type openGenericType, params Type[] genericArguments)
121121
{
@@ -127,7 +127,7 @@ public static IEnumerable<Type> GetDerivedGenericTypes(Assembly assembly, Type o
127127
/// Get all derivatives of the specified type.
128128
/// </summary>
129129
/// <param name="assembly">The assembly to search</param>
130-
/// <param name="openGenericType">The inherited type</param>
130+
/// <param name="inheritedType">The inherited type</param>
131131
/// <example>
132132
/// <code>
133133
/// GetDerivedGenericTypes(assembly, typeof(DbContext))

src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ public HookExecutorHelper(IGenericServiceFactory genericProcessorFactory,
3737
/// <inheritdoc/>
3838
public IResourceHookContainer GetResourceHookContainer(RightType rightType, ResourceHook hook = ResourceHook.None)
3939
{
40-
/// checking the cache if we have a reference for the requested container,
41-
/// regardless of the hook we will use it for. If the value is null,
42-
/// it means there was no implementation IResourceHookContainer at all,
43-
/// so we need not even bother.
40+
// checking the cache if we have a reference for the requested container,
41+
// regardless of the hook we will use it for. If the value is null,
42+
// it means there was no implementation IResourceHookContainer at all,
43+
// so we need not even bother.
4444
if (!_hookContainers.TryGetValue(rightType, out IResourceHookContainer container))
4545
{
4646
container = (_genericProcessorFactory.Get<IResourceHookContainer>(typeof(ResourceDefinition<>), rightType));
4747
_hookContainers[rightType] = container;
4848
}
4949
if (container == null) return container;
5050

51-
/// if there was a container, first check if it implements the hook we
52-
/// want to use it for.
51+
// if there was a container, first check if it implements the hook we
52+
// want to use it for.
5353
List<ResourceHook> targetHooks;
5454
if (hook == ResourceHook.None)
5555
{

src/JsonApiDotNetCore/Hooks/IResourceHookContainer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using JsonApiDotNetCore.Models;
33
using JsonApiDotNetCore.Services;
44

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

src/JsonApiDotNetCore/Hooks/IResourceHookExecutor.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using JsonApiDotNetCore.Models;
33
using JsonApiDotNetCore.Services;
44

@@ -67,6 +67,7 @@ public interface IDeleteHookExecutor
6767
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
6868
/// <typeparam name="TResource">The type of the root entities</typeparam>
6969
IEnumerable<TResource> BeforeDelete<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable;
70+
7071
/// <summary>
7172
/// Executes the After Cycle by firing the appropriate hooks if they are implemented.
7273
/// <para />
@@ -75,6 +76,7 @@ public interface IDeleteHookExecutor
7576
/// </summary>
7677
/// <param name="entities">Target entities for the Before cycle.</param>
7778
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
79+
/// <param name="succeeded">If set to <c>true</c> the deletion succeeded.</param>
7880
/// <typeparam name="TResource">The type of the root entities</typeparam>
7981
void AfterDelete<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline, bool succeeded) where TResource : class, IIdentifiable;
8082
}
@@ -92,8 +94,8 @@ public interface IReadHookExecutor
9294
/// entities as well as any related relationship.
9395
/// </summary>
9496
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
95-
/// <param name="stringId">StringId of the requested entity in the case of
96-
/// <see cref="DefaultResourceService{X, Y, Z}.GetAsync(Z)"/>.</param>
97+
/// <param name="stringId">StringId of the requested entity in the case of
98+
/// <see cref="DefaultResourceService{TResource,TId}.GetAsync(TId)"/>.</param>
9799
/// <typeparam name="TResource">The type of the request entity</typeparam>
98100
void BeforeRead<TResource>(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable;
99101
/// <summary>
@@ -166,4 +168,4 @@ public interface IOnReturnHookExecutor
166168
/// <typeparam name="TResource">The type of the root entities</typeparam>
167169
IEnumerable<TResource> OnReturn<TResource>(IEnumerable<TResource> entities, ResourcePipeline pipeline) where TResource : class, IIdentifiable;
168170
}
169-
}
171+
}

0 commit comments

Comments
 (0)