Skip to content

GD-310: Add analyzer to enforce file name and class name consistency #310

@MikeSchulze

Description

@MikeSchulze

A Task is not a bug or feature request

Problem

The test discoverer uses Mono.Cecil to scan for test classes by matching the class file name with the class name. When these don't match, tests are not discovered, leading to silent test failures.

Requirements

Create a static code analyzer that:

  • Validates naming consistency - Ensures C# class names match their file names (without extension)
  • Targets test classes specifically - Focus on classes decorated with [TestSuite] or similar test attributes
  • Provides clear diagnostics - Show helpful error messages when mismatches are found
  • Suggests fixes - Offer code fixes to rename either the file or class

Acceptance Criteria

[ ] Analyzer detects when ClassName.cs contains class DifferentName
[ ] Provides diagnostic with severity level Error ,includes helpful message: "Class name 'DifferentName' should match file name 'ClassName' for test discovery to work"
[ ] Only analyzes files in test projects or files with test attributes

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvementgdunit4.analyzersIssue is related to the `gdunit4.analyzers`
No fields configured for Feature.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions