Skip to content

Commit 88f19ae

Browse files
Bart Koelmanmaurei
andauthored
Code cleanup (#691)
* Fixed: XML comment is not placed on a valid language element * Fixed: Convert to method group * Fixed: Use null propagation * Fixed: Use string interpolation expression * Fixed: Use lambda expression * Fixed: Convert to compound assignment * Fixed: Convert to 'using' declaration * Fixed: Use 'await using' * Fixed: Convert to '?:' expression * Fixed: Merge conditional expression * Fixed: Use object initializer * Fixed: Qualifier is redundant * Fixed: Using directive is not required by the code and can be safely removed * Fixed: Redundant explicit array type specification * Fixed: Type argument specification is redundant * Fixed: Comparison with true is redundant * Fixed: Redundant string interpolation * Fixed: Conditional access qualifier expression is known to be not null * Fixed: Empty object or collection initializer list is redundant * Fixed: Redundant explicit array creation in argument of 'params' parameter * Fixed: Type cast is redundant * Fixed: The parameter {name} has the same default value * Fixed: Empty argument list is redundant * Fixed: Expression is always null * Fixed: Value assigned is not used in any execution path * Fixed: Redundant 'IEnumerable.Cast<T>' call * Fixed: '??' right operand is always null * Fixed: Redundant 'Object.ToString()' call * Fixed: Qualifier 'base.' is redundant * Fixed: The field is always assigned before being used and can be converted to local variable * Fixed: Merge cast with type check * Fixed: Replace with single call to First(..) * Fixed: Replace 'Enumerable.Count()' invocation with collection count property access * Fixed: Use format specifier * Fixed: Field is assigned but its value is never used * Fixed: Field can be made readonly * Fixed: Redundant method override * Fixed: Method is never used * Fixed: Base interface is redundant * Fixed: Field is never used * Fixed: Local variable is never used * Fixed: Method return value is never used * Fixed: Constructor is never used * Fixed: shared instance is never used * Fixed: Parameter is never used * Fixed: Method is never used * Fixed: Initializing field/property by default value is redundant * Fixed: Redundant base constructor call * Fixed: parameter hides outer local variable with the same name * Fixed: Cannot resolve symbol 'dynamic' * Fixed: Possible unintended reference comparison * Fixed: Co-variant array conversion can cause run-time exception on write operation * Fixed: Return value of pure method is not used * Fixed: Auto-property can be made get-only * Fixed: Inconsistent body style: use expression-bodied property * Fixed: Empty statement is redundant * Fixed: Local variable can be declared in inner scope * Fixed: Join declaration and assignment * Fixed: Convert constructor to protected in abstract class * Fixed: Replace with single call to FirstOrDefault/Count * Fixed: Use single deconstruction declaration * Fixed: Removed unused using directives * Fixed a few obvious naming violations * Fixed: Virtual member that is never overridden * Removed DefaultPageSize/RequestedPageSize from IPageService because where the calculated value comes from is an implementation detail and should not be exposed to external code that uses paging. * Fixed: Initializing property by default value is redundant * Reduced accessibility for some non-public types/members * Fixed: missing checkbox in Solution Configuration Manager * Made non-public (and a few public) types sealed * Fixed: Inconsistent modifiers style * Removed reference to xunit from benchmarks project, so that 'dotnet test' does not try to run tests from it * Empty commit to retry cibuild * Update IQueryableExtensions.cs Co-authored-by: Maurits Moeys <maurei@users.noreply.github.com>
1 parent ec5f8d5 commit 88f19ae

File tree

236 files changed

+1000
-1302
lines changed

Some content is hidden

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

236 files changed

+1000
-1302
lines changed

JsonApiDotnetCore.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ 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
111112
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.ActiveCfg = Release|Any CPU
112113
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x64.Build.0 = Release|Any CPU
113114
{DF0FCFB2-CB12-44BA-BBB5-1BE0BCFCD14C}.Release|x86.ActiveCfg = Release|Any CPU

benchmarks/BenchmarkResource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Benchmarks
44
{
5-
public class BenchmarkResource : Identifiable
5+
public sealed class BenchmarkResource : Identifiable
66
{
77
[Attr(BenchmarkResourcePublicNames.NameAttr)]
88
public string Name { get; set; }
@@ -17,7 +17,7 @@ public class SubResource : Identifiable
1717
public string Value { get; set; }
1818
}
1919

20-
public static class BenchmarkResourcePublicNames
20+
internal static class BenchmarkResourcePublicNames
2121
{
2222
public const string NameAttr = "full-name";
2323
public const string Type = "simple-types";

benchmarks/Benchmarks.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<ItemGroup>
77
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
88
<PackageReference Include="moq" Version="$(MoqVersion)" />
9-
<PackageReference Include="xunit" Version="$(xUnitVersion)" />
109
</ItemGroup>
1110
<ItemGroup>
1211
<ProjectReference Include="../src/JsonApiDotNetCore/JsonApiDotNetCore.csproj" />

benchmarks/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace Benchmarks
77
{
8-
class Program
8+
internal class Program
99
{
10-
static void Main(string[] args)
10+
private static void Main(string[] args)
1111
{
1212
var switcher = new BenchmarkSwitcher(new[]
1313
{

src/Examples/GettingStarted/Controllers/ArticlesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace GettingStarted
88
{
9-
public class ArticlesController : JsonApiController<Article>
9+
public sealed class ArticlesController : JsonApiController<Article>
1010
{
1111
public ArticlesController(
1212
IJsonApiOptions jsonApiOptions,

src/Examples/GettingStarted/Controllers/PeopleController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace GettingStarted
88
{
9-
public class PeopleController : JsonApiController<Person>
9+
public sealed class PeopleController : JsonApiController<Person>
1010
{
1111
public PeopleController(
1212
IJsonApiOptions jsonApiOptions,

src/Examples/GettingStarted/Models/Article.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace GettingStarted.Models
44
{
5-
public class Article : Identifiable
5+
public sealed class Article : Identifiable
66
{
77
[Attr]
88
public string Title { get; set; }
99
[HasOne]
1010
public Person Author { get; set; }
1111
public int AuthorId { get; set; }
1212
}
13-
}
13+
}

src/Examples/GettingStarted/Models/Person.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
namespace GettingStarted.Models
55
{
6-
public class Person : Identifiable
6+
public sealed class Person : Identifiable
77
{
88
[Attr]
99
public string Name { get; set; }
1010
[HasMany]
1111
public List<Article> Articles { get; set; }
1212
}
13-
}
13+
}

src/Examples/GettingStarted/ResourceDefinitionExample/Model.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace GettingStarted.ResourceDefinitionExample
44
{
5-
public class Model : Identifiable
5+
public sealed class Model : Identifiable
66
{
77
[Attr]
88
public string DoNotExpose { get; set; }

src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using JsonApiDotNetCore.Internal.Contracts;
32
using JsonApiDotNetCore.Models;
43

0 commit comments

Comments
 (0)