Browse Source

#2050: Add additional test where the integer field is nested in a struct field.

pull/2113/head
Daniel Grunwald 5 years ago
parent
commit
102ddcadc7
  1. 27
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/NullableTests.cs

27
ICSharpCode.Decompiler.Tests/TestCases/Correctness/NullableTests.cs

@ -27,9 +27,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
AvoidLifting(); AvoidLifting();
BitNot(); BitNot();
FieldAccessOrderOfEvaluation(null); FieldAccessOrderOfEvaluation(null);
FieldAccessOrderOfEvaluationWithStruct(null);
ArrayAccessOrderOfEvaluation(); ArrayAccessOrderOfEvaluation();
} }
struct SomeStruct
{
public int IntField;
}
static void AvoidLifting() static void AvoidLifting()
{ {
Console.WriteLine("MayThrow:"); Console.WriteLine("MayThrow:");
@ -113,6 +119,27 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
} }
} }
SomeStruct structField;
static void FieldAccessOrderOfEvaluationWithStruct(NullableTests c)
{
Console.WriteLine("GetInt, then NRE (with struct):");
try {
c.structField.IntField = GetValue<int>();
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
Console.WriteLine("NRE before GetInt (with struct):");
try {
#if CS60
ref SomeStruct s = ref c.structField;
s.IntField = GetValue<int>();
#endif
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
static T[] GetArray<T>() static T[] GetArray<T>()
{ {
Console.WriteLine("GetArray"); Console.WriteLine("GetArray");

Loading…
Cancel
Save