Skip to content

Report DM0021 for VerificationGlue.Mocks.MockAttribute - #143

Merged
ipjohnson merged 5 commits into
mainfrom
agent/stp-vgdm-dm0021
Nov 27, 2026
Merged

ipjohnson merged 5 commits into
mainfrom
agent/stp-vgdm-dm0021

Conversation

@ipjohnson

Copy link
Copy Markdown
Owner

What changed

DM0021 now reads VerificationGlue.Mocks.MockAttribute as well as DependencyModules.Testing.Attributes.MockAttribute. This is step 3 of "Changes, in the order they land" in docs/design/verificationglue.md.

  • KnownTypes.VerificationGlue.Mocks.MockAttribute is new. It is matched by namespace and name, and no shipping project references VerificationGlue.
  • TestAttributeDiagnostics accepts either attribute on the parameter. The keyed-mock and Moq exemptions are unchanged.
  • MockTestExportDiagnosticTests has six new tests with a stub of VerificationGlue's attribute. They check that a VG [Mock] with a [TestExport] on the same method gets the same DM0021 message, severity and location as DependencyModules' [Mock]. They also cover the qualified spelling, a keyed mock, another service, a class-level [TestExport], and a MockAttribute in an unrelated namespace.
  • The remarks of DependencyModules.Testing's MockAttribute say that under VerificationGlue the parameter is a VerificationGlue mock and needs no mock-support attribute.
  • PublicApiTests.SourceGeneratorApi.verified.txt lists the new public KnownTypes class.
  • The DM0021 section of website/reference/diagnostics.md and the CHANGELOG mention the second attribute.
  • Part 8 of the design said the MTP entry point file name was unchecked for DM0019. Microsoft.Testing.Platform.MSBuild 2.5.3 and 3.0.0-preview name it MicrosoftTestingPlatformEntryPoint.cs, which does not end in Program.cs, so DM0019 needs no change. The design doc now says so. The other diagnostics in Part 8 (VGT0006, VGT0008, VGM0001) are VerificationGlue changes, and DM0016 needs none.
  • The branch merges main at dacf783. The CHANGELOG conflict is settled by keeping both "Changed" entries.

Why

VerificationGlue tests use VerificationGlue.Mocks.MockAttribute, which has the same precedence over [TestExport]. DM0021 did not recognize it, so DM's analyzer and VG's generator disagreed about [Mock] on VG tests. VG adds no diagnostic of its own for this, so DM0021 is the only report.

How it was tested

After the merge with main:

  • dotnet csharpier check . passes.
  • scripts/coverage.sh 85 passes: DependencyModules.Tests (903 per framework), SutProject.Tests (174), SutProject.NUnitTests (46) and WebApiApp.Tests (2) on net8.0 and net10.0, and DependencyModules.Specs (326). Line coverage is 92.9%.
  • scripts/test-xunit.sh 4 passes.
  • Before the merge, dotnet build tests/DependencyModules.Tests -c Release --no-incremental reported no warnings other than NU1902. The merge changed no file of this branch other than CHANGELOG.md.

Not run: scripts/verify-packages.sh.

🤖 Generated with Claude Code


Opened by Agent Driver for step stp-vgdm-dm0021 of Task tsk-verificationglue.

Agent Driver and others added 5 commits November 27, 2026 14:44
DM0021 recognized only DependencyModules' [Mock], so a VerificationGlue
test with VG's [Mock] and a [TestExport] for the same service got no
report, though VG gives the parameter the same precedence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p-vgdm-dm0021

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge of main moved MockTestExportDiagnosticTests into DependencyModules.Specs, which runs
on VerificationGlue.Tests, so the six tests this branch added could not use xUnit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ipjohnson
ipjohnson merged commit 65b68e5 into main Nov 27, 2026
2 checks passed
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.

1 participant