Skip to content

Example usage of NullabilityInfoContext fails on preview.7 #57920

@SimonCropp

Description

@SimonCropp
  • 6.0.100-preview.7.21379.14
  • Current Window10
  • VS2019 Preview

here dotnet/core#6444 (comment) the following (slightly modified) example is used

class Target
{
    public (string?, object) TupleField;
}

[Fact]
public void Test()
{
    var type = typeof(Target);
    var tupleField = type.GetField("TupleField");

    var context = new NullabilityInfoContext();

    var tupleInfo = context.Create(tupleField);

    Assert.Equal(NullabilityState.NotNull, tupleInfo.ReadState);
    Assert.Equal(NullabilityState.Nullable, tupleInfo.GenericTypeArguments[0].ReadState);
    Assert.Equal(NullabilityState.NotNull, tupleInfo.GenericTypeArguments[1].ReadState);
}

it fails since tupleInfo.GenericTypeArguments is empty.

I am not sure if this is a bug, or if the API has evolved beyond that example.

Paging @buyaa-n since you posted that usage example

Metadata

Metadata

Assignees

Labels

area-System.Reflectionbugin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions