Skip to content

System.Collections.Generic.SortedSet<T>.TreeSubSet Min and Max work incorrectly after updating _underlying set #55760

@kzrnm

Description

@kzrnm

Description

Reproduce

below code

using System;
using System.Collections.Generic;

var set = new SortedSet<int>();
var view = set.GetViewBetween(0, 5);

set.UnionWith(new[] { 1, 2, 3, 4 });
Console.WriteLine($"Min:{view.Min} Max:{view.Max}");
view.Add(1);
Console.WriteLine($"Min:{view.Min} Max:{view.Max}");

expected

Min:1 Max:4
Min:1 Max:4

actual

Min:0 Max:0
Min:1 Max:4

Configuration

I run on main branch and .NET Core 2.1, .NET 5

Regression?

This works fine with .NET framework 4.8.

Other information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions