Skip to content

Sync Vendor ProductViewModelService to AdminShared's primary-constructor style - #788

Merged
KrzysztofPajak merged 1 commit into
developfrom
vendor-service-primary-ctor-style
Aug 16, 2026
Merged

Sync Vendor ProductViewModelService to AdminShared's primary-constructor style#788
KrzysztofPajak merged 1 commit into
developfrom
vendor-service-primary-ctor-style

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Summary

Continuation of the ProductController/ProductViewModelService duplication cleanup (#785, #786). This one targets the style half of the diff between Grand.Web.AdminShared/Services/ProductViewModelService.cs (used directly by Admin and Store) and its fork in Grand.Web.Vendor/Services/ProductViewModelService.cs.

What changed

Grand.Web.AdminShared's service was refactored to a C# primary constructor at some point; the Vendor fork never got the same treatment and still carried a classic constructor + 31 private fields. That drift alone was responsible for roughly half of the (real, unavoidable) diff between the two files - every method touching an injected service showed as changed purely because one side wrote _service and the other service.

This is a pure, scripted rename:

  • Removed the 31 field declarations and the explicit constructor.
  • Converted the class declaration to a primary constructor with the exact same parameter list/order.
  • Renamed every _fieldName reference to the matching parameter name throughout the file.

No logic touched, no line reordered beyond what the syntax change forces.

Result

Diff to AdminShared's service dropped from ~1412 to 960 changed lines. The remaining diff is the real vendor-specific behavior (VendorId assignment, vendor-scoped search, HasAccessToProduct filtering) - not noise.

Testing

  • dotnet build src/Web/Grand.Web.Vendor → clean
  • dotnet test src/Tests/Grand.Web.Vendor.Tests12/12, unmodified - the existing tests exercise exactly the renamed identifiers (constructor injection, field usage inside PrepareProducts/InsertProductModel/etc.), so a mismatched rename would have surfaced immediately as a compile error or a failing assertion.

Scope note

This does not eliminate the fork - Vendor still has its own copy of the service, because it needs vendor-scoping instead of store-scoping and genuinely different authorization logic. Merging the two implementations into one parameterized service was considered and deliberately deferred: it's a much larger, higher-risk change needing far more test coverage than exists today. This PR only removes the stylistic noise that made the real diff harder to see.

🤖 Generated with Claude Code

…tor style

Grand.Web.AdminShared/Services/ProductViewModelService.cs (which Admin and
Store both use directly) was refactored to a C# primary constructor at
some point; this fork in Vendor never got the same treatment, so it still
carried a classic constructor + 31 private fields. That style drift alone
accounted for roughly half of the (unavoidable, real) diff between the two
files - every method referencing an injected service showed as changed
purely because one side used `_service` and the other `service`.

Pure mechanical rename, scripted (not hand-edited): removed the field
declarations and explicit constructor, converted the class declaration to
a primary constructor with the same parameter list/order, and renamed
every `_fieldName` reference to the matching parameter name throughout the
file. No logic touched, no line reordered beyond what the syntax change
requires.

Diff to AdminShared's service dropped from ~1412 to 960 changed lines
(mechanical noise removed; the remaining diff is the real vendor-specific
behavior: VendorId assignment, vendor-scoped search, HasAccessToProduct
filtering).

Grand.Web.Vendor.Tests: 12/12 green, unmodified - the tests exercise
exactly the renamed identifiers (constructor injection, field usage
inside PrepareProducts/InsertProductModel/etc.), so a mismatched rename
would have surfaced immediately as a compile error or a failing test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 16, 2026 11:31

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs Dismissed
@KrzysztofPajak
KrzysztofPajak merged commit 95c8548 into develop Aug 16, 2026
4 of 5 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the vendor-service-primary-ctor-style branch August 16, 2026 11:39
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