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

Commit cd2f1cc

Browse files
committed
Fix several warnings in System.Linq.Expressions.Tests build
These warnings were being generated during the build: ``` SequenceTests\SequenceTests.cs(718,38): warning CS0168: The variable 'e' is declared but never used [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] SequenceTests\SequenceTests.cs(737,38): warning CS0168: The variable 'e' is declared but never used [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(2132,28): warning CS0183: The given expression is always of the provided ('Enum') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(2177,28): warning CS0183: The given expression is always of the provided ('object') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(3527,28): warning CS0183: The given expression is always of the provided ('object') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(3572,28): warning CS0183: The given expression is always of the provided ('ValueType') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(4427,28): warning CS0183: The given expression is always of the provided ('IEquatable<S>') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(4472,28): warning CS0183: The given expression is always of the provided ('object') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(4517,28): warning CS0183: The given expression is always of the provided ('ValueType') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(5012,28): warning CS0183: The given expression is always of the provided ('object') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsTests.cs(5057,28): warning CS0183: The given expression is always of the provided ('ValueType') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsNullableTests.cs(488,28): warning CS0183: The given expression is always of the provided ('object') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] Cast\IsNullableTests.cs(533,28): warning CS0183: The given expression is always of the provided ('ValueType') type [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] SequenceTests\SequenceTests.cs(2001,38): warning CS0168: The variable 'e' is declared but never used [corefx\src\System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj] ```
1 parent 6e5d09b commit cd2f1cc

File tree

3 files changed

+14
-399
lines changed

3 files changed

+14
-399
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)