Skip to content

Conversation

@buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Aug 24, 2021

Fixes #57920

Initially, I thought no need to check generic parameter for value types but turns out it needed

@buyaa-n buyaa-n added this to the 6.0.0 milestone Aug 24, 2021
public Tuple<T, string?, string>? PropertyTupleNonNullNonNull { get; set; }
public Tuple<string, string, T> PropertyTupleNonNonNonNon { get; set; } = null!;
public Tuple<T, int?, string>? PropertyTupleNonNullNonNull { get; set; }
public Tuple<int, string, T> PropertyTupleNonNonNonNon { get; set; } = null!;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found another bug when there is a value type included in the parameter list, the nullability of that value type is omitted from the nullability byte array, updated these test properties to test that fix


for (int i = 0, offset = 0; i < genericArguments.Length; i++)
{
if (!genericArguments[i].IsValueType)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when there is a value type included in the parameter list, the nullability of that value type is omitted from the nullability byte array

return nullability;
nullability = new NullabilityInfo(type, state, state, elementState, genericArgumentsState);

if (!type.IsValueType && state != NullabilityState.Unknown)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to add !type.IsValueType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API returns NullabilityState.NotNull for non-nullable value types, even if nullability is not enabled (unknown context), the same should happen for generics when the bound concrete type was a value type. Do not need to call TryLoadGenericMetaTypeNullability method to check if the meta definition of the member was a generic type and load the nullability info from there.

@steveharter
Copy link
Contributor

Should this be ported to 6.0?

@buyaa-n
Copy link
Contributor Author

buyaa-n commented Aug 30, 2021

Should this be ported to 6.0?

Yes it is, was planning to do so after the PR review done

/backport to release/6.0

@github-actions
Copy link
Contributor

@buyaa-n buyaa-n merged commit 4cf44d0 into dotnet:main Aug 30, 2021
@buyaa-n buyaa-n deleted the generic_value_tuple branch August 30, 2021 18:48
@buyaa-n
Copy link
Contributor Author

buyaa-n commented Aug 30, 2021

/backport to release/6.0

@github-actions
Copy link
Contributor

@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Example usage of NullabilityInfoContext fails on preview.7

3 participants