Skip to content

Replace casts with pattern matching for performance and readability - #890

Merged
304NotModified merged 2 commits into
masterfrom
replace-cast-with-pattern-matching
Nov 10, 2026
Merged

304NotModified merged 2 commits into
masterfrom
replace-cast-with-pattern-matching

Conversation

@304NotModified

@304NotModified 304NotModified commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Easier to read, shorter and better performance

Fixes

{D274B6EB-CA22-4C9C-9BE6-8035D9F88FA1}

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.94%. Comparing base (e1bde4c) to head (0c992e8).

Files with missing lines Patch % Lines
src/NLog.Extensions.Logging/Logging/NLogLogger.cs 73.33% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #890      +/-   ##
==========================================
+ Coverage   75.70%   75.94%   +0.24%     
==========================================
  Files          23       23              
  Lines        1457     1455       -2     
  Branches      430      430              
==========================================
+ Hits         1103     1105       +2     
+ Misses        173      169       -4     
  Partials      181      181              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@304NotModified
304NotModified marked this pull request as ready for review November 9, 2026 17:05
@304NotModified 304NotModified added this to the 6.3.0 milestone Nov 10, 2026
@304NotModified 304NotModified changed the title Replace cast with pattern matching Replace casts with pattern matching for performance and readability Nov 10, 2026
@304NotModified

Copy link
Copy Markdown
Member Author

I will test this with .NET 11 also, currently installing

@304NotModified

Copy link
Copy Markdown
Member Author

Unfortunately .NET 11 isn't supported by BenchmarkDotNet yey

The new results, with also .NET 9:

Image

@sonarqubecloud

Copy link
Copy Markdown

fuzzzerd pushed a commit to fuzzzerd/SharpFM that referenced this pull request Nov 16, 2026
Updated
[NLog.Extensions.Logging](https://github.com/NLog/NLog.Extensions.Logging)
from 6.2.2 to 6.3.0.

<details>
<summary>Release notes</summary>

_Sourced from [NLog.Extensions.Logging's
releases](https://github.com/NLog/NLog.Extensions.Logging/releases)._

## 6.3.0

**Platform Support**
- [#​891](NLog/NLog.Extensions.Logging#891)
Added .NET 11 support (@​304NotModified)
- [#​891](NLog/NLog.Extensions.Logging#891)
Removed .NET 6 support (@​304NotModified)

**Performance**
- [#​890](NLog/NLog.Extensions.Logging#890)
Replace casts with pattern matching for performance and readability
(@​304NotModified)

**Infrastructure**
- [#​874](NLog/NLog.Extensions.Logging#874) Move
to GitHub Actions and enable trusted publishing (@​304NotModified)
- [#​878](NLog/NLog.Extensions.Logging#878)
Improve ci.yml (@​304NotModified)
- [#​879](NLog/NLog.Extensions.Logging#879) Add
GitHub Actions unit test report (@​304NotModified)
- [#​887](NLog/NLog.Extensions.Logging#887)
Remove AppVeyor references (@​304NotModified)
- [#​880](NLog/NLog.Extensions.Logging#880)
Upload coverage to Codecov and SonarQube automatic analysis
(@​304NotModified)
- [#​885](NLog/NLog.Extensions.Logging#885) Add
Codecov config (@​304NotModified)
- [#​884](NLog/NLog.Extensions.Logging#884)
Upgrade release-drafter (@​304NotModified)

**Maintenance**
- [#​873](NLog/NLog.Extensions.Logging#873)
NLogLogger - Minor code adjustment (@​snakefoot)
- [#​881](NLog/NLog.Extensions.Logging#881)
Remove unneeded Microsoft.SourceLink.GitHub package (@​304NotModified)
- [#​882](NLog/NLog.Extensions.Logging#882) Bump
coverlet.collector from 6.0.4 to 10.1.0 (@​dependabot[bot])
- [#​883](NLog/NLog.Extensions.Logging#883) Add
tests (@​304NotModified)
- [#​888](NLog/NLog.Extensions.Logging#888) Add
tests (@​304NotModified)
- [#​889](NLog/NLog.Extensions.Logging#889)
Reduce cognitive complexity (@​304NotModified)
- [#​892](NLog/NLog.Extensions.Logging#892) Move
example projects (@​304NotModified)

Commits viewable in [compare
view](NLog/NLog.Extensions.Logging@v6.2.2...v6.3.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=NLog.Extensions.Logging&package-manager=nuget&previous-version=6.2.2&new-version=6.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants