From 04b333ce863379b4de095c8f50d9ce7fde5520bd Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 7 Feb 2017 14:26:12 -0800 Subject: [PATCH] Pass along the value that was unexpected when we encounter one. --- .../Portable/Syntax/LambdaUtilities.vb | 4 +- .../CSharpBraceCompletionSessionProvider.cs | 4 +- .../IEditorInlineRenameService.cs | 2 +- ...lineRenameSession.OpenTextBufferManager.cs | 2 +- .../InlineRename/Taggers/RenameTagger.cs | 2 +- .../FileSystem/FileSystemCompletionHelper.cs | 2 +- .../Presentation/ClassificationTags.cs | 2 +- ...sualBasicBraceCompletionSessionProvider.vb | 5 +-- .../SimplifyTypeNamesCodeFixProvider.cs | 2 +- .../CSharpEditAndContinueAnalyzer.cs | 8 ++-- .../StatementSyntaxComparer.cs | 4 +- .../Suppression/SuppressionHelpers.cs | 2 +- ...tractMoveTypeService.MoveTypeCodeAction.cs | 8 ++-- .../Core/Portable/Common/TaggedText.cs | 2 +- .../AbstractOverrideCompletionProvider.cs | 2 +- .../Portable/Diagnostics/AnalyzerHelper.cs | 2 +- ...SimplifyTypeNamesDiagnosticAnalyzerBase.cs | 2 +- .../AbstractEditAndContinueAnalyzer.cs | 4 +- ...teParameterizedMemberService.CodeAction.cs | 2 +- ...aAsSourceService.WrappedNamedTypeSymbol.cs | 5 ++- ...ctQualifyMemberAccessDiagnosticAnalyzer.cs | 2 +- .../SolutionCrawler/WorkCoordinator.cs | 8 ++-- .../IncorrectExitContinueCodeFixProvider.vb | 4 +- .../SimplifyTypeNamesCodeFixProvider.vb | 2 +- .../RecommendationHelpers.vb | 2 +- ...RemoveUnnecessaryCastDiagnosticAnalyzer.vb | 4 +- .../VisualBasicEditAndContinueAnalyzer.vb | 12 +++--- .../VsENCRebuildableProjectImpl.cs | 2 +- .../Progression/GraphBuilder.cs | 2 +- .../VisualBasicProjectOptionsHelper.vb | 2 +- .../BaseParameterListSyntaxExtensions.cs | 4 +- .../TypeDeclarationSyntaxExtensions.cs | 40 +++++++++---------- .../FixAllOccurrences/FixAllState.cs | 2 +- .../Rules/BaseIndentationFormattingRule.cs | 2 +- .../TriviaEngine/AbstractTriviaFormatter.cs | 6 +-- .../ISymbolExtensions_Accessibility.cs | 6 +-- .../ReduceTokensCodeCleanupProvider.vb | 4 +- .../ExpressionGenerator.StringPiece.vb | 4 +- .../Extensions/MethodBaseSyntaxExtensions.vb | 3 +- .../Extensions/TypeBlockSyntaxExtensions.vb | 24 +++++------ 40 files changed, 100 insertions(+), 101 deletions(-) diff --git a/src/Compilers/VisualBasic/Portable/Syntax/LambdaUtilities.vb b/src/Compilers/VisualBasic/Portable/Syntax/LambdaUtilities.vb index 988a58c6e10..4ff2c292174 100644 --- a/src/Compilers/VisualBasic/Portable/Syntax/LambdaUtilities.vb +++ b/src/Compilers/VisualBasic/Portable/Syntax/LambdaUtilities.vb @@ -88,7 +88,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Return If(oldJoinCondition.Left Is oldBody, GetJoinLeftLambdaBody(newJoinClause), GetJoinRightLambdaBody(newJoinClause)) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(oldLambda.Kind) End Select End Function @@ -587,7 +587,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Return DirectCast(clause, JoinClauseSyntax).JoinedVariables Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(clause.Kind) End Select End Function diff --git a/src/EditorFeatures/CSharp/AutomaticCompletion/CSharpBraceCompletionSessionProvider.cs b/src/EditorFeatures/CSharp/AutomaticCompletion/CSharpBraceCompletionSessionProvider.cs index 4ffe6fd3229..231390b5ada 100644 --- a/src/EditorFeatures/CSharp/AutomaticCompletion/CSharpBraceCompletionSessionProvider.cs +++ b/src/EditorFeatures/CSharp/AutomaticCompletion/CSharpBraceCompletionSessionProvider.cs @@ -80,9 +80,9 @@ protected override IEditorBraceCompletionSession CreateEditorSession(Document do case BraceCompletionSessionProvider.Parenthesis.OpenCharacter: return new ParenthesisCompletionSession(syntaxFactsService); case BraceCompletionSessionProvider.SingleQuote.OpenCharacter: return new CharLiteralCompletionSession(syntaxFactsService); case BraceCompletionSessionProvider.LessAndGreaterThan.OpenCharacter: return new LessAndGreaterThanCompletionSession(syntaxFactsService); + default: + throw ExceptionUtilities.UnexpectedValue(openingBrace); } - - throw ExceptionUtilities.Unreachable; } } } diff --git a/src/EditorFeatures/Core/Implementation/InlineRename/IEditorInlineRenameService.cs b/src/EditorFeatures/Core/Implementation/InlineRename/IEditorInlineRenameService.cs index bd2fd28f35f..7d006aaa970 100644 --- a/src/EditorFeatures/Core/Implementation/InlineRename/IEditorInlineRenameService.cs +++ b/src/EditorFeatures/Core/Implementation/InlineRename/IEditorInlineRenameService.cs @@ -67,7 +67,7 @@ private static InlineRenameReplacementKind GetReplacementKind(RelatedLocation lo return InlineRenameReplacementKind.UnresolvedConflict; default: case RelatedLocationType.PossiblyResolvableConflict: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(location.Type); } } } diff --git a/src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.OpenTextBufferManager.cs b/src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.OpenTextBufferManager.cs index 0128fd59406..7a7af903349 100644 --- a/src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.OpenTextBufferManager.cs +++ b/src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.OpenTextBufferManager.cs @@ -553,7 +553,7 @@ private static RenameSpanKind GetRenameSpanKind(InlineRenameReplacementKind kind return RenameSpanKind.Complexified; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(kind); } } diff --git a/src/EditorFeatures/Core/Implementation/InlineRename/Taggers/RenameTagger.cs b/src/EditorFeatures/Core/Implementation/InlineRename/Taggers/RenameTagger.cs index da4d2c22861..78301373761 100644 --- a/src/EditorFeatures/Core/Implementation/InlineRename/Taggers/RenameTagger.cs +++ b/src/EditorFeatures/Core/Implementation/InlineRename/Taggers/RenameTagger.cs @@ -30,7 +30,7 @@ protected override bool TryCreateTagSpan(SnapshotSpan span, RenameSpanKind type, tagKind = FixupTag.Instance; break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(type); } tagSpan = new TagSpan(span, tagKind); diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/FileSystem/FileSystemCompletionHelper.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/FileSystem/FileSystemCompletionHelper.cs index 3d7af0a4249..e334b9a4a88 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/FileSystem/FileSystemCompletionHelper.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/FileSystem/FileSystemCompletionHelper.cs @@ -161,7 +161,7 @@ private ImmutableArray GetFilesAndDirectories(string path, strin break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(pathKind); } return result.ToImmutableAndFree(); diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/ClassificationTags.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/ClassificationTags.cs index 5692e24b404..54d3b188d10 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/ClassificationTags.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/ClassificationTags.cs @@ -69,7 +69,7 @@ public static string GetClassificationTypeName(string textTag) return ClassificationTypeNames.Text; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(textTag); } } } diff --git a/src/EditorFeatures/VisualBasic/AutomaticCompletion/VisualBasicBraceCompletionSessionProvider.vb b/src/EditorFeatures/VisualBasic/AutomaticCompletion/VisualBasicBraceCompletionSessionProvider.vb index a8a18994b4d..567634ffc07 100644 --- a/src/EditorFeatures/VisualBasic/AutomaticCompletion/VisualBasicBraceCompletionSessionProvider.vb +++ b/src/EditorFeatures/VisualBasic/AutomaticCompletion/VisualBasicBraceCompletionSessionProvider.vb @@ -63,10 +63,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.AutomaticCompletion Else Return New StringLiteralCompletionSession(syntaxFactsService) End If - + Case Else + Throw ExceptionUtilities.UnexpectedValue(openingBrace) End Select - - Throw ExceptionUtilities.Unreachable End Function End Class End Namespace diff --git a/src/Features/CSharp/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs b/src/Features/CSharp/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs index 677af21eafa..2961e81906b 100644 --- a/src/Features/CSharp/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs @@ -101,7 +101,7 @@ internal static string GetCodeActionId(string diagnosticId, string nodeText) return CSharpFeaturesResources.Remove_this_qualification; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(diagnosticId); } } diff --git a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs index 1dd45449318..987a2197639 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs @@ -1725,7 +1725,7 @@ public void ClassifyEdit() return; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(_kind); } } @@ -1793,7 +1793,7 @@ private void ClassifyReorder(SyntaxNode oldNode, SyntaxNode newNode) return; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(newNode.Kind()); } } @@ -2209,7 +2209,7 @@ private void ClassifyUpdate(SyntaxNode oldNode, SyntaxNode newNode) return; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(newNode.Kind()); } } @@ -3039,7 +3039,7 @@ private static ExpressionSyntax GetExpressionFromStatementPart(SyntaxNode statem return ((ReturnStatementSyntax)statement).Expression; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(statement.Kind()); } } diff --git a/src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs b/src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs index c3f3cf27057..78c3d74277f 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs @@ -740,7 +740,7 @@ private static void GetLambdaParts(SyntaxNode lambda, out IEnumerable _title; @@ -65,9 +65,9 @@ private Editor GetEditor(CancellationToken cancellationToken) return new RenameTypeEditor(_service, _state, _fileName, cancellationToken); case OperationKind.RenameFile: return new RenameFileEditor(_service, _state, _fileName, cancellationToken); + default: + throw ExceptionUtilities.UnexpectedValue(_operationKind); } - - throw ExceptionUtilities.Unreachable; } internal override bool PerformFinalApplicabilityCheck => true; diff --git a/src/Features/Core/Portable/Common/TaggedText.cs b/src/Features/Core/Portable/Common/TaggedText.cs index 9ea789860a4..f3ee7980342 100644 --- a/src/Features/Core/Portable/Common/TaggedText.cs +++ b/src/Features/Core/Portable/Common/TaggedText.cs @@ -139,7 +139,7 @@ public static string ToClassificationTypeName(this string taggedTextTag) return ClassificationTypeNames.Text; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(taggedTextTag); } } diff --git a/src/Features/Core/Portable/Completion/Providers/AbstractOverrideCompletionProvider.cs b/src/Features/Core/Portable/Completion/Providers/AbstractOverrideCompletionProvider.cs index e8ea96a65fa..3f41d02b286 100644 --- a/src/Features/Core/Portable/Completion/Providers/AbstractOverrideCompletionProvider.cs +++ b/src/Features/Core/Portable/Completion/Providers/AbstractOverrideCompletionProvider.cs @@ -112,7 +112,7 @@ protected ITypeSymbol GetReturnType(ISymbol symbol) case SymbolKind.Property: return ((IPropertySymbol)symbol).Type; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(symbol.Kind); } } } diff --git a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs index 3150bf33f05..c5529b2a811 100644 --- a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs +++ b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs @@ -85,7 +85,7 @@ public static ReportDiagnostic MapSeverityToReport(this DiagnosticSeverity sever case DiagnosticSeverity.Error: return ReportDiagnostic.Error; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(severity); } } diff --git a/src/Features/Core/Portable/Diagnostics/Analyzers/SimplifyTypeNamesDiagnosticAnalyzerBase.cs b/src/Features/Core/Portable/Diagnostics/Analyzers/SimplifyTypeNamesDiagnosticAnalyzerBase.cs index bd1eb042be4..cda34277c5b 100644 --- a/src/Features/Core/Portable/Diagnostics/Analyzers/SimplifyTypeNamesDiagnosticAnalyzerBase.cs +++ b/src/Features/Core/Portable/Diagnostics/Analyzers/SimplifyTypeNamesDiagnosticAnalyzerBase.cs @@ -147,7 +147,7 @@ protected bool TrySimplifyTypeNameExpression(SemanticModel model, SyntaxNode nod break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(diagnosticId); } if (descriptor == null) diff --git a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs index 0d9a1321d78..e254c56be1c 100644 --- a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs +++ b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs @@ -2117,7 +2117,7 @@ public ConstructorEdit(INamedTypeSymbol oldType) { case EditKind.Move: // Move is always a Rude Edit. - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(edit.Kind); case EditKind.Delete: { @@ -2382,7 +2382,7 @@ public ConstructorEdit(INamedTypeSymbol oldType) break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(edit.Kind); } semanticEdits.Add(new SemanticEdit(editKind, oldSymbol, newSymbol, syntaxMapOpt, preserveLocalVariables: syntaxMapOpt != null)); diff --git a/src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs b/src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs index ccee7fe39a1..b26b86b8de9 100644 --- a/src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs +++ b/src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs @@ -55,7 +55,7 @@ private partial class GenerateParameterizedMemberCodeAction : CodeAction case MethodGenerationKind.ExplicitConversion: return _service.GetExplicitConversionDisplayText(_state); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(state.MethodGenerationKind); } } diff --git a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs index de88ffa2ad1..80056d64221 100644 --- a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs +++ b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs @@ -55,9 +55,10 @@ private static ISymbol WrapMember(ISymbol m, bool canImplementImplicitly, IDocum case SymbolKind.Property: return new WrappedPropertySymbol((IPropertySymbol)m, canImplementImplicitly, docCommentFormattingService); - } - throw ExceptionUtilities.Unreachable; + default: + throw ExceptionUtilities.UnexpectedValue(m.Kind); + } } public bool IsAnonymousType => _symbol.IsAnonymousType; diff --git a/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs b/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs index 5e6295d4faa..812a272c4fc 100644 --- a/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs @@ -113,7 +113,7 @@ internal static PerLanguageOption> GetApplicableOptionFrom case SymbolKind.Event: return CodeStyleOptions.QualifyEventAccess; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(symbolKind); } } } diff --git a/src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.cs b/src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.cs index d9b99472280..c30fd33616b 100644 --- a/src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.cs +++ b/src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.cs @@ -248,7 +248,7 @@ private void ProcessEvents(WorkspaceChangeEventArgs args, IAsyncToken asyncToken ProcessDocumentEvent(args, asyncToken); break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(args.Kind); } } @@ -290,7 +290,7 @@ private void ProcessDocumentEvent(WorkspaceChangeEventArgs e, IAsyncToken asyncT break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(e.Kind); } } @@ -310,7 +310,7 @@ private void ProcessProjectEvent(WorkspaceChangeEventArgs e, IAsyncToken asyncTo EnqueueEvent(e.OldSolution, e.NewSolution, e.ProjectId, asyncToken); break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(e.Kind); } } @@ -333,7 +333,7 @@ private void ProcessSolutionEvent(WorkspaceChangeEventArgs e, IAsyncToken asyncT EnqueueEvent(e.OldSolution, e.NewSolution, asyncToken); break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(e.Kind); } } diff --git a/src/Features/VisualBasic/Portable/CodeFixes/IncorrectExitContinue/IncorrectExitContinueCodeFixProvider.vb b/src/Features/VisualBasic/Portable/CodeFixes/IncorrectExitContinue/IncorrectExitContinueCodeFixProvider.vb index 1d524a69090..8a082c3e50a 100644 --- a/src/Features/VisualBasic/Portable/CodeFixes/IncorrectExitContinue/IncorrectExitContinueCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/CodeFixes/IncorrectExitContinue/IncorrectExitContinueCodeFixProvider.vb @@ -267,7 +267,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.IncorrectExitContinue Case SyntaxKind.GetAccessorBlock, SyntaxKind.SetAccessorBlock Return SyntaxKind.ExitPropertyStatement Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(blockKind) End Select End Function @@ -284,7 +284,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.IncorrectExitContinue Case SyntaxKind.WhileBlock Return SyntaxKind.ContinueWhileStatement Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(blockKind) End Select End Function diff --git a/src/Features/VisualBasic/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.vb b/src/Features/VisualBasic/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.vb index 4231cca7ff0..ee9f485e817 100644 --- a/src/Features/VisualBasic/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.vb @@ -88,7 +88,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.SimplifyTypeNames Return String.Format(VBFeaturesResources.Simplify_member_access_0, nodeText) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(simplifyDiagnosticId) End Select End Function diff --git a/src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/RecommendationHelpers.vb b/src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/RecommendationHelpers.vb index 0ed3a912396..b60216469e2 100644 --- a/src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/RecommendationHelpers.vb +++ b/src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/RecommendationHelpers.vb @@ -51,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders arrayCreation.Initializer.CloseBraceToken, asNewClause.Type.GetLastToken(includeZeroWidth:=True)) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(asNewClause.NewExpression.Kind) End Select Return token = lastToken diff --git a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.vb b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.vb index aa86a17c5a3..c1f108c9c17 100644 --- a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.vb @@ -30,7 +30,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Diagnostics.RemoveUnnecessaryCast Case SyntaxKind.PredefinedCastExpression Return DirectCast(node, PredefinedCastExpressionSyntax).IsUnnecessaryCast(model, assumeCallKeyword:=True, cancellationToken:=cancellationToken) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select End Function @@ -41,7 +41,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Diagnostics.RemoveUnnecessaryCast Case SyntaxKind.PredefinedCastExpression Return DirectCast(node, PredefinedCastExpressionSyntax).Keyword.Span Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select End Function End Class diff --git a/src/Features/VisualBasic/Portable/EditAndContinue/VisualBasicEditAndContinueAnalyzer.vb b/src/Features/VisualBasic/Portable/EditAndContinue/VisualBasicEditAndContinueAnalyzer.vb index 1499657ef89..4b2b269fd73 100644 --- a/src/Features/VisualBasic/Portable/EditAndContinue/VisualBasicEditAndContinueAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/EditAndContinue/VisualBasicEditAndContinueAnalyzer.vb @@ -1437,7 +1437,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue endToken = header.DeclarationKeyword Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(header.Kind) End Select End If @@ -1786,7 +1786,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue Return Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(_kind) End Select End Sub @@ -1865,7 +1865,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue Return Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(newNode.Kind) End Select End Sub @@ -2167,7 +2167,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue Return Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(oldNode.Kind) End Select End Sub @@ -2339,7 +2339,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue Return Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(newNode.Kind) End Select End Sub @@ -3093,7 +3093,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue Return DirectCast(statement, ReturnStatementSyntax).Expression Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(statement.Kind()) End Select End Function diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs index bed088270c8..980253103d0 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs @@ -859,7 +859,7 @@ public int GetENCBuildState(ShellInterop.ENC_BUILD_STATE[] pENCBuildState) break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(_lastEditSessionSummary); } log.Write("EnC state of '{0}' queried: {1}{2}", diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs index ffe0c3f9b0c..bdda5c345c6 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs @@ -589,7 +589,7 @@ private static async Task GetOrCreateNodeForNamedTypeAsync(Graph grap break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(namedType.TypeKind); } node[DgmlNodeProperties.Icon] = IconHelper.GetIconName(iconGroupName, namedType.DeclaredAccessibility); diff --git a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectOptionsHelper.vb b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectOptionsHelper.vb index e2b5553abd4..6bfed4965a8 100644 --- a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectOptionsHelper.vb +++ b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectOptionsHelper.vb @@ -267,7 +267,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim Return ReportDiagnostic.Error Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(level) End Select End Function diff --git a/src/Workspaces/CSharp/Portable/Extensions/BaseParameterListSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/BaseParameterListSyntaxExtensions.cs index 68ae6e63515..ff29b1e721b 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/BaseParameterListSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/BaseParameterListSyntaxExtensions.cs @@ -20,9 +20,9 @@ internal static class BaseParameterListSyntaxExtensions return ((BracketedParameterListSyntax)parameterList).WithParameters(parameters); case SyntaxKind.ParameterList: return ((ParameterListSyntax)parameterList).WithParameters(parameters); + default: + throw ExceptionUtilities.UnexpectedValue(parameterList.Kind()); } - - throw ExceptionUtilities.Unreachable; } } } diff --git a/src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs index 02687a895ba..49e4788c374 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs @@ -26,9 +26,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).AddMembers(members); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).AddMembers(members); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithMembers( @@ -42,9 +42,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithMembers(members); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithMembers(members); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithAttributeLists( @@ -58,9 +58,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithAttributeLists(attributes); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithAttributeLists(attributes); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithIdentifier( @@ -74,9 +74,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithIdentifier(identifier); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithIdentifier(identifier); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithModifiers( @@ -90,9 +90,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithModifiers(modifiers); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithModifiers(modifiers); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithTypeParameterList( @@ -106,9 +106,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithTypeParameterList(list); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithTypeParameterList(list); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithBaseList( @@ -122,9 +122,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithBaseList(list); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithBaseList(list); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithConstraintClauses( @@ -138,9 +138,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithConstraintClauses(constraintClauses); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithConstraintClauses(constraintClauses); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithOpenBraceToken( @@ -154,9 +154,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithOpenBraceToken(openBrace); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithOpenBraceToken(openBrace); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static TypeDeclarationSyntax WithCloseBraceToken( @@ -170,9 +170,9 @@ internal static class TypeDeclarationSyntaxExtensions return ((InterfaceDeclarationSyntax)node).WithCloseBraceToken(closeBrace); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithCloseBraceToken(closeBrace); + default: + throw ExceptionUtilities.UnexpectedValue(node.Kind()); } - - throw ExceptionUtilities.Unreachable; } public static IList GetInsertionIndices(this TypeDeclarationSyntax destination, CancellationToken cancellationToken) diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs index a529942a91b..5389493be48 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs @@ -185,7 +185,7 @@ internal string GetDefaultFixAllTitle() return string.Format(WorkspacesResources.Fix_all_0_in_Solution, diagnosticId); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(this.Scope); } } diff --git a/src/Workspaces/Core/Portable/Formatting/Rules/BaseIndentationFormattingRule.cs b/src/Workspaces/Core/Portable/Formatting/Rules/BaseIndentationFormattingRule.cs index f441fbfc6b1..114bd8fe490 100644 --- a/src/Workspaces/Core/Portable/Formatting/Rules/BaseIndentationFormattingRule.cs +++ b/src/Workspaces/Core/Portable/Formatting/Rules/BaseIndentationFormattingRule.cs @@ -122,7 +122,7 @@ private IndentBlockOperation CloneAndAdjustFormattingOperation(IndentBlockOperat case IndentBlockOption.AbsolutePosition: return FormattingOperations.CreateIndentBlockOperation(operation.StartToken, operation.EndToken, AdjustTextSpan(operation.TextSpan), operation.IndentationDeltaOrPosition, operation.Option); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(operation.Option); } } diff --git a/src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs b/src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs index ebbf5e6451b..90ab1bce99a 100644 --- a/src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs +++ b/src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs @@ -404,7 +404,7 @@ private LineColumnRule GetOverallLineColumnRuleBetween(SyntaxTrivia trivia1, Lin break; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(lineOperation.Option); } } @@ -556,7 +556,7 @@ private bool FirstLineBlank() return existingWhitespaceBetween.Spaces; default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(rule.IndentationOperation); } } @@ -570,7 +570,7 @@ private bool FirstLineBlank() return Math.Max(rule.Spaces, 0); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(rule.SpaceOperation); } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs index c945a7bc523..a2421041aa4 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs @@ -150,7 +150,7 @@ internal static partial class ISymbolExtensions return IsMemberAccessible(symbol.ContainingType, symbol.DeclaredAccessibility, within, throughTypeOpt, out failedThroughTypeCheck); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(symbol.Kind); } } @@ -221,7 +221,7 @@ private static bool IsNamedTypeAccessible(INamedTypeSymbol type, ISymbol within) return withinAssembly.IsSameAssemblyOrHasFriendAccessTo(assembly); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(declaredAccessibility); } } @@ -307,7 +307,7 @@ private static bool IsNamedTypeAccessible(INamedTypeSymbol type, ISymbol within) return IsProtectedSymbolAccessible(withinNamedType, withinAssembly, throughTypeOpt, originalContainingType, out failedThroughTypeCheck); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(declaredAccessibility); } } diff --git a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/ReduceTokensCodeCleanupProvider.vb b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/ReduceTokensCodeCleanupProvider.vb index 1fa009fe179..c5e33fe6181 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/ReduceTokensCodeCleanupProvider.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/ReduceTokensCodeCleanupProvider.vb @@ -278,7 +278,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers Dim asLong = CType(ConvertToULong(value), Long) Return "&B" + Convert.ToString(asLong, 2) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(base) End Select End Function @@ -296,7 +296,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers Case SyntaxKind.IntegerLiteralToken Return token.CopyAnnotationsTo(SyntaxFactory.IntegerLiteralToken(leading, newValueString, token.GetBase().Value, token.GetTypeCharacter(), DirectCast(newValue, ULong), trailing)) Case Else - Throw ExceptionUtilities.Unreachable + Throw ExceptionUtilities.UnexpectedValue(token.Kind) End Select End Function diff --git a/src/Workspaces/VisualBasic/Portable/CodeGeneration/ExpressionGenerator.StringPiece.vb b/src/Workspaces/VisualBasic/Portable/CodeGeneration/ExpressionGenerator.StringPiece.vb index b1012e6fc54..901fa990304 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeGeneration/ExpressionGenerator.StringPiece.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeGeneration/ExpressionGenerator.StringPiece.vb @@ -68,9 +68,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Return GenerateStringConstantExpression("vbTab") Case StringPieceKind.VerticalTab Return GenerateStringConstantExpression("vbVerticalTab") + Case Else + Throw ExceptionUtilities.UnexpectedValue(Me.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function Private Shared Function GenerateStringConstantExpression(name As String) As MemberAccessExpressionSyntax diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/MethodBaseSyntaxExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/MethodBaseSyntaxExtensions.vb index ddae63e3e9a..4859e134a60 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/MethodBaseSyntaxExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/MethodBaseSyntaxExtensions.vb @@ -38,5 +38,4 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Throw ExceptionUtilities.Unreachable End Function End Module - -End Namespace +End Namespace \ No newline at end of file diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb index 537273775df..b158675f301 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb @@ -18,9 +18,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).WithInherits(list) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).WithInherits(list) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function @@ -34,9 +34,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).WithImplements(list) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).WithImplements(list) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function @@ -50,9 +50,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).AddMembers(members) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).AddMembers(members) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function @@ -66,9 +66,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).WithMembers(members) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).WithMembers(members) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function @@ -82,9 +82,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).WithBlockStatement(DirectCast([begin], StructureStatementSyntax)) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).WithBlockStatement(DirectCast([begin], ClassStatementSyntax)) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function @@ -98,9 +98,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return DirectCast(node, StructureBlockSyntax).WithEndBlockStatement([end]) Case SyntaxKind.ClassBlock Return DirectCast(node, ClassBlockSyntax).WithEndBlockStatement([end]) + Case Else + Throw ExceptionUtilities.UnexpectedValue(node.Kind) End Select - - Throw ExceptionUtilities.Unreachable End Function -- GitLab