Skip to content

fix(quality): make Web feature types internal (CA1515)#147

Merged
mpaulosky merged 3 commits into
sprint/6-code-qualityfrom
squad/138-make-web-types-internal
Apr 24, 2026
Merged

fix(quality): make Web feature types internal (CA1515)#147
mpaulosky merged 3 commits into
sprint/6-code-qualityfrom
squad/138-make-web-types-internal

Conversation

@mpaulosky

Copy link
Copy Markdown
Owner

Summary

Closes #138

Working as Boromir (Backend/.NET)

Makes all Web feature types internal per CA1515 — application-level types that are not part of a public API should not be public.

Changes

23 types changed publicinternal across:

  • Features/BlogPosts/Create — Command, Validator, Handler
  • Features/BlogPosts/Delete — Command, Validator, Handler
  • Features/BlogPosts/Edit — Command, Validator, Handler, GetBlogPostByIdQuery
  • Features/BlogPosts/List — Handler, Query
  • Features/UserManagement — AssignRoleCommand, RemoveRoleCommand, GetAvailableRolesQuery, RoleDto, GetUsersWithRolesQuery, UserWithRolesDto, Handler
  • Data — BlogPostDto, MongoDbBlogPostRepository
  • Infrastructure/Caching — BlogPostCacheKeys, IBlogPostCacheService, CachingServiceExtensions
  • Security — RoleClaimsHelper

Assembly visibility updated (src/Web/Properties/AssemblyInfo.cs):

  • Added InternalsVisibleTo for Architecture.Tests, Web.Tests, Web.Tests.Bunit, Web.Tests.Integration
  • Added InternalsVisibleTo("DynamicProxyGenAssembly2") for NSubstitute proxy generation

Test fix (tests/Web.Tests.Integration/Infrastructure/RedisFixture.cs):

  • Changed CreateCacheService() from publicinternal to match IBlogPostCacheService visibility

Verification

  • Build: ✅ succeeded
  • Architecture.Tests: ✅ 11/11
  • Unit.Tests: ✅ 22/22
  • Web.Tests: ✅ 102/102

- Changed 23 top-level types from public to internal in Web features,
  data, infrastructure, and security layers
- Added InternalsVisibleTo entries in AssemblyInfo.cs for all test
  assemblies (Architecture.Tests, Web.Tests, Web.Tests.Bunit,
  Web.Tests.Integration, Unit.Tests, DynamicProxyGenAssembly2)
- Changed RedisFixture.CreateCacheService() to internal to match
  IBlogPostCacheService visibility

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 24, 2026 18:50
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label Apr 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Reduces the public surface area of the Web assembly by making non-API application-layer feature/data/caching types internal to satisfy CA1515, while preserving test access via InternalsVisibleTo.

Changes:

  • Changed CQRS feature commands/queries/handlers/validators and supporting DTOs/services from public to internal within src/Web.
  • Added InternalsVisibleTo entries for test assemblies and DynamicProxyGenAssembly2 (NSubstitute/Castle proxy generation).
  • Updated integration test fixture method visibility to align with the now-internal caching abstractions.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Web.Tests.Integration/Infrastructure/RedisFixture.cs Adjusted fixture factory method visibility to match internal caching types.
src/Web/Security/RoleClaimsHelper.cs Made helper type internal to reduce public API surface.
src/Web/Properties/AssemblyInfo.cs Added InternalsVisibleTo for test assemblies and dynamic proxy generation.
src/Web/Infrastructure/Caching/IBlogPostCacheService.cs Made caching abstraction internal.
src/Web/Infrastructure/Caching/CachingServiceExtensions.cs Made DI extension type internal.
src/Web/Infrastructure/Caching/BlogPostCacheKeys.cs Made cache key constants type internal.
src/Web/Features/UserManagement/UserManagementHandler.cs Made handler internal.
src/Web/Features/UserManagement/RemoveRoleCommand.cs Made command internal.
src/Web/Features/UserManagement/GetUsersWithRolesQuery.cs Made query + DTO internal.
src/Web/Features/UserManagement/GetAvailableRolesQuery.cs Made query + DTO internal.
src/Web/Features/UserManagement/AssignRoleCommand.cs Made command internal.
src/Web/Features/BlogPosts/List/GetBlogPostsQuery.cs Made query internal.
src/Web/Features/BlogPosts/List/GetBlogPostsHandler.cs Made handler internal.
src/Web/Features/BlogPosts/Edit/GetBlogPostByIdQuery.cs Made query internal.
src/Web/Features/BlogPosts/Edit/EditBlogPostHandler.cs Made handler internal.
src/Web/Features/BlogPosts/Edit/EditBlogPostCommandValidator.cs Made validator internal.
src/Web/Features/BlogPosts/Edit/EditBlogPostCommand.cs Made command internal.
src/Web/Features/BlogPosts/Delete/DeleteBlogPostHandler.cs Made handler internal.
src/Web/Features/BlogPosts/Delete/DeleteBlogPostCommandValidator.cs Made validator internal.
src/Web/Features/BlogPosts/Delete/DeleteBlogPostCommand.cs Made command internal.
src/Web/Features/BlogPosts/Create/CreateBlogPostHandler.cs Made handler internal.
src/Web/Features/BlogPosts/Create/CreateBlogPostCommandValidator.cs Made validator internal.
src/Web/Features/BlogPosts/Create/CreateBlogPostCommand.cs Made command internal.
src/Web/Data/MongoDbBlogPostRepository.cs Made repository implementation internal.
src/Web/Data/BlogPostDto.cs Made DTO internal.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results Summary

