Skip to content

[.NET6 fix port] NullabilityInfoContext.Create throws IndexOutOfRangeException #81022

Closed
@plachor

Description

@plachor

Description

Hi @danmoseley,

Issue #68461 was resolved in .NET7 however the fix was not applied to .NET6.
Since .NET6 is still under support till November 12, 2024 and is called LTS perhaps you could fix .NET6 as-well.

Any chances for that ?

Reproduction Steps

#nullable enable
using System.Collections.Generic;
using System.Reflection;
using FluentAssertions;
using Xunit;

namespace Reproduction;

public record GenericType<TType>(IReadOnlyDictionary<string, TType> Dictionary);

public class NullableContextIssue
{
    [Fact]
    public void ShouldNotThrow()
    {
        var property = typeof(GenericType<IReadOnlyCollection<bool>>)
                                     .GetProperty(nameof(GenericType<IReadOnlyCollection<bool>>.Dictionary));
        var action = () => new NullabilityInfoContext().Create(property);

        action.Should().NotThrow();
    }
}

Expected behavior

Should not throw exception.

Actual behavior

System.IndexOutOfRangeException is being observed.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions