Skip to content

New Assert.DoesNotContain overloads break compilation if LangVersion=latest is not specified #11022

Closed

Description

@avivanoff

Describe the bug

Assert.DoesNotContain overloads introduced in 4.4.0 break compilation when targeting anything but net10.0 if LangVersion=latest is not specified.
The same setup works with 4.3.3.

Version used

4.4.0

Steps To Reproduce

  1. Create MSTest.Sdk project.
  2. Change SDK version to 4.4.0.
  3. Change TargetFramework to net8.0.
  4. Comment out/delete LangVersion from the project.
  5. Build the project.

Expected behavior

Project builds with no error.

Actual behavior

Build is broken:

error CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.VisualStudio.TestTools.UnitTesting.Assert.DoesNotContain<T>(T, System.Collections.Generic.IEnumerable<T>, string?, string, string)' and 'Microsoft.VisualStudio.TestTools.UnitTesting.Assert.DoesNotContain<T>(T, System.Span<T>, string?, string, string)'

Sample project.

Activity

  1. added
    needs/triage
    on Sep 3, 2026
  2. added theissue type on Sep 3, 2026
  3. added
    area/assertion
    type/regression
    on Sep 3, 2026
  4. removed
    needs/triage
    on Sep 4, 2026
  5. Evangelink commented on Sep 4, 2026

    @Evangelink
    Member

    Thanks avivanoff! This is indeed a regression caused by adding a new overload (span). Older versions of the compiler are confused for arrays while new versions are good. We will provide a targeted fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/assertiontype/regression

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions