microsoft / microsoft/testfx

Analyzer Ideas: use non-whitespace, unique DisplayNames on DataRows

Open
#11,379 0 comments 0 reactions 0 assignees View on GitHub
area/analyzers needs/triage
Dominant language
C#
Stars
1k
Forks
312
Avg merge
8h 30m
Merged PRs (30d)
469

Description

## Summary

while copy and pasting, one might forget to change the DisplayName of a DataRow.
There is a Analyzer already for detecting duplicate DataRow data itself. this should be "extended" to DisplayNames

## Background and Motivation

writing some Tests for Whitespace-Adjustment, using the DisplayName sets a non-whitespace name to the DataRows.
a)
Image

Image

b)
Image

Image

## Proposed Feature

a) detect duplicate DisplayNames on DataRows
b) perhaps in the DisplayName detect whitespace, but especially line breaks, since it can lead to confusing Output in `dotnet test` or Visual Studio Test Explorer for TestCase Name (maybe even configurable, if i.e. single space are allowed?)
- also consider DataRows string-arguments, which contain spaces/line breaks without a ("clean") DisplayName

DataRows with non-strings, or strings without whitespace should still be allowed as-is, obviously. This is to combat confusing/whitespace Names in test output etc.

This will probably flag a lot of our own tests, but i'd rather have to deal with that by an analyzer rather than by a broken CI build.

## Alternative Designs
(only custom/private analyzer)

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing analyzer that detects duplicate DataRow data and trace its tests and diagnostics. Define how it should handle duplicate or whitespace-containing DisplayNames and string arguments, then add coverage showing valid non-string and non-whitespace cases remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.