Skip to content

Code quality refresh #1609

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 56 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d1ac6d6
Wrap faker.Generate methods, so that a non-nullable return type is in…
bkoelman Aug 18, 2024
08e1767
Turn off CA1822: Mark members as static
bkoelman Sep 8, 2024
0ba5650
In tests, turn off CA1707: Identifiers should not contain underscores
bkoelman Sep 8, 2024
7a5f8b1
Turn off CA1305: Specify IFormatProvider
bkoelman Sep 8, 2024
b22c7f8
Turn off CA1725: Parameter names should match base declaration
bkoelman Sep 8, 2024
796bbbf
Turn off CA1720: Identifier contains type name
bkoelman Sep 8, 2024
381fcca
Turn off CA1716: Identifiers should not match keywords
bkoelman Sep 8, 2024
e902ff2
Use source-generated structured logging, fixes rules:
bkoelman May 26, 2024
f81ec66
Fix CA1001: Types that own disposable fields should be disposable
bkoelman Sep 8, 2024
bbbec9e
Fix CA1860: Avoid using 'Enumerable.Any()' extension method
bkoelman Sep 8, 2024
6ff25b1
Fix CA1309: Use ordinal string comparison
bkoelman Sep 8, 2024
adeea31
Fix CA1304: Specify CultureInfo
bkoelman Sep 8, 2024
ab1616b
Fix CA1051: Do not declare visible instance fields
bkoelman Sep 8, 2024
8fcb14d
Fix CA1512: Use ArgumentOutOfRangeException throw helper
bkoelman Sep 8, 2024
f693a66
Fix CA1513: Use ObjectDisposedException throw helper
bkoelman Sep 8, 2024
44fc8b0
Suppress violations of CA1829: Use Length/Count property instead of C…
bkoelman Sep 8, 2024
0aa6334
Fix CA1841: Prefer Dictionary.Contains method
bkoelman Sep 8, 2024
b9ebc30
Fix CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' me…
bkoelman Sep 8, 2024
10a9e15
Fix CA2201: Do not raise reserved exception types
bkoelman Sep 8, 2024
978d9ec
Suppress violation of CA1711: Identifiers should not have incorrect s…
bkoelman Sep 8, 2024
6c5e2ff
Fix CA1859: Use concrete types when possible for improved performance
bkoelman Sep 8, 2024
adbd98d
Fix CA1826: Do not use Enumerable methods on indexable collections
bkoelman Sep 9, 2024
98e1faf
Activate and fix CA1033: Interface methods should be callable by chil…
bkoelman Sep 9, 2024
0f71ac4
Activate CA1027: Mark enums with FlagsAttribute
bkoelman Sep 9, 2024
88ad5b4
Activate and fix CA1062: Validate arguments of public methods
bkoelman Sep 15, 2024
ff85a9b
Activate CA1063: Implement IDisposable correctly
bkoelman Sep 15, 2024
2900fcf
Activate CA1064: Exceptions should be public
bkoelman Sep 15, 2024
2069400
Activate CA1065: Do not raise exceptions in unexpected locations
bkoelman Sep 15, 2024
50394d9
Activate CA1066: Implement IEquatable when overriding Equals
bkoelman Sep 15, 2024
221423e
Activate and fix CA1810: Initialize reference type static fields inline
bkoelman Sep 15, 2024
20c9da1
Activate and fix CA1820: Test for empty strings using string length
bkoelman Sep 15, 2024
66fa5b8
Activate and fix CA1849: Call async methods when in an async method
bkoelman Sep 15, 2024
eaf5e74
Activate and fix CA2000: Dispose objects before losing scope
bkoelman Sep 15, 2024
ae46adf
Activate CA2119: Seal methods that satisfy private interfaces
bkoelman Sep 15, 2024
3c25632
Activate CA2207: Initialize value type static fields inline
bkoelman Sep 15, 2024
102af34
Activate CA2217: Do not mark enums with FlagsAttribute
bkoelman Sep 15, 2024
fdc9f82
Order rule IDs
bkoelman Sep 15, 2024
435b998
Fix ASP0015: Suggest using IHeaderDictionary properties
bkoelman Sep 15, 2024
b1d11e2
Fix IDE0079: Remove unnecessary suppression
bkoelman Sep 15, 2024
e8b7160
Optimize RegexOptions
bkoelman Sep 15, 2024
3730a90
Fix IDE0200: Remove unnecessary lambda expression
bkoelman Sep 15, 2024
5bf36a8
Fix IDE0210: Convert to top-level statements
bkoelman Sep 15, 2024
bc53141
Fix IDE0290: Use primary constructor
bkoelman Sep 15, 2024
624bcc5
Fix IDE0041: Use 'is null' check
bkoelman Sep 15, 2024
b2e7953
Fix/suppress IDE0055: Formatting rule
bkoelman Sep 15, 2024
d7c06e3
Fix IDE0280: Use 'nameof'
bkoelman Sep 15, 2024
68d66d1
Fix IDE0078: Use pattern matching
bkoelman Sep 15, 2024
edcfcbf
Suppress IDE0019: Use pattern matching to avoid 'as' followed by a 'n…
bkoelman Sep 15, 2024
d98fc04
Optimize IDE* rules to minimize noise, enable recommended ruleset
bkoelman Sep 15, 2024
0202a8a
Turn off various info-level rules from CSharpGuidelinesAnalyzer
bkoelman Sep 15, 2024
8af76a1
Activate SYSLIB1045: Use GeneratedRegexAttribute to generate the regu…
bkoelman Sep 15, 2024
84608a8
Activate and fix CA1508: Avoid dead conditional code
bkoelman Sep 21, 2024
2cd4190
Review/update ArgumentGuard usages:
bkoelman Sep 21, 2024
37c03ec
Return better error for whitespace relationship name in request URL
bkoelman Sep 21, 2024
2b4ef36
Fix incorrect resource inheritance tests
bkoelman Sep 21, 2024
7061e4c
Use 'is' operator
bkoelman Sep 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
158 changes: 120 additions & 38 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,119 @@ root = true
[*]
indent_style = space
indent_size = 4
tab-width = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{config,csproj,css,js,json,props,ruleset,xslt,html}]
[*.{config,csproj,css,js,json,props,targets,xml,ruleset,xsd,xslt,html,yml,yaml}]
indent_size = 2
tab-width = 2
max_line_length = 160

