Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 11d32b3

Browse files
committed
Merge pull request #2176 from stephentoub/fix_linq_warnings
Fix System.Linq.Expressions.Tests build warnings and Console.WriteLine output
2 parents 3e441fb + a9423ae commit 11d32b3

File tree

3 files changed

+60
-464
lines changed

3 files changed

+60
-464
lines changed

src/System.Linq.Expressions/tests/Cast/IsNullableTests.cs

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -467,42 +467,7 @@ private static void VerifyGenericWithStructRestrictionIsObject<Ts>(Ts value) whe
467467
Expression.TypeIs(Expression.Constant(value, typeof(Ts)), typeof(object)),
468468
Enumerable.Empty<ParameterExpression>());
469469
Func<bool> f = e.Compile();
470-
471-
// compute the value with the expression tree
472-
bool etResult = default(bool);
473-
Exception etException = null;
474-
try
475-
{
476-
etResult = f();
477-
}
478-
catch (Exception ex)
479-
{
480-
etException = ex;
481-
}
482-
483-
// compute the value with regular IL
484-
bool csResult = default(bool);
485-
Exception csException = null;
486-
try
487-
{
488-
csResult = value is object;
489-
}
490-
catch (Exception ex)
491-
{
492-
csException = ex;
493-
}
494-
495-
// either both should have failed the same way or they should both produce the same result
496-
if (etException != null || csException != null)
497-
{
498-
Assert.NotNull(etException);
499-
Assert.NotNull(csException);
500-
Assert.Equal(csException.GetType(), etException.GetType());
501-
}
502-
else
503-
{
504-
Assert.Equal(csResult, etResult);
505-
}
470+
Assert.True(f());
506471
}
507472

508473
private static void VerifyGenericWithStructRestrictionIsValueType<Ts>(Ts value) where Ts : struct
@@ -512,42 +477,7 @@ private static void VerifyGenericWithStructRestrictionIsValueType<Ts>(Ts value)
512477
Expression.TypeIs(Expression.Constant(value, typeof(Ts)), typeof(ValueType)),
513478
Enumerable.Empty<ParameterExpression>());
514479
Func<bool> f = e.Compile();
515-
516-
// compute the value with the expression tree
517-
bool etResult = default(bool);
518-
Exception etException = null;
519-
try
520-
{
521-
etResult = f();
522-
}
523-
catch (Exception ex)
524-
{
525-
etException = ex;
526-
}
527-
528-
// compute the value with regular IL
529-
bool csResult = default(bool);
530-
Exception csException = null;
531-
try
532-
{
533-
csResult = value is ValueType;
534-
}
535-
catch (Exception ex)
536-
{
537-
csException = ex;
538-
}
539-
540-
// either both should have failed the same way or they should both produce the same result
541-
if (etException != null || csException != null)
542-
{
543-
Assert.NotNull(etException);
544-
Assert.NotNull(csException);
545-
Assert.Equal(csException.GetType(), etException.GetType());
546-
}
547-
else
548-
{
549-
Assert.Equal(csResult, etResult);
550-
}
480+
Assert.True(f());
551481
}
552482

553483
#endregion

0 commit comments

Comments
 (0)