diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs index 3202766415d..01abb10bb82 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs @@ -72,7 +72,7 @@ public override Expression Visit(Expression expression) } default: - throw new InvalidOperationException("IMPOSSIBLE"); + throw new UnreachableException(); } var updatedInExpression = inValues.Count > 0 diff --git a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs index f9c20410d79..9a2e955f2bd 100644 --- a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs @@ -282,7 +282,7 @@ or ExpressionType.LessThan { ExpressionType.Equal => inExpression, ExpressionType.NotEqual => _sqlExpressionFactory.Not(inExpression), - _ => throw new InvalidOperationException("IMPOSSIBLE") + _ => throw new UnreachableException() }; } } diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index c57dc400e1d..1e4abb0ff87 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -2700,7 +2700,7 @@ SelectExpression subquery => subquery.Projection.FirstOrDefault(p => p.Alias == columnExpression.Name) is { Expression.TypeMapping: null }, JoinExpressionBase - => throw new InvalidOperationException("Impossible: nested join"), + => throw new UnreachableException("Impossible: nested join"), // Any other table expression is considered a root (TableValuedFunctionExpression, ValuesExpression...) which *may* be // untyped, so we record the possible inference (note that TableValuedFunctionExpression may be typed, or not) diff --git a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs index 0bc92ae317b..3fbb25a484d 100644 --- a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs @@ -1453,7 +1453,7 @@ protected override Expression VisitSwitch(SwitchExpression switchExpression) newInstanceVariable); break; default: - throw new InvalidOperationException("IMPOSSIBLE"); + throw new UnreachableException(); } var managerVariable = Variable(typeof(Utf8JsonReaderManager), "jsonReaderManager"); diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs index 092e1b225da..82bea2dd9c7 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs @@ -3256,7 +3256,7 @@ or ExpressionType.LessThan ExpressionType.GreaterThan => ExpressionType.LessThan, ExpressionType.GreaterThanOrEqual => ExpressionType.LessThanOrEqual, - _ => throw new InvalidOperationException("IMPOSSIBLE") + _ => throw new UnreachableException() }; return new SqlBinaryExpression( diff --git a/src/EFCore.Sqlite.Core/Update/Internal/SqliteModificationCommand.cs b/src/EFCore.Sqlite.Core/Update/Internal/SqliteModificationCommand.cs index d9cb33eab01..0a9299687de 100644 --- a/src/EFCore.Sqlite.Core/Update/Internal/SqliteModificationCommand.cs +++ b/src/EFCore.Sqlite.Core/Update/Internal/SqliteModificationCommand.cs @@ -61,7 +61,7 @@ protected override void ProcessSinglePropertyJsonUpdate(ref ColumnModificationPa { true => "true", false => "false", - _ => throw new Exception("IMPOSSIBLE") + _ => throw new UnreachableException() } }; diff --git a/src/Shared/Check.cs b/src/Shared/Check.cs index a59e081db29..2ebf5ec1fca 100644 --- a/src/Shared/Check.cs +++ b/src/Shared/Check.cs @@ -112,12 +112,12 @@ public static void DebugAssert([DoesNotReturnIf(false)] bool condition, string m { if (!condition) { - throw new Exception($"Check.DebugAssert failed: {message}"); + throw new UnreachableException($"Check.DebugAssert failed: {message}"); } } [Conditional("DEBUG")] [DoesNotReturn] public static void DebugFail(string message) - => throw new Exception($"Check.DebugFail failed: {message}"); + => throw new UnreachableException($"Check.DebugFail failed: {message}"); }