From 2c6a1e71c2dba8efee3b1bd19681a17d7b6e1938 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 6 Apr 2022 22:04:38 +0200
Subject: [PATCH 1/2] Update package version and reference lib from cibuild
---
Directory.Build.props | 2 +-
src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 2075a3d..474010d 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
6.0.*
5.0.1
2.15.0
- 5.0.1
+ 5.0.2
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
9999
enable
diff --git a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
index 2cc225f..eaf7eb5 100644
--- a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
+++ b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
@@ -32,7 +32,7 @@
-
+
From 1fddd2eade024ef04427ac28e6eb9fcdf0c5bfe6 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 9 Nov 2022 10:47:57 +0100
Subject: [PATCH 2/2] Update to JADNC v5.1 (#16)
---
.config/dotnet-tools.json | 6 +-
.editorconfig | 62 ++++++++--------
.gitignore | 72 ++++++++++++++++---
.../.idea/.gitignore | 1 +
.../.idea/codeStyles/Project.xml | 20 ++++++
.../.idea/codeStyles/codeStyleConfig.xml | 5 ++
Build.ps1 | 27 ++++---
Directory.Build.props | 12 ++--
JsonApiDotNetCore.MongoDb.sln | 9 +++
JsonApiDotNetCore.MongoDb.sln.DotSettings | 23 ++++--
WarningSeverities.DotSettings | 1 -
appveyor.yml | 7 +-
cleanupcode.ps1 | 43 ++++++++---
src/Examples/GettingStarted/README.md | 4 +-
.../ArgumentGuard.cs | 9 ++-
.../AtomicOperations/MongoTransaction.cs | 2 +-
.../MongoTransactionFactory.cs | 2 +-
.../JsonApiDotNetCore.MongoDb.csproj | 2 +-
.../HideRelationshipsSparseFieldSetCache.cs | 4 +-
.../Repositories/MongoDataAccess.cs | 2 +-
.../Repositories/MongoModel.cs | 2 +-
.../MongoQueryExpressionValidator.cs | 2 +-
.../Repositories/MongoRepository.cs | 26 +++----
.../IntegrationTests/QueryStrings/BlogPost.cs | 2 +-
test/TestBuildingBlocks/IntegrationTest.cs | 3 +-
.../TestBuildingBlocks.csproj | 6 +-
26 files changed, 249 insertions(+), 105 deletions(-)
create mode 100644 .idea/.idea.JsonApiDotNetCore.MongoDb/.idea/.gitignore
create mode 100644 .idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/Project.xml
create mode 100644 .idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/codeStyleConfig.xml
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 1209106..d914fc3 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
- "version": "2021.3.4",
+ "version": "2022.2.3",
"commands": [
"jb"
]
},
"regitlint": {
- "version": "6.0.8",
+ "version": "6.1.1",
"commands": [
"regitlint"
]
@@ -21,7 +21,7 @@
]
},
"dotnet-reportgenerator-globaltool": {
- "version": "5.1.4",
+ "version": "5.1.3",
"commands": [
"reportgenerator"
]
diff --git a/.editorconfig b/.editorconfig
index b6d9a89..ca191cf 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -6,17 +6,20 @@ indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
-end_of_line = lf
insert_final_newline = true
-[*.{csproj,json}]
+[*.{config,csproj,css,js,json,props,ruleset,xslt}]
indent_size = 2
[*.{cs}]
-#### .NET Coding Conventions ####
+#### C#/.NET Coding Conventions ####
-# Organize usings
+# 'using' directive preferences
dotnet_sort_system_directives_first = true
+csharp_using_directive_placement = outside_namespace:suggestion
+
+# Namespace declarations
+csharp_style_namespace_declarations = file_scoped:suggestion
# this. preferences
dotnet_style_qualification_for_field = false:suggestion
@@ -30,6 +33,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
# 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
# Expression-level preferences
@@ -37,6 +41,7 @@ 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
# Parameter preferences
dotnet_code_quality_unused_parameters = non_public:suggestion
@@ -54,38 +59,38 @@ csharp_style_expression_bodied_properties = true:suggestion
# Code-block preferences
csharp_prefer_braces = true:suggestion
-# Expression-level preferences
-csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
-
-# 'using' directive preferences
-csharp_using_directive_placement = outside_namespace:suggestion
-
-
-#### C# Formatting Rules ####
-
# Indentation preferences
csharp_indent_case_contents_when_block = false
# Wrapping preferences
csharp_preserve_single_line_statements = false
+# 'var' usage preferences
+csharp_style_var_for_built_in_types = false:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = false:suggestion
+
+# 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
-#### Naming styles ####
+#### Naming Style ####
dotnet_diagnostic.IDE1006.severity = warning
# Naming rules
-dotnet_naming_rule.private_const_fields_should_be_pascal_case.symbols = private_const_fields
-dotnet_naming_rule.private_const_fields_should_be_pascal_case.style = pascal_case
-dotnet_naming_rule.private_const_fields_should_be_pascal_case.severity = warning
+dotnet_naming_rule.const_fields_should_be_pascal_case.symbols = const_fields
+dotnet_naming_rule.const_fields_should_be_pascal_case.style = pascal_case
+dotnet_naming_rule.const_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.private_static_readonly_fields_should_be_pascal_case.symbols = private_static_readonly_fields
dotnet_naming_rule.private_static_readonly_fields_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.private_static_readonly_fields_should_be_pascal_case.severity = warning
-dotnet_naming_rule.private_static_or_readonly_fields_should_start_with_underscore.symbols = private_static_or_readonly_fields
-dotnet_naming_rule.private_static_or_readonly_fields_should_start_with_underscore.style = camel_case_prefix_with_underscore
-dotnet_naming_rule.private_static_or_readonly_fields_should_start_with_underscore.severity = warning
+dotnet_naming_rule.private_fields_should_start_with_underscore.symbols = private_fields
+dotnet_naming_rule.private_fields_should_start_with_underscore.style = camel_case_prefix_with_underscore
+dotnet_naming_rule.private_fields_should_start_with_underscore.severity = warning
dotnet_naming_rule.locals_and_parameters_should_be_camel_case.symbols = locals_and_parameters
dotnet_naming_rule.locals_and_parameters_should_be_camel_case.style = camel_case
@@ -96,25 +101,24 @@ dotnet_naming_rule.types_and_members_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.types_and_members_should_be_pascal_case.severity = warning
# Symbol specifications
-dotnet_naming_symbols.private_const_fields.applicable_kinds = field
-dotnet_naming_symbols.private_const_fields.applicable_accessibilities = private
-dotnet_naming_symbols.private_const_fields.required_modifiers = const
+dotnet_naming_symbols.const_fields.applicable_kinds = field
+dotnet_naming_symbols.const_fields.applicable_accessibilities = *
+dotnet_naming_symbols.const_fields.required_modifiers = const
dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private
-dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static,readonly
+dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static, readonly
-dotnet_naming_symbols.private_static_or_readonly_fields.applicable_kinds = field
-dotnet_naming_symbols.private_static_or_readonly_fields.applicable_accessibilities = private
-dotnet_naming_symbols.private_static_or_readonly_fields.required_modifiers = static readonly
+dotnet_naming_symbols.private_fields.applicable_kinds = field
+dotnet_naming_symbols.private_fields.applicable_accessibilities = private
-dotnet_naming_symbols.locals_and_parameters.applicable_kinds = local,parameter
+dotnet_naming_symbols.locals_and_parameters.applicable_kinds = local, parameter
dotnet_naming_symbols.locals_and_parameters.applicable_accessibilities = *
dotnet_naming_symbols.types_and_members.applicable_kinds = *
dotnet_naming_symbols.types_and_members.applicable_accessibilities = *
-# Naming styles
+# Style specifications
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.camel_case_prefix_with_underscore.required_prefix = _
diff --git a/.gitignore b/.gitignore
index 2bd200a..85bd0f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
@@ -90,6 +90,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
+*.tlog
*.vspscc
*.vssscc
.builds
@@ -97,9 +98,6 @@ StyleCopReport.xml
*.svclog
*.scc
-# MacOS file systems
-**/.DS_STORE
-
# Chutzpah Test files
_Chutzpah*
@@ -134,9 +132,6 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
-# JetBrains Rider
-.idea/
-
# TeamCity is a build add-in
_TeamCity*
@@ -148,7 +143,9 @@ _TeamCity*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
-coverage*[.json, .xml, .info]
+coverage*.json
+coverage*.xml
+coverage*.info
# Visual Studio code coverage results
*.coverage
@@ -297,6 +294,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -353,6 +361,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
+# Visual Studio History (VSHistory) files
+.vshistory/
+
# BeatPulse healthcheck temp database
healthchecksdb
@@ -365,5 +376,50 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+
+#############################################
+### Additions specific to this repository ###
+#############################################
+
+# MacOS file systems
+**/.DS_STORE
+
# Sqlite example databases
*.db
+
+# JetBrains IDEs Rider/IntelliJ (based on https://intellij-support.jetbrains.com/hc/en-us/articles/206544839)
+**/.idea/**/*.xml
+**/.idea/**/*.iml
+**/.idea/**/*.ids
+**/.idea/**/*.ipr
+**/.idea/**/*.iws
+**/.idea/**/*.name
+**/.idea/**/*.properties
+**/.idea/**/*.ser
+**/.idea/**/shelf/
+**/.idea/**/dictionaries/
+**/.idea/**/libraries/
+**/.idea/**/artifacts/
+**/.idea/**/httpRequests/
+**/.idea/**/dataSources/
+!**/.idea/**/codeStyles/*
diff --git a/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/.gitignore b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/.gitignore
new file mode 100644
index 0000000..3933e94
--- /dev/null
+++ b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/.gitignore
@@ -0,0 +1 @@
+# Empty .gitignore file to prevent Rider from adding one
diff --git a/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/Project.xml b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..902b9f8
--- /dev/null
+++ b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/Project.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/codeStyleConfig.xml b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..405cd65
--- /dev/null
+++ b/.idea/.idea.JsonApiDotNetCore.MongoDb/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/Build.ps1 b/Build.ps1
index e973ea3..ce11718 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -8,8 +8,7 @@ function CheckLastExitCode {
function RunInspectCode {
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
- # passing --build instead of --no-build as workaround for https://youtrack.jetbrains.com/issue/RSRP-487054
- dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
+ dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
CheckLastExitCode
[xml]$xml = Get-Content "$outputPath"
@@ -40,16 +39,21 @@ function RunCleanupCode {
# When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes.
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
- Write-Output "Running code cleanup on changed files in pull request"
-
# In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued.
# When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error.
- # To prevent failing the build for unobvious reasons we use HEAD, which is always the latest version.
- $mergeCommitHash = git rev-parse "HEAD"
- $targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
+ # To prevent failing the build for unobvious reasons we use HEAD, which is always a detached head (the PR merge result).
+
+ $headCommitHash = git rev-parse HEAD
+ CheckLastExitCode
- dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --disable-jb-path-hack --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
+ $baseCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
CheckLastExitCode
+
+ if ($baseCommitHash -ne $headCommitHash) {
+ Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
+ dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
+ CheckLastExitCode
+ }
}
}
@@ -100,8 +104,11 @@ CheckLastExitCode
dotnet build -c Release
CheckLastExitCode
-RunInspectCode
-RunCleanupCode
+# https://youtrack.jetbrains.com/issue/RSRP-488628/Breaking-InspectCode-fails-with-Roslyn-Worker-process-exited-unexpectedly-after-update
+if ($IsWindows) {
+ RunInspectCode
+ RunCleanupCode
+}
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
CheckLastExitCode
diff --git a/Directory.Build.props b/Directory.Build.props
index 474010d..6915131 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,9 +2,9 @@
net6.0
6.0.*
- 5.0.1
+ 5.1.0
2.15.0
- 5.0.2
+ 5.1.0
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
9999
enable
@@ -14,8 +14,8 @@
-
-
+
+
@@ -31,8 +31,8 @@
- 3.1.2
+ 3.2.0
4.16.1
- 17.1.0
+ 17.4.0
diff --git a/JsonApiDotNetCore.MongoDb.sln b/JsonApiDotNetCore.MongoDb.sln
index 9514464..0f6c7b7 100644
--- a/JsonApiDotNetCore.MongoDb.sln
+++ b/JsonApiDotNetCore.MongoDb.sln
@@ -19,6 +19,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreMongoDbTes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestBuildingBlocks", "test\TestBuildingBlocks\TestBuildingBlocks.csproj", "{6A0AC606-F11E-4090-B12A-C547BD17EE56}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0D224872-1BD0-4ACA-8788-2407B0FD04F0}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ .gitignore = .gitignore
+ CodingGuidelines.ruleset = CodingGuidelines.ruleset
+ CSharpGuidelinesAnalyzer.config = CSharpGuidelinesAnalyzer.config
+ Directory.Build.props = Directory.Build.props
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/JsonApiDotNetCore.MongoDb.sln.DotSettings b/JsonApiDotNetCore.MongoDb.sln.DotSettings
index a3f03e1..8e80299 100644
--- a/JsonApiDotNetCore.MongoDb.sln.DotSettings
+++ b/JsonApiDotNetCore.MongoDb.sln.DotSettings
@@ -3,7 +3,7 @@
// $EXPR$ -- source expression
// $NAME$ -- source name (string literal or 'nameof' expression)
// $MESSAGE$ -- string literal in the form of "$NAME$ != null"
-JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($EXPR$, $NAME$);
+JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($EXPR$);
199
5000
99
@@ -54,6 +54,8 @@ JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($EXPR$, $NAME$);
WARNING
WARNING
WARNING
+ HINT
+ WARNING
DO_NOT_SHOW
HINT
SUGGESTION
@@ -598,12 +600,12 @@ JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($EXPR$, $NAME$);
CSHARP
False
Replace argument null check with Guard clause
- JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($argument$, nameof($argument$));
+ JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($argument$);
$left$ = $right$;
$left$ = $right$ ?? throw new ArgumentNullException(nameof($argument$));
WARNING
True
- Replace classic argument null check with Guard clause
+ Replace argument == null check with Guard clause
True
True
False
@@ -613,7 +615,7 @@ $left$ = $right$;
CSHARP
False
Replace argument null check with Guard clause
- JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($argument$, nameof($argument$));
+ JsonApiDotNetCore.MongoDb.ArgumentGuard.NotNull($argument$);
if ($argument$ == null) throw new ArgumentNullException(nameof($argument$));
WARNING
True
@@ -629,6 +631,19 @@ $left$ = $right$;
$collection$.IsNullOrEmpty()
$collection$ == null || !$collection$.Any()
WARNING
+ True
+ Replace argument is null check with Guard clause
+ True
+ True
+ False
+
+ IdentifierPlaceholder
+ True
+ CSHARP
+ False
+ JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
+ if ($argument$ is null) throw new ArgumentNullException(nameof($argument$));
+ WARNING
True
True
True
diff --git a/WarningSeverities.DotSettings b/WarningSeverities.DotSettings
index f4a9ae3..0d4eeba 100644
--- a/WarningSeverities.DotSettings
+++ b/WarningSeverities.DotSettings
@@ -87,7 +87,6 @@
WARNING
WARNING
WARNING
- WARNING
WARNING
WARNING
WARNING
diff --git a/appveyor.yml b/appveyor.yml
index 77e6b8d..2593740 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -45,7 +45,10 @@ for:
appveyor_repo_tag: true
build_script:
-- pwsh: dotnet --version
-- pwsh: .\Build.ps1
+- pwsh: |
+ Write-Output ".NET version:"
+ dotnet --version
+
+ .\Build.ps1
test: off
\ No newline at end of file
diff --git a/cleanupcode.ps1 b/cleanupcode.ps1
index 2d9cdca..717f369 100644
--- a/cleanupcode.ps1
+++ b/cleanupcode.ps1
@@ -1,17 +1,44 @@
#Requires -Version 7.0
-# This script reformats the entire codebase to make it compliant with our coding guidelines.
+# This script reformats (part of) the codebase to make it compliant with our coding guidelines.
-dotnet tool restore
+param(
+ # Git branch name or base commit hash to reformat only the subset of changed files. Omit for all files.
+ [string] $revision
+)
-if ($LASTEXITCODE -ne 0) {
- throw "Tool restore failed with exit code $LASTEXITCODE"
+function VerifySuccessExitCode {
+ if ($LastExitCode -ne 0) {
+ throw "Command failed with exit code $LastExitCode."
+ }
}
+dotnet tool restore
+VerifySuccessExitCode
+
dotnet restore
+VerifySuccessExitCode
-if ($LASTEXITCODE -ne 0) {
- throw "Package restore failed with exit code $LASTEXITCODE"
-}
+if ($revision) {
+ $headCommitHash = git rev-parse HEAD
+ VerifySuccessExitCode
-dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --disable-jb-path-hack --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN
+ $baseCommitHash = git rev-parse $revision
+ VerifySuccessExitCode
+
+ if ($baseCommitHash -eq $headCommitHash) {
+ Write-Output "Running code cleanup on staged/unstaged files."
+ dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified
+ VerifySuccessExitCode
+ }
+ else {
+ Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files."
+ dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
+ VerifySuccessExitCode
+ }
+}
+else {
+ Write-Output "Running code cleanup on all files."
+ dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN
+ VerifySuccessExitCode
+}
diff --git a/src/Examples/GettingStarted/README.md b/src/Examples/GettingStarted/README.md
index 571311c..aa8afe0 100644
--- a/src/Examples/GettingStarted/README.md
+++ b/src/Examples/GettingStarted/README.md
@@ -5,9 +5,9 @@
`dotnet run` to run the project
You can verify the project is running by checking this endpoint:
-`localhost:14141/api/people`
+`localhost:24141/api/people`
-For further documentation and implementation of a JsonApiDotnetCore Application see the documentation or GitHub page:
+For further documentation and implementation of a JsonApiDotNetCore Application see the documentation or GitHub page:
Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore
diff --git a/src/JsonApiDotNetCore.MongoDb/ArgumentGuard.cs b/src/JsonApiDotNetCore.MongoDb/ArgumentGuard.cs
index 20ca622..c7c9908 100644
--- a/src/JsonApiDotNetCore.MongoDb/ArgumentGuard.cs
+++ b/src/JsonApiDotNetCore.MongoDb/ArgumentGuard.cs
@@ -1,19 +1,18 @@
+using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
#pragma warning disable AV1008 // Class should not be static
+#pragma warning disable AV1553 // Do not use optional parameters with default value null for strings, collections or tasks
namespace JsonApiDotNetCore.MongoDb;
internal static class ArgumentGuard
{
[AssertionMethod]
- public static void NotNull([NoEnumeration] [SysNotNull] T? value, [InvokerParameterName] string name)
+ public static void NotNull([NoEnumeration] [SysNotNull] T? value, [CallerArgumentExpression("value")] string? parameterName = null)
where T : class
{
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
+ ArgumentNullException.ThrowIfNull(value, parameterName);
}
}
diff --git a/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransaction.cs b/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransaction.cs
index d2e5a36..7aa1388 100644
--- a/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransaction.cs
+++ b/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransaction.cs
@@ -16,7 +16,7 @@ public sealed class MongoTransaction : IOperationsTransaction
public MongoTransaction(IMongoDataAccess mongoDataAccess, bool ownsTransaction)
{
- ArgumentGuard.NotNull(mongoDataAccess, nameof(mongoDataAccess));
+ ArgumentGuard.NotNull(mongoDataAccess);
_mongoDataAccess = mongoDataAccess;
_ownsTransaction = ownsTransaction;
diff --git a/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransactionFactory.cs b/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransactionFactory.cs
index ba3f9a9..b51e1a1 100644
--- a/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransactionFactory.cs
+++ b/src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransactionFactory.cs
@@ -12,7 +12,7 @@ public sealed class MongoTransactionFactory : IOperationsTransactionFactory
public MongoTransactionFactory(IMongoDataAccess mongoDataAccess)
{
- ArgumentGuard.NotNull(mongoDataAccess, nameof(mongoDataAccess));
+ ArgumentGuard.NotNull(mongoDataAccess);
_mongoDataAccess = mongoDataAccess;
}
diff --git a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
index eaf7eb5..2cc225f 100644
--- a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
+++ b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj
@@ -32,7 +32,7 @@
-
+
diff --git a/src/JsonApiDotNetCore.MongoDb/Queries/Internal/HideRelationshipsSparseFieldSetCache.cs b/src/JsonApiDotNetCore.MongoDb/Queries/Internal/HideRelationshipsSparseFieldSetCache.cs
index be71664..fcd9d8a 100644
--- a/src/JsonApiDotNetCore.MongoDb/Queries/Internal/HideRelationshipsSparseFieldSetCache.cs
+++ b/src/JsonApiDotNetCore.MongoDb/Queries/Internal/HideRelationshipsSparseFieldSetCache.cs
@@ -16,8 +16,8 @@ public sealed class HideRelationshipsSparseFieldSetCache : ISparseFieldSetCache
public HideRelationshipsSparseFieldSetCache(IEnumerable constraintProviders,
IResourceDefinitionAccessor resourceDefinitionAccessor)
{
- ArgumentGuard.NotNull(constraintProviders, nameof(constraintProviders));
- ArgumentGuard.NotNull(resourceDefinitionAccessor, nameof(resourceDefinitionAccessor));
+ ArgumentGuard.NotNull(constraintProviders);
+ ArgumentGuard.NotNull(resourceDefinitionAccessor);
_innerCache = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
}
diff --git a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoDataAccess.cs b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoDataAccess.cs
index 6c449b6..fcbff6d 100644
--- a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoDataAccess.cs
+++ b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoDataAccess.cs
@@ -16,7 +16,7 @@ public sealed class MongoDataAccess : IMongoDataAccess
public MongoDataAccess(IMongoDatabase mongoDatabase)
{
- ArgumentGuard.NotNull(mongoDatabase, nameof(mongoDatabase));
+ ArgumentGuard.NotNull(mongoDatabase);
MongoDatabase = mongoDatabase;
}
diff --git a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs
index 6982f1e..336a098 100644
--- a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs
+++ b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs
@@ -9,7 +9,7 @@ internal sealed class MongoModel : RuntimeModel
{
public MongoModel(IResourceGraph resourceGraph)
{
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(resourceGraph);
foreach (ResourceType resourceType in resourceGraph.GetResourceTypes())
{
diff --git a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoQueryExpressionValidator.cs b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoQueryExpressionValidator.cs
index 11da469..58081c6 100644
--- a/src/JsonApiDotNetCore.MongoDb/Repositories/MongoQueryExpressionValidator.cs
+++ b/src/JsonApiDotNetCore.MongoDb/Repositories/MongoQueryExpressionValidator.cs
@@ -10,7 +10,7 @@ internal sealed class MongoQueryExpressionValidator : QueryExpressionRewriter : IResourceRepository constraintProviders, IResourceDefinitionAccessor resourceDefinitionAccessor)
{
- ArgumentGuard.NotNull(mongoDataAccess, nameof(mongoDataAccess));
- ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
- ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
- ArgumentGuard.NotNull(constraintProviders, nameof(constraintProviders));
- ArgumentGuard.NotNull(resourceDefinitionAccessor, nameof(resourceDefinitionAccessor));
+ ArgumentGuard.NotNull(mongoDataAccess);
+ ArgumentGuard.NotNull(targetedFields);
+ ArgumentGuard.NotNull(resourceGraph);
+ ArgumentGuard.NotNull(resourceFactory);
+ ArgumentGuard.NotNull(constraintProviders);
+ ArgumentGuard.NotNull(resourceDefinitionAccessor);
_mongoDataAccess = mongoDataAccess;
_targetedFields = targetedFields;
@@ -62,7 +62,7 @@ public MongoRepository(IMongoDataAccess mongoDataAccess, ITargetedFields targete
///
public virtual async Task> GetAsync(QueryLayer queryLayer, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(queryLayer, nameof(queryLayer));
+ ArgumentGuard.NotNull(queryLayer);
IMongoQueryable query = ApplyQueryLayer(queryLayer);
return await query.ToListAsync(cancellationToken);
@@ -86,7 +86,7 @@ public virtual Task CountAsync(FilterExpression? topFilter, CancellationTok
protected virtual IMongoQueryable ApplyQueryLayer(QueryLayer queryLayer)
#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
{
- ArgumentGuard.NotNull(queryLayer, nameof(queryLayer));
+ ArgumentGuard.NotNull(queryLayer);
var queryExpressionValidator = new MongoQueryExpressionValidator();
queryExpressionValidator.Validate(queryLayer);
@@ -165,8 +165,8 @@ public virtual Task GetForCreateAsync(Type resourceClrType, TId id, C
///
public virtual async Task CreateAsync(TResource resourceFromRequest, TResource resourceForDatabase, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(resourceFromRequest, nameof(resourceFromRequest));
- ArgumentGuard.NotNull(resourceForDatabase, nameof(resourceForDatabase));
+ ArgumentGuard.NotNull(resourceFromRequest);
+ ArgumentGuard.NotNull(resourceForDatabase);
AssertNoRelationshipsAreTargeted();
@@ -198,7 +198,7 @@ private void AssertNoRelationshipsAreTargeted()
///
public virtual async Task GetForUpdateAsync(QueryLayer queryLayer, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(queryLayer, nameof(queryLayer));
+ ArgumentGuard.NotNull(queryLayer);
IReadOnlyCollection resources = await GetAsync(queryLayer, cancellationToken);
return resources.FirstOrDefault();
@@ -207,8 +207,8 @@ private void AssertNoRelationshipsAreTargeted()
///
public virtual async Task UpdateAsync(TResource resourceFromRequest, TResource resourceFromDatabase, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(resourceFromRequest, nameof(resourceFromRequest));
- ArgumentGuard.NotNull(resourceFromDatabase, nameof(resourceFromDatabase));
+ ArgumentGuard.NotNull(resourceFromRequest);
+ ArgumentGuard.NotNull(resourceFromDatabase);
AssertNoRelationshipsAreTargeted();
diff --git a/test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/QueryStrings/BlogPost.cs b/test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/QueryStrings/BlogPost.cs
index 4508e2f..c2f318e 100644
--- a/test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/QueryStrings/BlogPost.cs
+++ b/test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/QueryStrings/BlogPost.cs
@@ -31,7 +31,7 @@ public sealed class BlogPost : HexStringMongoIdentifiable
[BsonIgnore]
public ISet Comments { get; set; } = new HashSet();
- [HasOne(CanInclude = false)]
+ [HasOne(Capabilities = HasOneCapabilities.All & ~HasOneCapabilities.AllowInclude)]
[BsonIgnore]
public Blog? Parent { get; set; }
}
diff --git a/test/TestBuildingBlocks/IntegrationTest.cs b/test/TestBuildingBlocks/IntegrationTest.cs
index bc74112..c66e6c5 100644
--- a/test/TestBuildingBlocks/IntegrationTest.cs
+++ b/test/TestBuildingBlocks/IntegrationTest.cs
@@ -73,8 +73,7 @@ public abstract class IntegrationTest
private string? SerializeRequest(object? requestBody)
{
- return requestBody == null ? null :
- requestBody is string stringRequestBody ? stringRequestBody : JsonSerializer.Serialize(requestBody, SerializerOptions);
+ return requestBody == null ? null : requestBody as string ?? JsonSerializer.Serialize(requestBody, SerializerOptions);
}
protected abstract HttpClient CreateClient();
diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
index e77aac7..db9e8da 100644
--- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj
+++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
@@ -10,11 +10,11 @@
-
+
-
-
+
+