[*.{cs,cshtml,ascx,aspx}]

[*.{cs}]
#### C#/.NET Coding Conventions ####

# Default severity for IDE* analyzers with category 'Style'
# Note: specific rules below use severity silent, because Resharper code cleanup auto-fixes them.
dotnet_analyzer_diagnostic.category-Style.severity = warning

# 'using' directive preferences
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:suggestion
csharp_using_directive_placement = outside_namespace:silent
# IDE0005: Remove unnecessary import
dotnet_diagnostic.IDE0005.severity = silent

# Namespace declarations
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_namespace_declarations = file_scoped:silent
# IDE0160: Use block-scoped namespace
dotnet_diagnostic.IDE0160.severity = silent
# IDE0161: Use file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent

# this. preferences
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
# IDE0003: Remove this or Me qualification
dotnet_diagnostic.IDE0003.severity = silent
# IDE0009: Add this or Me qualification
dotnet_diagnostic.IDE0009.severity = silent

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# IDE0049: Use language keywords instead of framework type names for type references
dotnet_diagnostic.IDE0049.severity = silent

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion
csharp_style_pattern_local_over_anonymous_function = false:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = silent
csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:silent
# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = silent

# Expression-level preferences
dotnet_style_operator_placement_when_wrapping = end_of_line
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
dotnet_style_prefer_auto_properties = true:silent
# IDE0032: Use auto property
dotnet_diagnostic.IDE0032.severity = silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
# IDE0045: Use conditional expression for assignment
dotnet_diagnostic.IDE0045.severity = silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
# IDE0046: Use conditional expression for return
dotnet_diagnostic.IDE0046.severity = silent
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
# IDE0058: Remove unused expression value
dotnet_diagnostic.IDE0058.severity = silent

# Collection expression preferences (note: partially turned off in Directory.Build.props)
dotnet_style_prefer_collection_expression = when_types_exactly_match

# Parameter preferences
dotnet_code_quality_unused_parameters = non_public:suggestion
dotnet_code_quality_unused_parameters = non_public

# Local functions vs lambdas
csharp_style_prefer_local_over_anonymous_function = false:silent
# IDE0039: Use local function instead of lambda
dotnet_diagnostic.IDE0039.severity = silent

# Expression-bodied members
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = false:suggestion
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_operators = false:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_accessors = true:silent
# IDE0027: Use expression body for accessors
dotnet_diagnostic.IDE0027.severity = silent
csharp_style_expression_bodied_constructors = false:silent
# IDE0021: Use expression body for constructors
dotnet_diagnostic.IDE0021.severity = silent
csharp_style_expression_bodied_indexers = true:silent
# IDE0026: Use expression body for indexers
dotnet_diagnostic.IDE0026.severity = silent
csharp_style_expression_bodied_lambdas = true:silent
# IDE0053: Use expression body for lambdas
dotnet_diagnostic.IDE0053.severity = silent
csharp_style_expression_bodied_local_functions = false:silent
# IDE0061: Use expression body for local functions
dotnet_diagnostic.IDE0061.severity = silent
csharp_style_expression_bodied_methods = false:silent
# IDE0022: Use expression body for methods
dotnet_diagnostic.IDE0022.severity = silent
csharp_style_expression_bodied_operators = false:silent
# IDE0023: Use expression body for conversion operators
dotnet_diagnostic.IDE0023.severity = silent
# IDE0024: Use expression body for operators
dotnet_diagnostic.IDE0024.severity = silent
csharp_style_expression_bodied_properties = true:silent
# IDE0025: Use expression body for properties
dotnet_diagnostic.IDE0025.severity = silent

# Code-block preferences
csharp_prefer_braces = true:suggestion
csharp_prefer_braces = true:silent
# IDE0011: Add braces
dotnet_diagnostic.IDE0011.severity = silent

# Indentation preferences
csharp_indent_case_contents_when_block = false
Expand All @@ -66,19 +125,42 @@ csharp_indent_case_contents_when_block = false
csharp_preserve_single_line_statements = false

# 'var' usage preferences
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = true:none
csharp_style_var_elsewhere = false:none
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = false:silent
# IDE0007: Use var instead of explicit type
dotnet_diagnostic.IDE0007.severity = silent
# IDE0008: Use explicit type instead of var
dotnet_diagnostic.IDE0008.severity = silent

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion

# Expression value is never used
dotnet_diagnostic.IDE0058.severity = none

#### Naming Style ####
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent
# IDE0047: Remove unnecessary parentheses
dotnet_diagnostic.IDE0047.severity = silent
# IDE0048: Add parentheses for clarity
dotnet_diagnostic.IDE0048.severity = silent

# IDE0010: Add missing cases to switch statement
dotnet_diagnostic.IDE0010.severity = silent
# IDE0072: Add missing cases to switch expression
dotnet_diagnostic.IDE0072.severity = silent

# IDE0029: Null check can be simplified
dotnet_diagnostic.IDE0029.severity = silent
# IDE0030: Null check can be simplified
dotnet_diagnostic.IDE0030.severity = silent
# IDE0270: Null check can be simplified
dotnet_diagnostic.IDE0270.severity = silent

# JSON002: Probable JSON string detected
dotnet_diagnostic.JSON002.severity = silent

# CA1062: Validate arguments of public methods
dotnet_code_quality.CA1062.excluded_symbol_names = Accept|DefaultVisit|Visit*|Apply*

#### .NET Naming Style ####

dotnet_diagnostic.IDE1006.severity = warning

Expand Down
48 changes: 35 additions & 13 deletions CodingGuidelines.ruleset
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Coding Guidelines" Description=" " ToolsVersion="16.0">
<RuleSet Name="Coding Guidelines" Description=" " ToolsVersion="17.0">
<Rules AnalyzerId="CSharpGuidelinesAnalyzer" RuleNamespace="CSharpGuidelinesAnalyzer">
<Rule Id="AV1008" Action="Warning" />
<Rule Id="AV1135" Action="None" />
<Rule Id="AV1500" Action="None" />
<Rule Id="AV1505" Action="Warning" />
<Rule Id="AV1506" Action="Warning" />
<Rule Id="AV1507" Action="Warning" />
<Rule Id="AV1008" Action="Warning" />
<Rule Id="AV1130" Action="Warning" />
<Rule Id="AV1135" Action="Info" />
<Rule Id="AV1536" Action="None" />
<Rule Id="AV1537" Action="None" />
<Rule Id="AV1551" Action="Info" />
<Rule Id="AV1555" Action="Warning" />
<Rule Id="AV1564" Action="Info" />
<Rule Id="AV1551" Action="None" />
<Rule Id="AV1564" Action="None" />
<Rule Id="AV1568" Action="Warning" />
<Rule Id="AV1580" Action="None" />
<Rule Id="AV1706" Action="Warning" />
<Rule Id="AV1710" Action="Info" />
<Rule Id="AV1711" Action="Info" />
<Rule Id="AV1704" Action="None" />
<Rule Id="AV1710" Action="None" />
<Rule Id="AV1711" Action="None" />
<Rule Id="AV1738" Action="Warning" />
<Rule Id="AV1739" Action="Warning" />
<Rule Id="AV1745" Action="Warning" />
<Rule Id="AV1755" Action="Warning" />
<Rule Id="AV2210" Action="Warning" />
<Rule Id="AV2220" Action="Warning" />
<Rule Id="AV2230" Action="Info" />
<Rule Id="AV2305" Action="None" />
<Rule Id="AV2310" Action="Info" />
<Rule Id="AV2318" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.NetAnalyzers">
<Rule Id="CA1027" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1062" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1064" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1066" Action="Warning" />
<Rule Id="CA1305" Action="None" />
<Rule Id="CA1716" Action="None" />
<Rule Id="CA1720" Action="None" />
<Rule Id="CA1725" Action="None" />
<Rule Id="CA1810" Action="Warning" />
<Rule Id="CA1820" Action="Warning" />
<Rule Id="CA1822" Action="None" />
<Rule Id="CA1849" Action="Warning" />
<Rule Id="CA2000" Action="Warning" />
<Rule Id="CA2119" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2217" Action="Warning" />
</Rules>
<Rules AnalyzerId="System.Text.RegularExpressions.Generator" RuleNamespace="System.Text.RegularExpressions.Generator">
<Rule Id="SYSLIB1045" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.NetAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.CSharp.NetAnalyzers">
<Rule Id="CA1508" Action="Info" />
</Rules>
</RuleSet>
50 changes: 39 additions & 11 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>Recommended</AnalysisMode>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
<RunSettingsFilePath>$(MSBuildThisFileDirectory)tests.runsettings</RunSettingsFilePath>
<JsonApiDotNetCoreVersionPrefix>5.6.1</JsonApiDotNetCoreVersionPrefix>
</PropertyGroup>

<PropertyGroup>
<!--
Disabled IDE analyzers for "Use collection expression" because they are dangerous in a subtle way.
For example, a suggestion for the following code is raised:
public IList<string> Items { get; } = new List<string>();
Taking the suggestion TODAY produces List<string>, but the spec doesn't require that, so the compiler may change it over time.
As a result, callers that cast back to List<string> will face a breaking change.
-->
<UseCollectionExpressionRules>IDE0028;IDE0300;IDE0301;IDE0302;IDE0303;IDE0304;IDE0305</UseCollectionExpressionRules>
<NoWarn>$(NoWarn);$(UseCollectionExpressionRules)</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<NoWarn>$(NoWarn);AV2210</NoWarn>
</PropertyGroup>
Expand All @@ -13,20 +38,23 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('Tests'))">
<NoWarn>$(NoWarn);CA1707;CA1062</NoWarn>
</PropertyGroup>

<PropertyGroup
Condition="$(MSBuildProjectName.EndsWith('Example')) Or '$(MSBuildProjectName)' == 'TestBuildingBlocks' Or '$(MSBuildProjectName)' == 'Benchmarks'">
<NoWarn>$(NoWarn);CA1062</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<!-- Workaround for https://github.com/dotnet/runtime/issues/72263 -->
<NoWarn>$(NoWarn);SYSLIB1006</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.*" PrivateAssets="All" />
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.*" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
</ItemGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
<RunSettingsFilePath>$(MSBuildThisFileDirectory)tests.runsettings</RunSettingsFilePath>
<JsonApiDotNetCoreVersionPrefix>5.6.1</JsonApiDotNetCoreVersionPrefix>
</PropertyGroup>
</Project>
33 changes: 25 additions & 8 deletions benchmarks/Deserialization/DeserializationBenchmarkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

namespace Benchmarks.Deserialization;

public abstract class DeserializationBenchmarkBase
public abstract class DeserializationBenchmarkBase : IDisposable
{
protected readonly JsonSerializerOptions SerializerReadOptions;
protected readonly DocumentAdapter DocumentAdapter;
private readonly ServiceContainer _serviceProvider = new();

protected JsonSerializerOptions SerializerReadOptions { get; }
protected DocumentAdapter DocumentAdapter { get; }

protected DeserializationBenchmarkBase()
{
Expand All @@ -23,12 +25,11 @@ protected DeserializationBenchmarkBase()
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;

var serviceContainer = new ServiceContainer();
var resourceFactory = new ResourceFactory(serviceContainer);
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, serviceContainer);
var resourceFactory = new ResourceFactory(_serviceProvider);
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, _serviceProvider);

serviceContainer.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);
serviceContainer.AddService(typeof(IResourceDefinition<IncomingResource, int>), new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));
_serviceProvider.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);
_serviceProvider.AddService(typeof(IResourceDefinition<IncomingResource, int>), new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));

// ReSharper disable once VirtualMemberCallInConstructor
JsonApiRequest request = CreateJsonApiRequest(resourceGraph);
Expand All @@ -53,6 +54,22 @@ protected DeserializationBenchmarkBase()

protected abstract JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph);

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

#pragma warning disable CA1063 // Implement IDisposable Correctly
private void Dispose(bool disposing)
#pragma warning restore CA1063 // Implement IDisposable Correctly
{
if (disposing)
{
_serviceProvider.Dispose();
}
}

[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public sealed class IncomingResource : Identifiable<int>
{
Expand Down
Loading
Loading