206 tests  ±0   206 ✅ ±0   14s ⏱️ ±0s
  5 suites ±0     0 💤 ±0 
  5 files   ±0     0 ❌ ±0 

Results for commit 7cc874f. ± Comparison against base commit 475185e.

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.12%. Comparing base (29f8ff2) to head (fd14c18).
⚠️ Report is 11 commits behind head on sprint/6-code-quality.

Files with missing lines Patch % Lines
...b/Features/UserManagement/UserManagementHandler.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           sprint/6-code-quality     #147   +/-   ##
======================================================
  Coverage                  72.12%   72.12%           
======================================================
  Files                         43       43           
  Lines                        721      721           
  Branches                     112      112           
======================================================
  Hits                         520      520           
  Misses                       150      150           
  Partials                      51       51           
Files with missing lines Coverage Δ
src/Web/Data/BlogPostDto.cs 100.00% <100.00%> (ø)
src/Web/Data/MongoDbBlogPostRepository.cs 100.00% <100.00%> (ø)
...Features/BlogPosts/Create/CreateBlogPostCommand.cs 100.00% <100.00%> (ø)
...BlogPosts/Create/CreateBlogPostCommandValidator.cs 100.00% <ø> (ø)
...Features/BlogPosts/Create/CreateBlogPostHandler.cs 71.42% <100.00%> (ø)
...Features/BlogPosts/Delete/DeleteBlogPostCommand.cs 100.00% <100.00%> (ø)
...BlogPosts/Delete/DeleteBlogPostCommandValidator.cs 100.00% <ø> (ø)
...Features/BlogPosts/Delete/DeleteBlogPostHandler.cs 77.77% <100.00%> (ø)
...Web/Features/BlogPosts/Edit/EditBlogPostCommand.cs 100.00% <100.00%> (ø)
...res/BlogPosts/Edit/EditBlogPostCommandValidator.cs 100.00% <ø> (ø)
... and 11 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Boromir and others added 2 commits April 24, 2026 12:46
…mocking of internal types

Without InternalsVisibleTo("DynamicProxyGenAssembly2"), Castle DynamicProxy
cannot create proxies for internal sealed classes, causing all NSubstitute-
based Web.Tests to fail at constructor time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mpaulosky
mpaulosky merged commit e0b6832 into sprint/6-code-quality Apr 24, 2026
3 checks passed
@mpaulosky
mpaulosky deleted the squad/138-make-web-types-internal branch April 24, 2026 19:49
mpaulosky added a commit that referenced this pull request Apr 25, 2026
## Sprint 6: Code Quality

**Goal:** Eliminate analyzer warnings, enforce internal visibility on
Web feature types, expand test coverage, and migrate Unit.Tests into
Web.Tests.

---

## Merged Feature PRs

- Closes #137 — PR #144 — fix(quality): rename `ct` →
`cancellationToken` in all MediatR handlers
- Closes #138 — PR #145 — test: add unit tests for BlogPost, Result, and
ValidationBehavior (42 tests)
- Closes #139 — PR #146 — test: add unit tests for UserManagementHandler
(16 tests)
- Closes #140 — PR #147 — fix(quality): make Web feature types
`internal` (CA1515, ~28 types)
- Closes #141 — PR #148 — test: add unit tests for BlogPostMappings (22
tests)
- Closes #142 — PR #149 — fix(quality): add ConfigureAwait(false) and
specific exception catches
- Closes #143 — PR #150 — fix(quality): address Domain and
ServiceDefaults analyzer warnings
- Closes #151 — PR #152 — feat(tests): migrate Unit.Tests → Web.Tests
and remove Unit.Tests project

---

## Test Summary

- **80+ new tests** added across all PRs
- **105 Web.Tests passing** (0 failures)
- `DynamicProxyGenAssembly2` added to `InternalsVisibleTo` in Web.csproj
for NSubstitute support

## Notable Changes

- `Unit.Tests` project removed; all tests now live in `Web.Tests`
- ~28 Web feature types changed from `public` to `internal` (CA1515
compliance)
- All MediatR handler parameters renamed from `ct` to
`cancellationToken` for clarity
- `ConfigureAwait(false)` applied to all async calls in service layer
- Domain and ServiceDefaults analyzer warnings resolved

---

## Checklist

- [x] All sprint issues closed (#137#143, #151)
- [x] CI green (0 build errors)
- [x] 105 Web.Tests passing
- [x] Milestone at 100%

---------

Co-authored-by: Boromir <boromir@squad.dev>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants