Skip to content

Added another case in the switch block to handle the object returned by Mono which differs from the object returned by CoreCLR #115885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -657,6 +657,11 @@ public bool ParseNullableState(int index, ref NullabilityState state)
when index < args.Count && args[index].Value is byte elementB:
state = TranslateByte(elementB);
return true;
#if MONO
case byte[] ba when index < ba.Length:
state = TranslateByte(ba[index]);
return true;
#endif
default:
return false;
}
Original file line number Diff line number Diff line change
@@ -50,6 +50,57 @@ public void FieldTest(string fieldName, NullabilityState readState, NullabilityS
Assert.Null(nullability.ElementType);
}

public class FI_FieldArray
{
public int[] intArray;
public object?[] objectArray;
public string?[] stringArray;
}

public class FI_GenericClassField<T>
{
public object?[] objectArray;
public T? genparamField;
public T?[] gparrayField;
}

public static IEnumerable<object[]> FieldArrayTestData()
{
yield return new object[] { "objectArray", NullabilityState.NotNull, NullabilityState.NotNull, typeof(object[]) };
yield return new object[] { "stringArray", NullabilityState.NotNull, NullabilityState.NotNull, typeof(string[]) };
}

[Theory]
[MemberData(nameof(FieldArrayTestData))]
public void FieldArrayTest(string fieldName, NullabilityState readState, NullabilityState writeState, Type type)
{
FieldInfo field = typeof(FI_FieldArray).GetField(fieldName, flags);
NullabilityInfo nullability = nullabilityContext.Create(field);
Assert.Equal(readState, nullability.ReadState);
Assert.Equal(writeState, nullability.WriteState);
Assert.Equal(type, nullability.Type);
Assert.Empty(nullability.GenericTypeArguments);
}

public static IEnumerable<object[]> GenericArrayFieldTypeTestData()
{
yield return new object[] { "objectArray", NullabilityState.NotNull, NullabilityState.NotNull, typeof(object[]) };
yield return new object[] { "genparamField", NullabilityState.NotNull, NullabilityState.NotNull, typeof(int) };
yield return new object[] { "gparrayField", NullabilityState.NotNull, NullabilityState.NotNull, typeof(int[]) };
}

[Theory]
[MemberData(nameof(GenericArrayFieldTypeTestData))]
public void GenericArrayFieldTypeTest(string fieldName, NullabilityState readState, NullabilityState writeState, Type type)
{
FieldInfo field = typeof(FI_GenericClassField<int>).GetField(fieldName, flags)!;
NullabilityInfo nullability = nullabilityContext.Create(field);
Assert.Equal(readState, nullability.ReadState);
Assert.Equal(writeState, nullability.WriteState);
Assert.Equal(type, nullability.Type);
Assert.Empty(nullability.GenericTypeArguments);
}

public static IEnumerable<object[]> EventTestData()
{
yield return new object[] { "EventNullable", NullabilityState.Nullable, NullabilityState.Nullable, typeof(EventHandler) };
Loading
Oops, something went wrong.