microsoft / testfx

MSTest framework and adapter
MIT License
697 stars 250 forks source link

Add analyzer for when a test member is shadowing another member #3263

Closed Evangelink closed 6 days ago

Evangelink commented 1 month ago

Summary

Prevent testing issues (such as NRE) when user is shadowing test members.

Background and Motivation

.NET allows to do shadowing of members and MSTest will respect the behavior but this is nearly always causing issues. When shadowing a member (test, TestContext property...) from a base class, the base class is ignored (see https://github.com/microsoft/playwright-dotnet/issues/2958).

Proposed Feature

Raise a diagnostic when a member is being shadowed even if the user is using the new keyword to force shadowing.

The analyzer should be enabled by default with a warning severity and its category should be design.

Alternative Designs

None

AB#2200925