Skip to content
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

refactor: Rewrite parameter null checks using helper methods #9024

Merged
merged 1 commit into from
Jul 29, 2023

Conversation

filzrev
Copy link
Contributor

@filzrev filzrev commented Jul 28, 2023

What's included in this PR
Rewrite parameter null check with following helper methods.

  • ArgumentNullException.ThrowIfNull(Require .NET 6 or later)
  • ArgumentNullException.ThrowIfNullOrEmpty (Require .NET 7)

These change will not affects application behaviors.
It's intended following purpose.

  • Code readability
  • Line coverage improvement.
  • Better code size and code inlining.

Related Roslyn Analyzer rules

CA1510: Use ArgumentNullException throw helper

https://github.com/dotnet/roslyn-analyzers/blob/main/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md#ca1510-use-argumentnullexception-throw-helper

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 83.21% and project coverage change: +0.68% 🎉

Comparison is base (c98926e) 76.87% compared to head (e5d7713) 77.55%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9024      +/-   ##
==========================================
+ Coverage   76.87%   77.55%   +0.68%     
==========================================
  Files         591      591              
  Lines       24758    24578     -180     
==========================================
+ Hits        19033    19062      +29     
+ Misses       5725     5516     -209     
Files Changed Coverage Δ
...ocfx.Build.Engine/OSPlatformSensitiveDictionary.cs 22.22% <0.00%> (+2.22%) ⬆️
...ngine/ResourceFileReaders/ArchiveResourceReader.cs 0.00% <0.00%> (ø)
...c/Docfx.Build.Engine/XRefMaps/XRefArchiveReader.cs 0.00% <0.00%> (ø)
src/Docfx.Common/LruList.cs 0.00% <0.00%> (ø)
src/Docfx.Common/TaskHelper.cs 0.00% <0.00%> (ø)
...alReferences/ExternalReferencePackageCollection.cs 0.00% <0.00%> (ø)
...ternalReferences/ExternalReferencePackageWriter.cs 0.00% <0.00%> (ø)
src/Docfx.Plugins/XRefSpec.cs 44.87% <0.00%> (+0.56%) ⬆️
src/docfx/Models/InitCommand.cs 0.00% <0.00%> (ø)
...cfx.Common/FileAbstractLayer/ManifestFileHelper.cs 47.05% <30.00%> (+8.96%) ⬆️
... and 82 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@yufeih yufeih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these NULL checks could be replaced by nullable reference types in the future. Nevertheless, this is still a great enhancement to the existing codebase we have!

@yufeih yufeih merged commit 4e2f827 into dotnet:main Jul 29, 2023
filzrev added a commit to filzrev/docfx that referenced this pull request Jul 29, 2023
filzrev added a commit to filzrev/docfx that referenced this pull request Jul 29, 2023
filzrev added a commit to filzrev/docfx that referenced this pull request Jul 29, 2023
yufeih pushed a commit that referenced this pull request Aug 1, 2023
* fix: Add empty filePath check (based on previous doc comment)

#9024 (comment)

* chore: Fix additional CA1510 rules

* chore: fix redundant names (IDE0020)

Commented on #9024 (comment)

* fix: Fix wrong behavior changes introduced by previous PR

Commented on #9024 (comment)

* fix: Change thrown exception type.

Commented on #9024 (comment)
@yufeih yufeih added the engineering Makes the pull request to appear in the "Engineering" section of the next release note label Aug 17, 2023
p-kostov pushed a commit to ErpNetDocs/docfx that referenced this pull request Jun 28, 2024
p-kostov pushed a commit to ErpNetDocs/docfx that referenced this pull request Jun 28, 2024
* fix: Add empty filePath check (based on previous doc comment)

dotnet#9024 (comment)

* chore: Fix additional CA1510 rules

* chore: fix redundant names (IDE0020)

Commented on dotnet#9024 (comment)

* fix: Fix wrong behavior changes introduced by previous PR

Commented on dotnet#9024 (comment)

* fix: Change thrown exception type.

Commented on dotnet#9024 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering Makes the pull request to appear in the "Engineering" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants