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
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