Skip to content

Enforce variable declaration style and format solution - #714

Merged
Shane32 merged 4 commits into
masterfrom
chore/var-style-warnings
Nov 2, 2026
Merged

Shane32 merged 4 commits into
masterfrom
chore/var-style-warnings

Conversation

@Shane32

@Shane32 Shane32 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Enforce all three var preferences as warnings: prefer explicit types for built-ins and elsewhere, and var when the initializer makes the type apparent.
  • Apply dotnet format across the solution, preserving span/array declarations and nullable annotations across target frameworks.

Test plan

  • dotnet build QRCoderTests/QRCoderTests.csproj --no-restore: all five test target frameworks build with zero warnings or errors.
  • dotnet format style QRCoder.slnx --diagnostics IDE0007 IDE0008 --verify-no-changes --no-restore --severity warn: passed for the loaded projects.
  • git diff --check: passed.

Full-solution formatting verification still reports existing IDE0060 diagnostics. References for netstandard1.3 and the UWP demo could not be loaded.

Summary by CodeRabbit

  • Chores
    • Updated C# style checks to flag inferred local-variable types as warnings.
    • Made local variable types explicit across the library, samples, command-line app, benchmarks, and tests. QR generation, rendering, payloads, and test expectations remain unchanged.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93dc1d70-7fac-4d14-9ba0-720c0fec4db5
Commits

Reviewing files that changed from the base of the PR and between 9123507 and 5e6ec8d.

Files selected for processing: 5
  • QRCoder/BitmapByteQRCode.cs
  • QRCoder/Extensions/StringExtensions.cs
  • QRCoder/PdfByteQRCode.cs
  • QRCoderTests/BitmapByteQRCodeRendererTests.cs
  • QRCoderTests/PdfByteQRCodeRendererTests.cs
Files skipped from review as they are similar to previous changes: 5
  • QRCoder/BitmapByteQRCode.cs
  • QRCoder/Extensions/StringExtensions.cs
  • QRCoderTests/BitmapByteQRCodeRendererTests.cs
  • QRCoderTests/PdfByteQRCodeRendererTests.cs
  • QRCoder/PdfByteQRCode.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The PR replaces inferred local-variable declarations with explicit types across QR generation, rendering, payload generation, supporting projects, and tests. It also changes two .editorconfig preferences from suggestions to warnings. The summaries report no changes to calculations, output behavior, or public signatures.

Changes: Explicit Local Typing

Layer / File(s) Summary
QR generation and data
QRCoder/QRCodeGenerator.cs, QRCoder/QRCodeGenerator/*, QRCoder/QRCodeData.cs
QR generation, capacity selection, matrix placement, and QR data code now declare local types explicitly.
QR renderers
QRCoder/ASCIIQRCode.cs, QRCoder/ArtQRCode.cs, QRCoder/Base64QRCode.cs, QRCoder/BitmapByteQRCode.cs, QRCoder/PdfByteQRCode.cs, QRCoder/PngByteQRCode.cs, QRCoder/PostscriptQRCode.cs, QRCoder/QRCode.cs, QRCoder/SvgQRCode.cs, QRCoder.Xaml/XamlQRCode.cs
Renderer implementations use explicit local types. The supplied summaries report unchanged rendering behavior.
Payload generation
QRCoder/PayloadGenerator.cs, QRCoder/PayloadGenerator/*
Payload validation, encoding, and serialization code uses explicit local types. The supplied summaries report unchanged validation and payload behavior.
Supporting code and applications
.editorconfig, QRCoder/Extensions/*, QRCoderApiTests/*, QRCoderBenchmarks/*, QRCoderConsole/*, QRCoderDemo/*, QRCoderSamples/*
Two .editorconfig preferences change from suggestions to warnings. Extensions, applications, API approval code, benchmarks, and samples use explicit local types.
Tests
QRCoderTests/*
Test locals use explicit types. Test inputs, assertions, and expected outputs remain unchanged.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Refactor

Suggested reviewers: codebude, krisvandermotten

Merge Risk: Minimal · up to 5e6ec

The previously flagged netstandard1.3 declaration is explicitly typed at the reviewed head. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 76.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: enforcing variable declaration style and formatting the solution.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 76.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 107 functions across 51 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment thread .editorconfig
Comment on lines -87 to +89
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_elsewhere = false:warning

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Changes of note

@Shane32

Shane32 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner Author

This PR enforces proper variable declarations throughout the codebase (which should match our review process). If it proves too troublesome I may wish to downgrade the alert level back to suggestion, and reviews at that point should reflect the same. But we can try it like this.

@Shane32
Shane32 requested a review from gfoidl November 2, 2026 14:35

@gfoidl gfoidl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Modulo the nit it LGTM.

Comment on lines +20 to +22
{
_writer = writer;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can be undone.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It can but dotnet format changed it so I presume that's part of the correct styling according to .editorconfig

@Shane32
Shane32 merged commit ca210b7 into master Nov 2, 2026
8 checks passed
@Shane32
Shane32 deleted the chore/var-style-warnings branch November 2, 2026 15:41
github-actions Bot pushed a commit to heckertobias/browser-game that referenced this pull request Nov 27, 2026
Updated [QRCoder](https://github.com/Shane32/QRCoder) from 1.8.1 to
1.9.0.

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

_Sourced from [QRCoder's
releases](https://github.com/Shane32/QRCoder/releases)._

## 1.9.0

## What's Changed
* Update to .NET 10 SDK and .slnx solution file format by
@​KrisVandermotten in Shane32/QRCoder#707
* Optimize QRCodeData.SaveRawData and QRCodeData.GetRawData by
@​KrisVandermotten in Shane32/QRCoder#708
* Optimize rawData QrCodeData constructor and improve input validation
by @​KrisVandermotten in Shane32/QRCoder#709
* Allow GiroCode generation without an amount by @​OidaTiftla in
Shane32/QRCoder#710
* Fix build by removing stale raw-data assertion by @​Shane32 in
Shane32/QRCoder#711
* Replace string concatenation with StringBuilder and invariant
interpolation by @​kamilla11 in
Shane32/QRCoder#696
* Reduce PDF rendering allocations with a shared content builder by
@​Shane32 in Shane32/QRCoder#712
* Avoid temporary color arrays in PDF and bitmap renderers by @​Shane32
in Shane32/QRCoder#713
* Enforce variable declaration style and format solution by @​Shane32 in
Shane32/QRCoder#714
* Format the SwissQrCode amount with the invariant culture by @​menes97
in Shane32/QRCoder#715
* Simplify date formatting inside AppendInvariant calls by @​Shane32 in
Shane32/QRCoder#717
* Use NuGet Trusted Publishing and update workflow actions by @​Shane32
in Shane32/QRCoder#718
* Run NuGet release publishing from the package output directory by
@​Shane32 in Shane32/QRCoder#719

## New Contributors
* @​OidaTiftla made their first contribution in
Shane32/QRCoder#710
* @​kamilla11 made their first contribution in
Shane32/QRCoder#696
* @​menes97 made their first contribution in
Shane32/QRCoder#715

**Full Changelog**:
Shane32/QRCoder@v1.8.1...v1.9.0

Commits viewable in [compare
view](Shane32/QRCoder@v1.8.1...v1.9.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=QRCoder&package-manager=nuget&previous-version=1.8.1&new-version=1.9.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>
This was referenced Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants