From 389e2c62e8cbbf5909c089ce73191ffd64271fe9 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 15:25:49 -0700 Subject: [PATCH 01/63] Add formatting options --- .editorconfig | 9 +++++++++ src/Compilers/.editorconfig | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/.editorconfig b/.editorconfig index 7400f6df98b17..e2f889b6b813e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -61,6 +61,10 @@ dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion +# Whitespace options +dotnet_style_allow_multiple_blank_lines_experimental = false:warning +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning + # Non-private static fields are PascalCase dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields @@ -182,6 +186,11 @@ csharp_indent_case_contents_when_block = true csharp_indent_switch_labels = true csharp_indent_labels = flush_left +# Whitespace options +csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning + # Prefer "var" everywhere csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion diff --git a/src/Compilers/.editorconfig b/src/Compilers/.editorconfig index e4be403701abf..2c4b236fe7b4b 100644 --- a/src/Compilers/.editorconfig +++ b/src/Compilers/.editorconfig @@ -12,8 +12,17 @@ dotnet_diagnostic.RS0101.severity = none # RS0102: Braces must not have blank lines between them dotnet_diagnostic.RS0102.severity = none +# Whitespace options +dotnet_style_allow_multiple_blank_lines_experimental = true:none +dotnet_style_allow_statement_immediately_after_block_experimental = true:none + # CSharp code style settings: [*.cs] csharp_style_var_for_built_in_types = false:none csharp_style_var_when_type_is_apparent = true:none csharp_style_var_elsewhere = false:none + +# Whitespace options +csharp_style_allow_embedded_statements_on_same_line_experimental = true:none +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:none +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:none From 7af44bdb92cc90d5729d899039c7f479160bd8a9 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 15:58:58 -0700 Subject: [PATCH 02/63] Update codestyle version --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index a703120f5e1a7..b2bf19dc7e13a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -30,7 +30,7 @@ 3.3.3-beta1.21105.3 6.0.0-preview1.21054.10 1.0.1-beta1.20623.3 - 3.9.0 + 3.10.0-3.final 16.10.44 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 From 1f16b54ab73a9d1b7166913f37bfa1fa7b6bd40d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:16:03 -0700 Subject: [PATCH 03/63] Update version --- eng/Versions.props | 2 +- .../CSharp/Impl/Options/Formatting/StyleViewModel.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index b2bf19dc7e13a..bc3133873a92d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -28,7 +28,7 @@ 3.3.3-beta1.21105.3 - 6.0.0-preview1.21054.10 + 6.0.0-preview6.21281.1 1.0.1-beta1.20623.3 3.10.0-3.final 16.10.44 diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs index 0ff0e414add14..82a0d4301dc2a 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs @@ -2033,6 +2033,14 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.AllowBlankLineAfterColonInConstructorInitializer, CSharpVSResources.Allow_bank_line_after_colon_in_constructor_initializer, s_allow_bank_line_after_colon_in_constructor_initializer_true, s_allow_bank_line_after_colon_in_constructor_initializer_false, this, optionStore, newLinePreferencesGroupTitle)); } + class Foo + { + public Foo() : + base() + { + } + } + private void AddParenthesesOptions(OptionStore optionStore) { AddParenthesesOption( From 12c50f126a92b05544ce193b0e7a983051249918 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:29:15 -0700 Subject: [PATCH 04/63] enable --- .editorconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.editorconfig b/.editorconfig index e2f889b6b813e..44101cefe5110 100644 --- a/.editorconfig +++ b/.editorconfig @@ -65,6 +65,11 @@ dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_allow_multiple_blank_lines_experimental = false:warning dotnet_style_allow_statement_immediately_after_block_experimental = false:warning +# dotnet_style_allow_multiple_blank_lines_experimental +dotnet_diagnostic.IDE2000.severity = warning +# dotnet_style_allow_statement_immediately_after_block_experimental +dotnet_diagnostic.IDE2003.severity = warning + # Non-private static fields are PascalCase dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields @@ -191,6 +196,17 @@ csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning +# csharp_style_allow_embedded_statements_on_same_line_experimental +dotnet_diagnostic.IDE2001.severity = warning +# csharp_style_allow_blank_lines_between_consecutive_braces_experimental +dotnet_diagnostic.IDE2002.severity = warning +# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental +dotnet_diagnostic.IDE2004.severity = warning + +# IDE0059: MultipleBlankLinesDiagnosticId +dotnet_diagnostic.IDE0059.severity = warning + + # Prefer "var" everywhere csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion From 55d574c366c8be3eb9c4d9dc55ca44f72012ef40 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:30:53 -0700 Subject: [PATCH 05/63] keep together --- .editorconfig | 18 ++++++++---------- .../Impl/Options/Formatting/StyleViewModel.cs | 8 -------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.editorconfig b/.editorconfig index 44101cefe5110..2b7c2a43913cf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -63,13 +63,12 @@ dotnet_style_explicit_tuple_names = true:suggestion # Whitespace options dotnet_style_allow_multiple_blank_lines_experimental = false:warning -dotnet_style_allow_statement_immediately_after_block_experimental = false:warning - -# dotnet_style_allow_multiple_blank_lines_experimental dotnet_diagnostic.IDE2000.severity = warning -# dotnet_style_allow_statement_immediately_after_block_experimental + +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning dotnet_diagnostic.IDE2003.severity = warning + # Non-private static fields are PascalCase dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields @@ -193,16 +192,15 @@ csharp_indent_labels = flush_left # Whitespace options csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning -csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning -csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning - -# csharp_style_allow_embedded_statements_on_same_line_experimental dotnet_diagnostic.IDE2001.severity = warning -# csharp_style_allow_blank_lines_between_consecutive_braces_experimental + +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning dotnet_diagnostic.IDE2002.severity = warning -# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental + +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning dotnet_diagnostic.IDE2004.severity = warning + # IDE0059: MultipleBlankLinesDiagnosticId dotnet_diagnostic.IDE0059.severity = warning diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs index 82a0d4301dc2a..0ff0e414add14 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs @@ -2033,14 +2033,6 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.AllowBlankLineAfterColonInConstructorInitializer, CSharpVSResources.Allow_bank_line_after_colon_in_constructor_initializer, s_allow_bank_line_after_colon_in_constructor_initializer_true, s_allow_bank_line_after_colon_in_constructor_initializer_false, this, optionStore, newLinePreferencesGroupTitle)); } - class Foo - { - public Foo() : - base() - { - } - } - private void AddParenthesesOptions(OptionStore optionStore) { AddParenthesesOption( From 24b767f0094e455cd0656f7734e8a758a7e6b9ee Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:43:03 -0700 Subject: [PATCH 06/63] Fix warning --- .../CompletionProviders/SymbolCompletionProviderTests.cs | 1 + .../Diagnostics/AddExplicitCast/AddExplicitCastTests.cs | 3 +++ .../CSharpTest/Diagnostics/Suppression/SuppressionTests.cs | 1 + src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs | 1 + .../InvocationExpressionSignatureHelpProviderTests.cs | 1 + .../SplitStringLiteralCommandHandlerTests.cs | 1 + 6 files changed, 8 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs index 01a35d5e86898..b2f7621ce799f 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs @@ -9576,6 +9576,7 @@ void goo() { await VerifyItemExistsAsync(markup, "Item" + i); } + await VerifyItemExistsAsync(markup, "ToString"); await VerifyItemIsAbsentAsync(markup, "Item1"); diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs index 76b210500ddf9..c959df4927171 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs @@ -2522,6 +2522,7 @@ public Test(string s, Base b, int i, params object[] list) : this(d : [||]b, s : var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(2, actions.Length); } + var expect_0 = @" class Program @@ -2671,6 +2672,7 @@ void M() var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(2, actions.Length); } + var expect_0 = @" class Program @@ -2746,6 +2748,7 @@ void M() var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(3, actions.Length); } + var expect_0 = @" class Program diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs index de59148fc6de0..0fc6908c7a5b2 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs @@ -927,6 +927,7 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, trivia.GetLocation())); } + break; } } diff --git a/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs b/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs index e14a8ea6bf880..e7d6f5af75de2 100644 --- a/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs +++ b/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs @@ -76,6 +76,7 @@ internal static async Task VerifyExpectedTextAsync(string intentName, string act { edit.Replace(change.Span.ToSpan(), change.NewText); } + edit.Apply(); Assert.Equal(expectedText, textBuffer.CurrentSnapshot.GetText()); diff --git a/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs b/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs index 6e676e6379bb9..bdad786acc55d 100644 --- a/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs @@ -2524,6 +2524,7 @@ void goo() expectedItems.Add(new SignatureHelpTestItem($"void C.M(object o)", currentParameterIndex: 0)); expectedItems.Add(new SignatureHelpTestItem($"void C.M(Action arg1, T arg2, bool flag)\r\n\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_contexts}", currentParameterIndex: 0)); } + await VerifyItemWithReferenceWorkerAsync(markup, expectedItems, hideAdvancedMembers: false); } } diff --git a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs index 92f503e11e5c5..48b8c995906dd 100644 --- a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs @@ -64,6 +64,7 @@ private static void TestWorker( { snapshotSpans.Add(selection.ToSnapshotSpan(originalSnapshot)); } + view.SetMultiSelection(snapshotSpans); var undoHistoryRegistry = workspace.GetService(); From f9ee81191fdebd5477718b63438864da680fffb9 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:47:01 -0700 Subject: [PATCH 07/63] Formatting style --- src/Dependencies/PooledObjects/PooledHashSet.cs | 4 ++-- .../Binders/PlaceholderLocalBinder.cs | 4 ++-- .../Source/ExpressionCompiler/EEAssemblyBuilder.cs | 4 ++-- .../Source/ExpressionCompiler/EETypeNameDecoder.cs | 4 ++-- .../ExpressionCompiler/Symbols/EENamedTypeSymbol.cs | 4 ++-- .../Symbols/ExceptionLocalSymbol.cs | 4 ++-- .../Symbols/ObjectAddressLocalSymbol.cs | 4 ++-- .../Symbols/ObjectIdLocalSymbol.cs | 4 ++-- .../Symbols/ReturnValueLocalSymbol.cs | 4 ++-- .../ExpressionCompiler/ReferencedModulesTests.cs | 4 ++-- .../ResultProvider/CSharpResultProviderTestBase.cs | 8 ++++---- .../Test/ResultProvider/CustomResultProviderTests.cs | 4 ++-- .../Engine/DkmClrDebuggerBrowsableAttribute.cs | 4 ++-- .../Engine/DkmClrDebuggerTypeProxyAttribute.cs | 4 ++-- .../Engine/DkmClrDebuggerVisualizerAttribute.cs | 4 ++-- .../Debugger/Engine/DkmClrModuleInstance.cs | 4 ++-- .../ResultProvider/Debugger/Engine/DkmClrType.cs | 8 ++++---- .../Debugger/Engine/DkmFailedEvaluationResult.cs | 4 ++-- .../Engine/DkmIntermediateEvaluationResult.cs | 4 ++-- .../Debugger/Engine/DkmSuccessEvaluationResult.cs | 4 ++-- .../Core/Portable/FindUsages/DefinitionItem.cs | 4 ++-- .../MiscellaneousDiagnosticListTable.cs | 4 ++-- .../TableDataSource/MiscellaneousTodoListTable.cs | 4 ++-- .../VisualStudioBaseDiagnosticListTable.cs | 4 ++-- ...StudioDiagnosticListTable.BuildTableDataSource.cs | 4 ++-- .../VisualStudioDiagnosticListTable.cs | 12 ++++++------ .../TableDataSource/VisualStudioTodoListTable.cs | 4 ++-- .../Impl/Client/RemoteDiagnosticListTable.cs | 4 ++-- .../IncrementalAnalyzerProviderMetadata.cs | 8 ++++---- .../Host/EventListener/EventListenerMetadata.cs | 8 ++++---- .../Services/DiagnosticAnalyzer/PerformanceQueue.cs | 4 ++-- .../DiagnosticAnalyzer/PerformanceTrackerService.cs | 4 ++-- 32 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/Dependencies/PooledObjects/PooledHashSet.cs b/src/Dependencies/PooledObjects/PooledHashSet.cs index 472380a3c3e4a..ee17f78e4384d 100644 --- a/src/Dependencies/PooledObjects/PooledHashSet.cs +++ b/src/Dependencies/PooledObjects/PooledHashSet.cs @@ -13,8 +13,8 @@ internal sealed partial class PooledHashSet : HashSet { private readonly ObjectPool> _pool; - private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) : - base(equalityComparer) + private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) + : base(equalityComparer) { _pool = pool; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs index d4ed8aaee3406..d4714330a250e 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs @@ -30,8 +30,8 @@ internal PlaceholderLocalBinder( ImmutableArray aliases, MethodSymbol containingMethod, EETypeNameDecoder typeNameDecoder, - Binder next) : - base(next) + Binder next) + : base(next) { _syntax = syntax; _containingMethod = containingMethod; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs index d7fe8de53c29e..0e3f61bc18f25 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs @@ -28,8 +28,8 @@ public EEAssemblyBuilder( Cci.ModulePropertiesForSerialization serializationProperties, ImmutableArray additionalTypes, Func getDynamicOperationContextType, - CompilationTestData? testData) : - base( + CompilationTestData? testData) + : base( sourceAssembly, emitOptions, outputKind: OutputKind.DynamicallyLinkedLibrary, diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs index 0318126cb87c3..d3605ea98bef7 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs @@ -14,8 +14,8 @@ internal sealed class EETypeNameDecoder : TypeNameDecoder ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) + GenerateMethodBody generateMethodBody) + : this(container, baseType, currentFrame, typeName, (m, t) => ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) { } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs index 81ae9aa1cf6c6..69200b7493a20 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs @@ -12,8 +12,8 @@ internal sealed class ExceptionLocalSymbol : PlaceholderLocalSymbol { private readonly string _getExceptionMethodName; - internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) : - base(method, name, displayName, type) + internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) + : base(method, name, displayName, type) { _getExceptionMethodName = getExceptionMethodName; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs index bfb4bc1de0906..f6bc3ca8cde8d 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectAddressLocalSymbol : PlaceholderLocalSymbol { private readonly ulong _address; - internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) : - base(method, name, name, type) + internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) + : base(method, name, name, type) { Debug.Assert(type.SpecialType == SpecialType.System_Object); _address = address; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs index 8e6c6d346ac2a..6552569dd78ff 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectIdLocalSymbol : PlaceholderLocalSymbol { private readonly bool _isWritable; - internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) : - base(method, name, displayName, type) + internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) + : base(method, name, displayName, type) { _isWritable = isWritable; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs index 9114143677872..03127935aa00a 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs @@ -14,8 +14,8 @@ internal sealed class ReturnValueLocalSymbol : PlaceholderLocalSymbol { private readonly int _index; - internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) : - base(method, name, displayName, type) + internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) + : base(method, name, displayName, type) { _index = index; } diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs index a6b74fa493568..951b398e069ab 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs @@ -1531,8 +1531,8 @@ private sealed class PEAssemblyBuilderWithAdditionalReferences : PEModuleBuilder private readonly CommonPEModuleBuilder _builder; private readonly NamespaceTypeDefinitionNoBase _objectType; - internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) : - base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) + internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) + : base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) { _builder = builder; _objectType = new NamespaceTypeDefinitionNoBase(objectType); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs index a7a748440564e..c397a2754dab2 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs @@ -21,13 +21,13 @@ public CSharpResultProviderTestBase() : this(new CSharpFormatter()) { } - private CSharpResultProviderTestBase(CSharpFormatter formatter) : - this(CreateDkmInspectionSession(formatter)) + private CSharpResultProviderTestBase(CSharpFormatter formatter) + : this(CreateDkmInspectionSession(formatter)) { } - internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) : - base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) + internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) + : base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) { } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs index 2515775653ece..4361c7b14c6ad 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs @@ -27,8 +27,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests /// public class CustomResultProviderTests : CSharpResultProviderTestBase { - public CustomResultProviderTests() : - base( + public CustomResultProviderTests() + : base( new DkmInspectionSession( ImmutableArray.Create(new CustomFormatter(new CSharpFormatter()), new CSharpFormatter()), ImmutableArray.Create(new CustomResultProvider(), new CSharpResultProvider()))) diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs index 6a8d4e4bfb724..3385276a8e4c7 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs @@ -20,8 +20,8 @@ public enum DkmClrDebuggerBrowsableAttributeState public class DkmClrDebuggerBrowsableAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) : - base(targetMember) + internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) + : base(targetMember) { this.State = state; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs index e1cd0e6bd4e9e..f4b8f020d5672 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs @@ -15,8 +15,8 @@ namespace Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation { public class DkmClrDebuggerTypeProxyAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) : - base(null) + internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) + : base(null) { this.ProxyType = proxyType; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs index b40d7da466d27..8db52ca741898 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs @@ -31,8 +31,8 @@ internal DkmClrDebuggerVisualizerAttribute(string targetMember, DkmClrCustomVisualizerAssemblyLocation uiSideVisualizerAssemblyLocation, string debuggeeSideVisualizerTypeName, string debuggeeSideVisualizerAssemblyName, - string visualizerDescription) : - base(null) + string visualizerDescription) + : base(null) { UISideVisualizerTypeName = uiSideVisualizerTypeName; UISideVisualizerAssemblyName = uiSideVisualizerAssemblyName; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs index b6940815f033d..9ff581028a5e5 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs @@ -26,8 +26,8 @@ public class DkmClrModuleInstance : DkmModuleInstance private readonly DkmClrRuntimeInstance _runtimeInstance; private int _resolveTypeNameFailures; - public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) : - base(module) + public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) + : base(module) { _runtimeInstance = runtimeInstance; this.Assembly = assembly; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs index 1a7ddb2982e84..964edc2b79be7 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs @@ -51,13 +51,13 @@ internal DkmClrType(DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type _favorites = favorites; } - internal DkmClrType(Type lmrType) : - this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) + internal DkmClrType(Type lmrType) + : this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) { } - internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) : - this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) + internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) + : this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) { } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs index 557035d74defc..728f57afc92eb 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs @@ -25,8 +25,8 @@ private DkmFailedEvaluationResult( string errorMessage, DkmEvaluationResultFlags flags, string type, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.ErrorMessage = errorMessage; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs index 9faafe7fc008b..4f45b059c4ebe 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs @@ -27,8 +27,8 @@ private DkmIntermediateEvaluationResult( string expression, DkmLanguage intermediateLanguage, DkmRuntimeInstance targetRuntime, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) { this.Expression = expression; this.IntermediateLanguage = intermediateLanguage; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs index 238dea57e89f1..55c1177370b40 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs @@ -41,8 +41,8 @@ private DkmSuccessEvaluationResult( DkmDataAddress address, ReadOnlyCollection customUIVisualizers, ReadOnlyCollection externalModules, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.Value = value; this.EditableValue = editableValue; diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs index 95640414d3ea6..c12672789b0ea 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs @@ -117,8 +117,8 @@ protected DefinitionItem( ImmutableArray originationParts, ImmutableArray sourceSpans, ImmutableDictionary properties, - bool displayIfNoReferences) : - this( + bool displayIfNoReferences) + : this( tags, displayParts, nameDisplayParts, diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs index d58222681a904..18e29d1645198 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs @@ -34,8 +34,8 @@ private sealed class MiscellaneousDiagnosticListTable : VisualStudioBaseDiagnost { private readonly LiveTableDataSource _source; - public MiscellaneousDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + public MiscellaneousDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { _source = new LiveTableDataSource(workspace, diagnosticService, IdentifierString); diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs index 8a92d5d82de14..6a431243b7fa2 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs @@ -31,8 +31,8 @@ public void StartListening(Workspace workspace, ITodoListProvider service) private sealed class MiscellaneousTodoListTable : VisualStudioBaseTodoListTable { - public MiscellaneousTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) : - base(workspace, todoListProvider, IdentifierString, provider) + public MiscellaneousTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) + : base(workspace, todoListProvider, IdentifierString, provider) { ConnectWorkspaceEvents(); } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs index 18186f1bfa44f..9ad21793b05f3 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs @@ -34,8 +34,8 @@ internal abstract partial class VisualStudioBaseDiagnosticListTable : AbstractTa StandardTableColumnDefinitions.SuppressionState }; - protected VisualStudioBaseDiagnosticListTable(Workspace workspace, ITableManagerProvider provider) : - base(workspace, provider, StandardTables.ErrorsTable) + protected VisualStudioBaseDiagnosticListTable(Workspace workspace, ITableManagerProvider provider) + : base(workspace, provider, StandardTables.ErrorsTable) { } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs index bb04f29635839..351cfcc868b05 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs @@ -126,8 +126,8 @@ private class TableEntriesSnapshot : AbstractTableEntriesSnapshot items) : - base(version, items, ImmutableArray.Empty) + DiagnosticTableEntriesSource source, int version, ImmutableArray items) + : base(version, items, ImmutableArray.Empty) { _source = source; } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs index 0401859b94c41..1ff234ca8b85c 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs @@ -79,8 +79,8 @@ public VisualStudioDiagnosticListTable( VisualStudioWorkspaceImpl workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider, - IErrorList errorList) : - base(workspace, provider) + IErrorList errorList) + : base(workspace, provider) { _errorList = errorList; @@ -104,15 +104,15 @@ private ITableDataSource GetCurrentDataSource() } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new LiveTableDataSource(workspace, diagnosticService, IdentifierString)); } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) : - base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) + : base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new BuildTableDataSource(workspace, errorSource)); } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs index a6e98ac5c464f..850ca550b0157 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs @@ -32,8 +32,8 @@ public void StartListening(Workspace workspace, ITodoListProvider service) internal class VisualStudioTodoListTable : VisualStudioBaseTodoListTable { // internal for testing - internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) : - base(workspace, todoListProvider, IdentifierString, provider) + internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) + : base(workspace, todoListProvider, IdentifierString, provider) { ConnectWorkspaceEvents(); } diff --git a/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs b/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs index 5d407bad2c7c9..52c3a081fd895 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs @@ -30,8 +30,8 @@ internal class RemoteDiagnosticListTable : VisualStudioBaseDiagnosticListTable [ImportingConstructor] [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Incorrectly used in production code: https://github.com/dotnet/roslyn/issues/42839")] public RemoteDiagnosticListTable( - SVsServiceProvider serviceProvider, RemoteLanguageServiceWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + SVsServiceProvider serviceProvider, RemoteLanguageServiceWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { _source = new LiveTableDataSource(workspace, diagnosticService, IdentifierString); AddInitialTableSource(workspace.CurrentSolution, _source); diff --git a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs index f6a8f05de4c65..af4b6cc9ba553 100644 --- a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs +++ b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs @@ -15,15 +15,15 @@ internal class IncrementalAnalyzerProviderMetadata : WorkspaceKindMetadata public bool HighPriorityForActiveFile { get; } public string Name { get; } - public IncrementalAnalyzerProviderMetadata(IDictionary data) : - base(data) + public IncrementalAnalyzerProviderMetadata(IDictionary data) + : base(data) { this.HighPriorityForActiveFile = (bool)data.GetValueOrDefault("HighPriorityForActiveFile"); this.Name = (string)data.GetValueOrDefault("Name"); } - public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) : - base(workspaceKinds) + public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) + : base(workspaceKinds) { this.HighPriorityForActiveFile = highPriorityForActiveFile; this.Name = name; diff --git a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs index 1d92e0042cdf6..51e54e6b4a3a7 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs @@ -18,14 +18,14 @@ internal class EventListenerMetadata : WorkspaceKindMetadata { public string Service { get; } - public EventListenerMetadata(IDictionary data) : - base(data) + public EventListenerMetadata(IDictionary data) + : base(data) { this.Service = (string)data.GetValueOrDefault("Service"); } - public EventListenerMetadata(string service, params string[] workspaceKinds) : - base(workspaceKinds) + public EventListenerMetadata(string service, params string[] workspaceKinds) + : base(workspaceKinds) { if (workspaceKinds?.Length == 0) { diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs index 6693cd16b0753..92b5a15249b5f 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs @@ -125,8 +125,8 @@ private class Snapshot /// private readonly Dictionary _performanceMap; - public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) : - this(Convert(snapshot), unitCount) + public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) + : this(Convert(snapshot), unitCount) { } diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs index d6cb2cde53457..2cfbc915461e0 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs @@ -44,8 +44,8 @@ internal class PerformanceTrackerService : IPerformanceTrackerService [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public PerformanceTrackerService() : - this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) + public PerformanceTrackerService() + : this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) { } From f7bc38689668c9387763c49f3f3b479a47f2f3e7 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:48:07 -0700 Subject: [PATCH 08/63] Formatting style --- .../TestUtilities/InProcess/FindReferencesWindow_InProc.cs | 1 + .../TestUtilities/InProcess/SolutionExplorer_InProc.cs | 7 +++++++ .../TestUtilities/InProcess/TextViewWindow_InProc.cs | 1 + .../TestUtilities/VisualStudioInstanceFactory.cs | 1 + 4 files changed, 10 insertions(+) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs index 21a550b58ec2f..4e648b6deea9d 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs @@ -37,6 +37,7 @@ public Reference[] GetContents(string windowCaption) groupingPriority: 0); newColumnsStates.Add(newState); } + tableControl.SetColumnStates(newColumnsStates); // Force a refresh, if necessary. This doesn't re-run the Find References or diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs index 4a4c5637182da..7d198c3c9398c 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs @@ -192,6 +192,7 @@ public void EditProjectFile(string projectName) { throw new ArgumentException($"Could not find project file, current hierarchy items '{string.Join(", ", rootHierarchyItems.Select(x => x.Name))}'"); } + project.Select(EnvDTE.vsUISelectionType.vsUISelectionTypeSelect); ExecuteCommand("Project.EditProjectFile"); } @@ -210,6 +211,7 @@ public void CreateSolution(string solutionName, string solutionElementString) { throw new ArgumentException(nameof(solutionElementString)); } + CreateSolution(solutionName); foreach (var projectElement in solutionElement.Elements("Project")) @@ -313,6 +315,7 @@ public void RemoveProjectReference(string projectName, string projectReferenceNa var projectReference = references.Where(x => x.ContainingProject != null).Select(x => x.Name); throw new ArgumentException($"reference to project {projectReferenceName} not found, references: '{string.Join(", ", projectReference)}'"); } + reference.Remove(); } @@ -324,6 +327,7 @@ public void OpenSolution(string path, bool saveExistingSolutionIfExists = false) { CloseSolution(saveExistingSolutionIfExists); } + dte.Solution.Open(path); _solution = (EnvDTE80.Solution2)dte.Solution; @@ -806,6 +810,7 @@ int IVsUpdateSolutionEvents.UpdateSolution_Begin(ref int pfCancelUpdate) { pfCancelUpdate = 1; } + return 0; } @@ -839,6 +844,7 @@ int IVsUpdateSolutionEvents2.UpdateSolution_Begin(ref int pfCancelUpdate) { pfCancelUpdate = 1; } + return 0; } @@ -884,6 +890,7 @@ private int UpdateSolution_StartUpdate(ref int pfCancelUpdate) { pfCancelUpdate = 1; } + return 0; } diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs index b4106b5aaede0..dc52c2ba9508c 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs @@ -300,6 +300,7 @@ bool filterTag(IMappingTagSpan tag) { return tag.Tag.GetType().Equals(type); } + var service = GetComponentModelService(); var aggregator = service.CreateTagAggregator(view); var allTags = aggregator.GetTags(new SnapshotSpan(view.TextSnapshot, 0, view.TextSnapshot.Length)); diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index 2428414f901d7..2ed1280bb6298 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -276,6 +276,7 @@ private static ISetupInstance LocateVisualStudioInstance(ImmutableHashSet Date: Tue, 8 Jun 2021 16:54:58 -0700 Subject: [PATCH 09/63] Formatting style --- src/Tools/BuildValidator/LocalReferenceResolver.cs | 1 + src/Tools/BuildValidator/PEReaderExtensions.cs | 2 ++ src/Tools/BuildValidator/Program.cs | 1 + 3 files changed, 4 insertions(+) diff --git a/src/Tools/BuildValidator/LocalReferenceResolver.cs b/src/Tools/BuildValidator/LocalReferenceResolver.cs index 3c93b7cb02796..8a569e6116e7f 100644 --- a/src/Tools/BuildValidator/LocalReferenceResolver.cs +++ b/src/Tools/BuildValidator/LocalReferenceResolver.cs @@ -45,6 +45,7 @@ public LocalReferenceResolver(Options options, ILoggerFactory loggerFactory) { _indexDirectories.Add(new DirectoryInfo(path)); } + _indexDirectories.Add(GetNugetCacheDirectory()); foreach (var path in options.ReferencesPaths) { diff --git a/src/Tools/BuildValidator/PEReaderExtensions.cs b/src/Tools/BuildValidator/PEReaderExtensions.cs index 53264be4a8e6e..cecfb5d76fd8c 100644 --- a/src/Tools/BuildValidator/PEReaderExtensions.cs +++ b/src/Tools/BuildValidator/PEReaderExtensions.cs @@ -86,6 +86,7 @@ private PEExportTable(PEReader peReader) { nameBuilder.Append((char)ascii); } + _namedExportRva.Add(nameBuilder.ToString(), addressTable[ordinalTable[entryIndex]]); } } @@ -113,6 +114,7 @@ public static int GetOffset(this PEReader reader, int rva) { throw new BadImageFormatException("Failed to convert invalid RVA to offset: " + rva); } + SectionHeader containingSection = reader.PEHeaders.SectionHeaders[index]; return rva - containingSection.VirtualAddress + containingSection.PointerToRawData; } diff --git a/src/Tools/BuildValidator/Program.cs b/src/Tools/BuildValidator/Program.cs index 83e4b6b9005f2..94c39cfdac474 100644 --- a/src/Tools/BuildValidator/Program.cs +++ b/src/Tools/BuildValidator/Program.cs @@ -344,6 +344,7 @@ private static ImmutableArray ResolveSourceLinks(CompilationOpt logger.LogInformation($@"""{link.Prefix}"": ""{link.Replace}"""); } } + return sourceLinks; static SourceLinkEntry makeSourceLink(KeyValuePair entry) From 0871724771a75b1eeb7e84ea8144772862e0a2a0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 16:55:52 -0700 Subject: [PATCH 10/63] Formatting style --- src/Tools/AnalyzerRunner/Options.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Tools/AnalyzerRunner/Options.cs b/src/Tools/AnalyzerRunner/Options.cs index 2e7bd8d9662e6..bd9e0e82a8613 100644 --- a/src/Tools/AnalyzerRunner/Options.cs +++ b/src/Tools/AnalyzerRunner/Options.cs @@ -216,6 +216,7 @@ internal static Options Create(string[] args) "Unrecognized option " + arg : "Unrecognized parameter " + arg)); } + break; } } From fab2b18de3a11fe94f99bed454785bd0cbb51a32 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:01:38 -0700 Subject: [PATCH 11/63] Formatting style --- eng/Versions.props | 2 +- .../DiscardSyntaxClassifier.cs | 2 ++ .../NameSyntaxClassifier.cs | 1 + .../CodeGeneration/CSharpSyntaxGenerator.cs | 33 +++++++++++++++++++ .../CSharpSimplificationService.Expander.cs | 2 ++ .../VirtualChars/CSharpVirtualCharService.cs | 1 + .../CSharpFormattingOptions2.Parsers.cs | 2 ++ .../Services/SyntaxFacts/CSharpSyntaxFacts.cs | 6 ++++ .../Simplifiers/CastSimplifier.cs | 1 + .../ContextQuery/SyntaxTreeExtensions.cs | 2 ++ .../DocumentationCommentExtensions.cs | 1 + ...CSharpTypeInferenceService.TypeInferrer.cs | 3 ++ 12 files changed, 55 insertions(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index bc3133873a92d..b2bf19dc7e13a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -28,7 +28,7 @@ 3.3.3-beta1.21105.3 - 6.0.0-preview6.21281.1 + 6.0.0-preview1.21054.10 1.0.1-beta1.20623.3 3.10.0-3.final 16.10.44 diff --git a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/DiscardSyntaxClassifier.cs b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/DiscardSyntaxClassifier.cs index 91be6c144caa2..23493dc55e668 100644 --- a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/DiscardSyntaxClassifier.cs +++ b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/DiscardSyntaxClassifier.cs @@ -42,6 +42,7 @@ public override void AddClassifications( { result.Add(new ClassifiedSpan(parameter.Identifier.Span, ClassificationTypeNames.Keyword)); } + break; case IdentifierNameSyntax identifierName when identifierName.Identifier.Text == "_": @@ -51,6 +52,7 @@ public override void AddClassifications( { result.Add(new ClassifiedSpan(syntax.Span, ClassificationTypeNames.Keyword)); } + break; } } diff --git a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs index badd7591a6ec2..f236e3444876a 100644 --- a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs +++ b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs @@ -212,6 +212,7 @@ private static bool TryClassifySymbol( classifiedSpan = new ClassifiedSpan(token.Span, classification); return true; } + break; case IFieldSymbol fieldSymbol: diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index b2f0ab1bfc4b1..eda1079d6b48e 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -854,6 +854,7 @@ private EnumMemberDeclarationSyntax AsEnumMember(SyntaxNode node) var vd = fd.Declaration.Variables[0]; return (EnumMemberDeclarationSyntax)this.EnumMember(vd.Identifier.ToString(), vd.Initializer?.Value); } + break; } @@ -1067,6 +1068,7 @@ public override IReadOnlyList GetAttributeArguments(SyntaxNode attri { return this.GetAttributeArguments(list.Attributes[0]); } + break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)attributeDeclaration; @@ -1074,6 +1076,7 @@ public override IReadOnlyList GetAttributeArguments(SyntaxNode attri { return attr.ArgumentList.Arguments; } + break; } @@ -1113,6 +1116,7 @@ private static AttributeArgumentListSyntax GetAttributeArgumentList(SyntaxNode d { return list.Attributes[0].ArgumentList; } + break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)declaration; @@ -1132,6 +1136,7 @@ private static SyntaxNode WithAttributeArgumentList(SyntaxNode declaration, Attr { return ReplaceWithTrivia(declaration, list.Attributes[0], list.Attributes[0].WithArgumentList(argList)); } + break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)declaration; @@ -1240,6 +1245,7 @@ private static ImmutableArray Flatten(IEnumerable declar { builder.Add(attrList); } + break; default: @@ -1832,6 +1838,7 @@ public override SyntaxNode GetType(SyntaxNode declaration) { return this.GetType(declaration.Parent); } + break; } @@ -1879,6 +1886,7 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) { return this.AsIsolatedDeclaration(vd.Parent); } + break; case SyntaxKind.VariableDeclarator: @@ -1887,6 +1895,7 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) { return this.ClearTrivia(WithVariable(v.Parent.Parent, v)); } + break; case SyntaxKind.Attribute: @@ -1896,6 +1905,7 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) var attrList = (AttributeListSyntax)attr.Parent; return attrList.WithAttributes(SyntaxFactory.SingletonSeparatedList(attr)).WithTarget(null); } + break; } } @@ -1955,6 +1965,7 @@ private static SyntaxNode GetFullDeclaration(SyntaxNode declaration) { return GetFullDeclaration(declaration.Parent); } + break; } @@ -1976,6 +1987,7 @@ private SyntaxNode AsNodeLike(SyntaxNode existingNode, SyntaxNode newNode) { return this.AsMemberOf(container, newNode); } + break; case DeclarationKind.Attribute: @@ -2124,6 +2136,7 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return pd.ExpressionBody.Expression; } + goto default; case SyntaxKind.IndexerDeclaration: @@ -2132,6 +2145,7 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return id.ExpressionBody.Expression; } + goto default; case SyntaxKind.MethodDeclaration: @@ -2140,6 +2154,7 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return method.ExpressionBody.Expression; } + goto default; case SyntaxKind.LocalFunctionStatement: @@ -2148,6 +2163,7 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return local.ExpressionBody.Expression; } + goto default; default: @@ -2176,6 +2192,7 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(pd, pd.ExpressionBody.Expression, expr); } + goto default; case SyntaxKind.IndexerDeclaration: @@ -2184,6 +2201,7 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(id, id.ExpressionBody.Expression, expr); } + goto default; case SyntaxKind.MethodDeclaration: @@ -2192,6 +2210,7 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(method, method.ExpressionBody.Expression, expr); } + goto default; case SyntaxKind.LocalFunctionStatement: @@ -2200,6 +2219,7 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(local, local.ExpressionBody.Expression, expr); } + goto default; default: @@ -2237,6 +2257,7 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return fd.Declaration.Variables[0].Initializer; } + break; case SyntaxKind.PropertyDeclaration: var pd = (PropertyDeclarationSyntax)declaration; @@ -2247,6 +2268,7 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return ld.Declaration.Variables[0].Initializer; } + break; case SyntaxKind.VariableDeclaration: var vd = (VariableDeclarationSyntax)declaration; @@ -2254,6 +2276,7 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return vd.Variables[0].Initializer; } + break; case SyntaxKind.VariableDeclarator: return ((VariableDeclaratorSyntax)declaration).Initializer; @@ -2274,6 +2297,7 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, fd.Declaration.Variables[0], fd.Declaration.Variables[0].WithInitializer(eq)); } + break; case SyntaxKind.PropertyDeclaration: var pd = (PropertyDeclarationSyntax)declaration; @@ -2284,6 +2308,7 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, ld.Declaration.Variables[0], ld.Declaration.Variables[0].WithInitializer(eq)); } + break; case SyntaxKind.VariableDeclaration: var vd = (VariableDeclarationSyntax)declaration; @@ -2291,6 +2316,7 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, vd.Variables[0], vd.Variables[0].WithInitializer(eq)); } + break; case SyntaxKind.VariableDeclarator: return ((VariableDeclaratorSyntax)declaration).WithInitializer(eq); @@ -2435,6 +2461,7 @@ private static AccessorDeclarationSyntax AsAccessor(SyntaxNode node, SyntaxKind case SyntaxKind.SetAccessorDeclaration: return (AccessorDeclarationSyntax)node; } + break; case SyntaxKind.EventDeclaration: switch (node.Kind()) @@ -2443,6 +2470,7 @@ private static AccessorDeclarationSyntax AsAccessor(SyntaxNode node, SyntaxKind case SyntaxKind.RemoveAccessorDeclaration: return (AccessorDeclarationSyntax)node; } + break; } @@ -2846,6 +2874,7 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire list if only one attribute return this.RemoveNodeInternal(root, attrList, options); } + break; case SyntaxKind.AttributeArgument: @@ -2854,6 +2883,7 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire argument list if only one argument return this.RemoveNodeInternal(root, declaration.Parent, options); } + break; case SyntaxKind.VariableDeclarator: @@ -2863,6 +2893,7 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove full declaration if only one declarator return this.RemoveNodeInternal(root, full, options); } + break; case SyntaxKind.SimpleBaseType: @@ -2871,6 +2902,7 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire base list if this is the only base type. return this.RemoveNodeInternal(root, baseList, options); } + break; default: @@ -2883,6 +2915,7 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S return this.RemoveNodeInternal(root, parent, options); } } + break; } diff --git a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs index e8cf99794241c..bf8c370f9fb1e 100644 --- a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs +++ b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs @@ -308,6 +308,7 @@ private static bool CanMakeNameExplicitInTuple(TupleExpressionSyntax tuple, stri // No duplicate names allowed return false; } + found = true; } } @@ -502,6 +503,7 @@ private ExpressionSyntax VisitSimpleName(SimpleNameSyntax rewrittenSimpleName, S { replacement = replacement.ReplaceToken(firstOriginalToken, tokenWithLeadingWhitespace); } + break; case SyntaxKind.QualifiedName: diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs index 4921a460d7edb..bf387e4683768 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs @@ -98,6 +98,7 @@ private static VirtualCharSequence TryConvertStringToVirtualChars( Debug.Fail("This should not be reachable as long as the compiler added no diagnostics."); return default; } + if (endDelimiter.Length > 0 && !tokenText.EndsWith(endDelimiter)) { Debug.Fail("This should not be reachable as long as the compiler added no diagnostics."); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs index fa3f0322fcff4..e35b6c78bc1fd 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs @@ -92,10 +92,12 @@ internal static bool DetermineIfNewLineOptionIsSet(string value, NewLineOption o { return option; } + if (s_legacyNewLineOptionsEditorConfigMap.TryGetValue(value, out var legacyOption)) { return legacyOption; } + return null; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs index 11e1bd60da9c8..49c4a03e97194 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs @@ -880,6 +880,7 @@ public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, strin { name = "~" + name; } + if ((options & DisplayNameOptions.IncludeTypeParameters) != 0) { var pooled = PooledStringBuilder.GetInstance(); @@ -907,6 +908,7 @@ public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, strin } } } + Debug.Assert(name != null, "Unexpected node type " + node.Kind()); return name; } @@ -922,6 +924,7 @@ private static void AppendTypeParameterList(StringBuilder builder, TypeParameter builder.Append(", "); builder.Append(typeParameterList.Parameters[i].Identifier.ValueText); } + builder.Append('>'); } } @@ -2042,6 +2045,7 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) return DeclarationKind.Variable; } } + break; } @@ -2051,6 +2055,7 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) { return DeclarationKind.Attribute; } + break; case SyntaxKind.Attribute: @@ -2058,6 +2063,7 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) { return DeclarationKind.Attribute; } + break; case SyntaxKind.GetAccessorDeclaration: diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs index 0e527a0c4f36f..f4ff1fa562605 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs @@ -914,6 +914,7 @@ private static ulong FindSurprisingSignExtensionBits(IOperation? operation, bool case 2: return unchecked((ulong)(ushort)recursive); case 4: return unchecked((ulong)(uint)recursive); } + Debug.Assert(false, "How did we get here?"); return recursive; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index b336edcc5a997..2616a24c40e74 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -1623,6 +1623,7 @@ private static SyntaxNode UnwrapPossibleTuple(SyntaxNode node) node = node.Parent; continue; } + if (node.Parent.IsKind(SyntaxKind.Argument) && node.Parent.Parent.IsKind(SyntaxKind.TupleExpression)) { node = node.Parent.Parent; @@ -1645,6 +1646,7 @@ private static bool IsPossibleVarDeconstructionOpenParenOrComma(SyntaxToken left return true; } } + return false; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs index e2caec752c8e0..a075030b96b56 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs @@ -16,6 +16,7 @@ public static bool IsMultilineDocComment([NotNullWhen(true)] this DocumentationC { return false; } + return documentationComment.ToFullString().StartsWith("/**", StringComparison.Ordinal); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs index b72e782fead03..fd0d31a104df4 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs @@ -678,6 +678,7 @@ private void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol { result[returnTypeParameter] = inferredType; } + return; } } @@ -705,6 +706,7 @@ private void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol DetermineTypeParameterMapping(inferredNamedType.TypeArguments[i], returnNamedType.TypeArguments[i], result); } } + return; } } @@ -831,6 +833,7 @@ private IEnumerable InferTypeInArrayType(ArrayTypeSyntax arra currentTypes = currentTypes.Select(t => t.InferredType).OfType() .SelectAsArray(a => new TypeInferenceInfo(a.ElementType)); } + return currentTypes; } From 3c0e0df0a72bb3dd5665c5fb6d74629b97f8fbcb Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:05:32 -0700 Subject: [PATCH 12/63] Formatting style --- .../Source/ExpressionCompiler/CustomTypeInfo.cs | 3 +++ .../DynamicFlagsCustomTypeInfo.cs | 1 + .../ExpressionEvaluatorFatalError.cs | 1 + .../ResultProvider/Expansion/ArrayExpansion.cs | 6 ++++++ .../Expansion/DebuggerTypeProxyExpansion.cs | 1 + .../ResultProvider/Expansion/MemberExpansion.cs | 5 +++++ .../Expansion/ResultsViewExpansion.cs | 4 ++++ .../Expansion/RootHiddenExpansion.cs | 2 ++ .../ResultProvider/Expansion/TupleExpansion.cs | 3 +++ .../ResultProvider/Formatter.TypeNames.cs | 7 +++++++ .../Source/ResultProvider/Formatter.Values.cs | 3 +++ .../Core/Source/ResultProvider/Formatter.cs | 13 +++++++++++++ .../ResultProvider/Helpers/ArrayBuilder.cs | 1 + .../ResultProvider/Helpers/AttributeHelpers.cs | 5 +++++ .../Helpers/CustomTypeInfoTypeArgumentMap.cs | 1 + .../Helpers/EvalResultDataItem.cs | 1 + .../ResultProvider/Helpers/TypeHelpers.cs | 17 +++++++++++++++++ .../ResultProvider/Helpers/ValueHelpers.cs | 2 ++ .../Source/ResultProvider/ResultProvider.cs | 9 +++++++++ .../Debugger/Engine/DkmClrModuleInstance.cs | 2 ++ .../Debugger/Engine/DkmClrRuntimeInstance.cs | 4 ++++ .../Debugger/Engine/DkmClrType.cs | 1 + .../Debugger/Engine/DkmClrValue.cs | 13 +++++++++++++ .../Engine/DkmEvaluationEnumAsyncResult.cs | 1 + .../Engine/DkmEvaluationResultEnumContext.cs | 1 + .../Engine/DkmGetChildrenAsyncResult.cs | 1 + .../Debugger/Engine/DkmInspectionSession.cs | 2 ++ .../Debugger/MemberInfo/TypeImpl.cs | 5 +++++ .../ResultProvider/ResultProviderTestBase.cs | 16 ++++++++++++++++ .../Source/CompilerGeneratorTools/.editorconfig | 11 ++++++++++- 30 files changed, 141 insertions(+), 1 deletion(-) diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs index 3b17f46f02499..6d1c90e1b7d97 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs @@ -102,6 +102,7 @@ internal static class CustomTypeInfo builder.Free(); return null; } + builder.Add((byte)length); builder.AddRange(dynamicFlags); } @@ -170,6 +171,7 @@ private static string JoinNames(ReadOnlyCollection names) builder.Append(name); } } + return pooledBuilder.ToStringAndFree(); } @@ -203,6 +205,7 @@ private static byte[] CopyBytes(ReadOnlyCollection bytes, int start, int l { array[i] = bytes[start + i]; } + return array; } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs index 47d780f62adf4..035cf7b2c4479 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs @@ -56,6 +56,7 @@ internal static bool GetFlag(ReadOnlyCollection? bytes, int index) { return false; } + var b = index / 8; return b < bytes.Count && (bytes[b] & (1 << (index % 8))) != 0; diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs index 8d133831fe449..52da802c80a9c 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs @@ -46,6 +46,7 @@ internal static class RegistryHelpers { Debug.Assert(false, "Failure checking registry key: " + ex.ToString()); } + return null; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs index de7e286615205..59daf23fde131 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs @@ -34,6 +34,7 @@ internal static ArrayExpansion CreateExpansion(TypeAndCustomInfo elementTypeAndI { count *= size; } + return (count > 0) ? new ArrayExpansion(elementTypeAndInfo, sizes, lowerBounds, count) : null; } @@ -116,6 +117,7 @@ private int[] GetIndices(int index) indices[i] = _lowerBounds[i] + index / divisor; index = index % divisor; } + return indices; } @@ -127,6 +129,7 @@ private static string[] GetIndicesAsStrings(int[] indices) { strings[i] = indices[i].ToString(); } + return strings; } @@ -144,6 +147,7 @@ private static ReadOnlyCollection CalculateDivisors(ReadOnlyCollection { divisors[i - 1] = divisors[i] * sizes[i]; } + return new ReadOnlyCollection(divisors); } @@ -159,6 +163,7 @@ private static string GetFullName(DkmInspectionContext inspectionContext, EvalRe { parentFullName = parentFullName.Parenthesize(); } + var parentRuntimeType = parent.Value.Type; if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType.GetLmrType())) { @@ -173,6 +178,7 @@ private static string GetFullName(DkmInspectionContext inspectionContext, EvalRe return null; // Contains invalid identifier. } } + return parentFullName + name; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs index a93e485f8c5a1..7e6329cc65678 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs @@ -135,6 +135,7 @@ private DebuggerTypeProxyExpansion( proxyTypeAndInfo.Info, new[] { childFullNamePrefix }); } + _proxyItem = new EvalResult( ExpansionKind.Default, name: string.Empty, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs index 949fb3c7fce84..caf9c4f43fd39 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs @@ -167,10 +167,12 @@ internal static Expansion CreateExpansion( { staticExpansions.Add(publicStaticExpansion); } + if (nonPublicStaticExpansion != null) { staticExpansions.Add(nonPublicStaticExpansion); } + Debug.Assert(staticExpansions.Count > 0); var staticMembersExpansion = new StaticMembersExpansion( type, @@ -235,6 +237,7 @@ private static void GetPublicAndNonPublicMembers( publicExpansions.Add(new MemberExpansion(publicMembers.ToArray(), customTypeInfoMap)); publicMembers.Clear(); } + publicExpansions.Add(new RootHiddenExpansion(member, customTypeInfoMap)); continue; case DkmClrDebuggerBrowsableAttributeState.Never: @@ -258,6 +261,7 @@ private static void GetPublicAndNonPublicMembers( { publicExpansions.Add(new MemberExpansion(publicMembers.ToArray(), customTypeInfoMap)); } + publicMembers.Free(); publicExpansion = AggregateExpansion.CreateExpansion(publicExpansions); @@ -499,6 +503,7 @@ internal static EvalResult CreateMemberDataItem( member.IsStatic, parent); } + return resultProvider.CreateDataItem( inspectionContext, memberName, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs index b9abaadc553d7..bf5f663b84dcb 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs @@ -25,6 +25,7 @@ internal static ResultsViewExpansion CreateExpansion(DkmInspectionContext inspec { return null; } + return CreateExpansion(inspectionContext, value, enumerableType, resultProvider); } @@ -65,6 +66,7 @@ internal static EvalResult CreateResultsOnlyRow( includeResultsFormatSpecifier: true, fullNameProvider: resultProvider.FullNameProvider); } + errorMessage = Resources.ResultsViewNoSystemCore; } else @@ -155,6 +157,7 @@ private static DkmClrType GetEnumerableType(DkmClrValue value, DkmClrType valueT { return null; } + enumerableType = type; } else @@ -269,6 +272,7 @@ private EvalResult CreateResultsViewRow( { formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, ResultsFormatSpecifier); } + var childFullNamePrefix = fullNameProvider.GetClrObjectCreationExpression( inspectionContext, _proxyValue.Type, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs index 01d1ead860784..4a0c148c46281 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs @@ -49,9 +49,11 @@ internal override void GetRows( var emptyMember = memberValue.Type.GetMemberByName("Empty"); memberValue = memberValue.GetMemberValue(emptyMember, inspectionContext); } + var row = new EvalResult(Resources.ErrorName, (string)memberValue.HostObjectValue, inspectionContext); rows.Add(row); } + index++; } else diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs index e06c5febff354..05f8f4cc7cdd7 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs @@ -100,6 +100,7 @@ private static EvalResult GetMemberRow( { parentFullName = parentFullName.Parenthesize(); } + var parentRuntimeType = parent.Value.Type; if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType.GetLmrType())) { @@ -198,6 +199,7 @@ private static DkmClrValue GetValueAndFullName( parentFullName, out parentFullName); } + var fieldName = field.FieldInfo.Name; fullName = (parentFullName == null) ? null : @@ -264,6 +266,7 @@ private Fields GetFields() { _lazyFields = GetFields(_typeAndInfo, _cardinality, _useRawView); } + return _lazyFields; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs index a8d04b4735543..219b7fa7a4ab4 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs @@ -89,6 +89,7 @@ protected void AppendQualifiedTypeName( // Null for function pointers. break; } + dynamicFlagIndex++; pointerCount++; type = elementType; @@ -102,6 +103,7 @@ protected void AppendQualifiedTypeName( nullableCount++; type = typeArg; } + Debug.Assert(nullableCount < 2, "Benign: someone is nesting nullables."); Debug.Assert(pointerCount == 0 || nullableCount == 0, "Benign: pointer to nullable?"); @@ -298,6 +300,7 @@ private void AppendNamespacePrefix(StringBuilder builder, Type type, bool escape identifierBuilder.Append(ch); } } + AppendIdentifier(builder, escapeKeywordIdentifiers, identifierBuilder.ToString(), out sawSingleInvalidIdentifier); sawInvalidIdentifier |= sawSingleInvalidIdentifier; pooled.Free(); @@ -306,6 +309,7 @@ private void AppendNamespacePrefix(StringBuilder builder, Type type, bool escape { AppendIdentifier(builder, escapeKeywordIdentifiers, @namespace, out sawInvalidIdentifier); } + builder.Append('.'); } } @@ -408,6 +412,7 @@ private void AppendTupleElements( { builder.Append(", "); } + bool sawSingleInvalidIdentifier; var name = CustomTypeInfo.GetTupleElementNameIfAny(tupleElementNames, nameIndex); nameIndex++; @@ -424,10 +429,12 @@ private void AppendTupleElements( sawInvalidIdentifier |= sawSingleInvalidIdentifier; any = true; } + if (nTypeArgs < TypeHelpers.TupleFieldRestPosition) { break; } + Debug.Assert(!DynamicFlagsCustomTypeInfo.GetFlag(dynamicFlags, dynamicFlagIndex)); dynamicFlagIndex++; type = typeArguments[nTypeArgs - 1]; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs index f86a1b3f59108..0273dcc70014f 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs @@ -50,6 +50,7 @@ private string GetValueString(DkmClrValue value, DkmInspectionContext inspection { return _nullString; } + return IncludeObjectId( value, FormatString(stringValue, options), @@ -161,6 +162,7 @@ private string GetValueString(DkmClrValue value, DkmInspectionContext inspection GetTupleExpression(values.ToArrayAndFree()), flags); } + values.Free(); } } @@ -290,6 +292,7 @@ private string GetEnumDisplayString(Type lmrType, DkmClrValue value, ObjectDispl { displayString = GetNameForEnumValue(fields, underlyingValue, valueForComparison, options, typeToDisplayOpt); } + fields.Free(); return displayString ?? FormatPrimitive(value, options, inspectionContext); diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs index 4e065bf34ae16..8ba6ef07555f6 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs @@ -92,6 +92,7 @@ string IDkmClrFullNameProvider.GetClrCastExpression(DkmInspectionContext inspect { return null; } + return GetCastExpression(argument, name, castExpressionOptions); } @@ -103,6 +104,7 @@ string IDkmClrFullNameProvider.GetClrObjectCreationExpression(DkmInspectionConte { return null; } + return GetObjectCreationExpression(name, arguments); } @@ -154,12 +156,14 @@ string IDkmClrFullNameProvider.GetClrMemberName( { return null; // FullName wouldn't be parseable. } + qualifier = GetCastExpression(parentFullName, typeName, DkmClrCastExpressionOptions.ParenthesizeEntireExpression); } else { qualifier = parentFullName; } + return $"{qualifier}.{memberName}"; } @@ -203,6 +207,7 @@ private bool NeedsParentheses(string expr) { return true; } + parens++; break; case '[': @@ -230,9 +235,11 @@ private bool NeedsParentheses(string expr) return true; } } + break; } } + return false; } @@ -251,6 +258,7 @@ internal static ReadOnlyCollection AddFormatSpecifier(ReadOnlyCollection { return formatSpecifiers; } + var builder = ArrayBuilder.GetInstance(); builder.AddRange(formatSpecifiers); builder.Add(formatSpecifier); @@ -263,13 +271,16 @@ protected string RemoveLeadingAndTrailingContent(string expression, int start, i for (; start < oldLength && leading(expression[start]); start++) { } + for (; length > start && trailing(expression[length - 1]); length--) { } + if ((start > 0) || (length < oldLength)) { return expression.Substring(start, length - start); } + return expression; } @@ -307,6 +318,7 @@ protected string RemoveFormatSpecifiers(string expression, out ReadOnlyCollectio Array.Reverse(specifiers); formatSpecifiers = new ReadOnlyCollection(specifiers); } + builder.Free(); Debug.Assert((formatSpecifiers.Count == 0) == (newLength == oldLength)); @@ -314,6 +326,7 @@ protected string RemoveFormatSpecifiers(string expression, out ReadOnlyCollectio { return expression.Substring(0, newLength); } + return expression; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs index 89e03e291c67e..4a76a5cbe78ef 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs @@ -29,6 +29,7 @@ public static ArrayBuilder GetInstance(int size = 0) { builder._items.Capacity = size; } + return builder; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs index 9a11b34137401..132fef5c00478 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs @@ -29,6 +29,7 @@ internal static DkmClrCustomTypeInfo GetCustomTypeInfo(this IList GetDynamicFlags(CustomAttributeData attr { builder.Add((bool)typedArg.Value); } + var result = DynamicFlagsCustomTypeInfo.ToBytes(builder); builder.Free(); return result; } } + return null; } @@ -85,9 +88,11 @@ private static ReadOnlyCollection GetTupleElementNames(CustomAttributeDa { builder.Add((string)typedArg.Value); } + return builder.ToImmutableAndFree(); } } + return null; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs index d7577931736af..6098b3c90917d 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs @@ -208,6 +208,7 @@ private static void AppendRangeFor( { return; } + var genericParameterPosition = type.GenericParameterPosition; AppendRange( collection, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs index d8b16ede688b3..6bf7f411b6b5e 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs @@ -120,6 +120,7 @@ public string FullName name += ", " + formatSpecifier; } } + return name; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs index 5a6d26fb2ff40..82345f2f2341d 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs @@ -205,6 +205,7 @@ private static DeclarationInfo AccessingBaseMemberWithSameNameRequiresExplicitCa { return DeclarationInfo.RequiresExplicitCast; } + return DeclarationInfo.None; default: throw ExceptionUtilities.UnexpectedValue(member.MemberType); @@ -220,6 +221,7 @@ internal static bool IsVisibleMember(MemberInfo member) case MemberTypes.Property: return GetNonIndexerGetMethod((PropertyInfo)member) != null; } + return false; } @@ -248,6 +250,7 @@ internal static bool IsPublic(this MemberInfo member) { return false; } + var attributes = getMethod.Attributes; return ((attributes & System.Reflection.MethodAttributes.Public) == System.Reflection.MethodAttributes.Public) || ((attributes & System.Reflection.MethodAttributes.Family) == System.Reflection.MethodAttributes.Family); @@ -351,6 +354,7 @@ internal static bool IsIDynamicMetaObjectProvider(this Type type) return true; } } + return false; } @@ -368,6 +372,7 @@ internal static Type GetNullableTypeArgument(this Type type) return typeArgs[0]; } } + return null; } @@ -393,6 +398,7 @@ internal static DkmClrValue GetNullableValue(this DkmClrValue value, Type nullab { return value; } + return value.GetNullableValue(inspectionContext); } @@ -484,20 +490,24 @@ internal static bool TryGetTupleFieldValues(this DkmClrValue tuple, int cardinal { return false; } + var value = tuple.GetFieldValue(fieldName, inspectionContext); var str = value.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers); values.Add(str); } + cardinality -= n; if (cardinality == 0) { return true; } + var restInfo = type.GetTupleField(TypeHelpers.TupleFieldRestName); if (restInfo == null) { return false; } + tuple = tuple.GetFieldValue(TupleFieldRestName, inspectionContext); } } @@ -557,6 +567,7 @@ private static Dictionary GetDebu { continue; } + if (result == null) { result = new Dictionary(); @@ -570,6 +581,7 @@ private static Dictionary GetDebu result.Add(browsableAttribute.TargetMember, browsableAttribute.State); } } + return result; } @@ -695,6 +707,7 @@ internal static Type Substitute(this Type type, Type typeDef, Type[] typeArgs) { builder.Add(t.Substitute(typeDef, typeArgs)); } + var typeDefinition = type.GetGenericTypeDefinition(); return typeDefinition.MakeGenericType(builder.ToArrayAndFree()); } @@ -742,6 +755,7 @@ internal static Type GetIEnumerableImplementationIfAny(this Type type) return @interface; } } + t = t.BaseType; } while (t != null); @@ -778,6 +792,7 @@ internal static bool IsOrInheritsFrom(this Type type, Type baseType) { return true; } + type = type.BaseType; } while (type != null); @@ -806,6 +821,7 @@ internal static bool IsOrInheritsFrom(this Type type, string @namespace, string { return true; } + type = type.BaseType; } while (type != null); @@ -855,6 +871,7 @@ internal static MemberInfo GetOriginalDefinition(this MemberInfo member) { return candidate; } + break; default: throw ExceptionUtilities.UnexpectedValue(memberType); diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs index 83cf812b482db..08649380717f9 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs @@ -25,6 +25,7 @@ internal static string IncludeObjectId(this DkmClrValue value, string valueStr) return $"{valueStr} {{{alias}}}"; } } + return valueStr; } @@ -73,6 +74,7 @@ internal static void AppendCommaSeparatedList(this StringBuilder builder, string { builder.Append(", "); } + builder.Append(value); any = true; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs index 4f2fa760946bf..f7053cd5b41c9 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs @@ -59,6 +59,7 @@ void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, Dk { formatSpecifiers = Formatter.NoFormatSpecifiers; } + if (resultFullName != null) { ReadOnlyCollection otherSpecifiers; @@ -68,6 +69,7 @@ void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, Dk formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, formatSpecifier); } } + var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e))); wl.ContinueWith( () => GetRootResultAndContinue( @@ -311,8 +313,10 @@ private void CreateEvaluationResultAndContinue(EvalResult result, WorkList workL TargetRuntime: process.GetNativeRuntimeInstance(), DataItem: result.ToDataItem()); } + completionRoutine(evalResult); } + break; case ExpansionKind.NonPublicMembers: completionRoutine(DkmSuccessEvaluationResult.Create( @@ -520,6 +524,7 @@ internal static string GetTypeName( return string.Format("{0} {{{1}}}", declaredTypeName, runtimeTypeName); } } + return declaredTypeName; } @@ -829,6 +834,7 @@ void completionRoutine(DkmEvaluateDebuggerDisplayStringAsyncResult result) onException(e); } } + if (displayInfo == null) { completionRoutine(default(DkmEvaluateDebuggerDisplayStringAsyncResult)); @@ -911,6 +917,7 @@ void completionRoutine(DkmEvaluationAsyncResult result) onException(e); } } + if (index < numRows) { GetChild( @@ -951,6 +958,7 @@ internal Expansion GetTypeExpansion( // Null array. No expansion. return null; } + var lowerBounds = value.ArrayLowerBounds; Type elementType; @@ -1086,6 +1094,7 @@ private void Execute() _onException(e); } } + _state = State.Executed; } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs index 9ff581028a5e5..29a8795ead4a0 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs @@ -53,12 +53,14 @@ public DkmClrType ResolveTypeName(string typeName, ReadOnlyCollection 0) { var typeArgs = typeArguments.Select(t => ((TypeImpl)t.GetLmrType()).Type).ToArray(); type = type.MakeGenericType(typeArgs); } + return _runtimeInstance.GetType((TypeImpl)type); } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs index f3d7a6fab89d9..51a73265fdc68 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs @@ -48,6 +48,7 @@ internal DkmClrRuntimeInstance( { getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null); } + this.Assemblies = assemblies; this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray(); _defaultModule = getModule(this, null); @@ -98,9 +99,11 @@ internal DkmClrType GetType(string typeName, params System.Type[] typeArguments) { result = result.MakeGenericType(typeArguments.Select(this.GetType).ToArray()); } + return result; } } + return null; } @@ -119,6 +122,7 @@ private static IEnumerable WithMscorlibLast(DkmClrModuleIn yield return module; } } + if (mscorlib != null) { yield return mscorlib; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs index 964edc2b79be7..823387470479e 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs @@ -134,6 +134,7 @@ public ReadOnlyCollection GenericArguments new ReadOnlyCollection(typeArgs.Select(t => DkmClrType.Create(_appDomain, t)).ToArray()); Interlocked.CompareExchange(ref _lazyGenericArguments, genericArgs, null); } + return _lazyGenericArguments; } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs index c323cd1fb0f88..dbddeb0db4be3 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs @@ -87,6 +87,7 @@ public DkmClrValue Dereference(DkmInspectionContext inspectionContext) { throw new InvalidOperationException("Cannot dereference invalid value"); } + var elementType = this.Type.GetLmrType().GetElementType(); var evalFlags = DkmEvaluationResultFlags.None; var valueFlags = DkmClrValueFlags.None; @@ -101,6 +102,7 @@ public DkmClrValue Dereference(DkmInspectionContext inspectionContext) value = e; evalFlags |= DkmEvaluationResultFlags.ExceptionThrown; } + var valueType = new DkmClrType(this.Type.RuntimeInstance, (value == null || elementType.IsPointer) ? elementType : (TypeImpl)value.GetType()); return new DkmClrValue( value, @@ -123,6 +125,7 @@ public bool IsNull // assert since the property may be called during debugging.) throw new InvalidOperationException(); } + var lmrType = Type.GetLmrType(); return ((RawValue == null) && !lmrType.IsValueType) || (lmrType.IsPointer && (Convert.ToInt64(RawValue) == 0)); } @@ -258,6 +261,7 @@ public void EvaluateDebuggerDisplayString(DkmWorkList workList, DkmInspectionCon { throw new ArgumentException(string.Format("Nested braces in '{0}'", formatString)); } + openPos = i; } else if (ch == '}') @@ -470,6 +474,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare { evalFlags |= DkmEvaluationResultFlags.ReadOnly; } + try { value = field.GetValue(RawValue); @@ -487,6 +492,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare category: category, access: access); } + break; case MemberTypes.Property: var property = declaringType.GetProperty(MemberName, bindingFlags); @@ -497,6 +503,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare { evalFlags |= DkmEvaluationResultFlags.ReadOnly; } + try { value = property.GetValue(RawValue, bindingFlags, null, null, null); @@ -514,6 +521,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare category: category, access: access); } + break; default: throw ExceptionUtilities.UnexpectedValue((MemberTypes)MemberType); @@ -595,6 +603,7 @@ public ReadOnlyCollection ArrayDimensions { builder.Add(array.GetUpperBound(i) - array.GetLowerBound(i) + 1); } + return builder.ToImmutableAndFree(); } } @@ -615,6 +624,7 @@ public ReadOnlyCollection ArrayLowerBounds { builder.Add(array.GetLowerBound(i)); } + return builder.ToImmutableAndFree(); } } @@ -710,6 +720,7 @@ private static DkmClrModuleInstance GetModule(DkmClrAppDomain appDomain, string return module; } } + return null; } @@ -734,6 +745,7 @@ private static Type GetAncestorType(Type type, string ancestorTypeName) { return GetAncestorType(baseType, ancestorTypeName); } + return null; } @@ -765,6 +777,7 @@ private static unsafe object Dereference(IntPtr ptr, Type elementType) { throw new InvalidOperationException("Dereferencing null"); } + var destinationType = elementType.IsPointer ? (Environment.Is64BitProcess ? typeof(long) : typeof(int)) : ((TypeImpl)elementType).Type; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs index b746822ea08c9..ddc7fcbf44c83 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs @@ -22,6 +22,7 @@ public DkmEvaluationEnumAsyncResult(DkmEvaluationResult[] Items) { throw new ArgumentNullException(); } + this.Items = Items; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs index 95b99c69d5634..3f44eb94f9467 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs @@ -33,6 +33,7 @@ public static DkmEvaluationResultEnumContext Create(int Count, DkmStackWalkFrame { enumContext.SetDataItem(DkmDataCreationDisposition.CreateNew, DataItem); } + return enumContext; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs index 445a5715ee834..0f1989e02aa0a 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs @@ -22,6 +22,7 @@ public DkmGetChildrenAsyncResult(DkmEvaluationResult[] InitialChildren, DkmEvalu { throw new ArgumentNullException(); } + this.InitialChildren = InitialChildren; this.EnumContext = EnumContext; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs index c5bf773a9e0dd..81557f7e33ce3 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs @@ -85,10 +85,12 @@ internal TResult Invoke(object instance, MethodId method, Func actual, params Dk { Console.WriteLine("{0}, ", ToString(result)); } + throw; } } @@ -395,21 +400,25 @@ private static string ToString(DkmSuccessEvaluationResult result) builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } + if (result.Category != DkmEvaluationResultCategory.Other) { builder.Append(", "); builder.Append(FormatEnumValue(result.Category)); } + if (result.Access != DkmEvaluationResultAccessType.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Access)); } + if (result.EditableValue != null) { builder.Append(", "); builder.Append(Quote(result.EditableValue)); } + builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -427,16 +436,19 @@ private static string ToString(DkmIntermediateEvaluationResult result) builder.Append(", "); builder.Append(Quote(result.Type)); } + if (result.FullName != null) { builder.Append(", "); builder.Append(Quote(Escape(result.FullName))); } + if (result.Flags != DkmEvaluationResultFlags.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } + builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -454,16 +466,19 @@ private static string ToString(DkmFailedEvaluationResult result) builder.Append(", "); builder.Append(Quote(result.Type)); } + if (result.FullName != null) { builder.Append(", "); builder.Append(Quote(Escape(result.FullName))); } + if (result.Flags != DkmEvaluationResultFlags.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } + builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -507,6 +522,7 @@ internal static void Verify(DkmEvaluationResult actual, DkmEvaluationResult expe { Assert.Equal(expectedSuccess.Category, actualSuccess.Category); } + if (expectedSuccess.Access != UnspecifiedAccessType) { Assert.Equal(expectedSuccess.Access, actualSuccess.Access); diff --git a/src/Tools/Source/CompilerGeneratorTools/.editorconfig b/src/Tools/Source/CompilerGeneratorTools/.editorconfig index 4fcdb85f0c49b..58001a6f4dc19 100644 --- a/src/Tools/Source/CompilerGeneratorTools/.editorconfig +++ b/src/Tools/Source/CompilerGeneratorTools/.editorconfig @@ -3,8 +3,17 @@ # Local functions are camelCase dotnet_naming_style.local_function_style.capitalization = camel_case +# Whitespace options +dotnet_style_allow_multiple_blank_lines_experimental = true:none +dotnet_style_allow_statement_immediately_after_block_experimental = true:none + # CSharp code style settings: [*.cs] csharp_style_var_for_built_in_types = false:none csharp_style_var_when_type_is_apparent = true:none -csharp_style_var_elsewhere = false:none \ No newline at end of file +csharp_style_var_elsewhere = false:none + +# Whitespace options +csharp_style_allow_embedded_statements_on_same_line_experimental = true:none +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:none +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:none \ No newline at end of file From f0bbb6d270cceefb00efd6d6a6c3f487b1bf562b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:06:09 -0700 Subject: [PATCH 13/63] Formatting style --- src/Tools/PrepareTests/MinimizeUtil.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Tools/PrepareTests/MinimizeUtil.cs b/src/Tools/PrepareTests/MinimizeUtil.cs index 4f543eb482f38..034f413fff3d2 100644 --- a/src/Tools/PrepareTests/MinimizeUtil.cs +++ b/src/Tools/PrepareTests/MinimizeUtil.cs @@ -83,6 +83,7 @@ Dictionary> initialWalk() Directory.CreateDirectory(currentOutputDirectory); lastOutputDirectory = currentOutputDirectory; } + var fileName = Path.GetFileName(sourceFilePath); if (fileName.EndsWith(".dll", StringComparison.Ordinal) && TryGetMvid(sourceFilePath, out var mvid)) @@ -180,6 +181,7 @@ static void writeWindowsRehydrateContent(StringBuilder builder, IGrouping nul"); } + builder.AppendLine($@" mklink /h %~dp0\{destFileName} %HELIX_CORRELATION_PAYLOAD%\{source} > nul if %errorlevel% neq 0 ( @@ -192,6 +194,7 @@ static void writeWindowsRehydrateContent(StringBuilder builder, IGrouping Date: Tue, 8 Jun 2021 17:07:43 -0700 Subject: [PATCH 14/63] Formatting style --- .../Source/ResultProvider/CSharpFormatter.TypeNames.cs | 2 ++ .../CSharp/Source/ResultProvider/CSharpFormatter.Values.cs | 5 +++++ .../CSharp/Source/ResultProvider/CSharpFormatter.cs | 3 +++ .../CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs | 1 + .../CSharp/Test/ResultProvider/FormatSpecifierTests.cs | 1 + .../CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs | 1 + .../CSharp/Test/ResultProvider/ValueFormattingTests.cs | 2 ++ 7 files changed, 15 insertions(+) diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs index 7231f115708c3..17ed0dcf747e6 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs @@ -26,6 +26,7 @@ protected override void AppendIdentifierEscapingPotentialKeywords(StringBuilder { builder.Append('@'); } + builder.Append(identifier); } @@ -63,6 +64,7 @@ protected override void AppendGenericTypeArguments( out sawSingleInvalidIdentifier); sawInvalidIdentifier |= sawSingleInvalidIdentifier; } + builder.Append('>'); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs index b1f861f6b9fa5..39a9f5ee36ef9 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs @@ -73,6 +73,7 @@ internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type l { builder.Append(", "); } + var lowerBound = lowerBounds[i]; var size = sizes[i]; if (lowerBound == 0) @@ -86,6 +87,7 @@ internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type l builder.Append(FormatLiteral(size + lowerBound - 1, options)); } } + builder.Append(']'); lmrType = originalLmrType.GetElementType(); // Strip off one layer (already handled). @@ -119,10 +121,12 @@ internal override string GetCastExpression(string argument, string type, DkmClrC { builder.Append('('); } + if ((options & DkmClrCastExpressionOptions.ParenthesizeArgument) != 0) { argument = $"({argument})"; } + if ((options & DkmClrCastExpressionOptions.ConditionalCast) != 0) { builder.Append(argument); @@ -136,6 +140,7 @@ internal override string GetCastExpression(string argument, string type, DkmClrC builder.Append(')'); builder.Append(argument); } + if ((options & DkmClrCastExpressionOptions.ParenthesizeEntireExpression) != 0) { builder.Append(')'); diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs index 70ed67b5b6bca..22ba75b415067 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs @@ -88,13 +88,16 @@ private static string RemoveComments(string expression) break; } } + builder.Append(ch); } } + if (builder.Length < length) { expression = builder.ToString(); } + pooledBuilder.Free(); return expression; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs index c9d2aa5ac121b..7e3ad419144c6 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs @@ -32,6 +32,7 @@ internal static string GetPredefinedTypeName(this Type type) { return "object"; } + return null; case TypeCode.Boolean: return "bool"; diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs index dc7beb9c73067..4a6c4b24667ee 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs @@ -526,6 +526,7 @@ VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue getMemberValue(Visua return null; } } + runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)), getMemberValue: getMemberValue); using (runtime.Load()) { diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs index 68f3c9508a951..905fc1ccead06 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs @@ -24,6 +24,7 @@ public static string GetTypeName(this System.Type type, DkmClrCustomTypeInfo typ var inspectionSession = new DkmInspectionSession(ImmutableArray.Create(formatter), ImmutableArray.Create(new CSharpResultProvider())); inspectionContext = new DkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null); } + return escapeKeywordIdentifiers ? ((IDkmClrFullNameProvider)formatter).GetClrTypeName(inspectionContext, clrType, typeInfo) : inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs index cd4e889633670..9439e100d8adc 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs @@ -130,6 +130,7 @@ public void Char() expected = FormatStringChar(ch); break; } + Assert.Equal(string.Format(format, (int)ch, expected), FormatValue(ch)); Assert.Equal(string.Format(formatUsingHex, (int)ch, expected), FormatValue(ch, useHexadecimal: true)); } @@ -199,6 +200,7 @@ public void String() expected = FormatStringChar(ch); break; } + Assert.Equal(string.Format(format, expected), FormatValue(ch.ToString())); Assert.Equal(string.Format(format, expected), FormatValue(ch.ToString(), useHexadecimal: true)); } From fcc6fc5b29066df0297540563a15f551e00a177a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:27:55 -0700 Subject: [PATCH 15/63] Formatting style --- .../Core/Source/ExpressionCompiler/DkmUtilities.cs | 8 ++++++++ .../ExpressionCompiler/EEMetadataReferenceResolver.cs | 2 ++ .../Source/ExpressionCompiler/ExpressionCompiler.cs | 5 +++++ .../Core/Source/ExpressionCompiler/FrameDecoder.cs | 1 + .../ExpressionCompiler/ImmutableArrayExtensions.cs | 1 + .../Source/ExpressionCompiler/InstructionDecoder.cs | 2 ++ .../Core/Source/ExpressionCompiler/MetadataBlock.cs | 1 + .../Source/ExpressionCompiler/MetadataUtilities.cs | 11 +++++++++++ .../ExpressionCompiler/PDB/MethodDebugInfo.Native.cs | 2 ++ .../PDB/MethodDebugInfo.Portable.cs | 5 +++++ 10 files changed, 38 insertions(+) diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs index 6746304361955..bf486a025aed9 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs @@ -81,6 +81,7 @@ internal static ImmutableArray GetMetadataBlocks( { continue; } + Debug.Assert(block.ModuleVersionId == module.Mvid); builder.Add(block); index++; @@ -109,12 +110,15 @@ internal static ImmutableArray GetMetadataBlocks(GetMetadataBytes { continue; } + if (builder == null) { builder = ArrayBuilder.GetInstance(); } + builder.Add(block); } + return builder == null ? ImmutableArray.Empty : builder.ToImmutableAndFree(); } @@ -128,6 +132,7 @@ internal static ImmutableArray MakeAssemblyReaders(this DkmClrI { continue; } + MetadataReader reader; unsafe { @@ -144,8 +149,10 @@ internal static ImmutableArray MakeAssemblyReaders(this DkmClrI continue; } } + builder.Add(new AssemblyReaders(reader, symReader)); } + return builder.ToImmutableAndFree(); } @@ -323,6 +330,7 @@ internal static void SetMetadataContext(this DkmClrAppDomain a 0); message.Post(); } + appDomain.SetDataItem(DkmDataCreationDisposition.CreateAlways, new MetadataContextItem>(context)); } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs index f9aaa769bc5e2..dd90a38d11d57 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs @@ -40,6 +40,7 @@ internal EEMetadataReferenceResolver( { request = (referenceIdentity, 0); } + Requests[referenceIdentity] = (result.Identity, request.Count + 1); #endif return (PortableExecutableReference?)result.Reference; @@ -74,6 +75,7 @@ public override int GetHashCode() { best = pair; } + break; default: throw ExceptionUtilities.UnexpectedValue(compareResult); diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs index 14f9fd413db72..4d5d31b9fb2c3 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs @@ -101,6 +101,7 @@ private static ImmutableArray GetAliases(DkmClrRuntimeInstance runtimeIns dkmAlias.CustomTypeInfoPayloadTypeId, dkmAlias.CustomTypeInfoPayload)); } + return builder.ToImmutableAndFree(); } @@ -226,6 +227,7 @@ internal MakeAssemblyReferencesKind GetMakeAssemblyReferencesKind(bool useRefere { return MakeAssemblyReferencesKind.DirectReferencesOnly; } + return _useReferencedAssembliesOnly ? MakeAssemblyReferencesKind.AllReferences : MakeAssemblyReferencesKind.AllAssemblies; } @@ -337,6 +339,7 @@ private EvaluationContextBase CreateMethodContext( // No local signature. May occur when debugging heapless dumps. localSignatureToken = 0; } + return CreateMethodContext( moduleInstance.AppDomain, metadataBlocks, @@ -418,6 +421,7 @@ internal static TResult CompileWithRetry( errorMessage = null; compileResult = otherResult; } + otherDiagnostics.Free(); } else @@ -436,6 +440,7 @@ internal static TResult CompileWithRetry( } } } + diagnostics.Free(); } while (tryAgain); assembliesLoadedInRetryLoop?.Free(); diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs index 5ccf6707691e8..dad130acf5a91 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs @@ -111,6 +111,7 @@ private void GetNameWithGenericTypeArguments( { method = _instructionDecoder.ConstructMethod(method, typeParameters, typeArguments); } + onSuccess(method); } catch (Exception e) diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs index 8207c4bd06b3d..9e64bed4d61b2 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs @@ -18,6 +18,7 @@ internal static int IndexOf(this ImmutableArray array, Func< return i; } } + return -1; } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs index c8288ebf1beb5..033780d08668a 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs @@ -106,6 +106,7 @@ internal string GetName(TMethodSymbol method, bool includeParameterTypes, bool i } } } + builder.Append(')'); } @@ -142,6 +143,7 @@ internal ImmutableArray GetTypeSymbols(TCompilation compilation, TM var typeNameDecoder = GetTypeNameDecoder(compilation, method); builder.Add(typeNameDecoder.GetTypeSymbolForSerializedType(name)); } + return builder.ToImmutableAndFree(); } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs index d2fac14a6d6c4..21ba4b323d753 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs @@ -56,6 +56,7 @@ public override bool Equals(object obj) { return false; } + return Equals((MetadataBlock)obj); } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs index 3fb1d95d561a1..d4f63f5a93c60 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs @@ -72,6 +72,7 @@ internal static ImmutableArray MakeAssemblyReferences( } } } + if (IsWindowsComponent(reader, metadata.Name)) { runtimeWinMdBuilder.Add(metadata); @@ -226,9 +227,11 @@ internal static ImmutableArray MakeAssemblyReferences( { referencedModules.Add(intrinsicsAssembly); } + RemoveUnreferencedModules(referencesBuilder, identitiesBuilder, identityComparer, referencedModules); referencedModules.Free(); } + identitiesBuilder.Free(); } @@ -294,6 +297,7 @@ private static void RemoveUnreferencedModules( { index = i; } + break; default: @@ -319,6 +323,7 @@ private static void RemoveUnreferencedModules( index++; } } + modules.Clip(index); referencedIndices.Free(); @@ -387,6 +392,7 @@ internal static string GetFileNameWithoutExtension(string fileName) return fileName.Substring(0, lastDotIndex); } } + return fileName; } @@ -400,6 +406,7 @@ private static byte[] GetWindowsProxyBytes() { stream.CopyTo(memoryStream); } + return bytes; } } @@ -425,10 +432,12 @@ internal static bool IsWindowsComponent(MetadataReader reader, string moduleName { return false; } + if (!IsWindowsComponentName(moduleName)) { return false; } + int majorVersion; int minorVersion; reader.GetWinMdVersion(out majorVersion, out minorVersion); @@ -470,6 +479,7 @@ internal static ImmutableArray GetLocalNames(this ArrayBuilder GetSynthesizedMethods(byte[] assembly, strin } } } + return builder.ToImmutableAndFree(); } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs index f87096fbaa0d0..91583f36b2cfb 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs @@ -314,6 +314,7 @@ private static void ReadCSharpNativeImportsInfo( Debug.WriteLine($"Failed to parse import string {importString}"); } } + importRecordGroupBuilder.Add(groupBuilder.ToImmutableAndFree()); } @@ -418,6 +419,7 @@ private static void GetCSharpDynamicLocalInfo( continue; } } + localBuilder ??= ImmutableDictionary.CreateBuilder>(); localBuilder[slot] = flags; } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs index 7b2d22d901180..f2928762e3472 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs @@ -247,8 +247,10 @@ private static string ReadUtf8String(ref BlobReader reader) { break; } + builder.Add(b); } + var bytes = builder.ToArrayAndFree(); return Encoding.UTF8.GetString(bytes, 0, bytes.Length); } @@ -426,10 +428,12 @@ private static bool TryGetCustomDebugInformation(MetadataReader reader, EntityHa { throw new BadImageFormatException(); } + customDebugInfo = info; foundAny = true; } } + return foundAny; } @@ -459,6 +463,7 @@ private static ImmutableArray DecodeDynamicFlags(BlobReader reader) var value = ReadUtf8String(ref reader); builder.Add(value.Length == 0 ? null : value); } + return builder.ToImmutableAndFree(); } From 5faf2737c528cf1128013f6c4d89d858e454f327 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:29:00 -0700 Subject: [PATCH 16/63] Formatting style --- .../Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs | 1 + .../Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs | 2 ++ src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs | 2 ++ src/Scripting/Core/ScriptBuilder.cs | 2 ++ 4 files changed, 7 insertions(+) diff --git a/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs b/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs index 0e2d76d022210..497111a757d2c 100644 --- a/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs +++ b/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs @@ -851,6 +851,7 @@ private Builder FormatWithEmbeddedExpressions(Builder result, string format, obj _memberDisplayFormat = oldMemberDisplayFormat; } } + i = expressionEnd + 1; } } diff --git a/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs b/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs index 16a56641938e2..b0ca79a3c17d6 100644 --- a/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs +++ b/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs @@ -226,6 +226,7 @@ private void AppendArrayRank(StringBuilder sb, Type arrayType) { sb.Append(',', rank - 1); } + sb.Append(ArrayClosing); } @@ -310,6 +311,7 @@ private void AppendTypeInstantiation( { builder.Append(", "); } + builder.Append(FormatTypeName(genericArguments[genericArgIndex++], options)); } diff --git a/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs b/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs index 094c1b8807804..41e2ec7ad3ed0 100644 --- a/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs +++ b/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs @@ -37,10 +37,12 @@ internal static bool TryParsePackageReference(string reference, out string name, { return true; } + break; } } } + name = null; version = null; return false; diff --git a/src/Scripting/Core/ScriptBuilder.cs b/src/Scripting/Core/ScriptBuilder.cs index 908836a5f2ba3..87524a47cdcd7 100644 --- a/src/Scripting/Core/ScriptBuilder.cs +++ b/src/Scripting/Core/ScriptBuilder.cs @@ -109,11 +109,13 @@ private static void ThrowIfAnyCompilationErrors(DiagnosticBag diagnostics, Diagn { return; } + var filtered = diagnostics.AsEnumerable().Where(d => d.Severity == DiagnosticSeverity.Error).AsImmutable(); if (filtered.IsEmpty) { return; } + throw new CompilationErrorException( formatter.Format(filtered[0], CultureInfo.CurrentCulture), filtered); From b8eec9ffbc107bf4d6630fe55881a5769d954163 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:30:50 -0700 Subject: [PATCH 17/63] Formatting style --- src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs index 10e91ddd6ad76..dba94bbc991dd 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs @@ -327,6 +327,7 @@ protected override void ApplyProjectChanges(ProjectChanges projectChanges) projectChanges.ProjectId)); return; } + if (_projectFileLoaderRegistry.TryGetLoaderFromProjectPath(projectPath, out var fileLoader)) { try @@ -375,6 +376,7 @@ protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceTe _reporter.Report(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, message, document.Id)); return; } + this.SaveDocumentText(documentId, document.FilePath, text, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); this.OnDocumentTextChanged(documentId, text, PreservationMode.PreserveValue); } @@ -392,6 +394,7 @@ protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId _reporter.Report(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, message, document.Id)); return; } + this.SaveDocumentText(documentId, document.FilePath, text, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); this.OnAdditionalDocumentTextChanged(documentId, text, PreservationMode.PreserveValue); } @@ -435,6 +438,7 @@ protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) { return; } + if (_projectFileLoaderRegistry.TryGetLoaderFromProjectPath(filePath, out _)) { var extension = _applyChangesProjectFile.GetDocumentExtension(info.SourceCodeKind); @@ -530,6 +534,7 @@ protected override void ApplyMetadataReferenceAdded(ProjectId projectId, Metadat _reporter.Report(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, message, projectId)); return; } + _applyChangesProjectFile.AddMetadataReference(metadataReference, identity); this.OnMetadataReferenceAdded(projectId, metadataReference); } @@ -544,6 +549,7 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad _reporter.Report(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, message, projectId)); return; } + _applyChangesProjectFile.RemoveMetadataReference(metadataReference, identity); this.OnMetadataReferenceRemoved(projectId, metadataReference); } @@ -555,6 +561,7 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad { return null; } + if (!project.MetadataReferences.Contains(metadataReference)) { project = project.AddMetadataReference(metadataReference); @@ -565,6 +572,7 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad { return null; } + var symbol = compilation.GetAssemblyOrModuleSymbol(metadataReference) as IAssemblySymbol; return symbol?.Identity; } From a8f54ecfdd31eb5698e2da45981800ba42f9b4e9 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:32:05 -0700 Subject: [PATCH 18/63] Formatting style --- .../Binders/PlaceholderLocalBinder.cs | 2 ++ .../Binders/WithTypeArgumentsBinder.cs | 2 ++ .../ExpressionCompiler/CSharpEESymbolProvider.cs | 2 ++ .../ExpressionCompiler/CSharpInstructionDecoder.cs | 3 +++ .../Source/ExpressionCompiler/CompilationContext.cs | 3 +++ .../ExpressionCompiler/CompilationExtensions.cs | 2 ++ .../Source/ExpressionCompiler/EEAssemblyBuilder.cs | 4 ++++ .../Source/ExpressionCompiler/EETypeNameDecoder.cs | 2 ++ .../Source/ExpressionCompiler/EvaluationContext.cs | 3 +++ .../Rewriters/CapturedVariableRewriter.cs | 3 +++ .../Rewriters/MayHaveSideEffectsVisitor.cs | 2 ++ .../Rewriters/PlaceholderLocalRewriter.cs | 2 ++ .../Symbols/DisplayClassVariable.cs | 1 + .../ExpressionCompiler/Symbols/EELocalSymbolBase.cs | 1 + .../ExpressionCompiler/Symbols/EEMethodSymbol.cs | 13 +++++++++++++ .../Symbols/EETypeParameterSymbol.cs | 1 + .../Symbols/PlaceholderLocalSymbol.cs | 1 + .../Source/ExpressionCompiler/SyntaxHelpers.cs | 6 ++++++ .../ExpressionCompiler/TypeParameterChecker.cs | 1 + 19 files changed, 54 insertions(+) diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs index d4714330a250e..e4d30d699e68c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs @@ -55,6 +55,7 @@ internal PlaceholderLocalBinder( lowercaseBuilder.Add(local.Name.ToLower(), local); } } + _lowercaseReturnValueAliases = lowercaseBuilder.ToImmutableDictionary(); _aliases = aliasesBuilder.ToImmutableAndFree(); } @@ -83,6 +84,7 @@ internal sealed override void LookupSymbolsInSingleBinder( // Invalid value should have been caught by Lexer. throw ExceptionUtilities.UnexpectedValue(valueText); } + var local = new ObjectAddressLocalSymbol(_containingMethod, name, this.Compilation.GetSpecialType(SpecialType.System_Object), address); result.MergeEqual(this.CheckViability(local, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved)); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs index b81bf38e5353d..14312aa1027e5 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs @@ -37,8 +37,10 @@ protected override MultiDictionary TypeParameterMap { result.Add(tps.Type.Name, (TypeParameterSymbol)tps.Type); } + Interlocked.CompareExchange(ref _lazyTypeParameterMap, result, null); } + return _lazyTypeParameterMap; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs index a24d60eff6282..70391f829af20 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs @@ -96,6 +96,7 @@ public override IAssemblySymbolInternal GetReferencedAssembly(AssemblyReferenceH { throw new BadImageFormatException(); } + return assembly; } @@ -116,6 +117,7 @@ private TypeSymbol IncludeDynamicAndTupleElementNamesIfAny( { type = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(type, _sourceAssembly, refKind, dynamicFlagsOpt, checkLength: false); } + return TupleTypeDecoder.DecodeTupleTypesIfApplicable(type, tupleElementNamesOpt); } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs index cac560827a160..2abda45dd6c0e 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs @@ -64,6 +64,7 @@ internal override void AppendFullName(StringBuilder builder, MethodSymbol method while (i < numParts && parts[i].Kind != SymbolDisplayPartKind.MethodName); i--; } + break; case SymbolDisplayPartKind.MethodName: @@ -88,6 +89,7 @@ internal override void AppendFullName(StringBuilder builder, MethodSymbol method { builder.Append(displayString); } + break; default: @@ -127,6 +129,7 @@ internal override MethodSymbol ConstructMethod(MethodSymbol method, ImmutableArr { method = method.Construct(ImmutableArray.Create(typeArguments, methodArgumentStartIndex, methodArity)); } + return method; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs index d3dab807d90fe..1b63994c591ce 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs @@ -776,6 +776,7 @@ private static CSharpCompilation GetCompilationWithExternAliases(CSharpCompilati updatedReferences.Add(reference); assembliesAndModulesBuilder.Add(compilation.GetAssemblyOrModuleSymbol(reference)!); } + Debug.Assert(assembliesAndModulesBuilder.Count == updatedReferences.Count); var assembliesAndModules = assembliesAndModulesBuilder.ToImmutableAndFree(); @@ -1306,6 +1307,7 @@ private static void GetDisplayClassVariables( } } } + GetAdditionalDisplayClassInstances(displayClassTypes, displayClassInstances, startIndex); displayClassTypes.Free(); @@ -1386,6 +1388,7 @@ private static void GetDisplayClassInstances( { continue; } + break; case GeneratedNameKind.ThisProxyField: if (GeneratedNames.GetKind(fieldType.Name) != GeneratedNameKind.LambdaDisplayClass) diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs index 4ae4b2f71fab9..36beacd23cb74 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs @@ -55,6 +55,7 @@ internal static PEMethodSymbol GetSourceMethod(this CSharpCompilation compilatio } } } + return method; } @@ -102,6 +103,7 @@ internal static CSharpCompilation ToCompilation(this ImmutableArray GetLocalDefinitions(ImmutableArray.Empty; } + diagnostics.Free(); return assembly; } @@ -487,6 +488,7 @@ internal static ImmutableArray GetMissingAssemblyIdentitiesHel return ImmutableArray.Create(identity); } } + break; case ErrorCode.ERR_DottedTypeNameNotFoundInNS: @@ -500,6 +502,7 @@ arguments[1] is NamespaceSymbol containingNamespace && var identity = new AssemblyIdentity($"{containingNamespace.ToDisplayString()}.{namespaceName}", contentType: System.Reflection.AssemblyContentType.WindowsRuntime); return ImmutableArray.Create(identity); } + break; case ErrorCode.ERR_NoSuchMemberOrExtension: // Commonly, but not always, caused by absence of System.Core. diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs index 137fb1b98f63c..8de7e2c0d754a 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs @@ -64,6 +64,7 @@ public override BoundNode VisitLocal(BoundLocal node) return result; } } + return node; } @@ -75,6 +76,7 @@ public override BoundNode VisitParameter(BoundParameter node) { return node; } + return variable.ToBoundExpression(node.Syntax); } @@ -128,6 +130,7 @@ private BoundExpression GenerateThisReference(BoundExpression node) { return rewrittenThis; } + var boundKind = node.Kind; Debug.Assert(boundKind == BoundKind.ThisReference || boundKind == BoundKind.BaseReference); var errorCode = boundKind == BoundKind.BaseReference diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs index 0c9de94a95694..5b70b4c6704a0 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs @@ -23,6 +23,7 @@ public override BoundNode Visit(BoundNode node) { return null; } + return base.Visit(node); } @@ -75,6 +76,7 @@ public override BoundNode VisitObjectInitializerExpression(BoundObjectInitialize initializer; this.Visit(expr); } + return null; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs index 1eae863ab14fb..dfc9ec0ef328c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs @@ -46,10 +46,12 @@ private BoundExpression RewriteLocal(BoundLocal node) { return placeholder.RewriteLocal(_compilation, _container, node.Syntax, _diagnostics); } + if (_declaredLocals.Contains(local)) { return ObjectIdLocalSymbol.RewriteLocal(_compilation, _container, node.Syntax, local); } + return node; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs index ac9473880375d..931a31429eb20 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs @@ -70,6 +70,7 @@ internal BoundExpression ToBoundExpression(SyntaxNode syntax) { expr = new BoundFieldAccess(syntax, expr, field, constantValueOpt: null) { WasCompilerGenerated = true }; } + fields.Free(); return expr; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs index d717b5cb363b5..440581d2368eb 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs @@ -21,6 +21,7 @@ internal static LocalSymbol ToOtherMethod(this LocalSymbol local, MethodSymbol m { return l.ToOtherMethod(method, typeMap); } + var type = typeMap.SubstituteType(local.TypeWithAnnotations); return new EELocalSymbol(method, local.Locations, local.Name, -1, local.DeclarationKind, type, local.RefKind, local.IsPinned, local.IsCompilerGenerated, local.CanScheduleToStack); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs index cb7091fa2d8cb..001d68b42b0e9 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs @@ -109,6 +109,7 @@ internal EEMethodSymbol( { this.SubstitutedSourceMethod = this.SubstitutedSourceMethod.Construct(_typeParameters.As()); } + TypeParameterChecker.Check(this.SubstitutedSourceMethod, _allTypeParameters); // Create a map from original parameter to target parameter. @@ -142,6 +143,7 @@ internal EEMethodSymbol( localsMap.Add(sourceLocal, local); localsBuilder.Add(local); } + this.Locals = localsBuilder.ToImmutableAndFree(); localsBuilder = ArrayBuilder.GetInstance(); foreach (var sourceLocal in sourceLocalsForBinding) @@ -152,8 +154,10 @@ internal EEMethodSymbol( local = sourceLocal.ToOtherMethod(this, this.TypeMap); localsMap.Add(sourceLocal, local); } + localsBuilder.Add(local); } + this.LocalsForBinding = localsBuilder.ToImmutableAndFree(); // Create a map from variable name to display class field. @@ -300,6 +304,7 @@ public override TypeWithAnnotations ReturnTypeWithAnnotations { throw new InvalidOperationException(); } + return _lazyReturnType; } } @@ -355,10 +360,12 @@ internal override Cci.CallingConvention CallingConvention { cc |= Cci.CallingConvention.ExtraArguments; } + if (this.IsGenericMethod) { cc |= Cci.CallingConvention.Generic; } + return cc; } } @@ -523,6 +530,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, localsBuilder.Add(local); localsSet.Add(local); } + foreach (var local in this.Locals) { if (localsSet.Add(local)) @@ -648,6 +656,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, Debug.Assert(!(local is EELocalSymbol) || (((EELocalSymbol)local).Ordinal == localBuilder.Count)); localBuilder.Add(local); } + foreach (var local in block.Locals) { if (local is EELocalSymbol oldLocal) @@ -655,6 +664,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, Debug.Assert(localBuilder[oldLocal.Ordinal] == oldLocal); continue; } + localBuilder.Add(local); } @@ -675,6 +685,7 @@ private BoundExpression GenerateThisReference(SyntaxNode syntax) { return thisProxy.ToBoundExpression(syntax); } + if ((object)_thisParameter != null) { var typeNameKind = GeneratedNames.GetKind(_thisParameter.TypeWithAnnotations.Type.Name); @@ -685,8 +696,10 @@ private BoundExpression GenerateThisReference(SyntaxNode syntax) $"Unexpected typeNameKind '{typeNameKind}'"); return null; } + return new BoundParameter(syntax, _thisParameter); } + return null; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs index d6631399d085c..299f288aa8186 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs @@ -178,6 +178,7 @@ private TypeMap TypeMap { Interlocked.CompareExchange(ref _lazyTypeMap, _getTypeMap(), null); } + return _lazyTypeMap; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs index 976d14545c3a8..99c48e43d7841 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs @@ -208,6 +208,7 @@ internal static MethodSymbol GetIntrinsicMethod(CSharpCompilation compilation, s { return null; } + var members = type.GetMembers(methodName); Debug.Assert(members.Length == 1); return (MethodSymbol)members[0]; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs index c67ee1d1d5839..ef666c52b24dc 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs @@ -50,6 +50,7 @@ internal static class SyntaxHelpers builder.Free(); } + return diagnostics.HasAnyErrors() ? null : syntax; } @@ -122,6 +123,7 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(token, diagnostics); return false; } + builder.Add(token); start = -1; expectingComma = (c != ','); @@ -133,6 +135,7 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(",", diagnostics); return false; } + expectingComma = false; } } @@ -150,6 +153,7 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(token, diagnostics); return false; } + builder.Add(token); } else if (!expectingComma) @@ -186,11 +190,13 @@ private static bool RemoveSemicolonIfAny(ref string str) str = str.Substring(0, i); return true; } + if (!SyntaxFacts.IsWhitespace(c)) { break; } } + return false; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs index d129a5fc568f5..4edcebb46bd3a 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs @@ -53,6 +53,7 @@ public override BoundNode Visit(BoundNode node) { _typeParameterChecker.Visit(expression.ExpressionSymbol.GetPublicSymbol()); } + return base.Visit(node); } } From bf9f07ad27ff7ee730b33b854dff155255f54a55 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:33:43 -0700 Subject: [PATCH 19/63] Formatting style --- .../ExpressionCompiler/Binders/PlaceholderLocalBinder.vb | 1 + .../Source/ExpressionCompiler/CompilationContext.vb | 7 +++++++ .../Source/ExpressionCompiler/CompilationExtensions.vb | 2 ++ .../Source/ExpressionCompiler/EEAssemblyBuilder.vb | 4 ++++ .../Source/ExpressionCompiler/EETypeNameDecoder.vb | 2 ++ .../Source/ExpressionCompiler/EvaluationContext.vb | 3 +++ .../Rewriters/CapturedVariableRewriter.vb | 2 ++ .../Rewriters/LocalDeclarationRewriter.vb | 2 ++ .../Rewriters/MayHaveSideEffectsVisitor.vb | 1 + .../Rewriters/PlaceholderLocalRewriter.vb | 2 ++ .../Source/ExpressionCompiler/SymbolExtensions.vb | 2 ++ .../ExpressionCompiler/Symbols/DisplayClassVariable.vb | 2 ++ .../ExpressionCompiler/Symbols/EELocalSymbolBase.vb | 1 + .../Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb | 9 +++++++++ .../ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb | 1 + .../Source/ExpressionCompiler/SyntaxHelpers.vb | 6 ++++++ .../ExpressionCompiler/VisualBasicInstructionDecoder.vb | 2 ++ 17 files changed, 49 insertions(+) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb index 8b0ae8c7d9691..a12c4327125db 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb @@ -83,6 +83,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If name.StartsWith("$", StringComparison.Ordinal) Then diagnostics.Add(ERRID.ERR_IllegalChar, identifier.GetLocation()) End If + Return local End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb index d550157d72cee..b465cef63a7e1 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb @@ -248,6 +248,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.GetUseSiteInfo().DiagnosticInfo?.Severity = DiagnosticSeverity.Error Then Continue For End If + Dim aliasMethod = Me.CreateMethod( container, methodName, @@ -533,6 +534,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Debug.Assert(isError = diagnostics.HasAnyErrors()) result = Not isError End If + diagnostics.Free() Return result End Function @@ -596,6 +598,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Else Debug.Assert([namespace] Is compilation.GlobalNamespace) End If + binder = New NamespaceBinder(binder, [namespace]) End While @@ -712,6 +715,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator importsBuilder.AddRange(projectLevelImportsBuilder) projectLevelImportsBuilder.Free() End If + If importsBuilder IsNot Nothing Then Dim [imports] As ImmutableArray(Of NamespaceOrTypeAndImportsClausePosition) = importsBuilder.ToImmutableAndFree() binder = New TypesOfImportedNamespacesMembersBinder(binder, [imports]) @@ -1109,6 +1113,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If End If Next + GetAdditionalDisplayClassInstances(displayClassTypes, displayClassInstances, startIndex) displayClassTypes.Free() @@ -1221,6 +1226,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If member.Kind <> SymbolKind.Field Then Continue For End If + Dim field = DirectCast(member, FieldSymbol) Dim fieldType = field.Type Dim fieldName As String = field.Name @@ -1413,6 +1419,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator While type.IsClosureOrStateMachineType() type = type.ContainingType End While + Debug.Assert(type IsNot Nothing) Return type diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb index e3f370b13606c..d6fed52e9238d 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb @@ -48,6 +48,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If Next End If + Return method End Function @@ -97,6 +98,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim resolver = New EEMetadataReferenceResolver(IdentityComparer, referencesBySimpleName) options = options.WithMetadataReferenceResolver(resolver) End If + Return VisualBasicCompilation.Create( assemblyName:=ExpressionCompilerUtilities.GenerateUniqueName(), references:=references, diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb index dc8dfea4640be..36e649a311f78 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb @@ -61,6 +61,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Return New Microsoft.CodeAnalysis.ExpressionEvaluator.AssemblyReference(identity) End If End If + Return MyBase.TranslateModule(symbol, diagnostics) End Function @@ -82,6 +83,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim defs = GetLocalDefinitions(method.Locals, diagnostics) Return New SlotAllocator(defs) End If + Return Nothing End Function @@ -97,6 +99,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator builder.Add(def) End Select Next + Return builder.ToImmutableAndFree() End Function @@ -150,6 +153,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local Is Nothing Then Return Nothing End If + Return _locals(local.Ordinal) End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb index bc0244cde2d96..d61d613817b1b 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb @@ -26,6 +26,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If index >= 0 Then Return index End If + If identity.IsWindowsComponent() Then ' Find placeholder Windows.winmd assembly (created ' in MetadataUtilities.MakeAssemblyReferences). @@ -40,6 +41,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If End If End If + Return -1 End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb index e4896807e92d4..b391bea0bd329 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb @@ -517,6 +517,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If member.Kind <> SymbolKind.Field Then Continue For End If + Dim methodName As String = Nothing Dim methodSignature As String = Nothing Dim localName As String = Nothing @@ -600,12 +601,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator pos = 1 Debug.Assert(pos < numParts) End If + Dim currNamespace = globalNamespace While pos < numParts Dim nextNamespace = currNamespace.GetMembers(nameParts(pos)).OfType(Of NamespaceSymbol).SingleOrDefault() If nextNamespace Is Nothing Then Exit While End If + pos += 1 currNamespace = nextNamespace End While diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb index 7377424f87449..02d794b8617ed 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb @@ -66,6 +66,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Debug.Assert(TypeSymbol.Equals(node.Type, result.Type, TypeCompareKind.ConsiderEverything)) Return result End If + Dim variable = GetVariable(local.Name) If variable IsNot Nothing Then Dim result = variable.ToBoundExpression(syntax, node.IsLValue, node.SuppressVirtualCalls) @@ -73,6 +74,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Return result End If End If + Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb index ae6db766bd0ca..9091eced61a65 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb @@ -23,6 +23,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator For Each local In locals builder.Add(GenerateCreateVariableStatement(compilation, container, syntax, local)) Next + builder.AddRange(block.Statements) block = New BoundBlock(syntax, block.StatementListSyntax, block.Locals, builder.ToImmutableAndFree()) End If @@ -46,6 +47,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.DeclarationKind = LocalDeclarationKind.ImplicitVariable Then _locals.Add(local) End If + Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb index d4ce20d2ce665..7c73208968c3d 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb @@ -61,6 +61,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator initializer) Visit(expr) Next + Return Nothing End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb index 3b5cb26faad94..bc07b1819889c 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb @@ -36,10 +36,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.DeclarationKind = LocalDeclarationKind.ImplicitVariable Then Return ObjectIdLocalSymbol.RewriteLocal(_compilation, _container, node.Syntax, local, node.IsLValue) End If + Dim placeholder = TryCast(local, PlaceholderLocalSymbol) If placeholder IsNot Nothing Then Return placeholder.RewriteLocal(_compilation, _container, node.Syntax, node.IsLValue, diagnostics) End If + Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb index a4df6a307bf69..ecd9a3f40d1b6 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb @@ -33,8 +33,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator containingSymbol = containingSymbol.ContainingSymbol End While + Return True End If + Return False End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb index 0f30b7d48cac7..6d73fc133c7fe 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb @@ -68,6 +68,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator For Each field In fields expr = New BoundFieldAccess(syntax, expr, field, isLValue, suppressVirtualCalls, constantsInProgressOpt:=Nothing, type:=field.Type).MakeCompilerGenerated() Next + fields.Free() Return expr End Function @@ -85,6 +86,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If Not fields.Any() Then Return ConsList(Of FieldSymbol).Empty End If + Dim head = SubstituteField(fields.Head, typeMap) Dim tail = SubstituteFields(fields.Tail, typeMap) Return tail.Prepend(head) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb index 61fdceacdda52..d37f99104f5bf 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb @@ -15,6 +15,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If l IsNot Nothing Then Return l.ToOtherMethod(method, typeMap) End If + Dim type = typeMap.SubstituteType(local.Type) Return New EELocalSymbol(method, local.Locations, local.Name, -1, local.DeclarationKind, type, local.IsByRef, local.IsPinned, local.CanScheduleToStack) End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb index 34f180d511429..6fd6ab1909115 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb @@ -97,6 +97,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If _typeParameters.Any() Then Me.SubstitutedSourceMethod = Me.SubstitutedSourceMethod.Construct(_typeParameters.As(Of TypeSymbol)()) End If + TypeParameterChecker.Check(Me.SubstitutedSourceMethod, _allTypeParameters) ' Create a map from original parameter to target parameter. @@ -127,6 +128,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator localsMap.Add(sourceLocal, local) localsBuilder.Add(local) Next + Me.Locals = localsBuilder.ToImmutableAndFree() localsBuilder = ArrayBuilder(Of LocalSymbol).GetInstance() For Each sourceLocal In sourceLocalsForBinding @@ -135,8 +137,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator local = sourceLocal.ToOtherMethod(Me, Me.TypeMap) localsMap.Add(sourceLocal, local) End If + localsBuilder.Add(local) Next + Me.LocalsForBinding = localsBuilder.ToImmutableAndFree() ' Create a map from variable name to display class field. @@ -275,6 +279,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If _lazyReturnType Is Nothing Then Throw New InvalidOperationException() End If + Return _lazyReturnType End Get End Property @@ -332,9 +337,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If Me.IsVararg Then cc = cc Or Cci.CallingConvention.ExtraArguments End If + If Me.IsGenericMethod Then cc = cc Or Cci.CallingConvention.Generic End If + Return cc End Get End Property @@ -481,11 +488,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator originalLocalsBuilder.Add(local) originalLocalsSet.Add(local) Next + For Each local In Me.Locals If originalLocalsSet.Add(local) Then originalLocalsBuilder.Add(local) End If Next + originalLocalsSet.Free() Dim originalLocals = originalLocalsBuilder.ToImmutableAndFree() Dim newBody = New BoundBlock(syntax, Nothing, originalLocals, statementsBuilder.ToImmutableAndFree()) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb index d57c77036919d..ac98718fdfd05 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb @@ -60,6 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If isLValue Then Return variable End If + Return variable.MakeRValue() End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb index 1a8649bef1419..bb14ae783a9ab 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb @@ -27,8 +27,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If ParseFormatSpecifiers(builder, expr, syntax.Expression.FullWidth, diagnostics) AndAlso builder.Count > 0 Then formatSpecifiers = New ReadOnlyCollection(Of String)(builder.ToArray()) End If + builder.Free() End If + Return If(diagnostics.HasAnyErrors(), Nothing, syntax) End Function @@ -96,6 +98,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(token, diagnostics) Return False End If + builder.Add(token) start = -1 expectingComma = c <> ","c @@ -104,11 +107,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(",", diagnostics) Return False End If + expectingComma = False End If ElseIf start < 0 Then start = offset End If + offset = offset + 1 End While @@ -118,6 +123,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(token, diagnostics) Return False End If + builder.Add(token) ElseIf Not expectingComma Then ReportInvalidFormatSpecifier(",", diagnostics) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb index 137dcd41d6a1a..94ff7a5f12d0b 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb @@ -44,6 +44,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Do i += 1 Loop While ((i < numParts) AndAlso parts(i).Kind <> SymbolDisplayPartKind.MethodName) + i -= 1 End If Case SymbolDisplayPartKind.MethodName @@ -77,6 +78,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If methodArity > 0 Then method = method.Construct(ImmutableArray.Create(typeArguments, methodArgumentStartIndex, methodArity)) End If + Return method End Function From 0ac098b67537c6ef8a531b9be84ebc37d43b7ed4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:34:46 -0700 Subject: [PATCH 20/63] Revert --- .../PooledObjects/PooledHashSet.cs | 4 +-- .../SymbolCompletionProviderTests.cs | 1 - .../AddExplicitCast/AddExplicitCastTests.cs | 3 -- .../Suppression/SuppressionTests.cs | 1 - .../CSharpTest/Intents/IntentTestsBase.cs | 1 - ...ionExpressionSignatureHelpProviderTests.cs | 1 - .../SplitStringLiteralCommandHandlerTests.cs | 1 - .../Binders/PlaceholderLocalBinder.cs | 6 ++-- .../Binders/WithTypeArgumentsBinder.cs | 2 -- .../CSharpEESymbolProvider.cs | 2 -- .../CSharpInstructionDecoder.cs | 3 -- .../ExpressionCompiler/CompilationContext.cs | 3 -- .../CompilationExtensions.cs | 2 -- .../ExpressionCompiler/EEAssemblyBuilder.cs | 8 ++--- .../ExpressionCompiler/EETypeNameDecoder.cs | 6 ++-- .../ExpressionCompiler/EvaluationContext.cs | 3 -- .../Rewriters/CapturedVariableRewriter.cs | 3 -- .../Rewriters/MayHaveSideEffectsVisitor.cs | 2 -- .../Rewriters/PlaceholderLocalRewriter.cs | 2 -- .../Symbols/DisplayClassVariable.cs | 1 - .../Symbols/EELocalSymbolBase.cs | 1 - .../Symbols/EEMethodSymbol.cs | 13 -------- .../Symbols/EENamedTypeSymbol.cs | 4 +-- .../Symbols/EETypeParameterSymbol.cs | 1 - .../Symbols/ExceptionLocalSymbol.cs | 4 +-- .../Symbols/ObjectAddressLocalSymbol.cs | 4 +-- .../Symbols/ObjectIdLocalSymbol.cs | 4 +-- .../Symbols/PlaceholderLocalSymbol.cs | 1 - .../Symbols/ReturnValueLocalSymbol.cs | 4 +-- .../ExpressionCompiler/SyntaxHelpers.cs | 6 ---- .../TypeParameterChecker.cs | 1 - .../CSharpFormatter.TypeNames.cs | 2 -- .../ResultProvider/CSharpFormatter.Values.cs | 5 --- .../Source/ResultProvider/CSharpFormatter.cs | 3 -- .../ResultProvider/Helpers/TypeExtensions.cs | 1 - .../ReferencedModulesTests.cs | 4 +-- .../CSharpResultProviderTestBase.cs | 8 ++--- .../CustomResultProviderTests.cs | 4 +-- .../ResultProvider/FormatSpecifierTests.cs | 1 - .../Helpers/TestTypeExtensions.cs | 1 - .../ResultProvider/ValueFormattingTests.cs | 2 -- .../ExpressionCompiler/CustomTypeInfo.cs | 3 -- .../Source/ExpressionCompiler/DkmUtilities.cs | 8 ----- .../DynamicFlagsCustomTypeInfo.cs | 1 - .../EEMetadataReferenceResolver.cs | 2 -- .../ExpressionCompiler/ExpressionCompiler.cs | 5 --- .../ExpressionEvaluatorFatalError.cs | 1 - .../Source/ExpressionCompiler/FrameDecoder.cs | 1 - .../ImmutableArrayExtensions.cs | 1 - .../ExpressionCompiler/InstructionDecoder.cs | 2 -- .../ExpressionCompiler/MetadataBlock.cs | 1 - .../ExpressionCompiler/MetadataUtilities.cs | 11 ------- .../PDB/MethodDebugInfo.Native.cs | 2 -- .../PDB/MethodDebugInfo.Portable.cs | 5 --- .../Expansion/ArrayExpansion.cs | 6 ---- .../Expansion/DebuggerTypeProxyExpansion.cs | 1 - .../Expansion/MemberExpansion.cs | 5 --- .../Expansion/ResultsViewExpansion.cs | 4 --- .../Expansion/RootHiddenExpansion.cs | 2 -- .../Expansion/TupleExpansion.cs | 3 -- .../ResultProvider/Formatter.TypeNames.cs | 7 ---- .../Source/ResultProvider/Formatter.Values.cs | 3 -- .../Core/Source/ResultProvider/Formatter.cs | 13 -------- .../ResultProvider/Helpers/ArrayBuilder.cs | 1 - .../Helpers/AttributeHelpers.cs | 5 --- .../Helpers/CustomTypeInfoTypeArgumentMap.cs | 1 - .../Helpers/EvalResultDataItem.cs | 1 - .../ResultProvider/Helpers/TypeHelpers.cs | 17 ---------- .../ResultProvider/Helpers/ValueHelpers.cs | 2 -- .../Source/ResultProvider/ResultProvider.cs | 9 ----- .../DkmClrDebuggerBrowsableAttribute.cs | 4 +-- .../DkmClrDebuggerTypeProxyAttribute.cs | 4 +-- .../DkmClrDebuggerVisualizerAttribute.cs | 4 +-- .../Debugger/Engine/DkmClrModuleInstance.cs | 6 ++-- .../Debugger/Engine/DkmClrRuntimeInstance.cs | 4 --- .../Debugger/Engine/DkmClrType.cs | 9 +++-- .../Debugger/Engine/DkmClrValue.cs | 13 -------- .../Engine/DkmEvaluationEnumAsyncResult.cs | 1 - .../Engine/DkmEvaluationResultEnumContext.cs | 1 - .../Engine/DkmFailedEvaluationResult.cs | 4 +-- .../Engine/DkmGetChildrenAsyncResult.cs | 1 - .../Debugger/Engine/DkmInspectionSession.cs | 2 -- .../Engine/DkmIntermediateEvaluationResult.cs | 4 +-- .../Engine/DkmSuccessEvaluationResult.cs | 4 +-- .../Debugger/MemberInfo/TypeImpl.cs | 5 --- .../ResultProvider/ResultProviderTestBase.cs | 16 --------- .../Binders/PlaceholderLocalBinder.vb | 1 - .../ExpressionCompiler/CompilationContext.vb | 7 ---- .../CompilationExtensions.vb | 2 -- .../ExpressionCompiler/EEAssemblyBuilder.vb | 4 --- .../ExpressionCompiler/EETypeNameDecoder.vb | 2 -- .../ExpressionCompiler/EvaluationContext.vb | 3 -- .../Rewriters/CapturedVariableRewriter.vb | 2 -- .../Rewriters/LocalDeclarationRewriter.vb | 2 -- .../Rewriters/MayHaveSideEffectsVisitor.vb | 1 - .../Rewriters/PlaceholderLocalRewriter.vb | 2 -- .../ExpressionCompiler/SymbolExtensions.vb | 2 -- .../Symbols/DisplayClassVariable.vb | 2 -- .../Symbols/EELocalSymbolBase.vb | 1 - .../Symbols/EEMethodSymbol.vb | 9 ----- .../Symbols/ObjectIdLocalSymbol.vb | 1 - .../ExpressionCompiler/SyntaxHelpers.vb | 6 ---- .../VisualBasicInstructionDecoder.vb | 2 -- .../Portable/FindUsages/DefinitionItem.cs | 4 +-- .../CommonObjectFormatter.Visitor.cs | 1 - .../CommonTypeNameFormatter.cs | 2 -- .../Hosting/Resolvers/NuGetPackageResolver.cs | 2 -- src/Scripting/Core/ScriptBuilder.cs | 2 -- src/Tools/AnalyzerRunner/Options.cs | 1 - .../BuildValidator/LocalReferenceResolver.cs | 1 - .../BuildValidator/PEReaderExtensions.cs | 2 -- src/Tools/BuildValidator/Program.cs | 1 - src/Tools/PrepareTests/MinimizeUtil.cs | 5 --- .../MiscellaneousDiagnosticListTable.cs | 4 +-- .../MiscellaneousTodoListTable.cs | 4 +-- .../VisualStudioBaseDiagnosticListTable.cs | 4 +-- ...iagnosticListTable.BuildTableDataSource.cs | 4 +-- .../VisualStudioDiagnosticListTable.cs | 12 +++---- .../VisualStudioTodoListTable.cs | 4 +-- .../InProcess/FindReferencesWindow_InProc.cs | 1 - .../InProcess/SolutionExplorer_InProc.cs | 7 ---- .../InProcess/TextViewWindow_InProc.cs | 1 - .../VisualStudioInstanceFactory.cs | 1 - .../Impl/Client/RemoteDiagnosticListTable.cs | 4 +-- .../DiscardSyntaxClassifier.cs | 2 -- .../NameSyntaxClassifier.cs | 1 - .../CodeGeneration/CSharpSyntaxGenerator.cs | 33 ------------------- .../CSharpSimplificationService.Expander.cs | 2 -- .../Core/MSBuild/MSBuild/MSBuildWorkspace.cs | 8 ----- .../IncrementalAnalyzerProviderMetadata.cs | 8 ++--- .../EventListener/EventListenerMetadata.cs | 8 ++--- .../DiagnosticAnalyzer/PerformanceQueue.cs | 4 +-- .../PerformanceTrackerService.cs | 4 +-- .../VirtualChars/CSharpVirtualCharService.cs | 1 - .../CSharpFormattingOptions2.Parsers.cs | 2 -- .../Services/SyntaxFacts/CSharpSyntaxFacts.cs | 6 ---- .../Simplifiers/CastSimplifier.cs | 1 - .../ContextQuery/SyntaxTreeExtensions.cs | 2 -- .../DocumentationCommentExtensions.cs | 1 - ...CSharpTypeInferenceService.TypeInferrer.cs | 3 -- 140 files changed, 76 insertions(+), 460 deletions(-) diff --git a/src/Dependencies/PooledObjects/PooledHashSet.cs b/src/Dependencies/PooledObjects/PooledHashSet.cs index ee17f78e4384d..472380a3c3e4a 100644 --- a/src/Dependencies/PooledObjects/PooledHashSet.cs +++ b/src/Dependencies/PooledObjects/PooledHashSet.cs @@ -13,8 +13,8 @@ internal sealed partial class PooledHashSet : HashSet { private readonly ObjectPool> _pool; - private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) - : base(equalityComparer) + private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) : + base(equalityComparer) { _pool = pool; } diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs index b2f7621ce799f..01a35d5e86898 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs @@ -9576,7 +9576,6 @@ void goo() { await VerifyItemExistsAsync(markup, "Item" + i); } - await VerifyItemExistsAsync(markup, "ToString"); await VerifyItemIsAbsentAsync(markup, "Item1"); diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs index c959df4927171..76b210500ddf9 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.cs @@ -2522,7 +2522,6 @@ public Test(string s, Base b, int i, params object[] list) : this(d : [||]b, s : var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(2, actions.Length); } - var expect_0 = @" class Program @@ -2672,7 +2671,6 @@ void M() var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(2, actions.Length); } - var expect_0 = @" class Program @@ -2748,7 +2746,6 @@ void M() var (actions, actionToInvoke) = await GetCodeActionsAsync(workspace, new TestParameters()); Assert.Equal(3, actions.Length); } - var expect_0 = @" class Program diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs index 0fc6908c7a5b2..de59148fc6de0 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs @@ -927,7 +927,6 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, trivia.GetLocation())); } - break; } } diff --git a/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs b/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs index e7d6f5af75de2..e14a8ea6bf880 100644 --- a/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs +++ b/src/EditorFeatures/CSharpTest/Intents/IntentTestsBase.cs @@ -76,7 +76,6 @@ internal static async Task VerifyExpectedTextAsync(string intentName, string act { edit.Replace(change.Span.ToSpan(), change.NewText); } - edit.Apply(); Assert.Equal(expectedText, textBuffer.CurrentSnapshot.GetText()); diff --git a/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs b/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs index bdad786acc55d..6e676e6379bb9 100644 --- a/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SignatureHelp/InvocationExpressionSignatureHelpProviderTests.cs @@ -2524,7 +2524,6 @@ void goo() expectedItems.Add(new SignatureHelpTestItem($"void C.M(object o)", currentParameterIndex: 0)); expectedItems.Add(new SignatureHelpTestItem($"void C.M(Action arg1, T arg2, bool flag)\r\n\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_contexts}", currentParameterIndex: 0)); } - await VerifyItemWithReferenceWorkerAsync(markup, expectedItems, hideAdvancedMembers: false); } } diff --git a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs index 48b8c995906dd..92f503e11e5c5 100644 --- a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs @@ -64,7 +64,6 @@ private static void TestWorker( { snapshotSpans.Add(selection.ToSnapshotSpan(originalSnapshot)); } - view.SetMultiSelection(snapshotSpans); var undoHistoryRegistry = workspace.GetService(); diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs index e4d30d699e68c..d4ed8aaee3406 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs @@ -30,8 +30,8 @@ internal PlaceholderLocalBinder( ImmutableArray aliases, MethodSymbol containingMethod, EETypeNameDecoder typeNameDecoder, - Binder next) - : base(next) + Binder next) : + base(next) { _syntax = syntax; _containingMethod = containingMethod; @@ -55,7 +55,6 @@ internal PlaceholderLocalBinder( lowercaseBuilder.Add(local.Name.ToLower(), local); } } - _lowercaseReturnValueAliases = lowercaseBuilder.ToImmutableDictionary(); _aliases = aliasesBuilder.ToImmutableAndFree(); } @@ -84,7 +83,6 @@ internal sealed override void LookupSymbolsInSingleBinder( // Invalid value should have been caught by Lexer. throw ExceptionUtilities.UnexpectedValue(valueText); } - var local = new ObjectAddressLocalSymbol(_containingMethod, name, this.Compilation.GetSpecialType(SpecialType.System_Object), address); result.MergeEqual(this.CheckViability(local, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved)); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs index 14312aa1027e5..b81bf38e5353d 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/WithTypeArgumentsBinder.cs @@ -37,10 +37,8 @@ protected override MultiDictionary TypeParameterMap { result.Add(tps.Type.Name, (TypeParameterSymbol)tps.Type); } - Interlocked.CompareExchange(ref _lazyTypeParameterMap, result, null); } - return _lazyTypeParameterMap; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs index 70391f829af20..a24d60eff6282 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpEESymbolProvider.cs @@ -96,7 +96,6 @@ public override IAssemblySymbolInternal GetReferencedAssembly(AssemblyReferenceH { throw new BadImageFormatException(); } - return assembly; } @@ -117,7 +116,6 @@ private TypeSymbol IncludeDynamicAndTupleElementNamesIfAny( { type = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(type, _sourceAssembly, refKind, dynamicFlagsOpt, checkLength: false); } - return TupleTypeDecoder.DecodeTupleTypesIfApplicable(type, tupleElementNamesOpt); } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs index 2abda45dd6c0e..cac560827a160 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CSharpInstructionDecoder.cs @@ -64,7 +64,6 @@ internal override void AppendFullName(StringBuilder builder, MethodSymbol method while (i < numParts && parts[i].Kind != SymbolDisplayPartKind.MethodName); i--; } - break; case SymbolDisplayPartKind.MethodName: @@ -89,7 +88,6 @@ internal override void AppendFullName(StringBuilder builder, MethodSymbol method { builder.Append(displayString); } - break; default: @@ -129,7 +127,6 @@ internal override MethodSymbol ConstructMethod(MethodSymbol method, ImmutableArr { method = method.Construct(ImmutableArray.Create(typeArguments, methodArgumentStartIndex, methodArity)); } - return method; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs index 1b63994c591ce..d3dab807d90fe 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs @@ -776,7 +776,6 @@ private static CSharpCompilation GetCompilationWithExternAliases(CSharpCompilati updatedReferences.Add(reference); assembliesAndModulesBuilder.Add(compilation.GetAssemblyOrModuleSymbol(reference)!); } - Debug.Assert(assembliesAndModulesBuilder.Count == updatedReferences.Count); var assembliesAndModules = assembliesAndModulesBuilder.ToImmutableAndFree(); @@ -1307,7 +1306,6 @@ private static void GetDisplayClassVariables( } } } - GetAdditionalDisplayClassInstances(displayClassTypes, displayClassInstances, startIndex); displayClassTypes.Free(); @@ -1388,7 +1386,6 @@ private static void GetDisplayClassInstances( { continue; } - break; case GeneratedNameKind.ThisProxyField: if (GeneratedNames.GetKind(fieldType.Name) != GeneratedNameKind.LambdaDisplayClass) diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs index 36beacd23cb74..4ae4b2f71fab9 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationExtensions.cs @@ -55,7 +55,6 @@ internal static PEMethodSymbol GetSourceMethod(this CSharpCompilation compilatio } } } - return method; } @@ -103,7 +102,6 @@ internal static CSharpCompilation ToCompilation(this ImmutableArray additionalTypes, Func getDynamicOperationContextType, - CompilationTestData? testData) - : base( + CompilationTestData? testData) : + base( sourceAssembly, emitOptions, outputKind: OutputKind.DynamicallyLinkedLibrary, @@ -61,7 +61,6 @@ protected override Cci.IModuleReference TranslateModule(ModuleSymbol symbol, Dia return new Microsoft.CodeAnalysis.ExpressionEvaluator.AssemblyReference(identity); } } - return base.TranslateModule(symbol, diagnostics); } @@ -86,12 +85,10 @@ private ImmutableArray GetLocalDefinitions(ImmutableArray.Empty; } - diagnostics.Free(); return assembly; } @@ -488,7 +487,6 @@ internal static ImmutableArray GetMissingAssemblyIdentitiesHel return ImmutableArray.Create(identity); } } - break; case ErrorCode.ERR_DottedTypeNameNotFoundInNS: @@ -502,7 +500,6 @@ arguments[1] is NamespaceSymbol containingNamespace && var identity = new AssemblyIdentity($"{containingNamespace.ToDisplayString()}.{namespaceName}", contentType: System.Reflection.AssemblyContentType.WindowsRuntime); return ImmutableArray.Create(identity); } - break; case ErrorCode.ERR_NoSuchMemberOrExtension: // Commonly, but not always, caused by absence of System.Core. diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs index 8de7e2c0d754a..137fb1b98f63c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs @@ -64,7 +64,6 @@ public override BoundNode VisitLocal(BoundLocal node) return result; } } - return node; } @@ -76,7 +75,6 @@ public override BoundNode VisitParameter(BoundParameter node) { return node; } - return variable.ToBoundExpression(node.Syntax); } @@ -130,7 +128,6 @@ private BoundExpression GenerateThisReference(BoundExpression node) { return rewrittenThis; } - var boundKind = node.Kind; Debug.Assert(boundKind == BoundKind.ThisReference || boundKind == BoundKind.BaseReference); var errorCode = boundKind == BoundKind.BaseReference diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs index 5b70b4c6704a0..0c9de94a95694 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.cs @@ -23,7 +23,6 @@ public override BoundNode Visit(BoundNode node) { return null; } - return base.Visit(node); } @@ -76,7 +75,6 @@ public override BoundNode VisitObjectInitializerExpression(BoundObjectInitialize initializer; this.Visit(expr); } - return null; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs index dfc9ec0ef328c..1eae863ab14fb 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.cs @@ -46,12 +46,10 @@ private BoundExpression RewriteLocal(BoundLocal node) { return placeholder.RewriteLocal(_compilation, _container, node.Syntax, _diagnostics); } - if (_declaredLocals.Contains(local)) { return ObjectIdLocalSymbol.RewriteLocal(_compilation, _container, node.Syntax, local); } - return node; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs index 931a31429eb20..ac9473880375d 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/DisplayClassVariable.cs @@ -70,7 +70,6 @@ internal BoundExpression ToBoundExpression(SyntaxNode syntax) { expr = new BoundFieldAccess(syntax, expr, field, constantValueOpt: null) { WasCompilerGenerated = true }; } - fields.Free(); return expr; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs index 440581d2368eb..d717b5cb363b5 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs @@ -21,7 +21,6 @@ internal static LocalSymbol ToOtherMethod(this LocalSymbol local, MethodSymbol m { return l.ToOtherMethod(method, typeMap); } - var type = typeMap.SubstituteType(local.TypeWithAnnotations); return new EELocalSymbol(method, local.Locations, local.Name, -1, local.DeclarationKind, type, local.RefKind, local.IsPinned, local.IsCompilerGenerated, local.CanScheduleToStack); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs index 001d68b42b0e9..cb7091fa2d8cb 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs @@ -109,7 +109,6 @@ internal EEMethodSymbol( { this.SubstitutedSourceMethod = this.SubstitutedSourceMethod.Construct(_typeParameters.As()); } - TypeParameterChecker.Check(this.SubstitutedSourceMethod, _allTypeParameters); // Create a map from original parameter to target parameter. @@ -143,7 +142,6 @@ internal EEMethodSymbol( localsMap.Add(sourceLocal, local); localsBuilder.Add(local); } - this.Locals = localsBuilder.ToImmutableAndFree(); localsBuilder = ArrayBuilder.GetInstance(); foreach (var sourceLocal in sourceLocalsForBinding) @@ -154,10 +152,8 @@ internal EEMethodSymbol( local = sourceLocal.ToOtherMethod(this, this.TypeMap); localsMap.Add(sourceLocal, local); } - localsBuilder.Add(local); } - this.LocalsForBinding = localsBuilder.ToImmutableAndFree(); // Create a map from variable name to display class field. @@ -304,7 +300,6 @@ public override TypeWithAnnotations ReturnTypeWithAnnotations { throw new InvalidOperationException(); } - return _lazyReturnType; } } @@ -360,12 +355,10 @@ internal override Cci.CallingConvention CallingConvention { cc |= Cci.CallingConvention.ExtraArguments; } - if (this.IsGenericMethod) { cc |= Cci.CallingConvention.Generic; } - return cc; } } @@ -530,7 +523,6 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, localsBuilder.Add(local); localsSet.Add(local); } - foreach (var local in this.Locals) { if (localsSet.Add(local)) @@ -656,7 +648,6 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, Debug.Assert(!(local is EELocalSymbol) || (((EELocalSymbol)local).Ordinal == localBuilder.Count)); localBuilder.Add(local); } - foreach (var local in block.Locals) { if (local is EELocalSymbol oldLocal) @@ -664,7 +655,6 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, Debug.Assert(localBuilder[oldLocal.Ordinal] == oldLocal); continue; } - localBuilder.Add(local); } @@ -685,7 +675,6 @@ private BoundExpression GenerateThisReference(SyntaxNode syntax) { return thisProxy.ToBoundExpression(syntax); } - if ((object)_thisParameter != null) { var typeNameKind = GeneratedNames.GetKind(_thisParameter.TypeWithAnnotations.Type.Name); @@ -696,10 +685,8 @@ private BoundExpression GenerateThisReference(SyntaxNode syntax) $"Unexpected typeNameKind '{typeNameKind}'"); return null; } - return new BoundParameter(syntax, _thisParameter); } - return null; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EENamedTypeSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EENamedTypeSymbol.cs index 4268933289567..d89910712becb 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EENamedTypeSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EENamedTypeSymbol.cs @@ -32,8 +32,8 @@ internal EENamedTypeSymbol( string typeName, string methodName, CompilationContext context, - GenerateMethodBody generateMethodBody) - : this(container, baseType, currentFrame, typeName, (m, t) => ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) + GenerateMethodBody generateMethodBody) : + this(container, baseType, currentFrame, typeName, (m, t) => ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) { } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs index 299f288aa8186..d6631399d085c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EETypeParameterSymbol.cs @@ -178,7 +178,6 @@ private TypeMap TypeMap { Interlocked.CompareExchange(ref _lazyTypeMap, _getTypeMap(), null); } - return _lazyTypeMap; } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs index 69200b7493a20..81ae9aa1cf6c6 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs @@ -12,8 +12,8 @@ internal sealed class ExceptionLocalSymbol : PlaceholderLocalSymbol { private readonly string _getExceptionMethodName; - internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) - : base(method, name, displayName, type) + internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) : + base(method, name, displayName, type) { _getExceptionMethodName = getExceptionMethodName; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs index f6bc3ca8cde8d..bfb4bc1de0906 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectAddressLocalSymbol : PlaceholderLocalSymbol { private readonly ulong _address; - internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) - : base(method, name, name, type) + internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) : + base(method, name, name, type) { Debug.Assert(type.SpecialType == SpecialType.System_Object); _address = address; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs index 6552569dd78ff..8e6c6d346ac2a 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectIdLocalSymbol : PlaceholderLocalSymbol { private readonly bool _isWritable; - internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) - : base(method, name, displayName, type) + internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) : + base(method, name, displayName, type) { _isWritable = isWritable; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs index 99c48e43d7841..976d14545c3a8 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/PlaceholderLocalSymbol.cs @@ -208,7 +208,6 @@ internal static MethodSymbol GetIntrinsicMethod(CSharpCompilation compilation, s { return null; } - var members = type.GetMembers(methodName); Debug.Assert(members.Length == 1); return (MethodSymbol)members[0]; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs index 03127935aa00a..9114143677872 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs @@ -14,8 +14,8 @@ internal sealed class ReturnValueLocalSymbol : PlaceholderLocalSymbol { private readonly int _index; - internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) - : base(method, name, displayName, type) + internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) : + base(method, name, displayName, type) { _index = index; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs index ef666c52b24dc..c67ee1d1d5839 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/SyntaxHelpers.cs @@ -50,7 +50,6 @@ internal static class SyntaxHelpers builder.Free(); } - return diagnostics.HasAnyErrors() ? null : syntax; } @@ -123,7 +122,6 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(token, diagnostics); return false; } - builder.Add(token); start = -1; expectingComma = (c != ','); @@ -135,7 +133,6 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(",", diagnostics); return false; } - expectingComma = false; } } @@ -153,7 +150,6 @@ private static bool ParseFormatSpecifiers( ReportInvalidFormatSpecifier(token, diagnostics); return false; } - builder.Add(token); } else if (!expectingComma) @@ -190,13 +186,11 @@ private static bool RemoveSemicolonIfAny(ref string str) str = str.Substring(0, i); return true; } - if (!SyntaxFacts.IsWhitespace(c)) { break; } } - return false; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs index 4edcebb46bd3a..d129a5fc568f5 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/TypeParameterChecker.cs @@ -53,7 +53,6 @@ public override BoundNode Visit(BoundNode node) { _typeParameterChecker.Visit(expression.ExpressionSymbol.GetPublicSymbol()); } - return base.Visit(node); } } diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs index 17ed0dcf747e6..7231f115708c3 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.TypeNames.cs @@ -26,7 +26,6 @@ protected override void AppendIdentifierEscapingPotentialKeywords(StringBuilder { builder.Append('@'); } - builder.Append(identifier); } @@ -64,7 +63,6 @@ protected override void AppendGenericTypeArguments( out sawSingleInvalidIdentifier); sawInvalidIdentifier |= sawSingleInvalidIdentifier; } - builder.Append('>'); } diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs index 39a9f5ee36ef9..b1f861f6b9fa5 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs @@ -73,7 +73,6 @@ internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type l { builder.Append(", "); } - var lowerBound = lowerBounds[i]; var size = sizes[i]; if (lowerBound == 0) @@ -87,7 +86,6 @@ internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type l builder.Append(FormatLiteral(size + lowerBound - 1, options)); } } - builder.Append(']'); lmrType = originalLmrType.GetElementType(); // Strip off one layer (already handled). @@ -121,12 +119,10 @@ internal override string GetCastExpression(string argument, string type, DkmClrC { builder.Append('('); } - if ((options & DkmClrCastExpressionOptions.ParenthesizeArgument) != 0) { argument = $"({argument})"; } - if ((options & DkmClrCastExpressionOptions.ConditionalCast) != 0) { builder.Append(argument); @@ -140,7 +136,6 @@ internal override string GetCastExpression(string argument, string type, DkmClrC builder.Append(')'); builder.Append(argument); } - if ((options & DkmClrCastExpressionOptions.ParenthesizeEntireExpression) != 0) { builder.Append(')'); diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs index 22ba75b415067..70ed67b5b6bca 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.cs @@ -88,16 +88,13 @@ private static string RemoveComments(string expression) break; } } - builder.Append(ch); } } - if (builder.Length < length) { expression = builder.ToString(); } - pooledBuilder.Free(); return expression; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs index 7e3ad419144c6..c9d2aa5ac121b 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/Helpers/TypeExtensions.cs @@ -32,7 +32,6 @@ internal static string GetPredefinedTypeName(this Type type) { return "object"; } - return null; case TypeCode.Boolean: return "bool"; diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs index 951b398e069ab..a6b74fa493568 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs @@ -1531,8 +1531,8 @@ private sealed class PEAssemblyBuilderWithAdditionalReferences : PEModuleBuilder private readonly CommonPEModuleBuilder _builder; private readonly NamespaceTypeDefinitionNoBase _objectType; - internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) - : base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) + internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) : + base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) { _builder = builder; _objectType = new NamespaceTypeDefinitionNoBase(objectType); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs index c397a2754dab2..a7a748440564e 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs @@ -21,13 +21,13 @@ public CSharpResultProviderTestBase() : this(new CSharpFormatter()) { } - private CSharpResultProviderTestBase(CSharpFormatter formatter) - : this(CreateDkmInspectionSession(formatter)) + private CSharpResultProviderTestBase(CSharpFormatter formatter) : + this(CreateDkmInspectionSession(formatter)) { } - internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) - : base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) + internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) : + base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) { } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs index 4361c7b14c6ad..2515775653ece 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs @@ -27,8 +27,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests /// public class CustomResultProviderTests : CSharpResultProviderTestBase { - public CustomResultProviderTests() - : base( + public CustomResultProviderTests() : + base( new DkmInspectionSession( ImmutableArray.Create(new CustomFormatter(new CSharpFormatter()), new CSharpFormatter()), ImmutableArray.Create(new CustomResultProvider(), new CSharpResultProvider()))) diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs index 4a6c4b24667ee..dc7beb9c73067 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs @@ -526,7 +526,6 @@ VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue getMemberValue(Visua return null; } } - runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)), getMemberValue: getMemberValue); using (runtime.Load()) { diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs index 905fc1ccead06..68f3c9508a951 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/Helpers/TestTypeExtensions.cs @@ -24,7 +24,6 @@ public static string GetTypeName(this System.Type type, DkmClrCustomTypeInfo typ var inspectionSession = new DkmInspectionSession(ImmutableArray.Create(formatter), ImmutableArray.Create(new CSharpResultProvider())); inspectionContext = new DkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null); } - return escapeKeywordIdentifiers ? ((IDkmClrFullNameProvider)formatter).GetClrTypeName(inspectionContext, clrType, typeInfo) : inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs index 9439e100d8adc..cd4e889633670 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ValueFormattingTests.cs @@ -130,7 +130,6 @@ public void Char() expected = FormatStringChar(ch); break; } - Assert.Equal(string.Format(format, (int)ch, expected), FormatValue(ch)); Assert.Equal(string.Format(formatUsingHex, (int)ch, expected), FormatValue(ch, useHexadecimal: true)); } @@ -200,7 +199,6 @@ public void String() expected = FormatStringChar(ch); break; } - Assert.Equal(string.Format(format, expected), FormatValue(ch.ToString())); Assert.Equal(string.Format(format, expected), FormatValue(ch.ToString(), useHexadecimal: true)); } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs index 6d1c90e1b7d97..3b17f46f02499 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/CustomTypeInfo.cs @@ -102,7 +102,6 @@ internal static class CustomTypeInfo builder.Free(); return null; } - builder.Add((byte)length); builder.AddRange(dynamicFlags); } @@ -171,7 +170,6 @@ private static string JoinNames(ReadOnlyCollection names) builder.Append(name); } } - return pooledBuilder.ToStringAndFree(); } @@ -205,7 +203,6 @@ private static byte[] CopyBytes(ReadOnlyCollection bytes, int start, int l { array[i] = bytes[start + i]; } - return array; } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs index bf486a025aed9..6746304361955 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DkmUtilities.cs @@ -81,7 +81,6 @@ internal static ImmutableArray GetMetadataBlocks( { continue; } - Debug.Assert(block.ModuleVersionId == module.Mvid); builder.Add(block); index++; @@ -110,15 +109,12 @@ internal static ImmutableArray GetMetadataBlocks(GetMetadataBytes { continue; } - if (builder == null) { builder = ArrayBuilder.GetInstance(); } - builder.Add(block); } - return builder == null ? ImmutableArray.Empty : builder.ToImmutableAndFree(); } @@ -132,7 +128,6 @@ internal static ImmutableArray MakeAssemblyReaders(this DkmClrI { continue; } - MetadataReader reader; unsafe { @@ -149,10 +144,8 @@ internal static ImmutableArray MakeAssemblyReaders(this DkmClrI continue; } } - builder.Add(new AssemblyReaders(reader, symReader)); } - return builder.ToImmutableAndFree(); } @@ -330,7 +323,6 @@ internal static void SetMetadataContext(this DkmClrAppDomain a 0); message.Post(); } - appDomain.SetDataItem(DkmDataCreationDisposition.CreateAlways, new MetadataContextItem>(context)); } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs index 035cf7b2c4479..47d780f62adf4 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/DynamicFlagsCustomTypeInfo.cs @@ -56,7 +56,6 @@ internal static bool GetFlag(ReadOnlyCollection? bytes, int index) { return false; } - var b = index / 8; return b < bytes.Count && (bytes[b] & (1 << (index % 8))) != 0; diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs index dd90a38d11d57..f9aaa769bc5e2 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EEMetadataReferenceResolver.cs @@ -40,7 +40,6 @@ internal EEMetadataReferenceResolver( { request = (referenceIdentity, 0); } - Requests[referenceIdentity] = (result.Identity, request.Count + 1); #endif return (PortableExecutableReference?)result.Reference; @@ -75,7 +74,6 @@ public override int GetHashCode() { best = pair; } - break; default: throw ExceptionUtilities.UnexpectedValue(compareResult); diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs index 4d5d31b9fb2c3..14f9fd413db72 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionCompiler.cs @@ -101,7 +101,6 @@ private static ImmutableArray GetAliases(DkmClrRuntimeInstance runtimeIns dkmAlias.CustomTypeInfoPayloadTypeId, dkmAlias.CustomTypeInfoPayload)); } - return builder.ToImmutableAndFree(); } @@ -227,7 +226,6 @@ internal MakeAssemblyReferencesKind GetMakeAssemblyReferencesKind(bool useRefere { return MakeAssemblyReferencesKind.DirectReferencesOnly; } - return _useReferencedAssembliesOnly ? MakeAssemblyReferencesKind.AllReferences : MakeAssemblyReferencesKind.AllAssemblies; } @@ -339,7 +337,6 @@ private EvaluationContextBase CreateMethodContext( // No local signature. May occur when debugging heapless dumps. localSignatureToken = 0; } - return CreateMethodContext( moduleInstance.AppDomain, metadataBlocks, @@ -421,7 +418,6 @@ internal static TResult CompileWithRetry( errorMessage = null; compileResult = otherResult; } - otherDiagnostics.Free(); } else @@ -440,7 +436,6 @@ internal static TResult CompileWithRetry( } } } - diagnostics.Free(); } while (tryAgain); assembliesLoadedInRetryLoop?.Free(); diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs index 52da802c80a9c..8d133831fe449 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs @@ -46,7 +46,6 @@ internal static class RegistryHelpers { Debug.Assert(false, "Failure checking registry key: " + ex.ToString()); } - return null; } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs index dad130acf5a91..5ccf6707691e8 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs @@ -111,7 +111,6 @@ private void GetNameWithGenericTypeArguments( { method = _instructionDecoder.ConstructMethod(method, typeParameters, typeArguments); } - onSuccess(method); } catch (Exception e) diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs index 9e64bed4d61b2..8207c4bd06b3d 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ImmutableArrayExtensions.cs @@ -18,7 +18,6 @@ internal static int IndexOf(this ImmutableArray array, Func< return i; } } - return -1; } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs index 033780d08668a..c8288ebf1beb5 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/InstructionDecoder.cs @@ -106,7 +106,6 @@ internal string GetName(TMethodSymbol method, bool includeParameterTypes, bool i } } } - builder.Append(')'); } @@ -143,7 +142,6 @@ internal ImmutableArray GetTypeSymbols(TCompilation compilation, TM var typeNameDecoder = GetTypeNameDecoder(compilation, method); builder.Add(typeNameDecoder.GetTypeSymbolForSerializedType(name)); } - return builder.ToImmutableAndFree(); } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs index 21ba4b323d753..d2fac14a6d6c4 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataBlock.cs @@ -56,7 +56,6 @@ public override bool Equals(object obj) { return false; } - return Equals((MetadataBlock)obj); } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs index d4f63f5a93c60..3fb1d95d561a1 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities.cs @@ -72,7 +72,6 @@ internal static ImmutableArray MakeAssemblyReferences( } } } - if (IsWindowsComponent(reader, metadata.Name)) { runtimeWinMdBuilder.Add(metadata); @@ -227,11 +226,9 @@ internal static ImmutableArray MakeAssemblyReferences( { referencedModules.Add(intrinsicsAssembly); } - RemoveUnreferencedModules(referencesBuilder, identitiesBuilder, identityComparer, referencedModules); referencedModules.Free(); } - identitiesBuilder.Free(); } @@ -297,7 +294,6 @@ private static void RemoveUnreferencedModules( { index = i; } - break; default: @@ -323,7 +319,6 @@ private static void RemoveUnreferencedModules( index++; } } - modules.Clip(index); referencedIndices.Free(); @@ -392,7 +387,6 @@ internal static string GetFileNameWithoutExtension(string fileName) return fileName.Substring(0, lastDotIndex); } } - return fileName; } @@ -406,7 +400,6 @@ private static byte[] GetWindowsProxyBytes() { stream.CopyTo(memoryStream); } - return bytes; } } @@ -432,12 +425,10 @@ internal static bool IsWindowsComponent(MetadataReader reader, string moduleName { return false; } - if (!IsWindowsComponentName(moduleName)) { return false; } - int majorVersion; int minorVersion; reader.GetWinMdVersion(out majorVersion, out minorVersion); @@ -479,7 +470,6 @@ internal static ImmutableArray GetLocalNames(this ArrayBuilder GetSynthesizedMethods(byte[] assembly, strin } } } - return builder.ToImmutableAndFree(); } } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs index 91583f36b2cfb..f87096fbaa0d0 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs @@ -314,7 +314,6 @@ private static void ReadCSharpNativeImportsInfo( Debug.WriteLine($"Failed to parse import string {importString}"); } } - importRecordGroupBuilder.Add(groupBuilder.ToImmutableAndFree()); } @@ -419,7 +418,6 @@ private static void GetCSharpDynamicLocalInfo( continue; } } - localBuilder ??= ImmutableDictionary.CreateBuilder>(); localBuilder[slot] = flags; } diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs index f2928762e3472..7b2d22d901180 100644 --- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs +++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Portable.cs @@ -247,10 +247,8 @@ private static string ReadUtf8String(ref BlobReader reader) { break; } - builder.Add(b); } - var bytes = builder.ToArrayAndFree(); return Encoding.UTF8.GetString(bytes, 0, bytes.Length); } @@ -428,12 +426,10 @@ private static bool TryGetCustomDebugInformation(MetadataReader reader, EntityHa { throw new BadImageFormatException(); } - customDebugInfo = info; foundAny = true; } } - return foundAny; } @@ -463,7 +459,6 @@ private static ImmutableArray DecodeDynamicFlags(BlobReader reader) var value = ReadUtf8String(ref reader); builder.Add(value.Length == 0 ? null : value); } - return builder.ToImmutableAndFree(); } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs index 59daf23fde131..de7e286615205 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs @@ -34,7 +34,6 @@ internal static ArrayExpansion CreateExpansion(TypeAndCustomInfo elementTypeAndI { count *= size; } - return (count > 0) ? new ArrayExpansion(elementTypeAndInfo, sizes, lowerBounds, count) : null; } @@ -117,7 +116,6 @@ private int[] GetIndices(int index) indices[i] = _lowerBounds[i] + index / divisor; index = index % divisor; } - return indices; } @@ -129,7 +127,6 @@ private static string[] GetIndicesAsStrings(int[] indices) { strings[i] = indices[i].ToString(); } - return strings; } @@ -147,7 +144,6 @@ private static ReadOnlyCollection CalculateDivisors(ReadOnlyCollection { divisors[i - 1] = divisors[i] * sizes[i]; } - return new ReadOnlyCollection(divisors); } @@ -163,7 +159,6 @@ private static string GetFullName(DkmInspectionContext inspectionContext, EvalRe { parentFullName = parentFullName.Parenthesize(); } - var parentRuntimeType = parent.Value.Type; if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType.GetLmrType())) { @@ -178,7 +173,6 @@ private static string GetFullName(DkmInspectionContext inspectionContext, EvalRe return null; // Contains invalid identifier. } } - return parentFullName + name; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs index 7e6329cc65678..a93e485f8c5a1 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs @@ -135,7 +135,6 @@ private DebuggerTypeProxyExpansion( proxyTypeAndInfo.Info, new[] { childFullNamePrefix }); } - _proxyItem = new EvalResult( ExpansionKind.Default, name: string.Empty, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs index caf9c4f43fd39..949fb3c7fce84 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs @@ -167,12 +167,10 @@ internal static Expansion CreateExpansion( { staticExpansions.Add(publicStaticExpansion); } - if (nonPublicStaticExpansion != null) { staticExpansions.Add(nonPublicStaticExpansion); } - Debug.Assert(staticExpansions.Count > 0); var staticMembersExpansion = new StaticMembersExpansion( type, @@ -237,7 +235,6 @@ private static void GetPublicAndNonPublicMembers( publicExpansions.Add(new MemberExpansion(publicMembers.ToArray(), customTypeInfoMap)); publicMembers.Clear(); } - publicExpansions.Add(new RootHiddenExpansion(member, customTypeInfoMap)); continue; case DkmClrDebuggerBrowsableAttributeState.Never: @@ -261,7 +258,6 @@ private static void GetPublicAndNonPublicMembers( { publicExpansions.Add(new MemberExpansion(publicMembers.ToArray(), customTypeInfoMap)); } - publicMembers.Free(); publicExpansion = AggregateExpansion.CreateExpansion(publicExpansions); @@ -503,7 +499,6 @@ internal static EvalResult CreateMemberDataItem( member.IsStatic, parent); } - return resultProvider.CreateDataItem( inspectionContext, memberName, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs index bf5f663b84dcb..b9abaadc553d7 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs @@ -25,7 +25,6 @@ internal static ResultsViewExpansion CreateExpansion(DkmInspectionContext inspec { return null; } - return CreateExpansion(inspectionContext, value, enumerableType, resultProvider); } @@ -66,7 +65,6 @@ internal static EvalResult CreateResultsOnlyRow( includeResultsFormatSpecifier: true, fullNameProvider: resultProvider.FullNameProvider); } - errorMessage = Resources.ResultsViewNoSystemCore; } else @@ -157,7 +155,6 @@ private static DkmClrType GetEnumerableType(DkmClrValue value, DkmClrType valueT { return null; } - enumerableType = type; } else @@ -272,7 +269,6 @@ private EvalResult CreateResultsViewRow( { formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, ResultsFormatSpecifier); } - var childFullNamePrefix = fullNameProvider.GetClrObjectCreationExpression( inspectionContext, _proxyValue.Type, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs index 4a0c148c46281..01d1ead860784 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/RootHiddenExpansion.cs @@ -49,11 +49,9 @@ internal override void GetRows( var emptyMember = memberValue.Type.GetMemberByName("Empty"); memberValue = memberValue.GetMemberValue(emptyMember, inspectionContext); } - var row = new EvalResult(Resources.ErrorName, (string)memberValue.HostObjectValue, inspectionContext); rows.Add(row); } - index++; } else diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs index 05f8f4cc7cdd7..e06c5febff354 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TupleExpansion.cs @@ -100,7 +100,6 @@ private static EvalResult GetMemberRow( { parentFullName = parentFullName.Parenthesize(); } - var parentRuntimeType = parent.Value.Type; if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType.GetLmrType())) { @@ -199,7 +198,6 @@ private static DkmClrValue GetValueAndFullName( parentFullName, out parentFullName); } - var fieldName = field.FieldInfo.Name; fullName = (parentFullName == null) ? null : @@ -266,7 +264,6 @@ private Fields GetFields() { _lazyFields = GetFields(_typeAndInfo, _cardinality, _useRawView); } - return _lazyFields; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs index 219b7fa7a4ab4..a8d04b4735543 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.TypeNames.cs @@ -89,7 +89,6 @@ protected void AppendQualifiedTypeName( // Null for function pointers. break; } - dynamicFlagIndex++; pointerCount++; type = elementType; @@ -103,7 +102,6 @@ protected void AppendQualifiedTypeName( nullableCount++; type = typeArg; } - Debug.Assert(nullableCount < 2, "Benign: someone is nesting nullables."); Debug.Assert(pointerCount == 0 || nullableCount == 0, "Benign: pointer to nullable?"); @@ -300,7 +298,6 @@ private void AppendNamespacePrefix(StringBuilder builder, Type type, bool escape identifierBuilder.Append(ch); } } - AppendIdentifier(builder, escapeKeywordIdentifiers, identifierBuilder.ToString(), out sawSingleInvalidIdentifier); sawInvalidIdentifier |= sawSingleInvalidIdentifier; pooled.Free(); @@ -309,7 +306,6 @@ private void AppendNamespacePrefix(StringBuilder builder, Type type, bool escape { AppendIdentifier(builder, escapeKeywordIdentifiers, @namespace, out sawInvalidIdentifier); } - builder.Append('.'); } } @@ -412,7 +408,6 @@ private void AppendTupleElements( { builder.Append(", "); } - bool sawSingleInvalidIdentifier; var name = CustomTypeInfo.GetTupleElementNameIfAny(tupleElementNames, nameIndex); nameIndex++; @@ -429,12 +424,10 @@ private void AppendTupleElements( sawInvalidIdentifier |= sawSingleInvalidIdentifier; any = true; } - if (nTypeArgs < TypeHelpers.TupleFieldRestPosition) { break; } - Debug.Assert(!DynamicFlagsCustomTypeInfo.GetFlag(dynamicFlags, dynamicFlagIndex)); dynamicFlagIndex++; type = typeArguments[nTypeArgs - 1]; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs index 0273dcc70014f..f86a1b3f59108 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs @@ -50,7 +50,6 @@ private string GetValueString(DkmClrValue value, DkmInspectionContext inspection { return _nullString; } - return IncludeObjectId( value, FormatString(stringValue, options), @@ -162,7 +161,6 @@ private string GetValueString(DkmClrValue value, DkmInspectionContext inspection GetTupleExpression(values.ToArrayAndFree()), flags); } - values.Free(); } } @@ -292,7 +290,6 @@ private string GetEnumDisplayString(Type lmrType, DkmClrValue value, ObjectDispl { displayString = GetNameForEnumValue(fields, underlyingValue, valueForComparison, options, typeToDisplayOpt); } - fields.Free(); return displayString ?? FormatPrimitive(value, options, inspectionContext); diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs index 8ba6ef07555f6..4e065bf34ae16 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs @@ -92,7 +92,6 @@ string IDkmClrFullNameProvider.GetClrCastExpression(DkmInspectionContext inspect { return null; } - return GetCastExpression(argument, name, castExpressionOptions); } @@ -104,7 +103,6 @@ string IDkmClrFullNameProvider.GetClrObjectCreationExpression(DkmInspectionConte { return null; } - return GetObjectCreationExpression(name, arguments); } @@ -156,14 +154,12 @@ string IDkmClrFullNameProvider.GetClrMemberName( { return null; // FullName wouldn't be parseable. } - qualifier = GetCastExpression(parentFullName, typeName, DkmClrCastExpressionOptions.ParenthesizeEntireExpression); } else { qualifier = parentFullName; } - return $"{qualifier}.{memberName}"; } @@ -207,7 +203,6 @@ private bool NeedsParentheses(string expr) { return true; } - parens++; break; case '[': @@ -235,11 +230,9 @@ private bool NeedsParentheses(string expr) return true; } } - break; } } - return false; } @@ -258,7 +251,6 @@ internal static ReadOnlyCollection AddFormatSpecifier(ReadOnlyCollection { return formatSpecifiers; } - var builder = ArrayBuilder.GetInstance(); builder.AddRange(formatSpecifiers); builder.Add(formatSpecifier); @@ -271,16 +263,13 @@ protected string RemoveLeadingAndTrailingContent(string expression, int start, i for (; start < oldLength && leading(expression[start]); start++) { } - for (; length > start && trailing(expression[length - 1]); length--) { } - if ((start > 0) || (length < oldLength)) { return expression.Substring(start, length - start); } - return expression; } @@ -318,7 +307,6 @@ protected string RemoveFormatSpecifiers(string expression, out ReadOnlyCollectio Array.Reverse(specifiers); formatSpecifiers = new ReadOnlyCollection(specifiers); } - builder.Free(); Debug.Assert((formatSpecifiers.Count == 0) == (newLength == oldLength)); @@ -326,7 +314,6 @@ protected string RemoveFormatSpecifiers(string expression, out ReadOnlyCollectio { return expression.Substring(0, newLength); } - return expression; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs index 4a76a5cbe78ef..89e03e291c67e 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs @@ -29,7 +29,6 @@ public static ArrayBuilder GetInstance(int size = 0) { builder._items.Capacity = size; } - return builder; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs index 132fef5c00478..9a11b34137401 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/AttributeHelpers.cs @@ -29,7 +29,6 @@ internal static DkmClrCustomTypeInfo GetCustomTypeInfo(this IList GetDynamicFlags(CustomAttributeData attr { builder.Add((bool)typedArg.Value); } - var result = DynamicFlagsCustomTypeInfo.ToBytes(builder); builder.Free(); return result; } } - return null; } @@ -88,11 +85,9 @@ private static ReadOnlyCollection GetTupleElementNames(CustomAttributeDa { builder.Add((string)typedArg.Value); } - return builder.ToImmutableAndFree(); } } - return null; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs index 6098b3c90917d..d7577931736af 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/CustomTypeInfoTypeArgumentMap.cs @@ -208,7 +208,6 @@ private static void AppendRangeFor( { return; } - var genericParameterPosition = type.GenericParameterPosition; AppendRange( collection, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs index 6bf7f411b6b5e..d8b16ede688b3 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs @@ -120,7 +120,6 @@ public string FullName name += ", " + formatSpecifier; } } - return name; } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs index 82345f2f2341d..5a6d26fb2ff40 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs @@ -205,7 +205,6 @@ private static DeclarationInfo AccessingBaseMemberWithSameNameRequiresExplicitCa { return DeclarationInfo.RequiresExplicitCast; } - return DeclarationInfo.None; default: throw ExceptionUtilities.UnexpectedValue(member.MemberType); @@ -221,7 +220,6 @@ internal static bool IsVisibleMember(MemberInfo member) case MemberTypes.Property: return GetNonIndexerGetMethod((PropertyInfo)member) != null; } - return false; } @@ -250,7 +248,6 @@ internal static bool IsPublic(this MemberInfo member) { return false; } - var attributes = getMethod.Attributes; return ((attributes & System.Reflection.MethodAttributes.Public) == System.Reflection.MethodAttributes.Public) || ((attributes & System.Reflection.MethodAttributes.Family) == System.Reflection.MethodAttributes.Family); @@ -354,7 +351,6 @@ internal static bool IsIDynamicMetaObjectProvider(this Type type) return true; } } - return false; } @@ -372,7 +368,6 @@ internal static Type GetNullableTypeArgument(this Type type) return typeArgs[0]; } } - return null; } @@ -398,7 +393,6 @@ internal static DkmClrValue GetNullableValue(this DkmClrValue value, Type nullab { return value; } - return value.GetNullableValue(inspectionContext); } @@ -490,24 +484,20 @@ internal static bool TryGetTupleFieldValues(this DkmClrValue tuple, int cardinal { return false; } - var value = tuple.GetFieldValue(fieldName, inspectionContext); var str = value.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers); values.Add(str); } - cardinality -= n; if (cardinality == 0) { return true; } - var restInfo = type.GetTupleField(TypeHelpers.TupleFieldRestName); if (restInfo == null) { return false; } - tuple = tuple.GetFieldValue(TupleFieldRestName, inspectionContext); } } @@ -567,7 +557,6 @@ private static Dictionary GetDebu { continue; } - if (result == null) { result = new Dictionary(); @@ -581,7 +570,6 @@ private static Dictionary GetDebu result.Add(browsableAttribute.TargetMember, browsableAttribute.State); } } - return result; } @@ -707,7 +695,6 @@ internal static Type Substitute(this Type type, Type typeDef, Type[] typeArgs) { builder.Add(t.Substitute(typeDef, typeArgs)); } - var typeDefinition = type.GetGenericTypeDefinition(); return typeDefinition.MakeGenericType(builder.ToArrayAndFree()); } @@ -755,7 +742,6 @@ internal static Type GetIEnumerableImplementationIfAny(this Type type) return @interface; } } - t = t.BaseType; } while (t != null); @@ -792,7 +778,6 @@ internal static bool IsOrInheritsFrom(this Type type, Type baseType) { return true; } - type = type.BaseType; } while (type != null); @@ -821,7 +806,6 @@ internal static bool IsOrInheritsFrom(this Type type, string @namespace, string { return true; } - type = type.BaseType; } while (type != null); @@ -871,7 +855,6 @@ internal static MemberInfo GetOriginalDefinition(this MemberInfo member) { return candidate; } - break; default: throw ExceptionUtilities.UnexpectedValue(memberType); diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs index 08649380717f9..83cf812b482db 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ValueHelpers.cs @@ -25,7 +25,6 @@ internal static string IncludeObjectId(this DkmClrValue value, string valueStr) return $"{valueStr} {{{alias}}}"; } } - return valueStr; } @@ -74,7 +73,6 @@ internal static void AppendCommaSeparatedList(this StringBuilder builder, string { builder.Append(", "); } - builder.Append(value); any = true; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs index f7053cd5b41c9..4f2fa760946bf 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs @@ -59,7 +59,6 @@ void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, Dk { formatSpecifiers = Formatter.NoFormatSpecifiers; } - if (resultFullName != null) { ReadOnlyCollection otherSpecifiers; @@ -69,7 +68,6 @@ void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, Dk formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, formatSpecifier); } } - var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e))); wl.ContinueWith( () => GetRootResultAndContinue( @@ -313,10 +311,8 @@ private void CreateEvaluationResultAndContinue(EvalResult result, WorkList workL TargetRuntime: process.GetNativeRuntimeInstance(), DataItem: result.ToDataItem()); } - completionRoutine(evalResult); } - break; case ExpansionKind.NonPublicMembers: completionRoutine(DkmSuccessEvaluationResult.Create( @@ -524,7 +520,6 @@ internal static string GetTypeName( return string.Format("{0} {{{1}}}", declaredTypeName, runtimeTypeName); } } - return declaredTypeName; } @@ -834,7 +829,6 @@ void completionRoutine(DkmEvaluateDebuggerDisplayStringAsyncResult result) onException(e); } } - if (displayInfo == null) { completionRoutine(default(DkmEvaluateDebuggerDisplayStringAsyncResult)); @@ -917,7 +911,6 @@ void completionRoutine(DkmEvaluationAsyncResult result) onException(e); } } - if (index < numRows) { GetChild( @@ -958,7 +951,6 @@ internal Expansion GetTypeExpansion( // Null array. No expansion. return null; } - var lowerBounds = value.ArrayLowerBounds; Type elementType; @@ -1094,7 +1086,6 @@ private void Execute() _onException(e); } } - _state = State.Executed; } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs index 3385276a8e4c7..6a8d4e4bfb724 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs @@ -20,8 +20,8 @@ public enum DkmClrDebuggerBrowsableAttributeState public class DkmClrDebuggerBrowsableAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) - : base(targetMember) + internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) : + base(targetMember) { this.State = state; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs index f4b8f020d5672..e1cd0e6bd4e9e 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs @@ -15,8 +15,8 @@ namespace Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation { public class DkmClrDebuggerTypeProxyAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) - : base(null) + internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) : + base(null) { this.ProxyType = proxyType; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs index 8db52ca741898..b40d7da466d27 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs @@ -31,8 +31,8 @@ internal DkmClrDebuggerVisualizerAttribute(string targetMember, DkmClrCustomVisualizerAssemblyLocation uiSideVisualizerAssemblyLocation, string debuggeeSideVisualizerTypeName, string debuggeeSideVisualizerAssemblyName, - string visualizerDescription) - : base(null) + string visualizerDescription) : + base(null) { UISideVisualizerTypeName = uiSideVisualizerTypeName; UISideVisualizerAssemblyName = uiSideVisualizerAssemblyName; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs index 29a8795ead4a0..b6940815f033d 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs @@ -26,8 +26,8 @@ public class DkmClrModuleInstance : DkmModuleInstance private readonly DkmClrRuntimeInstance _runtimeInstance; private int _resolveTypeNameFailures; - public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) - : base(module) + public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) : + base(module) { _runtimeInstance = runtimeInstance; this.Assembly = assembly; @@ -53,14 +53,12 @@ public DkmClrType ResolveTypeName(string typeName, ReadOnlyCollection 0) { var typeArgs = typeArguments.Select(t => ((TypeImpl)t.GetLmrType()).Type).ToArray(); type = type.MakeGenericType(typeArgs); } - return _runtimeInstance.GetType((TypeImpl)type); } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs index 51a73265fdc68..f3d7a6fab89d9 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrRuntimeInstance.cs @@ -48,7 +48,6 @@ internal DkmClrRuntimeInstance( { getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null); } - this.Assemblies = assemblies; this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray(); _defaultModule = getModule(this, null); @@ -99,11 +98,9 @@ internal DkmClrType GetType(string typeName, params System.Type[] typeArguments) { result = result.MakeGenericType(typeArguments.Select(this.GetType).ToArray()); } - return result; } } - return null; } @@ -122,7 +119,6 @@ private static IEnumerable WithMscorlibLast(DkmClrModuleIn yield return module; } } - if (mscorlib != null) { yield return mscorlib; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs index 823387470479e..1a7ddb2982e84 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs @@ -51,13 +51,13 @@ internal DkmClrType(DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type _favorites = favorites; } - internal DkmClrType(Type lmrType) - : this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) + internal DkmClrType(Type lmrType) : + this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) { } - internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) - : this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) + internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) : + this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) { } @@ -134,7 +134,6 @@ public ReadOnlyCollection GenericArguments new ReadOnlyCollection(typeArgs.Select(t => DkmClrType.Create(_appDomain, t)).ToArray()); Interlocked.CompareExchange(ref _lazyGenericArguments, genericArgs, null); } - return _lazyGenericArguments; } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs index dbddeb0db4be3..c323cd1fb0f88 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs @@ -87,7 +87,6 @@ public DkmClrValue Dereference(DkmInspectionContext inspectionContext) { throw new InvalidOperationException("Cannot dereference invalid value"); } - var elementType = this.Type.GetLmrType().GetElementType(); var evalFlags = DkmEvaluationResultFlags.None; var valueFlags = DkmClrValueFlags.None; @@ -102,7 +101,6 @@ public DkmClrValue Dereference(DkmInspectionContext inspectionContext) value = e; evalFlags |= DkmEvaluationResultFlags.ExceptionThrown; } - var valueType = new DkmClrType(this.Type.RuntimeInstance, (value == null || elementType.IsPointer) ? elementType : (TypeImpl)value.GetType()); return new DkmClrValue( value, @@ -125,7 +123,6 @@ public bool IsNull // assert since the property may be called during debugging.) throw new InvalidOperationException(); } - var lmrType = Type.GetLmrType(); return ((RawValue == null) && !lmrType.IsValueType) || (lmrType.IsPointer && (Convert.ToInt64(RawValue) == 0)); } @@ -261,7 +258,6 @@ public void EvaluateDebuggerDisplayString(DkmWorkList workList, DkmInspectionCon { throw new ArgumentException(string.Format("Nested braces in '{0}'", formatString)); } - openPos = i; } else if (ch == '}') @@ -474,7 +470,6 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare { evalFlags |= DkmEvaluationResultFlags.ReadOnly; } - try { value = field.GetValue(RawValue); @@ -492,7 +487,6 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare category: category, access: access); } - break; case MemberTypes.Property: var property = declaringType.GetProperty(MemberName, bindingFlags); @@ -503,7 +497,6 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare { evalFlags |= DkmEvaluationResultFlags.ReadOnly; } - try { value = property.GetValue(RawValue, bindingFlags, null, null, null); @@ -521,7 +514,6 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare category: category, access: access); } - break; default: throw ExceptionUtilities.UnexpectedValue((MemberTypes)MemberType); @@ -603,7 +595,6 @@ public ReadOnlyCollection ArrayDimensions { builder.Add(array.GetUpperBound(i) - array.GetLowerBound(i) + 1); } - return builder.ToImmutableAndFree(); } } @@ -624,7 +615,6 @@ public ReadOnlyCollection ArrayLowerBounds { builder.Add(array.GetLowerBound(i)); } - return builder.ToImmutableAndFree(); } } @@ -720,7 +710,6 @@ private static DkmClrModuleInstance GetModule(DkmClrAppDomain appDomain, string return module; } } - return null; } @@ -745,7 +734,6 @@ private static Type GetAncestorType(Type type, string ancestorTypeName) { return GetAncestorType(baseType, ancestorTypeName); } - return null; } @@ -777,7 +765,6 @@ private static unsafe object Dereference(IntPtr ptr, Type elementType) { throw new InvalidOperationException("Dereferencing null"); } - var destinationType = elementType.IsPointer ? (Environment.Is64BitProcess ? typeof(long) : typeof(int)) : ((TypeImpl)elementType).Type; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs index ddc7fcbf44c83..b746822ea08c9 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationEnumAsyncResult.cs @@ -22,7 +22,6 @@ public DkmEvaluationEnumAsyncResult(DkmEvaluationResult[] Items) { throw new ArgumentNullException(); } - this.Items = Items; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs index 3f44eb94f9467..95b99c69d5634 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultEnumContext.cs @@ -33,7 +33,6 @@ public static DkmEvaluationResultEnumContext Create(int Count, DkmStackWalkFrame { enumContext.SetDataItem(DkmDataCreationDisposition.CreateNew, DataItem); } - return enumContext; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs index 728f57afc92eb..557035d74defc 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs @@ -25,8 +25,8 @@ private DkmFailedEvaluationResult( string errorMessage, DkmEvaluationResultFlags flags, string type, - DkmDataItem dataItem) - : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) : + base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.ErrorMessage = errorMessage; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs index 0f1989e02aa0a..445a5715ee834 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmGetChildrenAsyncResult.cs @@ -22,7 +22,6 @@ public DkmGetChildrenAsyncResult(DkmEvaluationResult[] InitialChildren, DkmEvalu { throw new ArgumentNullException(); } - this.InitialChildren = InitialChildren; this.EnumContext = EnumContext; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs index 81557f7e33ce3..c5bf773a9e0dd 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionSession.cs @@ -85,12 +85,10 @@ internal TResult Invoke(object instance, MethodId method, Func customUIVisualizers, ReadOnlyCollection externalModules, - DkmDataItem dataItem) - : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) : + base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.Value = value; this.EditableValue = editableValue; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/MemberInfo/TypeImpl.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/MemberInfo/TypeImpl.cs index dcd563e7d8d70..6b1931febf992 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/MemberInfo/TypeImpl.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/MemberInfo/TypeImpl.cs @@ -355,22 +355,18 @@ protected override System.Reflection.TypeAttributes GetAttributeFlagsImpl() { result |= System.Reflection.TypeAttributes.Class; } - if (this.Type.IsInterface) { result |= System.Reflection.TypeAttributes.Interface; } - if (this.Type.IsAbstract) { result |= System.Reflection.TypeAttributes.Abstract; } - if (this.Type.IsSealed) { result |= System.Reflection.TypeAttributes.Sealed; } - return result; } @@ -460,7 +456,6 @@ public override Type[] GetInterfacesOnType() builder.Add((TypeImpl)@interface); } } - return builder.ToArrayAndFree(); } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs index f7834dfb7059c..634ef933a7c6d 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs @@ -67,7 +67,6 @@ internal DkmClrValue CreateDkmClrValue( { type = value.GetType(); } - return new DkmClrValue( value, DkmClrValue.GetHostObjectValue((TypeImpl)type, value), @@ -191,7 +190,6 @@ internal DkmEvaluationResult FormatResult(string name, string fullName, DkmClrVa { ExceptionDispatchInfo.Capture(exception).Throw(); } - return asyncResult.Result; } @@ -261,7 +259,6 @@ internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, int i { ExceptionDispatchInfo.Capture(exception).Throw(); } - enumContext = getChildrenResult.EnumContext; return getChildrenResult.InitialChildren; } @@ -277,7 +274,6 @@ internal DkmEvaluationResult[] GetItems(DkmEvaluationResultEnumContext enumConte { ExceptionDispatchInfo.Capture(exception).Throw(); } - return getItemsResult.Items; } @@ -367,7 +363,6 @@ internal static void Verify(IReadOnlyList actual, params Dk { Console.WriteLine("{0}, ", ToString(result)); } - throw; } } @@ -400,25 +395,21 @@ private static string ToString(DkmSuccessEvaluationResult result) builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } - if (result.Category != DkmEvaluationResultCategory.Other) { builder.Append(", "); builder.Append(FormatEnumValue(result.Category)); } - if (result.Access != DkmEvaluationResultAccessType.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Access)); } - if (result.EditableValue != null) { builder.Append(", "); builder.Append(Quote(result.EditableValue)); } - builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -436,19 +427,16 @@ private static string ToString(DkmIntermediateEvaluationResult result) builder.Append(", "); builder.Append(Quote(result.Type)); } - if (result.FullName != null) { builder.Append(", "); builder.Append(Quote(Escape(result.FullName))); } - if (result.Flags != DkmEvaluationResultFlags.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } - builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -466,19 +454,16 @@ private static string ToString(DkmFailedEvaluationResult result) builder.Append(", "); builder.Append(Quote(result.Type)); } - if (result.FullName != null) { builder.Append(", "); builder.Append(Quote(Escape(result.FullName))); } - if (result.Flags != DkmEvaluationResultFlags.None) { builder.Append(", "); builder.Append(FormatEnumValue(result.Flags)); } - builder.Append(")"); return pooledBuilder.ToStringAndFree(); } @@ -522,7 +507,6 @@ internal static void Verify(DkmEvaluationResult actual, DkmEvaluationResult expe { Assert.Equal(expectedSuccess.Category, actualSuccess.Category); } - if (expectedSuccess.Access != UnspecifiedAccessType) { Assert.Equal(expectedSuccess.Access, actualSuccess.Access); diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb index a12c4327125db..8b0ae8c7d9691 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb @@ -83,7 +83,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If name.StartsWith("$", StringComparison.Ordinal) Then diagnostics.Add(ERRID.ERR_IllegalChar, identifier.GetLocation()) End If - Return local End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb index b465cef63a7e1..d550157d72cee 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb @@ -248,7 +248,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.GetUseSiteInfo().DiagnosticInfo?.Severity = DiagnosticSeverity.Error Then Continue For End If - Dim aliasMethod = Me.CreateMethod( container, methodName, @@ -534,7 +533,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Debug.Assert(isError = diagnostics.HasAnyErrors()) result = Not isError End If - diagnostics.Free() Return result End Function @@ -598,7 +596,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Else Debug.Assert([namespace] Is compilation.GlobalNamespace) End If - binder = New NamespaceBinder(binder, [namespace]) End While @@ -715,7 +712,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator importsBuilder.AddRange(projectLevelImportsBuilder) projectLevelImportsBuilder.Free() End If - If importsBuilder IsNot Nothing Then Dim [imports] As ImmutableArray(Of NamespaceOrTypeAndImportsClausePosition) = importsBuilder.ToImmutableAndFree() binder = New TypesOfImportedNamespacesMembersBinder(binder, [imports]) @@ -1113,7 +1109,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If End If Next - GetAdditionalDisplayClassInstances(displayClassTypes, displayClassInstances, startIndex) displayClassTypes.Free() @@ -1226,7 +1221,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If member.Kind <> SymbolKind.Field Then Continue For End If - Dim field = DirectCast(member, FieldSymbol) Dim fieldType = field.Type Dim fieldName As String = field.Name @@ -1419,7 +1413,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator While type.IsClosureOrStateMachineType() type = type.ContainingType End While - Debug.Assert(type IsNot Nothing) Return type diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb index d6fed52e9238d..e3f370b13606c 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationExtensions.vb @@ -48,7 +48,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If Next End If - Return method End Function @@ -98,7 +97,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim resolver = New EEMetadataReferenceResolver(IdentityComparer, referencesBySimpleName) options = options.WithMetadataReferenceResolver(resolver) End If - Return VisualBasicCompilation.Create( assemblyName:=ExpressionCompilerUtilities.GenerateUniqueName(), references:=references, diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb index 36e649a311f78..dc8dfea4640be 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EEAssemblyBuilder.vb @@ -61,7 +61,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Return New Microsoft.CodeAnalysis.ExpressionEvaluator.AssemblyReference(identity) End If End If - Return MyBase.TranslateModule(symbol, diagnostics) End Function @@ -83,7 +82,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim defs = GetLocalDefinitions(method.Locals, diagnostics) Return New SlotAllocator(defs) End If - Return Nothing End Function @@ -99,7 +97,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator builder.Add(def) End Select Next - Return builder.ToImmutableAndFree() End Function @@ -153,7 +150,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local Is Nothing Then Return Nothing End If - Return _locals(local.Ordinal) End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb index d61d613817b1b..bc0244cde2d96 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EETypeNameDecoder.vb @@ -26,7 +26,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If index >= 0 Then Return index End If - If identity.IsWindowsComponent() Then ' Find placeholder Windows.winmd assembly (created ' in MetadataUtilities.MakeAssemblyReferences). @@ -41,7 +40,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End If End If End If - Return -1 End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb index b391bea0bd329..e4896807e92d4 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb @@ -517,7 +517,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If member.Kind <> SymbolKind.Field Then Continue For End If - Dim methodName As String = Nothing Dim methodSignature As String = Nothing Dim localName As String = Nothing @@ -601,14 +600,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator pos = 1 Debug.Assert(pos < numParts) End If - Dim currNamespace = globalNamespace While pos < numParts Dim nextNamespace = currNamespace.GetMembers(nameParts(pos)).OfType(Of NamespaceSymbol).SingleOrDefault() If nextNamespace Is Nothing Then Exit While End If - pos += 1 currNamespace = nextNamespace End While diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb index 02d794b8617ed..7377424f87449 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.vb @@ -66,7 +66,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Debug.Assert(TypeSymbol.Equals(node.Type, result.Type, TypeCompareKind.ConsiderEverything)) Return result End If - Dim variable = GetVariable(local.Name) If variable IsNot Nothing Then Dim result = variable.ToBoundExpression(syntax, node.IsLValue, node.SuppressVirtualCalls) @@ -74,7 +73,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Return result End If End If - Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb index 9091eced61a65..ae6db766bd0ca 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb @@ -23,7 +23,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator For Each local In locals builder.Add(GenerateCreateVariableStatement(compilation, container, syntax, local)) Next - builder.AddRange(block.Statements) block = New BoundBlock(syntax, block.StatementListSyntax, block.Locals, builder.ToImmutableAndFree()) End If @@ -47,7 +46,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.DeclarationKind = LocalDeclarationKind.ImplicitVariable Then _locals.Add(local) End If - Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb index 7c73208968c3d..d4ce20d2ce665 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/MayHaveSideEffectsVisitor.vb @@ -61,7 +61,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator initializer) Visit(expr) Next - Return Nothing End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb index bc07b1819889c..3b5cb26faad94 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/PlaceholderLocalRewriter.vb @@ -36,12 +36,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If local.DeclarationKind = LocalDeclarationKind.ImplicitVariable Then Return ObjectIdLocalSymbol.RewriteLocal(_compilation, _container, node.Syntax, local, node.IsLValue) End If - Dim placeholder = TryCast(local, PlaceholderLocalSymbol) If placeholder IsNot Nothing Then Return placeholder.RewriteLocal(_compilation, _container, node.Syntax, node.IsLValue, diagnostics) End If - Return node End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb index ecd9a3f40d1b6..a4df6a307bf69 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SymbolExtensions.vb @@ -33,10 +33,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator containingSymbol = containingSymbol.ContainingSymbol End While - Return True End If - Return False End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb index 6d73fc133c7fe..0f30b7d48cac7 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/DisplayClassVariable.vb @@ -68,7 +68,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator For Each field In fields expr = New BoundFieldAccess(syntax, expr, field, isLValue, suppressVirtualCalls, constantsInProgressOpt:=Nothing, type:=field.Type).MakeCompilerGenerated() Next - fields.Free() Return expr End Function @@ -86,7 +85,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If Not fields.Any() Then Return ConsList(Of FieldSymbol).Empty End If - Dim head = SubstituteField(fields.Head, typeMap) Dim tail = SubstituteFields(fields.Tail, typeMap) Return tail.Prepend(head) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb index d37f99104f5bf..61fdceacdda52 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.vb @@ -15,7 +15,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If l IsNot Nothing Then Return l.ToOtherMethod(method, typeMap) End If - Dim type = typeMap.SubstituteType(local.Type) Return New EELocalSymbol(method, local.Locations, local.Name, -1, local.DeclarationKind, type, local.IsByRef, local.IsPinned, local.CanScheduleToStack) End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb index 6fd6ab1909115..34f180d511429 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/EEMethodSymbol.vb @@ -97,7 +97,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If _typeParameters.Any() Then Me.SubstitutedSourceMethod = Me.SubstitutedSourceMethod.Construct(_typeParameters.As(Of TypeSymbol)()) End If - TypeParameterChecker.Check(Me.SubstitutedSourceMethod, _allTypeParameters) ' Create a map from original parameter to target parameter. @@ -128,7 +127,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator localsMap.Add(sourceLocal, local) localsBuilder.Add(local) Next - Me.Locals = localsBuilder.ToImmutableAndFree() localsBuilder = ArrayBuilder(Of LocalSymbol).GetInstance() For Each sourceLocal In sourceLocalsForBinding @@ -137,10 +135,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator local = sourceLocal.ToOtherMethod(Me, Me.TypeMap) localsMap.Add(sourceLocal, local) End If - localsBuilder.Add(local) Next - Me.LocalsForBinding = localsBuilder.ToImmutableAndFree() ' Create a map from variable name to display class field. @@ -279,7 +275,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If _lazyReturnType Is Nothing Then Throw New InvalidOperationException() End If - Return _lazyReturnType End Get End Property @@ -337,11 +332,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If Me.IsVararg Then cc = cc Or Cci.CallingConvention.ExtraArguments End If - If Me.IsGenericMethod Then cc = cc Or Cci.CallingConvention.Generic End If - Return cc End Get End Property @@ -488,13 +481,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator originalLocalsBuilder.Add(local) originalLocalsSet.Add(local) Next - For Each local In Me.Locals If originalLocalsSet.Add(local) Then originalLocalsBuilder.Add(local) End If Next - originalLocalsSet.Free() Dim originalLocals = originalLocalsBuilder.ToImmutableAndFree() Dim newBody = New BoundBlock(syntax, Nothing, originalLocals, statementsBuilder.ToImmutableAndFree()) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb index ac98718fdfd05..d57c77036919d 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.vb @@ -60,7 +60,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If isLValue Then Return variable End If - Return variable.MakeRValue() End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb index bb14ae783a9ab..1a8649bef1419 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/SyntaxHelpers.vb @@ -27,10 +27,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If ParseFormatSpecifiers(builder, expr, syntax.Expression.FullWidth, diagnostics) AndAlso builder.Count > 0 Then formatSpecifiers = New ReadOnlyCollection(Of String)(builder.ToArray()) End If - builder.Free() End If - Return If(diagnostics.HasAnyErrors(), Nothing, syntax) End Function @@ -98,7 +96,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(token, diagnostics) Return False End If - builder.Add(token) start = -1 expectingComma = c <> ","c @@ -107,13 +104,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(",", diagnostics) Return False End If - expectingComma = False End If ElseIf start < 0 Then start = offset End If - offset = offset + 1 End While @@ -123,7 +118,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ReportInvalidFormatSpecifier(token, diagnostics) Return False End If - builder.Add(token) ElseIf Not expectingComma Then ReportInvalidFormatSpecifier(",", diagnostics) diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb index 94ff7a5f12d0b..137dcd41d6a1a 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/VisualBasicInstructionDecoder.vb @@ -44,7 +44,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Do i += 1 Loop While ((i < numParts) AndAlso parts(i).Kind <> SymbolDisplayPartKind.MethodName) - i -= 1 End If Case SymbolDisplayPartKind.MethodName @@ -78,7 +77,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator If methodArity > 0 Then method = method.Construct(ImmutableArray.Create(typeArguments, methodArgumentStartIndex, methodArity)) End If - Return method End Function diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs index c12672789b0ea..95640414d3ea6 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs @@ -117,8 +117,8 @@ protected DefinitionItem( ImmutableArray originationParts, ImmutableArray sourceSpans, ImmutableDictionary properties, - bool displayIfNoReferences) - : this( + bool displayIfNoReferences) : + this( tags, displayParts, nameDisplayParts, diff --git a/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs b/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs index 497111a757d2c..0e2d76d022210 100644 --- a/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs +++ b/src/Scripting/Core/Hosting/ObjectFormatter/CommonObjectFormatter.Visitor.cs @@ -851,7 +851,6 @@ private Builder FormatWithEmbeddedExpressions(Builder result, string format, obj _memberDisplayFormat = oldMemberDisplayFormat; } } - i = expressionEnd + 1; } } diff --git a/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs b/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs index b0ca79a3c17d6..16a56641938e2 100644 --- a/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs +++ b/src/Scripting/Core/Hosting/ObjectFormatter/CommonTypeNameFormatter.cs @@ -226,7 +226,6 @@ private void AppendArrayRank(StringBuilder sb, Type arrayType) { sb.Append(',', rank - 1); } - sb.Append(ArrayClosing); } @@ -311,7 +310,6 @@ private void AppendTypeInstantiation( { builder.Append(", "); } - builder.Append(FormatTypeName(genericArguments[genericArgIndex++], options)); } diff --git a/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs b/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs index 41e2ec7ad3ed0..094c1b8807804 100644 --- a/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs +++ b/src/Scripting/Core/Hosting/Resolvers/NuGetPackageResolver.cs @@ -37,12 +37,10 @@ internal static bool TryParsePackageReference(string reference, out string name, { return true; } - break; } } } - name = null; version = null; return false; diff --git a/src/Scripting/Core/ScriptBuilder.cs b/src/Scripting/Core/ScriptBuilder.cs index 87524a47cdcd7..908836a5f2ba3 100644 --- a/src/Scripting/Core/ScriptBuilder.cs +++ b/src/Scripting/Core/ScriptBuilder.cs @@ -109,13 +109,11 @@ private static void ThrowIfAnyCompilationErrors(DiagnosticBag diagnostics, Diagn { return; } - var filtered = diagnostics.AsEnumerable().Where(d => d.Severity == DiagnosticSeverity.Error).AsImmutable(); if (filtered.IsEmpty) { return; } - throw new CompilationErrorException( formatter.Format(filtered[0], CultureInfo.CurrentCulture), filtered); diff --git a/src/Tools/AnalyzerRunner/Options.cs b/src/Tools/AnalyzerRunner/Options.cs index bd9e0e82a8613..2e7bd8d9662e6 100644 --- a/src/Tools/AnalyzerRunner/Options.cs +++ b/src/Tools/AnalyzerRunner/Options.cs @@ -216,7 +216,6 @@ internal static Options Create(string[] args) "Unrecognized option " + arg : "Unrecognized parameter " + arg)); } - break; } } diff --git a/src/Tools/BuildValidator/LocalReferenceResolver.cs b/src/Tools/BuildValidator/LocalReferenceResolver.cs index 8a569e6116e7f..3c93b7cb02796 100644 --- a/src/Tools/BuildValidator/LocalReferenceResolver.cs +++ b/src/Tools/BuildValidator/LocalReferenceResolver.cs @@ -45,7 +45,6 @@ public LocalReferenceResolver(Options options, ILoggerFactory loggerFactory) { _indexDirectories.Add(new DirectoryInfo(path)); } - _indexDirectories.Add(GetNugetCacheDirectory()); foreach (var path in options.ReferencesPaths) { diff --git a/src/Tools/BuildValidator/PEReaderExtensions.cs b/src/Tools/BuildValidator/PEReaderExtensions.cs index cecfb5d76fd8c..53264be4a8e6e 100644 --- a/src/Tools/BuildValidator/PEReaderExtensions.cs +++ b/src/Tools/BuildValidator/PEReaderExtensions.cs @@ -86,7 +86,6 @@ private PEExportTable(PEReader peReader) { nameBuilder.Append((char)ascii); } - _namedExportRva.Add(nameBuilder.ToString(), addressTable[ordinalTable[entryIndex]]); } } @@ -114,7 +113,6 @@ public static int GetOffset(this PEReader reader, int rva) { throw new BadImageFormatException("Failed to convert invalid RVA to offset: " + rva); } - SectionHeader containingSection = reader.PEHeaders.SectionHeaders[index]; return rva - containingSection.VirtualAddress + containingSection.PointerToRawData; } diff --git a/src/Tools/BuildValidator/Program.cs b/src/Tools/BuildValidator/Program.cs index 94c39cfdac474..83e4b6b9005f2 100644 --- a/src/Tools/BuildValidator/Program.cs +++ b/src/Tools/BuildValidator/Program.cs @@ -344,7 +344,6 @@ private static ImmutableArray ResolveSourceLinks(CompilationOpt logger.LogInformation($@"""{link.Prefix}"": ""{link.Replace}"""); } } - return sourceLinks; static SourceLinkEntry makeSourceLink(KeyValuePair entry) diff --git a/src/Tools/PrepareTests/MinimizeUtil.cs b/src/Tools/PrepareTests/MinimizeUtil.cs index 034f413fff3d2..4f543eb482f38 100644 --- a/src/Tools/PrepareTests/MinimizeUtil.cs +++ b/src/Tools/PrepareTests/MinimizeUtil.cs @@ -83,7 +83,6 @@ Dictionary> initialWalk() Directory.CreateDirectory(currentOutputDirectory); lastOutputDirectory = currentOutputDirectory; } - var fileName = Path.GetFileName(sourceFilePath); if (fileName.EndsWith(".dll", StringComparison.Ordinal) && TryGetMvid(sourceFilePath, out var mvid)) @@ -181,7 +180,6 @@ static void writeWindowsRehydrateContent(StringBuilder builder, IGrouping nul"); } - builder.AppendLine($@" mklink /h %~dp0\{destFileName} %HELIX_CORRELATION_PAYLOAD%\{source} > nul if %errorlevel% neq 0 ( @@ -194,7 +192,6 @@ static void writeWindowsRehydrateContent(StringBuilder builder, IGrouping items) - : base(version, items, ImmutableArray.Empty) + DiagnosticTableEntriesSource source, int version, ImmutableArray items) : + base(version, items, ImmutableArray.Empty) { _source = source; } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs index 1ff234ca8b85c..0401859b94c41 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs @@ -79,8 +79,8 @@ public VisualStudioDiagnosticListTable( VisualStudioWorkspaceImpl workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider, - IErrorList errorList) - : base(workspace, provider) + IErrorList errorList) : + base(workspace, provider) { _errorList = errorList; @@ -104,15 +104,15 @@ private ITableDataSource GetCurrentDataSource() } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) - : base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : + base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new LiveTableDataSource(workspace, diagnosticService, IdentifierString)); } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) - : base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) : + base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new BuildTableDataSource(workspace, errorSource)); } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs index 850ca550b0157..a6e98ac5c464f 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs @@ -32,8 +32,8 @@ public void StartListening(Workspace workspace, ITodoListProvider service) internal class VisualStudioTodoListTable : VisualStudioBaseTodoListTable { // internal for testing - internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) - : base(workspace, todoListProvider, IdentifierString, provider) + internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) : + base(workspace, todoListProvider, IdentifierString, provider) { ConnectWorkspaceEvents(); } diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs index 4e648b6deea9d..21a550b58ec2f 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/FindReferencesWindow_InProc.cs @@ -37,7 +37,6 @@ public Reference[] GetContents(string windowCaption) groupingPriority: 0); newColumnsStates.Add(newState); } - tableControl.SetColumnStates(newColumnsStates); // Force a refresh, if necessary. This doesn't re-run the Find References or diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs index 7d198c3c9398c..4a4c5637182da 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs @@ -192,7 +192,6 @@ public void EditProjectFile(string projectName) { throw new ArgumentException($"Could not find project file, current hierarchy items '{string.Join(", ", rootHierarchyItems.Select(x => x.Name))}'"); } - project.Select(EnvDTE.vsUISelectionType.vsUISelectionTypeSelect); ExecuteCommand("Project.EditProjectFile"); } @@ -211,7 +210,6 @@ public void CreateSolution(string solutionName, string solutionElementString) { throw new ArgumentException(nameof(solutionElementString)); } - CreateSolution(solutionName); foreach (var projectElement in solutionElement.Elements("Project")) @@ -315,7 +313,6 @@ public void RemoveProjectReference(string projectName, string projectReferenceNa var projectReference = references.Where(x => x.ContainingProject != null).Select(x => x.Name); throw new ArgumentException($"reference to project {projectReferenceName} not found, references: '{string.Join(", ", projectReference)}'"); } - reference.Remove(); } @@ -327,7 +324,6 @@ public void OpenSolution(string path, bool saveExistingSolutionIfExists = false) { CloseSolution(saveExistingSolutionIfExists); } - dte.Solution.Open(path); _solution = (EnvDTE80.Solution2)dte.Solution; @@ -810,7 +806,6 @@ int IVsUpdateSolutionEvents.UpdateSolution_Begin(ref int pfCancelUpdate) { pfCancelUpdate = 1; } - return 0; } @@ -844,7 +839,6 @@ int IVsUpdateSolutionEvents2.UpdateSolution_Begin(ref int pfCancelUpdate) { pfCancelUpdate = 1; } - return 0; } @@ -890,7 +884,6 @@ private int UpdateSolution_StartUpdate(ref int pfCancelUpdate) { pfCancelUpdate = 1; } - return 0; } diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs index dc52c2ba9508c..b4106b5aaede0 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs @@ -300,7 +300,6 @@ bool filterTag(IMappingTagSpan tag) { return tag.Tag.GetType().Equals(type); } - var service = GetComponentModelService(); var aggregator = service.CreateTagAggregator(view); var allTags = aggregator.GetTags(new SnapshotSpan(view.TextSnapshot, 0, view.TextSnapshot.Length)); diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index 2ed1280bb6298..2428414f901d7 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -276,7 +276,6 @@ private static ISetupInstance LocateVisualStudioInstance(ImmutableHashSet GetAttributeArguments(SyntaxNode attri { return this.GetAttributeArguments(list.Attributes[0]); } - break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)attributeDeclaration; @@ -1076,7 +1074,6 @@ public override IReadOnlyList GetAttributeArguments(SyntaxNode attri { return attr.ArgumentList.Arguments; } - break; } @@ -1116,7 +1113,6 @@ private static AttributeArgumentListSyntax GetAttributeArgumentList(SyntaxNode d { return list.Attributes[0].ArgumentList; } - break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)declaration; @@ -1136,7 +1132,6 @@ private static SyntaxNode WithAttributeArgumentList(SyntaxNode declaration, Attr { return ReplaceWithTrivia(declaration, list.Attributes[0], list.Attributes[0].WithArgumentList(argList)); } - break; case SyntaxKind.Attribute: var attr = (AttributeSyntax)declaration; @@ -1245,7 +1240,6 @@ private static ImmutableArray Flatten(IEnumerable declar { builder.Add(attrList); } - break; default: @@ -1838,7 +1832,6 @@ public override SyntaxNode GetType(SyntaxNode declaration) { return this.GetType(declaration.Parent); } - break; } @@ -1886,7 +1879,6 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) { return this.AsIsolatedDeclaration(vd.Parent); } - break; case SyntaxKind.VariableDeclarator: @@ -1895,7 +1887,6 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) { return this.ClearTrivia(WithVariable(v.Parent.Parent, v)); } - break; case SyntaxKind.Attribute: @@ -1905,7 +1896,6 @@ private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration) var attrList = (AttributeListSyntax)attr.Parent; return attrList.WithAttributes(SyntaxFactory.SingletonSeparatedList(attr)).WithTarget(null); } - break; } } @@ -1965,7 +1955,6 @@ private static SyntaxNode GetFullDeclaration(SyntaxNode declaration) { return GetFullDeclaration(declaration.Parent); } - break; } @@ -1987,7 +1976,6 @@ private SyntaxNode AsNodeLike(SyntaxNode existingNode, SyntaxNode newNode) { return this.AsMemberOf(container, newNode); } - break; case DeclarationKind.Attribute: @@ -2136,7 +2124,6 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return pd.ExpressionBody.Expression; } - goto default; case SyntaxKind.IndexerDeclaration: @@ -2145,7 +2132,6 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return id.ExpressionBody.Expression; } - goto default; case SyntaxKind.MethodDeclaration: @@ -2154,7 +2140,6 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return method.ExpressionBody.Expression; } - goto default; case SyntaxKind.LocalFunctionStatement: @@ -2163,7 +2148,6 @@ public override SyntaxNode GetExpression(SyntaxNode declaration) { return local.ExpressionBody.Expression; } - goto default; default: @@ -2192,7 +2176,6 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(pd, pd.ExpressionBody.Expression, expr); } - goto default; case SyntaxKind.IndexerDeclaration: @@ -2201,7 +2184,6 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(id, id.ExpressionBody.Expression, expr); } - goto default; case SyntaxKind.MethodDeclaration: @@ -2210,7 +2192,6 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(method, method.ExpressionBody.Expression, expr); } - goto default; case SyntaxKind.LocalFunctionStatement: @@ -2219,7 +2200,6 @@ private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxN { return ReplaceWithTrivia(local, local.ExpressionBody.Expression, expr); } - goto default; default: @@ -2257,7 +2237,6 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return fd.Declaration.Variables[0].Initializer; } - break; case SyntaxKind.PropertyDeclaration: var pd = (PropertyDeclarationSyntax)declaration; @@ -2268,7 +2247,6 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return ld.Declaration.Variables[0].Initializer; } - break; case SyntaxKind.VariableDeclaration: var vd = (VariableDeclarationSyntax)declaration; @@ -2276,7 +2254,6 @@ private static EqualsValueClauseSyntax GetEqualsValue(SyntaxNode declaration) { return vd.Variables[0].Initializer; } - break; case SyntaxKind.VariableDeclarator: return ((VariableDeclaratorSyntax)declaration).Initializer; @@ -2297,7 +2274,6 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, fd.Declaration.Variables[0], fd.Declaration.Variables[0].WithInitializer(eq)); } - break; case SyntaxKind.PropertyDeclaration: var pd = (PropertyDeclarationSyntax)declaration; @@ -2308,7 +2284,6 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, ld.Declaration.Variables[0], ld.Declaration.Variables[0].WithInitializer(eq)); } - break; case SyntaxKind.VariableDeclaration: var vd = (VariableDeclarationSyntax)declaration; @@ -2316,7 +2291,6 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla { return ReplaceWithTrivia(declaration, vd.Variables[0], vd.Variables[0].WithInitializer(eq)); } - break; case SyntaxKind.VariableDeclarator: return ((VariableDeclaratorSyntax)declaration).WithInitializer(eq); @@ -2461,7 +2435,6 @@ private static AccessorDeclarationSyntax AsAccessor(SyntaxNode node, SyntaxKind case SyntaxKind.SetAccessorDeclaration: return (AccessorDeclarationSyntax)node; } - break; case SyntaxKind.EventDeclaration: switch (node.Kind()) @@ -2470,7 +2443,6 @@ private static AccessorDeclarationSyntax AsAccessor(SyntaxNode node, SyntaxKind case SyntaxKind.RemoveAccessorDeclaration: return (AccessorDeclarationSyntax)node; } - break; } @@ -2874,7 +2846,6 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire list if only one attribute return this.RemoveNodeInternal(root, attrList, options); } - break; case SyntaxKind.AttributeArgument: @@ -2883,7 +2854,6 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire argument list if only one argument return this.RemoveNodeInternal(root, declaration.Parent, options); } - break; case SyntaxKind.VariableDeclarator: @@ -2893,7 +2863,6 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove full declaration if only one declarator return this.RemoveNodeInternal(root, full, options); } - break; case SyntaxKind.SimpleBaseType: @@ -2902,7 +2871,6 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S // remove entire base list if this is the only base type. return this.RemoveNodeInternal(root, baseList, options); } - break; default: @@ -2915,7 +2883,6 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, S return this.RemoveNodeInternal(root, parent, options); } } - break; } diff --git a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs index bf8c370f9fb1e..e8cf99794241c 100644 --- a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs +++ b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs @@ -308,7 +308,6 @@ private static bool CanMakeNameExplicitInTuple(TupleExpressionSyntax tuple, stri // No duplicate names allowed return false; } - found = true; } } @@ -503,7 +502,6 @@ private ExpressionSyntax VisitSimpleName(SimpleNameSyntax rewrittenSimpleName, S { replacement = replacement.ReplaceToken(firstOriginalToken, tokenWithLeadingWhitespace); } - break; case SyntaxKind.QualifiedName: diff --git a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs index dba94bbc991dd..10e91ddd6ad76 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs @@ -327,7 +327,6 @@ protected override void ApplyProjectChanges(ProjectChanges projectChanges) projectChanges.ProjectId)); return; } - if (_projectFileLoaderRegistry.TryGetLoaderFromProjectPath(projectPath, out var fileLoader)) { try @@ -376,7 +375,6 @@ protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceTe _reporter.Report(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, message, document.Id)); return; } - this.SaveDocumentText(documentId, document.FilePath, text, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); this.OnDocumentTextChanged(documentId, text, PreservationMode.PreserveValue); } @@ -394,7 +392,6 @@ protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId _reporter.Report(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, message, document.Id)); return; } - this.SaveDocumentText(documentId, document.FilePath, text, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); this.OnAdditionalDocumentTextChanged(documentId, text, PreservationMode.PreserveValue); } @@ -438,7 +435,6 @@ protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) { return; } - if (_projectFileLoaderRegistry.TryGetLoaderFromProjectPath(filePath, out _)) { var extension = _applyChangesProjectFile.GetDocumentExtension(info.SourceCodeKind); @@ -534,7 +530,6 @@ protected override void ApplyMetadataReferenceAdded(ProjectId projectId, Metadat _reporter.Report(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, message, projectId)); return; } - _applyChangesProjectFile.AddMetadataReference(metadataReference, identity); this.OnMetadataReferenceAdded(projectId, metadataReference); } @@ -549,7 +544,6 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad _reporter.Report(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, message, projectId)); return; } - _applyChangesProjectFile.RemoveMetadataReference(metadataReference, identity); this.OnMetadataReferenceRemoved(projectId, metadataReference); } @@ -561,7 +555,6 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad { return null; } - if (!project.MetadataReferences.Contains(metadataReference)) { project = project.AddMetadataReference(metadataReference); @@ -572,7 +565,6 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad { return null; } - var symbol = compilation.GetAssemblyOrModuleSymbol(metadataReference) as IAssemblySymbol; return symbol?.Identity; } diff --git a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs index af4b6cc9ba553..f6a8f05de4c65 100644 --- a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs +++ b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs @@ -15,15 +15,15 @@ internal class IncrementalAnalyzerProviderMetadata : WorkspaceKindMetadata public bool HighPriorityForActiveFile { get; } public string Name { get; } - public IncrementalAnalyzerProviderMetadata(IDictionary data) - : base(data) + public IncrementalAnalyzerProviderMetadata(IDictionary data) : + base(data) { this.HighPriorityForActiveFile = (bool)data.GetValueOrDefault("HighPriorityForActiveFile"); this.Name = (string)data.GetValueOrDefault("Name"); } - public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) - : base(workspaceKinds) + public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) : + base(workspaceKinds) { this.HighPriorityForActiveFile = highPriorityForActiveFile; this.Name = name; diff --git a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs index 51e54e6b4a3a7..1d92e0042cdf6 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs @@ -18,14 +18,14 @@ internal class EventListenerMetadata : WorkspaceKindMetadata { public string Service { get; } - public EventListenerMetadata(IDictionary data) - : base(data) + public EventListenerMetadata(IDictionary data) : + base(data) { this.Service = (string)data.GetValueOrDefault("Service"); } - public EventListenerMetadata(string service, params string[] workspaceKinds) - : base(workspaceKinds) + public EventListenerMetadata(string service, params string[] workspaceKinds) : + base(workspaceKinds) { if (workspaceKinds?.Length == 0) { diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs index 92b5a15249b5f..6693cd16b0753 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs @@ -125,8 +125,8 @@ private class Snapshot /// private readonly Dictionary _performanceMap; - public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) - : this(Convert(snapshot), unitCount) + public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) : + this(Convert(snapshot), unitCount) { } diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs index 2cfbc915461e0..d6cb2cde53457 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs @@ -44,8 +44,8 @@ internal class PerformanceTrackerService : IPerformanceTrackerService [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public PerformanceTrackerService() - : this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) + public PerformanceTrackerService() : + this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) { } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs index bf387e4683768..4921a460d7edb 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/EmbeddedLanguages/VirtualChars/CSharpVirtualCharService.cs @@ -98,7 +98,6 @@ private static VirtualCharSequence TryConvertStringToVirtualChars( Debug.Fail("This should not be reachable as long as the compiler added no diagnostics."); return default; } - if (endDelimiter.Length > 0 && !tokenText.EndsWith(endDelimiter)) { Debug.Fail("This should not be reachable as long as the compiler added no diagnostics."); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs index e35b6c78bc1fd..fa3f0322fcff4 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpFormattingOptions2.Parsers.cs @@ -92,12 +92,10 @@ internal static bool DetermineIfNewLineOptionIsSet(string value, NewLineOption o { return option; } - if (s_legacyNewLineOptionsEditorConfigMap.TryGetValue(value, out var legacyOption)) { return legacyOption; } - return null; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs index 49c4a03e97194..11e1bd60da9c8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs @@ -880,7 +880,6 @@ public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, strin { name = "~" + name; } - if ((options & DisplayNameOptions.IncludeTypeParameters) != 0) { var pooled = PooledStringBuilder.GetInstance(); @@ -908,7 +907,6 @@ public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, strin } } } - Debug.Assert(name != null, "Unexpected node type " + node.Kind()); return name; } @@ -924,7 +922,6 @@ private static void AppendTypeParameterList(StringBuilder builder, TypeParameter builder.Append(", "); builder.Append(typeParameterList.Parameters[i].Identifier.ValueText); } - builder.Append('>'); } } @@ -2045,7 +2042,6 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) return DeclarationKind.Variable; } } - break; } @@ -2055,7 +2051,6 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) { return DeclarationKind.Attribute; } - break; case SyntaxKind.Attribute: @@ -2063,7 +2058,6 @@ public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) { return DeclarationKind.Attribute; } - break; case SyntaxKind.GetAccessorDeclaration: diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs index f4ff1fa562605..0e527a0c4f36f 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Simplification/Simplifiers/CastSimplifier.cs @@ -914,7 +914,6 @@ private static ulong FindSurprisingSignExtensionBits(IOperation? operation, bool case 2: return unchecked((ulong)(ushort)recursive); case 4: return unchecked((ulong)(uint)recursive); } - Debug.Assert(false, "How did we get here?"); return recursive; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index 2616a24c40e74..b336edcc5a997 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -1623,7 +1623,6 @@ private static SyntaxNode UnwrapPossibleTuple(SyntaxNode node) node = node.Parent; continue; } - if (node.Parent.IsKind(SyntaxKind.Argument) && node.Parent.Parent.IsKind(SyntaxKind.TupleExpression)) { node = node.Parent.Parent; @@ -1646,7 +1645,6 @@ private static bool IsPossibleVarDeconstructionOpenParenOrComma(SyntaxToken left return true; } } - return false; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs index a075030b96b56..e2caec752c8e0 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs @@ -16,7 +16,6 @@ public static bool IsMultilineDocComment([NotNullWhen(true)] this DocumentationC { return false; } - return documentationComment.ToFullString().StartsWith("/**", StringComparison.Ordinal); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs index fd0d31a104df4..b72e782fead03 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs @@ -678,7 +678,6 @@ private void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol { result[returnTypeParameter] = inferredType; } - return; } } @@ -706,7 +705,6 @@ private void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol DetermineTypeParameterMapping(inferredNamedType.TypeArguments[i], returnNamedType.TypeArguments[i], result); } } - return; } } @@ -833,7 +831,6 @@ private IEnumerable InferTypeInArrayType(ArrayTypeSyntax arra currentTypes = currentTypes.Select(t => t.InferredType).OfType() .SelectAsArray(a => new TypeInferenceInfo(a.ElementType)); } - return currentTypes; } From 66d43643b62d45abd2416b6f444769dace8bc666 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:37:55 -0700 Subject: [PATCH 21/63] Disable --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2b7c2a43913cf..3d3a87118281c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -65,8 +65,8 @@ dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_allow_multiple_blank_lines_experimental = false:warning dotnet_diagnostic.IDE2000.severity = warning -dotnet_style_allow_statement_immediately_after_block_experimental = false:warning -dotnet_diagnostic.IDE2003.severity = warning +dotnet_style_allow_statement_immediately_after_block_experimental = true:none +dotnet_diagnostic.IDE2003.severity = none # Non-private static fields are PascalCase From e4d86874815c9f42f0af2b25ecd75e2f4ceaa687 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 17:47:07 -0700 Subject: [PATCH 22/63] Place colon consistently --- src/Dependencies/PooledObjects/PooledHashSet.cs | 4 ++-- .../Binders/PlaceholderLocalBinder.cs | 4 ++-- .../Source/ExpressionCompiler/EEAssemblyBuilder.cs | 4 ++-- .../Source/ExpressionCompiler/EETypeNameDecoder.cs | 4 ++-- .../ExpressionCompiler/Symbols/EENamedTypeSymbol.cs | 4 ++-- .../Symbols/ExceptionLocalSymbol.cs | 4 ++-- .../Symbols/ObjectAddressLocalSymbol.cs | 4 ++-- .../Symbols/ObjectIdLocalSymbol.cs | 4 ++-- .../Symbols/ReturnValueLocalSymbol.cs | 4 ++-- .../ExpressionCompiler/ReferencedModulesTests.cs | 4 ++-- .../ResultProvider/CSharpResultProviderTestBase.cs | 8 ++++---- .../Test/ResultProvider/CustomResultProviderTests.cs | 4 ++-- .../Engine/DkmClrDebuggerBrowsableAttribute.cs | 4 ++-- .../Engine/DkmClrDebuggerTypeProxyAttribute.cs | 4 ++-- .../Engine/DkmClrDebuggerVisualizerAttribute.cs | 4 ++-- .../Debugger/Engine/DkmClrModuleInstance.cs | 4 ++-- .../ResultProvider/Debugger/Engine/DkmClrType.cs | 8 ++++---- .../Debugger/Engine/DkmFailedEvaluationResult.cs | 4 ++-- .../Engine/DkmIntermediateEvaluationResult.cs | 4 ++-- .../Debugger/Engine/DkmSuccessEvaluationResult.cs | 4 ++-- .../Core/Portable/FindUsages/DefinitionItem.cs | 4 ++-- .../MiscellaneousDiagnosticListTable.cs | 4 ++-- .../TableDataSource/MiscellaneousTodoListTable.cs | 4 ++-- .../VisualStudioBaseDiagnosticListTable.cs | 4 ++-- ...StudioDiagnosticListTable.BuildTableDataSource.cs | 4 ++-- .../VisualStudioDiagnosticListTable.cs | 12 ++++++------ .../TableDataSource/VisualStudioTodoListTable.cs | 4 ++-- .../Impl/Client/RemoteDiagnosticListTable.cs | 4 ++-- .../IncrementalAnalyzerProviderMetadata.cs | 8 ++++---- .../Host/EventListener/EventListenerMetadata.cs | 8 ++++---- .../Services/DiagnosticAnalyzer/PerformanceQueue.cs | 4 ++-- .../DiagnosticAnalyzer/PerformanceTrackerService.cs | 4 ++-- 32 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/Dependencies/PooledObjects/PooledHashSet.cs b/src/Dependencies/PooledObjects/PooledHashSet.cs index 472380a3c3e4a..ee17f78e4384d 100644 --- a/src/Dependencies/PooledObjects/PooledHashSet.cs +++ b/src/Dependencies/PooledObjects/PooledHashSet.cs @@ -13,8 +13,8 @@ internal sealed partial class PooledHashSet : HashSet { private readonly ObjectPool> _pool; - private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) : - base(equalityComparer) + private PooledHashSet(ObjectPool> pool, IEqualityComparer equalityComparer) + : base(equalityComparer) { _pool = pool; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs index d4ed8aaee3406..d4714330a250e 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.cs @@ -30,8 +30,8 @@ internal PlaceholderLocalBinder( ImmutableArray aliases, MethodSymbol containingMethod, EETypeNameDecoder typeNameDecoder, - Binder next) : - base(next) + Binder next) + : base(next) { _syntax = syntax; _containingMethod = containingMethod; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs index d7fe8de53c29e..0e3f61bc18f25 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EEAssemblyBuilder.cs @@ -28,8 +28,8 @@ public EEAssemblyBuilder( Cci.ModulePropertiesForSerialization serializationProperties, ImmutableArray additionalTypes, Func getDynamicOperationContextType, - CompilationTestData? testData) : - base( + CompilationTestData? testData) + : base( sourceAssembly, emitOptions, outputKind: OutputKind.DynamicallyLinkedLibrary, diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs index 0318126cb87c3..d3605ea98bef7 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/EETypeNameDecoder.cs @@ -14,8 +14,8 @@ internal sealed class EETypeNameDecoder : TypeNameDecoder ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) + GenerateMethodBody generateMethodBody) + : this(container, baseType, currentFrame, typeName, (m, t) => ImmutableArray.Create(context.CreateMethod(t, methodName, syntax, generateMethodBody))) { } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs index 81ae9aa1cf6c6..69200b7493a20 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ExceptionLocalSymbol.cs @@ -12,8 +12,8 @@ internal sealed class ExceptionLocalSymbol : PlaceholderLocalSymbol { private readonly string _getExceptionMethodName; - internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) : - base(method, name, displayName, type) + internal ExceptionLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, string getExceptionMethodName) + : base(method, name, displayName, type) { _getExceptionMethodName = getExceptionMethodName; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs index bfb4bc1de0906..f6bc3ca8cde8d 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectAddressLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectAddressLocalSymbol : PlaceholderLocalSymbol { private readonly ulong _address; - internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) : - base(method, name, name, type) + internal ObjectAddressLocalSymbol(MethodSymbol method, string name, TypeSymbol type, ulong address) + : base(method, name, name, type) { Debug.Assert(type.SpecialType == SpecialType.System_Object); _address = address; diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs index 8e6c6d346ac2a..6552569dd78ff 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ObjectIdLocalSymbol.cs @@ -15,8 +15,8 @@ internal sealed class ObjectIdLocalSymbol : PlaceholderLocalSymbol { private readonly bool _isWritable; - internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) : - base(method, name, displayName, type) + internal ObjectIdLocalSymbol(MethodSymbol method, TypeSymbol type, string name, string displayName, bool isWritable) + : base(method, name, displayName, type) { _isWritable = isWritable; } diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs index 9114143677872..03127935aa00a 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/ReturnValueLocalSymbol.cs @@ -14,8 +14,8 @@ internal sealed class ReturnValueLocalSymbol : PlaceholderLocalSymbol { private readonly int _index; - internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) : - base(method, name, displayName, type) + internal ReturnValueLocalSymbol(MethodSymbol method, string name, string displayName, TypeSymbol type, int index) + : base(method, name, displayName, type) { _index = index; } diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs index a6b74fa493568..951b398e069ab 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs @@ -1531,8 +1531,8 @@ private sealed class PEAssemblyBuilderWithAdditionalReferences : PEModuleBuilder private readonly CommonPEModuleBuilder _builder; private readonly NamespaceTypeDefinitionNoBase _objectType; - internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) : - base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) + internal PEAssemblyBuilderWithAdditionalReferences(CommonPEModuleBuilder builder, EmitOptions emitOptions, INamespaceTypeDefinition objectType) + : base((SourceModuleSymbol)builder.CommonSourceModule, emitOptions, builder.OutputKind, builder.SerializationProperties, builder.ManifestResources) { _builder = builder; _objectType = new NamespaceTypeDefinitionNoBase(objectType); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs index a7a748440564e..c397a2754dab2 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs @@ -21,13 +21,13 @@ public CSharpResultProviderTestBase() : this(new CSharpFormatter()) { } - private CSharpResultProviderTestBase(CSharpFormatter formatter) : - this(CreateDkmInspectionSession(formatter)) + private CSharpResultProviderTestBase(CSharpFormatter formatter) + : this(CreateDkmInspectionSession(formatter)) { } - internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) : - base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) + internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) + : base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) { } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs index 2515775653ece..4361c7b14c6ad 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs @@ -27,8 +27,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests /// public class CustomResultProviderTests : CSharpResultProviderTestBase { - public CustomResultProviderTests() : - base( + public CustomResultProviderTests() + : base( new DkmInspectionSession( ImmutableArray.Create(new CustomFormatter(new CSharpFormatter()), new CSharpFormatter()), ImmutableArray.Create(new CustomResultProvider(), new CSharpResultProvider()))) diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs index 6a8d4e4bfb724..3385276a8e4c7 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerBrowsableAttribute.cs @@ -20,8 +20,8 @@ public enum DkmClrDebuggerBrowsableAttributeState public class DkmClrDebuggerBrowsableAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) : - base(targetMember) + internal DkmClrDebuggerBrowsableAttribute(string targetMember, DkmClrDebuggerBrowsableAttributeState state) + : base(targetMember) { this.State = state; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs index e1cd0e6bd4e9e..f4b8f020d5672 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerTypeProxyAttribute.cs @@ -15,8 +15,8 @@ namespace Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation { public class DkmClrDebuggerTypeProxyAttribute : DkmClrEvalAttribute { - internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) : - base(null) + internal DkmClrDebuggerTypeProxyAttribute(DkmClrType proxyType) + : base(null) { this.ProxyType = proxyType; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs index b40d7da466d27..8db52ca741898 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrDebuggerVisualizerAttribute.cs @@ -31,8 +31,8 @@ internal DkmClrDebuggerVisualizerAttribute(string targetMember, DkmClrCustomVisualizerAssemblyLocation uiSideVisualizerAssemblyLocation, string debuggeeSideVisualizerTypeName, string debuggeeSideVisualizerAssemblyName, - string visualizerDescription) : - base(null) + string visualizerDescription) + : base(null) { UISideVisualizerTypeName = uiSideVisualizerTypeName; UISideVisualizerAssemblyName = uiSideVisualizerAssemblyName; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs index b6940815f033d..9ff581028a5e5 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrModuleInstance.cs @@ -26,8 +26,8 @@ public class DkmClrModuleInstance : DkmModuleInstance private readonly DkmClrRuntimeInstance _runtimeInstance; private int _resolveTypeNameFailures; - public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) : - base(module) + public DkmClrModuleInstance(DkmClrRuntimeInstance runtimeInstance, Assembly assembly, DkmModule module) + : base(module) { _runtimeInstance = runtimeInstance; this.Assembly = assembly; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs index 1a7ddb2982e84..964edc2b79be7 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrType.cs @@ -51,13 +51,13 @@ internal DkmClrType(DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type _favorites = favorites; } - internal DkmClrType(Type lmrType) : - this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) + internal DkmClrType(Type lmrType) + : this(DkmClrRuntimeInstance.DefaultRuntime, lmrType) { } - internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) : - this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) + internal DkmClrType(DkmClrRuntimeInstance runtime, Type lmrType) + : this(runtime.DefaultModule, runtime.DefaultAppDomain, lmrType) { } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs index 557035d74defc..728f57afc92eb 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmFailedEvaluationResult.cs @@ -25,8 +25,8 @@ private DkmFailedEvaluationResult( string errorMessage, DkmEvaluationResultFlags flags, string type, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.ErrorMessage = errorMessage; } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs index 9faafe7fc008b..4f45b059c4ebe 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmIntermediateEvaluationResult.cs @@ -27,8 +27,8 @@ private DkmIntermediateEvaluationResult( string expression, DkmLanguage intermediateLanguage, DkmRuntimeInstance targetRuntime, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) { this.Expression = expression; this.IntermediateLanguage = intermediateLanguage; diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs index 238dea57e89f1..55c1177370b40 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs @@ -41,8 +41,8 @@ private DkmSuccessEvaluationResult( DkmDataAddress address, ReadOnlyCollection customUIVisualizers, ReadOnlyCollection externalModules, - DkmDataItem dataItem) : - base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) + DkmDataItem dataItem) + : base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem) { this.Value = value; this.EditableValue = editableValue; diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs index 95640414d3ea6..c12672789b0ea 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs @@ -117,8 +117,8 @@ protected DefinitionItem( ImmutableArray originationParts, ImmutableArray sourceSpans, ImmutableDictionary properties, - bool displayIfNoReferences) : - this( + bool displayIfNoReferences) + : this( tags, displayParts, nameDisplayParts, diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs index d58222681a904..18e29d1645198 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousDiagnosticListTable.cs @@ -34,8 +34,8 @@ private sealed class MiscellaneousDiagnosticListTable : VisualStudioBaseDiagnost { private readonly LiveTableDataSource _source; - public MiscellaneousDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + public MiscellaneousDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { _source = new LiveTableDataSource(workspace, diagnosticService, IdentifierString); diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs index 8a92d5d82de14..6a431243b7fa2 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/MiscellaneousTodoListTable.cs @@ -31,8 +31,8 @@ public void StartListening(Workspace workspace, ITodoListProvider service) private sealed class MiscellaneousTodoListTable : VisualStudioBaseTodoListTable { - public MiscellaneousTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) : - base(workspace, todoListProvider, IdentifierString, provider) + public MiscellaneousTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) + : base(workspace, todoListProvider, IdentifierString, provider) { ConnectWorkspaceEvents(); } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs index 18186f1bfa44f..9ad21793b05f3 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs @@ -34,8 +34,8 @@ internal abstract partial class VisualStudioBaseDiagnosticListTable : AbstractTa StandardTableColumnDefinitions.SuppressionState }; - protected VisualStudioBaseDiagnosticListTable(Workspace workspace, ITableManagerProvider provider) : - base(workspace, provider, StandardTables.ErrorsTable) + protected VisualStudioBaseDiagnosticListTable(Workspace workspace, ITableManagerProvider provider) + : base(workspace, provider, StandardTables.ErrorsTable) { } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs index bb04f29635839..351cfcc868b05 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs @@ -126,8 +126,8 @@ private class TableEntriesSnapshot : AbstractTableEntriesSnapshot items) : - base(version, items, ImmutableArray.Empty) + DiagnosticTableEntriesSource source, int version, ImmutableArray items) + : base(version, items, ImmutableArray.Empty) { _source = source; } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs index 0401859b94c41..1ff234ca8b85c 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.cs @@ -79,8 +79,8 @@ public VisualStudioDiagnosticListTable( VisualStudioWorkspaceImpl workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider, - IErrorList errorList) : - base(workspace, provider) + IErrorList errorList) + : base(workspace, provider) { _errorList = errorList; @@ -104,15 +104,15 @@ private ITableDataSource GetCurrentDataSource() } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new LiveTableDataSource(workspace, diagnosticService, IdentifierString)); } /// this is for test only - internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) : - base(workspace, provider) + internal VisualStudioDiagnosticListTable(Workspace workspace, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) + : base(workspace, provider) { AddInitialTableSource(workspace.CurrentSolution, new BuildTableDataSource(workspace, errorSource)); } diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs index a6e98ac5c464f..850ca550b0157 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioTodoListTable.cs @@ -32,8 +32,8 @@ public void StartListening(Workspace workspace, ITodoListProvider service) internal class VisualStudioTodoListTable : VisualStudioBaseTodoListTable { // internal for testing - internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) : - base(workspace, todoListProvider, IdentifierString, provider) + internal VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) + : base(workspace, todoListProvider, IdentifierString, provider) { ConnectWorkspaceEvents(); } diff --git a/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs b/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs index 5d407bad2c7c9..52c3a081fd895 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/RemoteDiagnosticListTable.cs @@ -30,8 +30,8 @@ internal class RemoteDiagnosticListTable : VisualStudioBaseDiagnosticListTable [ImportingConstructor] [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Incorrectly used in production code: https://github.com/dotnet/roslyn/issues/42839")] public RemoteDiagnosticListTable( - SVsServiceProvider serviceProvider, RemoteLanguageServiceWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) : - base(workspace, provider) + SVsServiceProvider serviceProvider, RemoteLanguageServiceWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) + : base(workspace, provider) { _source = new LiveTableDataSource(workspace, diagnosticService, IdentifierString); AddInitialTableSource(workspace.CurrentSolution, _source); diff --git a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs index f6a8f05de4c65..af4b6cc9ba553 100644 --- a/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs +++ b/src/Workspaces/Core/Portable/SolutionCrawler/IncrementalAnalyzerProviderMetadata.cs @@ -15,15 +15,15 @@ internal class IncrementalAnalyzerProviderMetadata : WorkspaceKindMetadata public bool HighPriorityForActiveFile { get; } public string Name { get; } - public IncrementalAnalyzerProviderMetadata(IDictionary data) : - base(data) + public IncrementalAnalyzerProviderMetadata(IDictionary data) + : base(data) { this.HighPriorityForActiveFile = (bool)data.GetValueOrDefault("HighPriorityForActiveFile"); this.Name = (string)data.GetValueOrDefault("Name"); } - public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) : - base(workspaceKinds) + public IncrementalAnalyzerProviderMetadata(string name, bool highPriorityForActiveFile, params string[] workspaceKinds) + : base(workspaceKinds) { this.HighPriorityForActiveFile = highPriorityForActiveFile; this.Name = name; diff --git a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs index 1d92e0042cdf6..51e54e6b4a3a7 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/EventListener/EventListenerMetadata.cs @@ -18,14 +18,14 @@ internal class EventListenerMetadata : WorkspaceKindMetadata { public string Service { get; } - public EventListenerMetadata(IDictionary data) : - base(data) + public EventListenerMetadata(IDictionary data) + : base(data) { this.Service = (string)data.GetValueOrDefault("Service"); } - public EventListenerMetadata(string service, params string[] workspaceKinds) : - base(workspaceKinds) + public EventListenerMetadata(string service, params string[] workspaceKinds) + : base(workspaceKinds) { if (workspaceKinds?.Length == 0) { diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs index 6693cd16b0753..92b5a15249b5f 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceQueue.cs @@ -125,8 +125,8 @@ private class Snapshot /// private readonly Dictionary _performanceMap; - public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) : - this(Convert(snapshot), unitCount) + public Snapshot(IEnumerable<(string analyzerId, TimeSpan timeSpan)> snapshot, int unitCount) + : this(Convert(snapshot), unitCount) { } diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs index d6cb2cde53457..2cfbc915461e0 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/PerformanceTrackerService.cs @@ -44,8 +44,8 @@ internal class PerformanceTrackerService : IPerformanceTrackerService [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public PerformanceTrackerService() : - this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) + public PerformanceTrackerService() + : this(DefaultMinLOFValue, DefaultAverageThreshold, DefaultStddevThreshold) { } From 33b91b3c184e2fff1c47bbe741781e1871a38aea Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 18:38:40 -0700 Subject: [PATCH 23/63] Fix IDE0059: Unnecessary assignment --- .../Test/Emit/Attributes/AttributeTests.cs | 2 +- .../Attributes/AttributeTests_Assembly.cs | 6 +- .../AttributeTests_CallerInfoAttributes.cs | 3 +- .../Emit/Attributes/AttributeTests_Dynamic.cs | 6 +- .../AttributeTests_WellKnownAttributes.cs | 7 +- .../Emit/CodeGen/CodeGenAsyncMainTests.cs | 22 +- .../Emit/CodeGen/CodeGenAsyncSpillTests.cs | 10 +- .../Test/Emit/CodeGen/CodeGenCheckedTests.cs | 41 +-- .../Emit/CodeGen/CodeGenClosureLambdaTests.cs | 31 ++- .../Emit/CodeGen/CodeGenConversionTests.cs | 4 +- .../Emit/CodeGen/CodeGenDeconstructTests.cs | 10 +- .../Test/Emit/CodeGen/CodeGenDynamicTests.cs | 4 +- .../Emit/CodeGen/CodeGenExprLambdaTests.cs | 54 ++-- .../Test/Emit/CodeGen/CodeGenForEachTests.cs | 20 +- .../CodeGen/CodeGenFunctionPointersTests.cs | 2 +- .../CodeGenImplicitImplementationTests.cs | 9 +- .../CodeGenImplicitlyTypeArraysTests.cs | 4 +- .../CodeGen/CodeGenInterfaceImplementation.cs | 8 +- .../Test/Emit/CodeGen/CodeGenIterators.cs | 4 +- .../Emit/CodeGen/CodeGenLocalFunctionTests.cs | 6 +- .../Test/Emit/CodeGen/CodeGenOperators.cs | 51 ++-- .../CodeGenOptimizedNullableOperators.cs | 8 +- .../CodeGen/CodeGenOverridingAndHiding.cs | 55 ++-- .../CodeGen/CodeGenReadonlyStructTests.cs | 4 +- .../Test/Emit/CodeGen/CodeGenRefLocalTests.cs | 24 +- .../Emit/CodeGen/CodeGenRefReturnTests.cs | 11 +- .../CodeGenShortCircuitOperatorTests.cs | 57 ++-- .../CSharp/Test/Emit/CodeGen/CodeGenTests.cs | 50 ++-- .../Emit/CodeGen/CodeGenTupleEqualityTests.cs | 2 +- .../Test/Emit/CodeGen/CodeGenTupleTest.cs | 253 +++++++----------- .../Test/Emit/CodeGen/CodeGenTypeofTests.cs | 3 +- .../CodeGen/CodeGenUsingStatementTests.cs | 2 +- .../CSharp/Test/Emit/CodeGen/ForLoopsTests.cs | 13 +- .../Test/Emit/CodeGen/IndexAndRangeTests.cs | 2 +- .../CSharp/Test/Emit/CodeGen/IndexerTests.cs | 2 +- .../ObjectAndCollectionInitializerTests.cs | 15 +- .../CSharp/Test/Emit/CodeGen/PatternTests.cs | 34 +-- .../CSharp/Test/Emit/CodeGen/SwitchTests.cs | 10 +- .../CSharp/Test/Emit/CodeGen/UnsafeTests.cs | 15 +- .../Test/Emit/Emit/CompilationEmitTests.cs | 2 +- .../DynamicInstrumentationTests.cs | 4 +- .../EditAndContinue/LocalSlotMappingTests.cs | 2 +- .../CSharp/Test/Emit/Emit/EmitErrorTests.cs | 4 +- .../CSharp/Test/Emit/PrivateProtected.cs | 4 +- 44 files changed, 380 insertions(+), 500 deletions(-) diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs index 9a8cb51483959..98e76f430b281 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs @@ -5861,7 +5861,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: ""); + _ = CompileAndVerify(source, expectedOutput: ""); } [WorkItem(541858, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541858")] diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Assembly.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Assembly.cs index 13b6ea06ed48b..2bb5db9f6d000 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Assembly.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Assembly.cs @@ -1022,7 +1022,7 @@ static void Main(string[] args) { } Assert.NotNull(consoleappCompilation.GetTypeByMetadataName("System.Runtime.CompilerServices.AssemblyAttributesGoHere")); Assert.NotNull(consoleappCompilation.GetTypeByMetadataName("System.Runtime.CompilerServices.AssemblyAttributesGoHereM")); - var diagnostics = consoleappCompilation.GetDiagnostics(); + _ = consoleappCompilation.GetDiagnostics(); var attrs = consoleappCompilation.Assembly.GetAttributes(); Assert.Equal(4, attrs.Length); @@ -1209,7 +1209,7 @@ static void Main(string[] args) { } "; var consoleappCompilation = CreateCompilationWithMscorlib40(consoleappSource, references: new[] { GetNetModuleWithAssemblyAttributesRef() }, options: TestOptions.ReleaseExe); - var diagnostics = consoleappCompilation.GetDiagnostics(); + _ = consoleappCompilation.GetDiagnostics(); TestDuplicateAssemblyAttributesNotEmitted(consoleappCompilation, expectedSrcAttrCount: 2, @@ -1312,7 +1312,7 @@ static void Main(string[] args) { } "; var consoleappCompilation = CreateCompilationWithMscorlib40(consoleappSource, references: new[] { GetNetModuleWithAssemblyAttributesRef() }, options: TestOptions.ReleaseExe); - var diagnostics = consoleappCompilation.GetDiagnostics(); + _ = consoleappCompilation.GetDiagnostics(); var attrs = consoleappCompilation.Assembly.GetAttributes(); Assert.Equal(5, attrs.Length); diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs index 1485e83a73bba..98b1ea03cd6ab 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs @@ -2787,8 +2787,7 @@ static void Main(string[] args) } } "; - - var compilation = CreateCompilationWithMscorlib45(new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(source, options: TestOptions.Regular7, path: @"C:\filename") }).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(source, options: TestOptions.Regular7, path: @"C:\filename") }).VerifyDiagnostics( // C:\filename(7,38): error CS4018: CallerFilePathAttribute cannot be applied because there are no standard conversions from type 'string' to type 'int' // static void M1([CallerLineNumber,CallerFilePath,CallerMemberName] int i = 0) { Console.WriteLine(); } Diagnostic(ErrorCode.ERR_NoConversionForCallerFilePathParam, "CallerFilePath").WithArguments("string", "int").WithLocation(7, 38), diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Dynamic.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Dynamic.cs index 7fcf5f7768c2f..9906974040d24 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Dynamic.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Dynamic.cs @@ -867,8 +867,7 @@ public void TestDynamicAttributeForScript_DynamicTypeArgument_NoCore() { var source = GetNoCS1980String(typeName: "Gen") + @" Gen x = null;"; - - var comp = CreateCompilationWithMscorlib45(source: source, parseOptions: TestOptions.Script).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source: source, parseOptions: TestOptions.Script).VerifyDiagnostics( // (20,5): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference? // Gen x = null; Diagnostic(ErrorCode.ERR_DynamicAttributeMissing, "dynamic").WithArguments("System.Runtime.CompilerServices.DynamicAttribute")); @@ -903,8 +902,7 @@ public void TestDynamicAttributeForScript_DynamicTypeInAliasTarget_NoCore() "using X = Gen;" + GetNoCS1980String(typeName: @"Gen") + "X x = null;"; - - var comp = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Script).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Script).VerifyDiagnostics( // (20,1): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference? // X x = null; Diagnostic(ErrorCode.ERR_DynamicAttributeMissing, "X").WithArguments("System.Runtime.CompilerServices.DynamicAttribute").WithLocation(20, 1)); diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs index 022e63e1cb9b1..3f52a2054fe91 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs @@ -1968,7 +1968,7 @@ public class C } } "; - var comp = CompileAndVerify(source, expectedSignatures: new[] + _ = CompileAndVerify(source, expectedSignatures: new[] { Signature("C", "get_Item", ".method public hidebysig specialname instance System.Decimal get_Item(" + @@ -1994,7 +1994,7 @@ public void DecimalConstant_Delegates() public delegate void D([Optional, DecimalConstantAttribute(hi: 3, sign: 2, mid: 4, low: 5, scale: 1)]ref decimal a, decimal b = 2m); "; - var comp = CompileAndVerify(source, expectedSignatures: new[] + _ = CompileAndVerify(source, expectedSignatures: new[] { Signature("D", "BeginInvoke", ".method public hidebysig newslot virtual instance System.IAsyncResult BeginInvoke(" + @@ -5002,8 +5002,7 @@ public AttributeUsageAttribute(AttributeTargets x) }"; var syntaxTree = Parse(source, filename: "test.cs"); var compilation = CreateCompilationWithMscorlib40(syntaxTree); - - var comp = compilation.VerifyDiagnostics( + _ = compilation.VerifyDiagnostics( // test.cs(4,6): warning CS0436: The type 'AttributeUsageAttribute' in 'test.cs' conflicts with the imported type 'AttributeUsageAttribute' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in 'test.cs'. // [AttributeUsage(AttributeTargets.Class)] Diagnostic(ErrorCode.WRN_SameFullNameThisAggAgg, "AttributeUsage").WithArguments("test.cs", "System.AttributeUsageAttribute", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.AttributeUsageAttribute").WithLocation(4, 6), diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs index 9c7317c979a22..0613cc0c0010b 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs @@ -447,7 +447,7 @@ static async Task Main() { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0); } [Fact] @@ -487,7 +487,7 @@ static async Task Main(string[] args) { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10); } [Fact] @@ -506,7 +506,7 @@ static async Task Main(params string[] args) { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10); } [Fact] @@ -524,7 +524,7 @@ static async Task Main(string[] args) { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0); } [Fact] @@ -564,7 +564,7 @@ static async Task Main(string[] args) { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10, args: new string[] { "async main" }); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 10, args: new string[] { "async main" }); } [Fact] @@ -582,7 +582,7 @@ static async Task Main(string[] args) { } }"; var c = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0, args: new string[] { "async main" }); + _ = CompileAndVerify(c, expectedOutput: "hello async main", expectedReturnCode: 0, args: new string[] { "async main" }); } [Fact] @@ -1189,7 +1189,7 @@ async static int Main() return 1; } }"; - var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( // (11,22): error CS1983: The return type of an async method must be void, Task or Task // async static int Main() Diagnostic(ErrorCode.ERR_BadAsyncReturn, "Main").WithLocation(11, 22), @@ -1217,7 +1217,7 @@ static async void Main(string[] args) System.Console.WriteLine(""Async Void Main""); } }"; - var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)).VerifyDiagnostics( // (6,23): error CS4009: A void or int returning entry point cannot be async // static async void Main(string[] args) Diagnostic(ErrorCode.ERR_NonTaskMainCantBeAsync, "Main").WithArguments("A.Main(string[])").WithLocation(6, 23), @@ -1270,7 +1270,7 @@ async static Task Main(string[] args) return 0.0F; } }"; - var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseDebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseDebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics( // (6,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. // async static Task Main() Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(6, 28), @@ -1307,7 +1307,7 @@ static Task Main(string[] args) return Task.FromResult(0.0F); } }"; - var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseDebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseDebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics( // (6,12): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater. // static Task Main() Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task").WithArguments("async main", "7.1").WithLocation(6, 12), @@ -1518,7 +1518,7 @@ static Task Main() { } }"; var sourceCompilation = CreateCompilationWithMscorlib40(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7_1)); - var verifier = sourceCompilation.VerifyEmitDiagnostics( + _ = sourceCompilation.VerifyEmitDiagnostics( // (25,43): warning CS0436: The type 'Task' in '' conflicts with the imported type 'Task' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in ''. // public static Awaiter GetAwaiter(this Task task) { Diagnostic(ErrorCode.WRN_SameFullNameThisAggAgg, "Task").WithArguments("", "System.Threading.Tasks.Task", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Threading.Tasks.Task").WithLocation(25, 43), diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs index 30b1c5292d027..8d51d7123f69c 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs @@ -3273,8 +3273,7 @@ public static async Task Boom() } } "; - - var v = CompileAndVerify(source, "System.Int32"); + _ = CompileAndVerify(source, "System.Int32"); } [Fact] @@ -3354,8 +3353,7 @@ public static void Main() } } "; - - var v = CompileAndVerify(source, "42"); + _ = CompileAndVerify(source, "42"); } [Fact] @@ -3625,7 +3623,7 @@ static Task Async1(int k, int i) ); comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics(); - v = CompileAndVerify( + _ = CompileAndVerify( compilation: comp, expectedOutput: expectedOutput, verify: Verification.Fails // localloc is not verifiable. @@ -3667,7 +3665,7 @@ static Task Async1(int k, int i) ); comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics(); - v = CompileAndVerify( + _ = CompileAndVerify( compilation: comp, expectedOutput: expectedOutput, verify: Verification.Fails // localloc is not verifiable. diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenCheckedTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenCheckedTests.cs index 9a29ca8a52daa..5596506edcfd2 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenCheckedTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenCheckedTests.cs @@ -1334,7 +1334,7 @@ .maxstack 1 [Fact] public void Lambda_Statement() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1363,7 +1363,7 @@ .maxstack 2 [Fact] public void Lambda_QueryStmt() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" using System.Linq; class C @@ -1391,7 +1391,7 @@ .maxstack 2 [Fact] public void Lambda_QueryExpr() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" using System.Linq; class C @@ -1416,7 +1416,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfAssignment() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1443,7 +1443,7 @@ .maxstack 2 [Fact] public void Lambda_Add() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1469,7 +1469,7 @@ .maxstack 2 [Fact] public void Lambda_Cast() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1495,7 +1495,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfCompoundAssignment() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1522,7 +1522,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfArgument() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1550,7 +1550,8 @@ .maxstack 2 [Fact] public void Lambda_AddOvfArgument2() { - var verifier = CompileAndVerify(@" + CompilationVerifier verifier; + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1578,7 +1579,7 @@ .maxstack 2 [Fact] public void Lambda_AddArgument3() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1606,7 +1607,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfArgument4() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1635,7 +1636,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfArgument5() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1663,7 +1664,7 @@ .maxstack 2 [Fact] public void Lambda_AddArgument6() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1691,7 +1692,7 @@ .maxstack 2 [Fact] public void Lambda_AddArgument7() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1719,7 +1720,7 @@ .maxstack 2 [Fact] public void Lambda_AddOvfArgument8() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1747,7 +1748,7 @@ .maxstack 2 [Fact] public void Lambda_LambdaVsDelegate1() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1771,7 +1772,7 @@ .maxstack 2 [Fact] public void Lambda_LambdaVsDelegate2() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1794,7 +1795,7 @@ .maxstack 2 [Fact] public void Lambda_LambdaVsDelegate3() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static void F() @@ -1817,7 +1818,7 @@ .maxstack 2 [Fact] public void Lambda_NewDelegate1() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } @@ -1842,7 +1843,7 @@ .maxstack 2 [Fact] public void Lambda_NewDelegate2() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" class C { static System.Func Id(System.Func x) { return x; } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs index 3c344df4204a4..8320186ea9668 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs @@ -19,7 +19,7 @@ public class CodeGenClosureLambdaTests : CSharpTestBase [Fact] public void LambdaInIndexerAndBinaryOperator() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C @@ -253,7 +253,7 @@ static void Main(string[] args) Console.WriteLine(d(2)); } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"12"); + _ = CompileAndVerify(source, expectedOutput: @"12"); } [Fact] @@ -942,8 +942,7 @@ static void Main() } } }"; - - var verifier = CompileAndVerify(source, expectedOutput: "pass"); + _ = CompileAndVerify(source, expectedOutput: "pass"); } [Fact] @@ -1216,7 +1215,7 @@ static void F() where T : Exception })(); } }"; - var verifier = CompileAndVerify(source, expectedOutput: "pass_xy"); + _ = CompileAndVerify(source, expectedOutput: "pass_xy"); } [Fact] @@ -4390,7 +4389,7 @@ static void Main() } } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( source, expectedOutput: "12"); } @@ -4413,7 +4412,7 @@ static void Main(string[] args) } } "; - var compilation = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: @"True + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: @"True False"); } @@ -4435,7 +4434,7 @@ static void Main(string[] args) } } "; - var compilation = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"True + _ = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"True False"); } @@ -4462,7 +4461,7 @@ static Func> Goo() } } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( source, expectedOutput: ""); } @@ -4520,7 +4519,7 @@ public static void Main(string[] args) new Program(1); } }"; - var verifier = CompileAndVerify( + _ = CompileAndVerify( source, expectedOutput: "11102"); } @@ -4595,7 +4594,7 @@ static void Main() } } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( source, expectedOutput: "True"); } @@ -4622,7 +4621,7 @@ static void Main() } } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( source, expectedOutput: "0"); } @@ -4664,7 +4663,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: "0"); + _ = CompileAndVerify(source, expectedOutput: "0"); } [WorkItem(545430, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545430")] @@ -5048,7 +5047,7 @@ private void TryIsolatedOperation() }); } }"; - var compilation = CompileAndVerify(source, expectedOutput: "success"); + _ = CompileAndVerify(source, expectedOutput: "success"); } [WorkItem(546748, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546748")] @@ -5105,7 +5104,7 @@ public static void Sleep(Func sleepDelegate) where TException }; } }"; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } [WorkItem(530911, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530911")] @@ -5136,7 +5135,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } [WorkItem(691006, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/691006")] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenConversionTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenConversionTests.cs index 770fbd03b3ae4..b1c753d501ed4 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenConversionTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenConversionTests.cs @@ -78,7 +78,7 @@ public static void Main(string[] args) } } "; - var compilationVerifier = CompileAndVerify(source, expectedOutput: @""); + _ = CompileAndVerify(source, expectedOutput: @""); } [Fact] @@ -113,7 +113,7 @@ static void Goo(J x) } } "; - var compilationVerifier = CompileAndVerify(source, expectedOutput: @"Goo(J x) + _ = CompileAndVerify(source, expectedOutput: @"Goo(J x) "); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs index d47cd7fb86dc5..f47a2d2d6d1a8 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs @@ -5105,7 +5105,7 @@ public void NestedDeconstructionInScript() var comp = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Script, options: TestOptions.DebugExe, references: s_valueTupleRefs); comp.VerifyDiagnostics(); - var verifier = CompileAndVerify(comp, expectedOutput: "hello 42 43"); + _ = CompileAndVerify(comp, expectedOutput: "hello 42 43"); } [Fact] @@ -5119,7 +5119,7 @@ public void VarDeconstructionInScript() var comp = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Script, options: TestOptions.DebugExe, references: s_valueTupleRefs); comp.VerifyDiagnostics(); - var verifier = CompileAndVerify(comp, expectedOutput: "hello 42"); + _ = CompileAndVerify(comp, expectedOutput: "hello 42"); } [Fact] @@ -6147,7 +6147,7 @@ static void Main() ); var tree = comp.SyntaxTrees.First(); - var model = comp.GetSemanticModel(tree); + _ = comp.GetSemanticModel(tree); Assert.Empty(GetDiscardIdentifiers(tree)); } @@ -6177,7 +6177,7 @@ static void Main() ); var tree = comp.SyntaxTrees.First(); - var model = comp.GetSemanticModel(tree); + _ = comp.GetSemanticModel(tree); Assert.Empty(GetDiscardIdentifiers(tree)); } @@ -8137,7 +8137,7 @@ static async Task M() var comp = CreateCompilationWithMscorlib45(source, references: s_valueTupleRefs, options: TestOptions.DebugExe); comp.VerifyDiagnostics(); - var verifier = CompileAndVerify(comp, expectedOutput: "3"); + _ = CompileAndVerify(comp, expectedOutput: "3"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs index 94a249ba9bcd1..c3e3803d1bcdf 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs @@ -3375,7 +3375,7 @@ public static int M() } } }"; - var verifier = CompileAndVerifyIL(source, "C.M", expectedUnoptimizedIL: @" + _ = CompileAndVerifyIL(source, "C.M", expectedUnoptimizedIL: @" { // Code size 169 (0xa9) .maxstack 10 @@ -15488,7 +15488,7 @@ class C1 public int Length = 123; } "; - var comp = CompileAndVerify(source, expectedOutput: "321 123", references: new[] { CSharpRef }); + _ = CompileAndVerify(source, expectedOutput: "321 123", references: new[] { CSharpRef }); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExprLambdaTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExprLambdaTests.cs index 5769b9b9b15c8..2c268c6700c62 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExprLambdaTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExprLambdaTests.cs @@ -387,7 +387,7 @@ public static string GetCultureInvariantString(object value) [Fact] public void ExprLambdaReordering() { - var verifier = CompileAndVerify(new[] { ExpressionTestLibrary, @" + _ = CompileAndVerify(new[] { ExpressionTestLibrary, @" using System; using System.Linq; @@ -412,7 +412,7 @@ static void F(IQueryable q) [Fact] public void ExprLambdaIndexerCompoundAssignment() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; using System.Linq.Expressions; @@ -643,7 +643,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new string[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -665,7 +665,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -691,7 +691,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -716,7 +716,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -738,7 +738,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -784,7 +784,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"k"); } @@ -806,7 +806,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -914,7 +914,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -969,7 +969,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1021,7 +1021,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1073,7 +1073,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1125,7 +1125,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1177,7 +1177,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1229,7 +1229,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1275,7 +1275,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1324,7 +1324,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1386,7 +1386,7 @@ public static void Main2(string expected) Check(() => default(T), expected); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "123k"); } @@ -1408,7 +1408,7 @@ static void Main() Console.WriteLine(expr); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: @"Invoke(MemberAccess(Constant(P+<>c__DisplayClass0_0 Type:P+<>c__DisplayClass0_0).f Type:System.Func`2[System.Int32,System.Int32])(Constant(12 Type:System.Int32)) Type:System.Int32) @@ -1510,7 +1510,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1561,7 +1561,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1629,7 +1629,7 @@ public static void Main(string[] args) MemberInit(NewExpression: New([Void .ctor()]() Type:Node) Bindings:[MemberListBinding(Member=System.Collections.Generic.List`1[Node] C ElementInit(Void Add(Node) Parameter(x Type:Node)) ElementInit(Void Add(Node) Parameter(x Type:Node)))] Type:Node) MemberInit(NewExpression: New([Void .ctor()]() Type:Node) Bindings:[MemberListBinding(Member=System.Collections.Generic.List`1[Node] D ElementInit(Void Add(Node) Parameter(x Type:Node)) ElementInit(Void Add(Node) Parameter(x Type:Node)))] Type:Node) MemberInit(NewExpression: New([Void .ctor()]() Type:Node) Bindings:[MemberAssignment(Member=System.String S Expression=Add(Constant(hello Type:System.String) Call(Parameter(x Type:Node).[System.String ToString()]() Type:System.String) Method:[System.String Concat(System.String, System.String)] Type:System.String))] Type:Node)"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: expectedOutput); } @@ -1658,7 +1658,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1683,7 +1683,7 @@ orderby x descending Console.WriteLine(e.ToString()); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source }, expectedOutput: "s => s.SelectMany(x => s, (x, y) => new <>f__AnonymousType0`2(x = x, y = y)).OrderByDescending(<>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.x).Select(<>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.x)"); } @@ -1721,7 +1721,7 @@ public static void Main(string[] args) Console.Write('k'); } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { source, ExpressionTestLibrary }, expectedOutput: "k"); } @@ -1784,7 +1784,7 @@ static string P(S? s) return (s == null) ? ""null"" : ""S""; } }"; - var compilation = CompileAndVerifyUtil( + _ = CompileAndVerifyUtil( new[] { text, ExpressionTestLibrary }, expectedOutput: @"null S"); diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenForEachTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenForEachTests.cs index 4ebd2028fb9b0..d47d7f431c4fa 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenForEachTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenForEachTests.cs @@ -1347,7 +1347,7 @@ class NonDisposableEnumerator : AbstractEnumerator }"; // Both loops generate the same disposal code, but one calls dispose and // the other doesn't. - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3 @@ -1447,7 +1447,7 @@ ref struct DisposableEnumerator public bool MoveNext() { return ++x < 4; } public void Dispose(params object[] args) { System.Console.WriteLine($""Done with DisposableEnumerator. args was {args}, length {args.Length}""); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3 @@ -1481,7 +1481,7 @@ ref struct DisposableEnumerator public bool MoveNext() { return ++x < 4; } public void Dispose(int arg = 1) { System.Console.WriteLine($""Done with DisposableEnumerator. arg was {arg}""); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3 @@ -1663,7 +1663,7 @@ struct DisposableEnumerator public bool MoveNext() { return ++x < 4; } public void Dispose() { System.Console.WriteLine(""Done with DisposableEnumerator""); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3"); @@ -1696,7 +1696,7 @@ class DisposableEnumerator public bool MoveNext() { return ++x < 4; } public void Dispose() { System.Console.WriteLine(""Done with DisposableEnumerator""); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3"); @@ -1729,7 +1729,7 @@ ref struct DisposableEnumerator public bool MoveNext() { return ++x < 4; } public void Dispose() { System.Console.WriteLine(""Done with DisposableEnumerator""); } }"; - var compilation = CompileAndVerify(source, parseOptions: TestOptions.Regular7_3, expectedOutput: @" + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular7_3, expectedOutput: @" 1 2 3"); @@ -1870,7 +1870,7 @@ static void Main() } }"; // NOTE: this is specifically not the dev10 behavior. In dev10, the output is 3, 3, 3. - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 2 3"); @@ -1914,7 +1914,7 @@ public List.Enumerator GetEnumerator(params int[] x) return new List.Enumerator(); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" a b c"); @@ -1956,7 +1956,7 @@ public T MoveNext() public int Current { get; set; } } "; - var compilation = CompileAndVerify(source, expectedOutput: "1"); + _ = CompileAndVerify(source, expectedOutput: "1"); } [WorkItem(540958, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540958")] @@ -1982,7 +1982,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: "1"); + _ = CompileAndVerify(source, expectedOutput: "1"); } [WorkItem(9229, "DevDiv_Projects/Roslyn")] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenFunctionPointersTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenFunctionPointersTests.cs index 9e638053b093a..196b3d394bed6 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenFunctionPointersTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenFunctionPointersTests.cs @@ -4989,7 +4989,7 @@ static void Main() [Fact] public void RecursivelyUsedTypeInFunctionPointer() { - var verifier = CompileAndVerifyFunctionPointers(@" + _ = CompileAndVerifyFunctionPointers(@" namespace Interop { public unsafe struct PROPVARIANT diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitImplementationTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitImplementationTests.cs index 994bd0ee1bbd3..a291a42956df0 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitImplementationTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitImplementationTests.cs @@ -955,8 +955,7 @@ public static void Main() i2.Method(out i, ref s1, l1); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Base.Method(1, 2, b) Class.Method(2, 3, c) @@ -1212,7 +1211,7 @@ public static void Main() i.Property = x; } }"; - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" Base2.Method() Derived2.Method(1) Derived4.Method(1, 0) @@ -1356,7 +1355,7 @@ public static void Main() i.Property = x; } }"; - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" Derived2.Method() Derived2.Method(1) Base2.Method(1, 0) @@ -1856,7 +1855,7 @@ public static void Main() } "; // TODO: Will need to update once CompilerGeneratedAttribute is emitted on synthesized accessor - var comp = CompileAndVerify(text, + _ = CompileAndVerify(text, expectedOutput: "23123", expectedSignatures: new[] { diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitlyTypeArraysTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitlyTypeArraysTests.cs index 4a962930b11ee..0fdd32cfef8db 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitlyTypeArraysTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenImplicitlyTypeArraysTests.cs @@ -251,7 +251,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify( + _ = CompileAndVerify( testSrc, expectedOutput: "True"); } @@ -432,7 +432,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify( + _ = CompileAndVerify( testSrc, expectedOutput: "True"); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInterfaceImplementation.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInterfaceImplementation.cs index eaff9bc547594..afaa2ffd48fe0 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInterfaceImplementation.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInterfaceImplementation.cs @@ -137,7 +137,7 @@ public static void Main() i3.Property = x; } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.Method(1, a) Base.Method(2) @@ -249,8 +249,7 @@ public static void Main() b.Method3(new int[6]{1, 2, 3, 4, 5, 6}, a, 8, 9, 10, 11, 12, 13, 14); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.Method( , 1, [1]) Derived.Method( , 2, [2]) @@ -2557,8 +2556,7 @@ public void TestInterfaceMembersSignature() void Method(); int Prop { get; set; } }"; - - var comp = CompileAndVerify(source, expectedSignatures: new[] + _ = CompileAndVerify(source, expectedSignatures: new[] { Signature("IFace", "Method", ".method public hidebysig newslot abstract virtual instance System.Void Method() cil managed"), Signature("IFace", "get_Prop", ".method public hidebysig newslot specialname abstract virtual instance System.Int32 get_Prop() cil managed"), diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs index 5b00142ccda9c..5956ea035c1f5 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs @@ -84,7 +84,7 @@ static void Main() } } }"; - var compilation = CompileAndVerify(source, expectedOutput: "123456789X"); + _ = CompileAndVerify(source, expectedOutput: "123456789X"); } [Fact] @@ -121,7 +121,7 @@ static void Main(string[] args) foreach (var i in IE()) Console.Write(i); } }"; - var compilation = CompileAndVerify(source, expectedOutput: "0123456789"); + _ = CompileAndVerify(source, expectedOutput: "0123456789"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs index 038c442ed13cd..a1df8c5b1470c 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs @@ -237,7 +237,7 @@ class Class1 [WorkItem(21811, "https://github.com/dotnet/roslyn/issues/21811")] public void Repro21811() { - var comp = CreateCompilation(@" + _ = CreateCompilation(@" using System.Collections.Generic; using System.Linq; @@ -1027,7 +1027,7 @@ void InnerMethod2() [WorkItem(17719, "https://github.com/dotnet/roslyn/issues/17719")] public void Repro17719() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -1543,7 +1543,7 @@ bool local(T tmp) } } "; - var comp = CompileAndVerify(src); + _ = CompileAndVerify(src); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOperators.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOperators.cs index a44a2e1b40a7f..960c03aecfa1a 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOperators.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOperators.cs @@ -424,7 +424,7 @@ public static void Main() 123456 123456123 "; - var compilation = CompileAndVerify(source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, expectedOutput: expectedOutput); } [Fact] @@ -490,7 +490,7 @@ public static void Main() 789789987 GetC100 11"; - var compilation = CompileAndVerify(source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, expectedOutput: expectedOutput); } // TODO: Add VerifyIL for is and as Codegen tests @@ -545,7 +545,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } // TODO: Add VerifyIL for is and as Codegen tests @@ -579,7 +579,7 @@ public static void M(T t, U u, W w) } } "; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } [Fact] @@ -903,7 +903,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } [Fact] @@ -2764,7 +2764,7 @@ public static void Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [WorkItem(543569, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543569")] @@ -2791,7 +2791,7 @@ public static void Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"PASS"); + _ = CompileAndVerify(source, expectedOutput: @"PASS"); } [WorkItem(543577, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543577")] @@ -2816,7 +2816,7 @@ public static void Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [WorkItem(543446, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543446"), WorkItem(543446, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543446")] @@ -2854,7 +2854,7 @@ static void Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"01"); + _ = CompileAndVerify(source, expectedOutput: @"01"); } [WorkItem(543586, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543586")] @@ -2889,7 +2889,7 @@ public static implicit operator Str(double i) } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"10"); + _ = CompileAndVerify(source, expectedOutput: @"10"); } [WorkItem(543602, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543602")] @@ -2925,7 +2925,7 @@ public static int Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [WorkItem(543498, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543498")] @@ -3044,7 +3044,7 @@ static void Main(string[] args) False True "; - var compilation = CompileAndVerify(source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, expectedOutput: expectedOutput); } [Fact] @@ -3094,7 +3094,7 @@ static void Main(string[] args) @"3 5 6"; - var compilation = CompileAndVerify(source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, expectedOutput: expectedOutput); } [Fact] @@ -3859,7 +3859,7 @@ void M(bool b) }"; //NOTE: all xors optimized away - var comp = CompileAndVerify(text).VerifyIL("C.M", @" + _ = CompileAndVerify(text).VerifyIL("C.M", @" { // Code size 31 (0x1f) .maxstack 2 @@ -3898,8 +3898,7 @@ static void Main() Console.WriteLine(y[0] ^ true); } }"; - - var comp = CompileAndVerify(text, expectedOutput: @"True + _ = CompileAndVerify(text, expectedOutput: @"True False"); } @@ -3926,8 +3925,7 @@ static void Main() Console.WriteLine(1f / (-1f * -0f)); } }"; - - var comp = CompileAndVerify(text, expectedOutput: @" + _ = CompileAndVerify(text, expectedOutput: @" True Infinity -Infinity @@ -3962,8 +3960,7 @@ static void Main() Console.WriteLine(1d / (-1d * -0d)); } }"; - - var comp = CompileAndVerify(text, expectedOutput: @" + _ = CompileAndVerify(text, expectedOutput: @" True Infinity -Infinity @@ -3999,8 +3996,7 @@ static void Main() Console.WriteLine(1d / (double)(-1m * -0m)); } }"; - - var comp = CompileAndVerify(text, expectedOutput: @" + _ = CompileAndVerify(text, expectedOutput: @" True Infinity -Infinity @@ -5190,8 +5186,7 @@ public static long Calculate2(long[] f) } } "; - - var result = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: "True"); + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: "True"); } private static string BuildSequenceOfBinaryExpressions_01(int count = 4096) @@ -5237,8 +5232,7 @@ public static double Calculate(long[] f) } } "; - - var result = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: "11461640193"); + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: "11461640193"); } [ConditionalFact(typeof(ClrOnly), typeof(NoIOperationValidation), Reason = "https://github.com/dotnet/roslyn/issues/29428")] @@ -5384,8 +5378,7 @@ public static double Calculate(double[] f) } } "; - - var result = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: @"5180801 + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: @"5180801 5180801"); } @@ -5467,7 +5460,7 @@ static void Main() @"4242691 4242691 4242691"; - var result = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); } [Fact, WorkItem(17756, "https://github.com/dotnet/roslyn/issues/17756")] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOptimizedNullableOperators.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOptimizedNullableOperators.cs index fa47926703adc..50125c4b9ec0d 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOptimizedNullableOperators.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOptimizedNullableOperators.cs @@ -2219,9 +2219,7 @@ static void Main() } } "; - - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 42 42 -42 @@ -2376,9 +2374,7 @@ static void Main() } } "; - - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 42 42 -42 diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs index e013c7f76c9a1..bb1f0c9515707 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs @@ -105,7 +105,7 @@ public static void Main() db.Property = 10; } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.Method(1, a) Derived.Method(2, a) @@ -310,7 +310,7 @@ public static void Main() Class5.Test(); } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Class3.Member1 Class4.Member1 @@ -383,8 +383,7 @@ public static void Main() b.@virtual(i, l, i, i, l); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.virtual1 Derived.virtual2 @@ -468,7 +467,7 @@ public static void Main() b.Method3(new int[6]{1, 2, 3, 4, 5, 6}, 8, 9, 10, 11, 12, 13, 14); } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.Method( , 1, [1]) Derived.Method( , 2, [2]) @@ -571,8 +570,7 @@ public static void Main() x = b3.Property; } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Base4.Method(a, b) Base4.Method(a, b) @@ -1023,8 +1021,7 @@ public static void Main() b.Method(); } }"; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" Base2.Method() Derived.Method() Derived.Method<> @@ -1110,8 +1107,7 @@ public static void Main() Console.Write(b.Method(new List(), new List())); } }"; - - var comp = CompileAndVerify(source, expectedOutput: @"2545571191011111114151617"); + _ = CompileAndVerify(source, expectedOutput: @"2545571191011111114151617"); } [Fact] @@ -1260,7 +1256,8 @@ static void Main() } var substitutedExpected = subst(expectedOutput); - var verifier = CompileAndVerify(compilation, expectedOutput: substitutedExpected); + CompilationVerifier verifier; + _ = CompileAndVerify(compilation, expectedOutput: substitutedExpected); } } } @@ -1311,8 +1308,7 @@ static void Main() bd.P++; } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.P.Get=1 Base.P.Set(2) @@ -1368,8 +1364,7 @@ static void Main() bd.P++; } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Base.P.Get=1 Derived.P.Set(2) @@ -1412,7 +1407,7 @@ public static void Main() b.Property3 = b.Property3; } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.get_Property2 Derived.set_Property1 @@ -1478,7 +1473,7 @@ public static void Main() b2.Property2 *= 1; } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.get_Property1 Base1.set_Property1 @@ -1558,7 +1553,7 @@ public static void Main() b2.Property3--; } }"; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" Derived.get_Property1 Derived.set_Property2 @@ -2076,8 +2071,7 @@ class Derived : Base2 protected sealed override List Method1(){ return null; } protected sealed override List Method2(){ return null; } }"; - - var comp = CompileAndVerify(source, expectedSignatures: new[] + _ = CompileAndVerify(source, expectedSignatures: new[] { Signature("Base`1", "Method1", ".method family hidebysig newslot virtual instance System.Collections.Generic.List`1[T] Method1() cil managed"), Signature("Base2`1", "Method2", ".method family hidebysig newslot abstract virtual instance System.Collections.Generic.List`1[T] Method2() cil managed"), @@ -3221,8 +3215,7 @@ static void Main() references: new[] { asm01, asm02 }, options: TestOptions.ReleaseExe, assemblyName: "OHI_BridgeMethodFromBaseVB007"); - - var verifier = CompileAndVerify( + _ = CompileAndVerify( comp, expectedOutput: @"Derived (OVSealed) VBaseFunc (Non-Virtual)", expectedSignatures: new[] @@ -3522,7 +3515,7 @@ static void Main() } } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( text, new[] { TestReferences.SymbolsTests.CustomModifiers.Modifiers.dll }, expectedOutput: @"Hello 3", @@ -3556,7 +3549,7 @@ public static void Main() } } "; - var verifier = CompileAndVerify(text, + _ = CompileAndVerify(text, references: new[] { TestReferences.SymbolsTests.CustomModifiers.ModoptTests }, expectedOutput: "51"); } @@ -3595,8 +3588,7 @@ static void Main() var comp = (CSharpCompilation)verifier.Compilation; comp.VerifyDiagnostics(); - - var baseType = comp.GlobalNamespace.GetMember("Metadata").GetMember("LeastModoptsWin"); + _ = comp.GlobalNamespace.GetMember("Metadata").GetMember("LeastModoptsWin"); var derivedType = comp.GlobalNamespace.GetMember("Derived"); var overridingMethod = derivedType.GetMember("M"); @@ -3700,7 +3692,7 @@ static void Main() //Assert.Equal(1, errs.Count()); //Assert.Equal(109, errs.First().Code); - var verifier = CompileAndVerify(text, + _ = CompileAndVerify(text, references: new[] { TestReferences.SymbolsTests.CustomModifiers.ModoptTests }, expectedOutput: "1122", expectedSignatures: new[] @@ -4154,7 +4146,7 @@ public static void Main() } }"; var compref = CreateCompilation(source, assemblyName: "XNoDefaultForParams_Dev10781558_Library"); - var comp = CompileAndVerify(source2, references: new[] { new CSharpCompilationReference(compref) }, expectedOutput: "M"); + _ = CompileAndVerify(source2, references: new[] { new CSharpCompilationReference(compref) }, expectedOutput: "M"); } [Fact] @@ -4322,7 +4314,7 @@ public static void Main() d.M(y: 2); } }"; - var comp = CompileAndVerify(source, expectedOutput: + _ = CompileAndVerify(source, expectedOutput: @"Base.M(x:1) Derived.M(y:2)"); } @@ -4344,8 +4336,7 @@ public void MissingAssemblyReference01() compilationOptions: TestOptions.ReleaseDll, referencedCompilations: new[] { A }); CompileAndVerify(B).VerifyDiagnostics(); - - var D = CreateCSharpCompilation("D", @"public class D : C, B { }", + _ = CreateCSharpCompilation("D", @"public class D : C, B { }", compilationOptions: TestOptions.ReleaseDll, referencedCompilations: new[] { B, C }).VerifyDiagnostics( // (1,21): error CS0012: The type 'A' is defined in an assembly that is not referenced. You must add a reference to assembly 'A, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs index 11765060fecc6..ba73f4c94f09a 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs @@ -1004,7 +1004,7 @@ public override string ToString() Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind); // T - TypeSymbol type = namedType.TypeParameters[0]; + _ = namedType.TypeParameters[0]; Assert.True(namedType.IsReadOnly); Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind); Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind); @@ -1038,7 +1038,7 @@ public override string ToString() Assert.Equal(RefKind.None, namedType.GetMethod("Invoke").ThisParameter.RefKind); // object[] - type = comp.CreateArrayTypeSymbol(comp.ObjectType); + TypeSymbol type = comp.CreateArrayTypeSymbol(comp.ObjectType); Assert.False(type.IsReadOnly); // dynamic diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefLocalTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefLocalTests.cs index 750864589f1b9..b3cc6f84255f1 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefLocalTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefLocalTests.cs @@ -126,7 +126,7 @@ .locals init (int V_0, //x [Fact] public void ReassignmentInOut() { - var verifier = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -535,7 +535,7 @@ public static void Main() [Fact] public void RefReassignRefExpressions() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -568,7 +568,7 @@ static void Main() [Fact] public void RefReassignParamByVal() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -921,7 +921,7 @@ .locals init (S V_0, //s1 [Fact] public void RefReadonlyStackSchedule() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; struct S { @@ -1028,7 +1028,7 @@ .locals init (S V_0, //s1 [Fact] public void RefReassignTernary() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -1109,7 +1109,7 @@ .locals init (int V_0, //x [Fact] public void RefReassignFor() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -1137,7 +1137,7 @@ static void Main() [Fact] public void AssignInMethodCall() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C { @@ -1319,7 +1319,7 @@ .locals init (int V_0, //a [Fact] public void RefReassignIn() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C @@ -1364,7 +1364,7 @@ static void M(in int rx) [Fact] public void RefReassignOut() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C @@ -1417,7 +1417,7 @@ static void M(out int rx) [Fact] public void RefReassignRefParam() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C @@ -1466,7 +1466,7 @@ static void M(ref int rx) [Fact] public void RefReassignRefReadonlyLocal() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C @@ -1602,7 +1602,7 @@ .locals init (int V_0, //x [Fact] public void RefReadonlyReassign() { - var comp = CompileAndVerify(@" + _ = CompileAndVerify(@" using System; class C diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs index 6fda7e60019ce..a8901d700a529 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs @@ -2591,7 +2591,7 @@ class E : Exception public E(int value) { this.Value = value; } } "; - var v = CompileAndVerify(text, expectedOutput: "12345"); + _ = CompileAndVerify(text, expectedOutput: "12345"); } [Fact] @@ -2710,8 +2710,7 @@ static void Main() System.Console.WriteLine(o.F()); } }"; - - var v = CompileAndVerify(source, expectedOutput: "2"); + _ = CompileAndVerify(source, expectedOutput: "2"); } [Fact] @@ -2788,8 +2787,7 @@ static void Main() System.Console.Write(o.F()); } }"; - - var v = CompileAndVerify(source, expectedOutput: "23"); + _ = CompileAndVerify(source, expectedOutput: "23"); } [Fact] @@ -3083,8 +3081,7 @@ public static ref dynamic Test(ref dynamic arg1, ref dynamic arg2) "; var comp = CreateCompilationWithMscorlib45AndCSharp(source, options: TestOptions.ReleaseExe); - - var v = CompileAndVerify(comp, verify: Verification.Fails, expectedOutput: "2"); + _ = CompileAndVerify(comp, verify: Verification.Fails, expectedOutput: "2"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenShortCircuitOperatorTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenShortCircuitOperatorTests.cs index 2b69bd5d8ef77..2cc28864d0a60 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenShortCircuitOperatorTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenShortCircuitOperatorTests.cs @@ -1199,8 +1199,7 @@ static void Test(dynamic x) System.Console.Write(x?.ToString()?[1].ToString() ?? ""NULL""); } }"; - - var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] @@ -1222,8 +1221,7 @@ static void Test(string s, dynamic ds) System.Console.Write(s?.CompareTo(ds) ?? ""NULL""); } }"; - - var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#-1"); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#-1"); } [Fact] @@ -1246,8 +1244,7 @@ static void Test(int[] x, dynamic i) System.Console.Write(x?.ToString()?[i].ToString() ?? ""NULL""); } }"; - - var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] @@ -1270,8 +1267,7 @@ static void Test(dynamic x) System.Console.Write(x?.Length.ToString() ?? ""NULL""); } }"; - - var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] @@ -1294,8 +1290,7 @@ static void Test(dynamic x) System.Console.Write(x?.Length?.ToString() ?? ""NULL""); } }"; - - var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] @@ -2013,7 +2008,7 @@ static void Main() } } "; - var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 + _ = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } @@ -2070,7 +2065,7 @@ static void Main() } } "; - var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 + _ = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } @@ -2622,7 +2617,7 @@ static void Test(ref T x, ref T y) where T : IDisposable1 } } "; - var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False + _ = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); @@ -2681,7 +2676,7 @@ static void Test(T x, T y) where T : IDisposable1 } } "; - var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False + _ = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); @@ -2747,7 +2742,7 @@ static async Task Test(T[] x, T[] y) where T : IDisposable1 } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False True"); @@ -2816,7 +2811,7 @@ static async Task Test(T x, T y) where T : IDisposable1 } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False False"); @@ -2897,7 +2892,7 @@ static async Task Test(T x, T y) where T : IDisposable1 } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False False"); @@ -2967,7 +2962,7 @@ static async Task Test(T[] x, T[] y) where T : IDisposable1 } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False True @@ -3050,7 +3045,7 @@ static async Task Test(T[] x, T[] y) where T : IDisposable1 } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False True @@ -3133,7 +3128,7 @@ static async Task Test(T[] x, T[] y) where T : IDisposable1 } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True False True @@ -4396,7 +4391,7 @@ static void Main() } } "; - var comp = CompileAndVerify(source, expectedOutput: @"Success"); + _ = CompileAndVerify(source, expectedOutput: @"Success"); } [Fact(), WorkItem(836, "GitHub")] @@ -4469,7 +4464,7 @@ private static void Test(T s) where T : IEnumerable } } "; - var comp = CompileAndVerify(source, expectedOutput: @"Success"); + _ = CompileAndVerify(source, expectedOutput: @"Success"); } @@ -5670,7 +5665,7 @@ public T M() } } "; - var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @" --- + _ = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @" --- Loop --- Loop @@ -5719,7 +5714,7 @@ public T M() } } "; - var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- + _ = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- --- M ---"); @@ -5808,7 +5803,7 @@ public T M() } } "; - var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- + _ = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- M1(Action> x) --- M1(Action> x) @@ -6193,7 +6188,7 @@ static async Task Bar() "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); + _ = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] @@ -6230,7 +6225,7 @@ static async Task Bar() "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); + _ = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] @@ -6273,7 +6268,7 @@ static async Task Bar(int arg) "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); + _ = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } @@ -6310,7 +6305,7 @@ static async Task Bar() } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"# + _ = CompileAndVerify(c, expectedOutput: @"# False# FalseqBarBar# True"); @@ -6353,7 +6348,7 @@ static async Task Bar(string arg) } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True"); } @@ -6388,7 +6383,7 @@ static async Task Bar(string arg) } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); - var comp = CompileAndVerify(c, expectedOutput: @"False + _ = CompileAndVerify(c, expectedOutput: @"False True"); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs index c28916a7c7bb4..6f2fe46e9c9d8 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs @@ -706,7 +706,7 @@ static void Main() System.Console.WriteLine(x); // 4 } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1133 133 33 @@ -4689,7 +4689,7 @@ public static void Main() }}"; // If we ever stop verifying the execution of this, we need to add IL verification for some of the method bodies. - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" aaaaSystem.ApplicationException: hellobyeSystem.ApplicationException: ccccaaaaSystem.ApplicationException: hellobyeSystem.ApplicationException: cccc "); } @@ -9883,7 +9883,7 @@ public static int Main() return ret; } }"; - var compilation = CompileAndVerify(source, expectedOutput: "0"). + _ = CompileAndVerify(source, expectedOutput: "0"). VerifyIL("MyClass.Main", @" { // Code size 228 (0xe4) @@ -10713,7 +10713,8 @@ static void Main() }"; if (ExecutionConditionUtil.IsCoreClr) { - var compilation = CompileAndVerify(source, expectedOutput: + CompilationVerifier compilation; + _ = CompileAndVerify(source, expectedOutput: @"0.0000000000000000000000000031 0.0000000000000000000000000031 @@ -10728,7 +10729,7 @@ static void Main() } else if (ExecutionConditionUtil.IsDesktop) { - var compilation = CompileAndVerify(source, expectedOutput: + _ = CompileAndVerify(source, expectedOutput: @"0.0000000000000000000000000031 0.0000000000000000000000000030 @@ -11184,7 +11185,7 @@ static void Main(string[] args) public static int I { get; set; } } "; - var compilation = CompileAndVerify(source); + _ = CompileAndVerify(source); } [Fact] @@ -11207,7 +11208,7 @@ static void Main(string[] args) } } "; - var compilation = CompileAndVerify(source, expectedOutput: "11"); + _ = CompileAndVerify(source, expectedOutput: "11"); } [WorkItem(543888, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543888")] @@ -11240,7 +11241,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" One Three Five @@ -11273,7 +11274,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 4 6 @@ -11305,7 +11306,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1 E2 "); @@ -11408,7 +11409,7 @@ static void Main(string[] args) M(123456789.0123456789M, 123456789.1123456789M); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1007 993 7000 @@ -11475,7 +11476,7 @@ static void Main(string[] args) M(new decimal(123.456), new decimal(123456000, 0, 0, false, 6)); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" True False True @@ -11667,7 +11668,7 @@ static void Main(string[] args) DecIncrDecrUnary(+7.5000000000000000000000000001M); } }"; - var compilation = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 1.000000123 -0.999999877 @@ -11995,7 +11996,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"1A"); + _ = CompileAndVerify(source, expectedOutput: @"1A"); } [WorkItem(543090, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543090")] @@ -12027,7 +12028,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"1A"); + _ = CompileAndVerify(source, expectedOutput: @"1A"); } [WorkItem(543530, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543530")] @@ -12068,7 +12069,7 @@ static void Main(string[] args) B(""Main""); } }"; - var compilation = CompileAndVerify(source, expectedOutput: "null;null;C1;"); + _ = CompileAndVerify(source, expectedOutput: "null;null;C1;"); } [WorkItem(543091, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543091")] [Fact()] @@ -12099,7 +12100,7 @@ static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"1A"); + _ = CompileAndVerify(source, expectedOutput: @"1A"); } [WorkItem(543156, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543156")] @@ -12128,7 +12129,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"00"); + _ = CompileAndVerify(source, expectedOutput: @"00"); } [WorkItem(543157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543157")] @@ -12164,7 +12165,7 @@ class C } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [WorkItem(543566, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543566")] @@ -12193,7 +12194,7 @@ public static void Main() } } "; - var compilation = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [Fact(), WorkItem(543667, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543667")] @@ -13387,8 +13388,7 @@ public static void Main() } } "; - - var compilation = CompileAndVerifyWithMscorlib40(code, expectedOutput: "4"); + _ = CompileAndVerifyWithMscorlib40(code, expectedOutput: "4"); } [WorkItem(26113, "https://github.com/dotnet/roslyn/issues/26113")] @@ -15720,8 +15720,7 @@ static void Main() } } "; - - var compilation = CompileAndVerifyWithMscorlib40(source, new[] { SystemCoreRef, CSharpRef }, expectedOutput: "long.ex caught"); + _ = CompileAndVerifyWithMscorlib40(source, new[] { SystemCoreRef, CSharpRef }, expectedOutput: "long.ex caught"); } [WorkItem(10463, "https://github.com/dotnet/roslyn/issues/10463")] @@ -17173,7 +17172,8 @@ static unsafe void CheckNaN(float nan) } } "; - var compilation = CompileAndVerify(source, options: TestOptions.ReleaseExe.WithAllowUnsafe(true), verify: Verification.Skipped, expectedOutput: @""); + CompilationVerifier compilation; + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe.WithAllowUnsafe(true), verify: Verification.Skipped, expectedOutput: @""); } } } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs index 5c099ac55b72b..a2826ebe577d5 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs @@ -4378,7 +4378,7 @@ public static void Main() var comp = CreateCompilation(source, options: TestOptions.DebugExe); comp.VerifyDiagnostics(); - var verifier = CompileAndVerify(comp, expectedOutput: "True"); + _ = CompileAndVerify(comp, expectedOutput: "True"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index 2a38098059bb5..fdd5254afeb93 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -1515,8 +1515,7 @@ static void Main() } " + trivial3uple; - - var comp = CompileAndVerify(source, expectedOutput: @"{1, hello, 2}"); + _ = CompileAndVerify(source, expectedOutput: @"{1, hello, 2}"); } [Fact] @@ -1636,7 +1635,7 @@ static void Main() } } " + trivial2uple + tupleattributes_cs; - var comp = CompileAndVerify(source, expectedOutput: @"1 + _ = CompileAndVerify(source, expectedOutput: @"1 hello"); } @@ -1653,8 +1652,7 @@ static void Main() } } " + trivial2uple + trivial3uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @"1 hello hello 3"); + _ = CompileAndVerify(source, expectedOutput: @"1 hello hello 3"); } [Fact] @@ -1713,8 +1711,7 @@ static void Main() } } " + trivial2uple + trivial3uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @"1 hello 3"); + _ = CompileAndVerify(source, expectedOutput: @"1 hello 3"); } [Fact] @@ -2168,8 +2165,7 @@ public void Test((S1, S2) val, System.Action d) } } " + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: + _ = CompileAndVerify(source, expectedOutput: @"System.Action`1[System.Int32] 1 True @@ -2878,8 +2874,7 @@ public async Task Test((S1, S2) val, System.Action d) } } " + tupleattributes_cs; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"System.Action`1[System.Int32] 1 @@ -3077,8 +3072,7 @@ static void Main() } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @"0 + _ = CompileAndVerify(source, expectedOutput: @"0 null"); } @@ -3432,7 +3426,7 @@ static void Main() } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"0 False"); } @@ -3483,8 +3477,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"42 Alice"); } @@ -3502,8 +3495,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"42 Alice"); } @@ -3522,8 +3514,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"42 Alice"); } @@ -3603,8 +3594,7 @@ static void M(int x, (int a, string b) y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"42 Alice"); } @@ -4174,8 +4164,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"(1, hello)"); } @@ -4222,7 +4211,7 @@ public static void Main() comp1.VerifyDiagnostics(); var comp2 = CreateCompilation(source2); comp2.VerifyDiagnostics(); - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"1 1 2 2 3 3 4 4", references: new[] { new CSharpCompilationReference(comp1), @@ -4419,7 +4408,7 @@ public static void Main() comp1.VerifyDiagnostics(); var comp2 = CreateCompilationWithMscorlib40(source2); comp2.VerifyDiagnostics(); - var comp = CompileAndVerifyWithMscorlib40(source, expectedOutput: @"1 1 2 2 3 3 4 4 5 5 6 6 True", references: new[] { new CSharpCompilationReference(comp1), new CSharpCompilationReference(comp2) }); + _ = CompileAndVerifyWithMscorlib40(source, expectedOutput: @"1 1 2 2 3 3 4 4 5 5 6 6 True", references: new[] { new CSharpCompilationReference(comp1), new CSharpCompilationReference(comp2) }); } [Fact] @@ -5498,7 +5487,7 @@ static void Main(string[] args) var comp = CreateCompilation(new[] { tree }); var model = comp.GetSemanticModel(tree, ignoreAccessibility: false); - var nodes = tree.GetCompilationUnitRoot().DescendantNodes(); + _ = tree.GetCompilationUnitRoot().DescendantNodes(); model.LookupStaticMembers(201); // This position is inside Main method for (int pos = 0; pos < source.Length; pos++) @@ -5806,8 +5795,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, expectedOutput: "12345678901234567890123456789012345"); + _ = CompileAndVerify(source, expectedOutput: "12345678901234567890123456789012345"); } [Fact] @@ -7712,8 +7700,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" byte byte @@ -7791,8 +7778,7 @@ static void Test((Func, Func) x, T y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" second first @@ -7830,8 +7816,7 @@ static void Test((Func, Func) x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" third 7 @@ -7863,8 +7848,7 @@ static void Test(T arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.Nullable`1[System.ValueTuple`2[System.Int32,System.Double]] (1, 2) @@ -7902,8 +7886,7 @@ static void Test((Func, Func, Func, Func, Func, Func, Func< } } "; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" second first third @@ -7936,8 +7919,7 @@ static void Test(T arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.Nullable`1[System.ValueTuple`2[System.Int32,System.String]] (1, ) @@ -7969,7 +7951,7 @@ static void Test(T arg) } } "; - var comp = CompileAndVerify(source, expectedOutput: + _ = CompileAndVerify(source, expectedOutput: @"1 8 (1, , 1, 2, 3, 4, 5, 6, 7, 8) @@ -8010,8 +7992,7 @@ static void Test((int, int, int, int, int, int, int, int, int, int) x) } } "; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" first first fourth @@ -9212,8 +9193,7 @@ static void Test((Func, Func) x, T y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" second first @@ -9251,8 +9231,7 @@ static void Test((Func, Func) x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" third 7 @@ -9288,8 +9267,7 @@ static void Test(Func x, Func y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" third 7 @@ -9325,8 +9303,7 @@ static void Test((Func, Func) x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @" third 5 @@ -9359,8 +9336,7 @@ static void Test( Func<(int alice, int bob), T> x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" first 3 @@ -9397,8 +9373,7 @@ static void Test( (Func<(int alice, int bob), T> f1, Func<(int, int), T> f2) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" first 2 @@ -9433,8 +9408,7 @@ static void M1((Func f, object o) a) } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" 2 "); } @@ -9468,8 +9442,7 @@ static void Test2(U f1, Func f2) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" 1 1 @@ -9512,8 +9485,7 @@ static void Test2(T x, object y, Func f) } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" test1 {1, 2} test2_1 @@ -9563,8 +9535,7 @@ static void Test2(T x, object y, Func f) } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" test1 {1, 2} test2_1 @@ -9596,8 +9567,7 @@ static void Test1(T x, T y) } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" System.ValueType "); } @@ -9978,8 +9948,7 @@ static void Test1((T, U) x, (T, U) y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.Object System.ValueTuple`2[System.Int32,System.Int32] @@ -10015,8 +9984,7 @@ static void Test1((T, U)? x, (T, U) y) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.Object System.Object @@ -10114,8 +10082,7 @@ static void Test1((T, U) x, (T, U) y, System.Func<(T x, U z), T> f) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.String w @@ -10147,8 +10114,7 @@ static void Test((T, T, T) x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" System.Int32 System.Int64 @@ -10607,8 +10573,7 @@ static void Main() public (int Alice, string Bob) P1 => (r: 1, s: ""hello""); } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, hello) "); } @@ -10640,8 +10605,7 @@ static void Main() public (int Alice, string Bob) P1 => (r: 1, s: ""hello""); } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, hello) 1"); } @@ -10670,8 +10634,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"((1, Australia), (2, Brazil))"); } @@ -10700,8 +10663,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"((1, Australia, 2, Brazil, 3, Columbia, 4, Ecuador), (5, France, 6, Germany, 7, Honduras, 8, India))"); } @@ -14670,8 +14632,7 @@ public static implicit operator ValueTuple(KeyValuePair kvp) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, options: TestOptions.ReleaseExe, expectedOutput: @@ -14734,8 +14695,7 @@ public static explicit operator double(ValueTuple? source) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, options: TestOptions.ReleaseExe, expectedOutput: @@ -15288,8 +15248,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: @"(1, 2) @@ -17102,8 +17061,7 @@ static public implicit operator (byte, byte)(C1 arg) } } "; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) (2, 2) @@ -17151,8 +17109,7 @@ static public explicit operator (byte, byte)(C1 arg) } } "; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) (2, 2) @@ -17369,8 +17326,7 @@ static public implicit operator (byte c, byte d)(C1 arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (2, 2) (2, 2) @@ -17409,8 +17365,7 @@ static public explicit operator (byte c, byte d)(C1 arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (2, 2) (2, 2) @@ -17469,8 +17424,7 @@ static public implicit operator (byte c, byte d)(C1 arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (1, 2) (3, (4, 5)) @@ -17597,8 +17551,7 @@ static public implicit operator (byte c, byte d)(C1 arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (1, (2, (3, (4, (5, 6))))) "); @@ -17655,8 +17608,7 @@ static public explicit operator (byte c, byte d)(C1 arg) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (1, (2, (3, (4, (5, 6))))) "); @@ -17864,8 +17816,7 @@ public static implicit operator C2(int arg) } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" {Program+C2, Program+C2} "); } @@ -17896,8 +17847,7 @@ public static explicit operator C2(int arg) } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" {Program+C2, Program+C2} "); } @@ -18175,8 +18125,7 @@ public static implicit operator D(C x) } } " + trivial2uple + tupleattributes_cs; - - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" explicit original @@ -18283,8 +18232,7 @@ static void Test((long?, long?) x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" first first @@ -18316,8 +18264,7 @@ static void Test((long?, long?)? x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" second second @@ -18354,8 +18301,7 @@ static void Test((long?, long?)? x) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" first second @@ -20977,8 +20923,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, w) "); @@ -21004,8 +20949,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(w, w)"); } @@ -21028,8 +20972,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, (w, e)) "); @@ -21070,8 +21013,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q, q, q, q, q, q, q, q) "); @@ -21112,8 +21054,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q, q, q, q, q, q, q, q) "); @@ -21154,8 +21095,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q, q, q, q, q, q, q, q) "); @@ -21196,8 +21136,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q) "); @@ -21231,8 +21170,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q) "); @@ -21276,8 +21214,7 @@ static void Assign(out T v) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (q, q, q, q, q, q, q, , , ) "); @@ -21314,8 +21251,7 @@ static void Assign(out T r, T v) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"w"); } @@ -22172,7 +22108,7 @@ static void Main(string[] args) var text = SourceText.From(source1); var startTree = SyntaxFactory.ParseSyntaxTree(text); - var finalString = startTree.GetCompilationUnitRoot().ToFullString(); + _ = startTree.GetCompilationUnitRoot().ToFullString(); var pos = source1.IndexOf("var(a, )") + 8; var newText = text.WithChanges(new TextChange(new TextSpan(pos, 0), " ")); // add space before closing-paren @@ -23102,8 +23038,7 @@ public static implicit operator AA ((int X1, int Y1) x) return new AA(); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2) (3, 4) @@ -23142,8 +23077,7 @@ public static implicit operator AA ((int X1, int Y1) x) return new AA(); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2) (3, 4) @@ -23186,8 +23120,7 @@ public static implicit operator AA ((int X1, int Y1) x) return new AA(); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(3, 4) (7, 8) @@ -23221,8 +23154,7 @@ public static implicit operator (int, int) (AA x) return (1, 2); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2)"); } @@ -23252,8 +23184,7 @@ public static implicit operator (int X1, int Y1) (AA x) return (1, 2); } }"; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2)"); } @@ -23298,8 +23229,7 @@ struct BB { } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"implicit operator AA implicit operator AA @@ -23521,8 +23451,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @"(1, 2)"); } @@ -24688,8 +24617,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (1, 3) (2, 4) @@ -24722,8 +24650,7 @@ static void Main() } } "; - - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, parseOptions: TestOptions.Regular, expectedOutput: @" (qq, (1, (2, 3))) (123, ) @@ -25505,7 +25432,7 @@ public static void Main() } public class A {}"; - var comp = CompileAndVerify(source, expectedOutput: "24"); + _ = CompileAndVerify(source, expectedOutput: "24"); } [Fact] @@ -25524,7 +25451,7 @@ public static void Main() public static void M2((T, int) a) { Console.Write(3); } public static void M2(((T, int), int) a) { Console.Write(4); } }"; - var comp = CompileAndVerify(source, expectedOutput: "4"); + _ = CompileAndVerify(source, expectedOutput: "4"); } [Fact] @@ -25548,7 +25475,7 @@ public static void Main() public static void M2(ValueTuple a) where TRest : struct { Console.Write(3); } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25573,7 +25500,7 @@ public static void Main() public static void M2(ref ValueTuple a) where TRest : struct { Console.Write(3); } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25599,7 +25526,7 @@ public static void Main() public interface I{} "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25625,7 +25552,7 @@ public static void Main() public interface I{} "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25648,7 +25575,7 @@ public static void Main() public static void M2(ValueTuple a) where TRest : struct { Console.Write(3); } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25669,7 +25596,7 @@ public static void Main() public static void M2(ValueTuple, Func, Func, Func, Func, Func, Func, TRest> a) where TRest : struct { Console.Write(3); } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"2"); } @@ -25716,7 +25643,7 @@ public static void Main() public static void M2(ValueTuple a) where TRest : struct { Console.Write(3); } } "; - var comp = CompileAndVerify(source, + _ = CompileAndVerify(source, expectedOutput: @"12"); } @@ -25738,7 +25665,7 @@ public static void M1(((T, int), int, int, int, int, int, int, int, int public static void M1((T, int, int, int, int, int, int, int, int, U, (V, int)) a) { Console.Write(4); } }"; - var comp = CompileAndVerify(source, expectedOutput: "3"); + _ = CompileAndVerify(source, expectedOutput: "3"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTypeofTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTypeofTests.cs index c0b29fd2d4064..a479dcd01e2b1 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTypeofTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTypeofTests.cs @@ -432,8 +432,7 @@ static void Main() typeof(C).GetCustomAttributes(false); } }"; - - var comp = CompileAndVerify(source, expectedOutput: ""); + _ = CompileAndVerify(source, expectedOutput: ""); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs index 92223943b5106..f3cee95ff3dae 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs @@ -2826,7 +2826,7 @@ static void Main() } } }"; - var comp = CompileAndVerify(source, expectedOutput: @""); + _ = CompileAndVerify(source, expectedOutput: @""); } // Anonymous Delegate in using block diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/ForLoopsTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/ForLoopsTests.cs index f3867fa81beb6..c0164bbfac298 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/ForLoopsTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/ForLoopsTests.cs @@ -1618,7 +1618,7 @@ select z into w } } "; - var comp = CompileAndVerify(text, expectedOutput: @"1 + _ = CompileAndVerify(text, expectedOutput: @"1 2 3"); } @@ -1654,7 +1654,7 @@ select z into w } } "; - var comp = CompileAndVerify(text, expectedOutput: @"1 + _ = CompileAndVerify(text, expectedOutput: @"1 2 3"); } @@ -1702,8 +1702,7 @@ static void Main(string[] args) } } "; - - var comp = CompileAndVerify(text, expectedOutput: @"1 + _ = CompileAndVerify(text, expectedOutput: @"1 4 9 16"); @@ -1810,7 +1809,7 @@ static void Main(string[] args) } } "; - var comp = CompileAndVerify(text, expectedOutput: @"1 + _ = CompileAndVerify(text, expectedOutput: @"1 2 3 4"); @@ -1833,7 +1832,7 @@ static void Main(string[] args) } } "; - var comp = CompileAndVerify(text, expectedOutput: @"1 + _ = CompileAndVerify(text, expectedOutput: @"1 2 3 4"); @@ -1860,7 +1859,7 @@ static int goo(int x) } } "; - var comp = CompileAndVerify(text, expectedOutput: @"-1 + _ = CompileAndVerify(text, expectedOutput: @"-1 -2 -3 -4 diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexAndRangeTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexAndRangeTests.cs index e6f6e36bfa95c..db1c001e1c374 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexAndRangeTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexAndRangeTests.cs @@ -1280,7 +1280,7 @@ static void Main() _ = c[0..]; } }"; - var verifier = CompileAndVerifyWithIndexAndRange(src, expectedOutput: @" + _ = CompileAndVerifyWithIndexAndRange(src, expectedOutput: @" int Index Range"); diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs index 962aad44400e0..6b5705d4bf372 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs @@ -671,7 +671,7 @@ static void Main() } } "; - var compVerifier = CompileAndVerify(text, expectedOutput: @" + _ = CompileAndVerify(text, expectedOutput: @" 1,2,10,20,10,20,-29, 1,2,10,20,10,20,-29, 1,2,10,20,10,20,-29, diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/ObjectAndCollectionInitializerTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/ObjectAndCollectionInitializerTests.cs index ec99d6dd3ae82..68e656793d4bb 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/ObjectAndCollectionInitializerTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/ObjectAndCollectionInitializerTests.cs @@ -1148,8 +1148,7 @@ static void Main() - - 5"; - - var compVerifier = CompileAndVerify(source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, expectedOutput: expectedOutput); } [Fact] @@ -1252,8 +1251,7 @@ static void Main() - - 3"; - - var compVerifier = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); } [Fact] @@ -1814,8 +1812,7 @@ public dynamic this[string value] } "; string expectedOutput = @"422"; - - var compVerifier = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); } [Fact] @@ -1870,8 +1867,7 @@ public Dictionary this[string arg] } "; string expectedOutput = @"422"; - - var compVerifier = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: expectedOutput); } [Fact] @@ -1926,8 +1922,7 @@ public dynamic this[string arg] } "; string expectedOutput = @"422"; - - var compVerifier = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); + _ = CompileAndVerify(source, targetFramework: TargetFramework.StandardAndCSharp, expectedOutput: expectedOutput); } [Fact, WorkItem(1073330, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1073330")] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs index 81c4fecd75385..fb9d5a67e2260 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs @@ -2498,7 +2498,7 @@ public static int Get() compilation.VerifyDiagnostics(); var expectedOutput = @"eval 1"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(17266, "https://github.com/dotnet/roslyn/issues/17266")] @@ -2533,7 +2533,7 @@ public struct Assignment var expectedOutput = @"eval 1 2"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -2552,7 +2552,7 @@ public static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularWithRecursivePatterns); compilation.VerifyDiagnostics(); var expectedOutput = @"False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -2942,7 +2942,7 @@ static void Main() { var expectedOutput = @"x = 3, y = 4 x = 5, y = 6 x = 7, y = 8"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -2983,7 +2983,7 @@ struct S var expectedOutput = @"x = 3, y = 4 x = 5, y = 6 x = 7, y = 8"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(28632, "https://github.com/dotnet/roslyn/issues/28632")] @@ -3122,7 +3122,7 @@ public static int M9(int x) var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe, references: new[] { CSharpRef }); compilation.VerifyDiagnostics(); var expectedOutput = @"222222222"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -3150,7 +3150,7 @@ public static int M2(string s) var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); var expectedOutput = @"99"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -3180,7 +3180,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); var expectedOutput = @"11"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4383,7 +4383,7 @@ static bool M(Func func) var expectedOutput = @"correct"; var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4420,7 +4420,7 @@ static async Task Main() // (7,23): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. // static async Task Main() Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(7, 23)); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4454,7 +4454,7 @@ static async Task Main() // (7,23): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. // static async Task Main() Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(7, 23)); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [WorkItem(48563, "https://github.com/dotnet/roslyn/issues/48563")] @@ -4649,7 +4649,7 @@ class B var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); var expectedOutput = @"22"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4682,7 +4682,7 @@ class B var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); var expectedOutput = @"22"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4756,7 +4756,7 @@ class B : Exception var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); var expectedOutput = @"22"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.RestrictedTypesNeedDesktop)] @@ -4792,7 +4792,7 @@ class B var expectedOutput = @"new A; A->new B; 1 new B; 1"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4829,7 +4829,7 @@ class B var expectedOutput = @"new A; A->int; 4 new B; B->int; 2"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); } [Fact] @@ -5331,7 +5331,7 @@ public C() var expectedOutput = @"new A; A->new B; B->new C; . new B; B->new C; ."; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/SwitchTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/SwitchTests.cs index 47e3778234193..fd60fdcb06f36 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/SwitchTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/SwitchTests.cs @@ -3715,7 +3715,7 @@ public static int Main() } } "; - var verifier = CompileAndVerify(source, expectedOutput: @"0"); + _ = CompileAndVerify(source, expectedOutput: @"0"); } [WorkItem(543660, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543660")] @@ -8600,7 +8600,7 @@ public static T M2(ValueType o) where T : struct } } "; - var compVerifier = CompileAndVerify(source, + _ = CompileAndVerify(source, options: TestOptions.DebugDll.WithOutputKind(OutputKind.ConsoleApplication), expectedOutput: "2300"); } @@ -8651,7 +8651,7 @@ class X : B { } // case T t: Diagnostic(ErrorCode.ERR_PatternWrongGenericTypeInVersion, "T").WithArguments("A", "T", "7.0", "7.1").WithLocation(20, 18) ); - var compVerifier = CompileAndVerify(source, + _ = CompileAndVerify(source, options: TestOptions.DebugDll.WithOutputKind(OutputKind.ConsoleApplication), parseOptions: TestOptions.Regular7_1, expectedOutput: "XXBB"); @@ -8706,7 +8706,7 @@ class X : B { } // case T t: Diagnostic(ErrorCode.ERR_PatternWrongGenericTypeInVersion, "T").WithArguments("A", "T", "7.0", "7.1").WithLocation(20, 18) ); - var compVerifier = CompileAndVerify(source, + _ = CompileAndVerify(source, options: TestOptions.DebugDll.WithOutputKind(OutputKind.ConsoleApplication), parseOptions: TestOptions.Regular7_1, expectedOutput: "XXBB"); @@ -8763,7 +8763,7 @@ struct B : I1 options: TestOptions.DebugDll.WithOutputKind(OutputKind.ConsoleApplication), parseOptions: TestOptions.Regular7_1) .VerifyDiagnostics(); - var compVerifier = CompileAndVerify(compilation, + _ = CompileAndVerify(compilation, expectedOutput: "FalseFalseTrueTrue"); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/UnsafeTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/UnsafeTests.cs index 1201de4334c0b..0dc01450e1fc4 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/UnsafeTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/UnsafeTests.cs @@ -1115,7 +1115,7 @@ static void Main() } } "; - var compVerifier = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @" + _ = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @" 1 0 -1", verify: Verification.Fails); @@ -1144,7 +1144,7 @@ static void Main() } } "; - var compVerifier = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: "210", verify: Verification.Fails); + _ = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: "210", verify: Verification.Fails); } [Fact] @@ -1164,7 +1164,7 @@ static void Main() } "; // NOTE: no pointer arithmetic - just dereference p. - var compVerifier = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: "1", verify: Verification.Fails).VerifyIL("C.Main", @" + _ = CompileAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: "1", verify: Verification.Fails).VerifyIL("C.Main", @" { // Code size 12 (0xc) .maxstack 1 @@ -10819,8 +10819,7 @@ public struct S2 } } "; - - var verifier = CompileAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Passes); + _ = CompileAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Passes); } [Fact, WorkItem(531327, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531327")] @@ -10843,8 +10842,7 @@ unsafe struct S1 } "; - - var verifier = CompileAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Fails); + _ = CompileAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Fails); } [Fact, WorkItem(748530, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/748530")] @@ -11314,8 +11312,7 @@ static void Main(string[] args) var compilation = CreateCompilationWithILAndMscorlib40(csharpSource, ilSource, targetFramework: TargetFramework.Mscorlib40, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - - var result = CompileAndVerify(compilation, expectedOutput: "5"); + _ = CompileAndVerify(compilation, expectedOutput: "5"); } diff --git a/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs index fe1000a62b48a..4dcf04e8731c4 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs @@ -4346,7 +4346,7 @@ static void Main(string[] args) } } "; - var comp = CreateCompilation(text, options: TestOptions.ReleaseExe).VerifyDiagnostics( + _ = CreateCompilation(text, options: TestOptions.ReleaseExe).VerifyDiagnostics( // (7,18): warning CS0665: Assignment in conditional expression is always constant; did you mean to use == instead of = ? // int s = (b = false) ? 5 : 100; // Warning Diagnostic(ErrorCode.WRN_IncorrectBooleanAssg, "b = false"), diff --git a/src/Compilers/CSharp/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.cs index 805e7440a5a59..f789cea13da78 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.cs @@ -1589,7 +1589,7 @@ File 1 True True "; - CompilationVerifier verifier = CompileAndVerify(source + InstrumentationHelperSource, expectedOutput: expectedOutput); + _ = CompileAndVerify(source + InstrumentationHelperSource, expectedOutput: expectedOutput); } [Fact] @@ -1678,7 +1678,7 @@ File 1 True True "; - CompilationVerifier verifier = CompileAndVerify(source + InstrumentationHelperSource, expectedOutput: expectedOutput); + _ = CompileAndVerify(source + InstrumentationHelperSource, expectedOutput: expectedOutput); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs index 21b020ad0cdb1..b5270383020e3 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs @@ -1490,7 +1490,7 @@ static void M(object o) methodData0.EncDebugInfoProvider()); var method1 = compilation1.GetMember("C.M"); - var diff1 = compilation1.EmitDifference( + _ = compilation1.EmitDifference( generation0, ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); } diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs index 3a559fcdc2531..ffa413b519633 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs @@ -110,7 +110,7 @@ public static void Main() } } "; - var compilation2 = CompileAndVerify( + _ = CompileAndVerify( source2, new[] { new CSharpCompilationReference(compilation1) }, verify: Verification.Fails); @@ -142,7 +142,7 @@ public static void Main() } } "; - var compilation2 = CompileAndVerify( + _ = CompileAndVerify( source2, new[] { new CSharpCompilationReference(compilation1) }, verify: Verification.Fails); diff --git a/src/Compilers/CSharp/Test/Emit/PrivateProtected.cs b/src/Compilers/CSharp/Test/Emit/PrivateProtected.cs index 059a107ff10ba..2be51aa87f632 100644 --- a/src/Compilers/CSharp/Test/Emit/PrivateProtected.cs +++ b/src/Compilers/CSharp/Test/Emit/PrivateProtected.cs @@ -74,7 +74,7 @@ void M() } } "; - var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular7_2) + _ = CreateCompilation(source, parseOptions: TestOptions.Regular7_2) .VerifyDiagnostics( ); } @@ -594,7 +594,7 @@ private protected void M() {} private protected int F; } "; - var verifier = CompileAndVerify( + _ = CompileAndVerify( text, parseOptions: TestOptions.Regular7_2, expectedSignatures: new[] From 641e51d862503ac9721e85f82a6185daf0e69cb4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 19:33:32 -0700 Subject: [PATCH 24/63] Fix IDE0059: Unnecessary assignment --- .../DiagnosticAnalyzerTests.AllInOne.cs | 2 +- .../Diagnostics/GetDiagnosticsTests.cs | 2 +- .../FlowAnalysis/RegionAnalysisTests.cs | 7 +- .../Semantics/AmbiguousOverrideTests.cs | 6 +- .../Semantics/AwaitExpressionTests.cs | 3 +- .../Semantic/Semantics/BetterCandidates.cs | 6 +- .../Semantic/Semantics/BindingAwaitTests.cs | 2 +- .../Test/Semantic/Semantics/BindingTests.cs | 17 ++-- .../Semantics/FieldInitializerBindingTests.cs | 3 +- .../Semantics/GlobalUsingDirectiveTests.cs | 3 +- .../Semantics/ImplicitObjectCreationTests.cs | 36 +++---- .../Semantic/Semantics/IndexAndRangeTests.cs | 28 +++--- .../Semantics/InheritanceBindingTests.cs | 96 +++++++++---------- .../Semantic/Semantics/InterpolationTests.cs | 2 +- .../Test/Semantic/Semantics/LambdaTests.cs | 16 ++-- .../Test/Semantic/Semantics/LookupTests.cs | 2 +- .../Semantics/MultiDimensionalArrayTests.cs | 17 ++-- .../Test/Semantic/Semantics/NameOfTests.cs | 14 +-- .../Semantic/Semantics/NativeIntegerTests.cs | 2 +- .../Semantics/NullableConversionTests.cs | 6 +- .../Semantics/NullableReferenceTypesTests.cs | 42 ++++---- .../Test/Semantic/Semantics/NullableTests.cs | 32 +++---- .../Test/Semantic/Semantics/OperatorTests.cs | 6 +- .../Test/Semantic/Semantics/OutVarTests.cs | 6 +- .../Semantics/PatternMatchingTestBase.cs | 3 +- .../Semantics/PatternMatchingTests.cs | 66 ++++++------- .../Semantics/PatternMatchingTests2.cs | 32 +++---- .../Semantics/PatternMatchingTests3.cs | 64 ++++++------- .../Semantics/PatternMatchingTests4.cs | 50 +++++----- .../Semantics/PatternMatchingTests_Global.cs | 10 +- .../Semantic/Semantics/PatternSwitchTests.cs | 56 +++++------ .../Test/Semantic/Semantics/QueryTests.cs | 2 +- .../Semantic/Semantics/RecordStructTests.cs | 2 +- .../Test/Semantic/Semantics/RecordTests.cs | 8 +- .../Semantic/Semantics/SemanticErrorTests.cs | 4 +- .../TargetTypedConditionalOperatorTests.cs | 4 +- .../Semantics/TargetTypedDefaultTests.cs | 2 +- .../Test/Semantic/Semantics/UnsafeTests.cs | 5 +- .../Semantics/UserDefinedConversionTests.cs | 19 ++-- .../Semantic/Semantics/UsingStatementTests.cs | 7 +- .../SourceGeneration/GeneratorDriverTests.cs | 18 ++-- 41 files changed, 331 insertions(+), 377 deletions(-) diff --git a/src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs b/src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs index edeb611cea0f9..ecce5dd95f2e4 100644 --- a/src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs +++ b/src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs @@ -82,7 +82,7 @@ public string this[int index] [Fact] public void DiagnosticAnalyzerExpressionBodiedProperty() { - var comp = CreateCompilationWithMscorlib45(@" + _ = CreateCompilationWithMscorlib45(@" public class C { public int P => 10; diff --git a/src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs b/src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs index fcbefcbe73577..ae1843646f151 100644 --- a/src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs @@ -311,7 +311,7 @@ public void TestEventQueueCompletionForEmptyCompilation() var compilation = CreateCompilationWithMscorlib45(CSharpTestSource.None).WithEventQueue(new AsyncQueue()); // Force complete compilation event queue - var unused = compilation.GetDiagnostics(); + _ = compilation.GetDiagnostics(); Assert.True(compilation.EventQueue.IsCompleted); } diff --git a/src/Compilers/CSharp/Test/Semantic/FlowAnalysis/RegionAnalysisTests.cs b/src/Compilers/CSharp/Test/Semantic/FlowAnalysis/RegionAnalysisTests.cs index 702f3242a7332..5ac0c32303a87 100644 --- a/src/Compilers/CSharp/Test/Semantic/FlowAnalysis/RegionAnalysisTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/FlowAnalysis/RegionAnalysisTests.cs @@ -1534,7 +1534,7 @@ static void Main() } } enum color { blue, green }"); - var tmp = dataFlows.VariablesDeclared; // ensure no exception thrown + _ = dataFlows.VariablesDeclared; // ensure no exception thrown Assert.Empty(dataFlows.VariablesDeclared); } @@ -4073,8 +4073,7 @@ public int P var ctrlFlows = results.Item1; var dataFlows = results.Item2; - - var tmp = ctrlFlows.EndPointIsReachable; // ensure no exception thrown + _ = ctrlFlows.EndPointIsReachable; // ensure no exception thrown Assert.Empty(dataFlows.VariablesDeclared); } @@ -5998,7 +5997,7 @@ void Goo(string[] args) Assert.Equal("this.EditorOperations = 1;", statement.ToString()); var analysis = model.AnalyzeDataFlow(statement); Assert.True(analysis.Succeeded); - var v = analysis.DataFlowsOut; + _ = analysis.DataFlowsOut; } [Fact, WorkItem(547059, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547059")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/AmbiguousOverrideTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/AmbiguousOverrideTests.cs index f9dac8f2cce60..b604a4ab5dedd 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/AmbiguousOverrideTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/AmbiguousOverrideTests.cs @@ -1380,8 +1380,7 @@ abstract class TestClass public void Method(ref int x) { } public void Method(in int x) { } }"; - - var comp = CreateCompilation(text).VerifyDiagnostics( + _ = CreateCompilation(text).VerifyDiagnostics( // (5,17): error CS0663: 'TestClass' cannot define an overloaded method that differs only on parameter modifiers 'in' and 'ref' // public void Method(in int x) { } Diagnostic(ErrorCode.ERR_OverloadRefKind, "Method").WithArguments("TestClass", "method", "in", "ref").WithLocation(5, 17)); @@ -1397,8 +1396,7 @@ abstract class TestClass public void Method(out int x) { x = 0; } public void Method(in int x) { } }"; - - var comp = CreateCompilation(text).VerifyDiagnostics( + _ = CreateCompilation(text).VerifyDiagnostics( // (5,17): error CS0663: 'TestClass' cannot define an overloaded method that differs only on parameter modifiers 'in' and 'out' // public void Method(in int x) { } Diagnostic(ErrorCode.ERR_OverloadRefKind, "Method").WithArguments("TestClass", "method", "in", "out").WithLocation(5, 17)); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs index ff547024e3d84..f8061562dc0a8 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs @@ -83,8 +83,7 @@ private AwaitExpressionInfo GetAwaitExpressionInfo(string text, out CSharpCompil private AwaitExpressionInfo GetAwaitExpressionInfo(string text, params DiagnosticDescription[] diagnostics) { - CSharpCompilation temp; - return GetAwaitExpressionInfo(text, out temp, diagnostics); + return GetAwaitExpressionInfo(text, out _, diagnostics); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BetterCandidates.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BetterCandidates.cs index 32280b50301e3..be6a0a78dae6f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BetterCandidates.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BetterCandidates.cs @@ -272,7 +272,7 @@ public bool MoveNext() // foreach (var q in c) { } Diagnostic(ErrorCode.ERR_BadGetEnumerator, "c").WithArguments("MyEnumerator", "MyCollection.GetEnumerator()").WithLocation(6, 27) ); - var compilation = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( + _ = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( // (26,24): error CS0111: Type 'MyEnumerator' already defines a member called 'MoveNext' with the same parameter types // public static bool MoveNext() => throw null; Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "MoveNext").WithArguments("MoveNext", "MyEnumerator").WithLocation(26, 24) @@ -359,7 +359,7 @@ public MyTaskAwaiter(TResult value) // var z = await x; Diagnostic(ErrorCode.ERR_BadAwaitArg, "await x").WithArguments("MyTask").WithLocation(9, 17) ); - var compilation = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( + _ = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( // (9,17): error CS1986: 'await' requires that the type MyTask have a suitable GetAwaiter method // var z = await x; Diagnostic(ErrorCode.ERR_BadAwaitArg, "await x").WithArguments("MyTask").WithLocation(9, 17) @@ -410,7 +410,7 @@ public MyTaskAwaiter(TResult value) // var z = await x; Diagnostic(ErrorCode.ERR_ObjectProhibited, "await x").WithArguments("MyTaskAwaiter.GetResult()").WithLocation(9, 17) ); - var compilation = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( + _ = CreateCompilationWithBetterCandidates(source, options: TestOptions.ReleaseExe).VerifyDiagnostics( // (9,17): error CS0176: Member 'MyTaskAwaiter.GetResult()' cannot be accessed with an instance reference; qualify it with a type name instead // var z = await x; Diagnostic(ErrorCode.ERR_ObjectProhibited, "await x").WithArguments("MyTaskAwaiter.GetResult()").WithLocation(9, 17) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAwaitTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAwaitTests.cs index b6d0a3a64f4aa..6d4544a802b0c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAwaitTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAwaitTests.cs @@ -28,7 +28,7 @@ public void Bug18241() TextChange change = new TextChange(span, "/*comment*/"); SourceText newText = text.WithChanges(change); // This line caused an assertion and then crashed in the parser. - var newTree = tree.WithChangedText(newText); + _ = tree.WithChangedText(newText); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs index 5b29dc781eef4..d053dde6d9ba5 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs @@ -746,8 +746,7 @@ public class DerivedClass: BaseAssembly.BaseClass { } } ", assemblyName: "DerivedAssembly1", references: new List() { baseAssembly.EmitToImageReference() }).VerifyDiagnostics(); - - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = DerivedAssembly.DerivedClass; public class Test @@ -785,8 +784,7 @@ public class DerivedClass: BaseAssembly.BaseClass { } } ", assemblyName: "DerivedAssembly2", references: new List() { baseAssembly.EmitToImageReference() }).VerifyDiagnostics(); - - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = DerivedAssembly.DerivedClass; public class Test @@ -824,8 +822,7 @@ public class DerivedClass: BaseAssembly.BaseClass { } } ", assemblyName: "DerivedAssembly3", references: new List() { baseAssembly.EmitToImageReference() }).VerifyDiagnostics(); - - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = DerivedAssembly.DerivedClass; public class Test @@ -1422,7 +1419,7 @@ public interface IBase3 [Fact] public void UseSiteErrorViaAliasTest04() { - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = Class1; public class Test @@ -1454,7 +1451,7 @@ void m() [Fact] public void UseSiteErrorViaAliasTest05() { - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = Class1; public class Test @@ -1480,7 +1477,7 @@ void m() [Fact] public void UseSiteErrorViaAliasTest06() { - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = Class1; public class Test @@ -1513,7 +1510,7 @@ void m2(ClassAlias p) { } [Fact] public void UseSiteErrorViaAliasTest07() { - var testAssembly = CreateCompilation( + _ = CreateCompilation( @" using ClassAlias = Class1; public class Test diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/FieldInitializerBindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/FieldInitializerBindingTests.cs index 4e3a7a1f9ed14..34a9749061009 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/FieldInitializerBindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/FieldInitializerBindingTests.cs @@ -290,14 +290,13 @@ private static void CheckBoundInitializers(IEnumerable expe private static ImmutableArray BindInitializersWithoutDiagnostics(SourceNamedTypeSymbol typeSymbol, ImmutableArray> initializers) { DiagnosticBag diagnostics = DiagnosticBag.GetInstance(); - ImportChain unused; var boundInitializers = ArrayBuilder.GetInstance(); Binder.BindRegularCSharpFieldInitializers( typeSymbol.DeclaringCompilation, initializers, boundInitializers, new BindingDiagnosticBag(diagnostics), - firstDebugImports: out unused); + firstDebugImports: out _); diagnostics.Verify(); diagnostics.Free(); return boundInitializers.ToImmutableAndFree(); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs index ed1ed989e9023..acb0574bc3b37 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs @@ -406,8 +406,7 @@ static void Main() }; comp2.VerifyDiagnostics(expected); - - var comp3 = CreateCompilation(new[] { source3, source2 }, parseOptions: TestOptions.RegularPreview, options: TestOptions.DebugExe, references: new[] { comp1Ref }); + _ = CreateCompilation(new[] { source3, source2 }, parseOptions: TestOptions.RegularPreview, options: TestOptions.DebugExe, references: new[] { comp1Ref }); comp2.VerifyDiagnostics(expected); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/ImplicitObjectCreationTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/ImplicitObjectCreationTests.cs index 263f11dfc8515..8f6845f2c6af2 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/ImplicitObjectCreationTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/ImplicitObjectCreationTests.cs @@ -899,8 +899,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,15): error CS0121: The call is ambiguous between the following methods or properties: 'C.C(object, C)' and 'C.C(C, object)' // C c = new(new(), new()); Diagnostic(ErrorCode.ERR_AmbigCall, "new(new(), new())").WithArguments("C.C(object, C)", "C.C(C, object)").WithLocation(9, 15) @@ -1308,8 +1307,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (6,9): error CS0131: The left-hand side of an assignment must be a variable, property or indexer // new() ??= new C(); Diagnostic(ErrorCode.ERR_AssgLvalueExpected, "new()").WithLocation(6, 9), @@ -1337,8 +1335,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (12,9): error CS0411: The type arguments for method 'C.M(Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. // M(b => { if (b) return new(); else return new(); }); Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "M").WithArguments("C.M(System.Func)").WithLocation(12, 9) @@ -1361,8 +1358,7 @@ static void M() } } "; - - var comp = CreateCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics( // (8,16): error CS0417: 'A': cannot provide arguments when creating an instance of a variable type // A v1 = new(1); Diagnostic(ErrorCode.ERR_NewTyvarWithArgs, "new(1)").WithArguments("A").WithLocation(8, 16), @@ -1414,8 +1410,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (8,28): error CS0200: Property or indexer 'string.Length' cannot be assigned to -- it is read only // string x = new() { Length = 5 }; Diagnostic(ErrorCode.ERR_AssgReadonlyProp, "Length").WithArguments("string.Length").WithLocation(6, 28), @@ -1513,8 +1508,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (18,11): error CS1729: 'D' does not contain a constructor that takes 1 arguments // M(new(1), 1); Diagnostic(ErrorCode.ERR_BadCtorArgCount, "new(1)").WithArguments("D", "1").WithLocation(18, 11) @@ -1576,8 +1570,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (18,15): error CS0103: The name 'Missing' does not exist in the current context // M(new(Missing())); Diagnostic(ErrorCode.ERR_NameNotInContext, "Missing").WithArguments("Missing").WithLocation(18, 15) @@ -1605,8 +1598,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (15,9): error CS0103: The name 'Missing' does not exist in the current context // Missing(new(1)); Diagnostic(ErrorCode.ERR_NameNotInContext, "Missing").WithArguments("Missing").WithLocation(15, 9) @@ -1637,8 +1629,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'Program.M(A, int)' and 'Program.M(B, object)' // M(new(), 1); Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("Program.M(A, int)", "Program.M(B, object)").WithLocation(18, 9) @@ -1660,8 +1651,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,19): error CS1729: 'C' does not contain a constructor that takes 0 arguments // C c = new(new(), new()); Diagnostic(ErrorCode.ERR_BadCtorArgCount, "new()").WithArguments("C", "0").WithLocation(9, 19) @@ -1726,8 +1716,7 @@ public static void Main() } } "; - - var comp = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( + _ = CreateCompilation(source, options: TestOptions.DebugExe).VerifyDiagnostics( // (6,9): error CS0131: The left-hand side of an assignment must be a variable, property or indexer // new() = 5; Diagnostic(ErrorCode.ERR_AssgLvalueExpected, "new()").WithLocation(6, 9) @@ -3684,8 +3673,7 @@ static void Main() Func f = () => new() ?? ""hello""; } }"; - - var comp = CreateCompilation(text).VerifyDiagnostics( + _ = CreateCompilation(text).VerifyDiagnostics( // (7,32): error CS8754: There is no target type for 'new()' // Func f = () => new() ?? "hello"; Diagnostic(ErrorCode.ERR_ImplicitObjectCreationNoTargetType, "new()").WithArguments("new()").WithLocation(7, 32) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/IndexAndRangeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/IndexAndRangeTests.cs index 53ecf36fa7afb..1d22842f3cdf4 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/IndexAndRangeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/IndexAndRangeTests.cs @@ -799,7 +799,7 @@ public void M() { [Fact] public void IndexExpression_TypeNotFound() { - var compilation = CreateCompilation(@" + _ = CreateCompilation(@" class Test { void M(int arg) @@ -818,7 +818,7 @@ void M(int arg) [Fact] public void IndexExpression_LiftedTypeIsNotNullable() { - var compilation = CreateCompilation(@" + _ = CreateCompilation(@" namespace System { public class Index @@ -841,7 +841,7 @@ void M(int? arg) [Fact] public void IndexExpression_NullableConstructorNotFound() { - var compilation = CreateEmptyCompilation(@" + _ = CreateEmptyCompilation(@" namespace System { public struct Int32 { } @@ -944,7 +944,7 @@ void M(int? arg) [Fact] public void IndexExpression_InvalidTypes() { - var compilation = CreateCompilationWithIndex(@" + _ = CreateCompilationWithIndex(@" class Test { void M() @@ -968,7 +968,7 @@ void M() [Fact] public void IndexExpression_NoOperatorOverloading() { - var compilation = CreateCompilationWithIndex(@" + _ = CreateCompilationWithIndex(@" public class Test { public static Test operator ^(Test value) => default; @@ -995,14 +995,14 @@ void M() var x = ^1; } }"; - var compilation = CreateCompilationWithIndex(source, parseOptions: TestOptions.Regular7_3).VerifyDiagnostics(expected); - compilation = CreateCompilationWithIndex(source, parseOptions: TestOptions.Regular8).VerifyDiagnostics(); + _ = CreateCompilationWithIndex(source, parseOptions: TestOptions.Regular7_3).VerifyDiagnostics(expected); + _ = CreateCompilationWithIndex(source, parseOptions: TestOptions.Regular8).VerifyDiagnostics(); } [Fact] public void RangeExpression_RangeNotFound() { - var compilation = CreateCompilationWithIndex(@" + _ = CreateCompilationWithIndex(@" class Test { void M(int arg) @@ -1030,7 +1030,7 @@ void M(int arg) [Fact] public void RangeExpression_LiftedRangeNotNullable() { - var compilation = CreateCompilationWithIndex(@" + _ = CreateCompilationWithIndex(@" namespace System { public class Range @@ -1053,7 +1053,7 @@ void M(System.Index? index) [Fact] public void RangeExpression_LiftedIndexNotNullable() { - var compilation = CreateCompilation(@" + _ = CreateCompilation(@" namespace System { public class Index @@ -1145,7 +1145,7 @@ void M(int arg) [Fact] public void RangeExpression_NullableConstructorNotFound() { - var compilation = CreateEmptyCompilation(@" + _ = CreateEmptyCompilation(@" namespace System { public struct Int32 { } @@ -1187,7 +1187,7 @@ void M(System.Index? arg) [Fact] public void RangeExpression_BooleanNotFound() { - var compilation = CreateEmptyCompilation(@" + _ = CreateEmptyCompilation(@" namespace System { public struct Int32 { } @@ -1407,7 +1407,7 @@ void M(Index? start, Index? end) [Fact] public void RangeExpression_InvalidTypes() { - var compilation = CreateCompilationWithIndexAndRange(@" + _ = CreateCompilationWithIndexAndRange(@" class Test { void M() @@ -1435,7 +1435,7 @@ void M() [Fact] public void RangeExpression_NoOperatorOverloading() { - var compilation = CreateCompilationWithIndexAndRange(@" + _ = CreateCompilationWithIndexAndRange(@" public class Test { public static Test operator ..(Test value) => default; diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs index 46544f147fa73..3cb6ea467091c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs @@ -8742,7 +8742,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -8784,7 +8784,7 @@ class Derived : Base public override void Goo(T value) where U : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,48): error CS0699: 'Derived.Goo(T)' does not define type parameter 'U' // public override void Goo(T value) where U : struct { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "Derived.Goo(T)").WithLocation(9, 48)); @@ -8804,7 +8804,7 @@ class Derived : Base public override void Goo(T value) where U : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,48): error CS0699: 'Derived.Goo(T)' does not define type parameter 'U' // public override void Goo(T value) where U : class { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "Derived.Goo(T)").WithLocation(9, 48)); @@ -8824,7 +8824,7 @@ class Derived : Base public override void Goo(T value) where U : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,48): error CS0699: 'Derived.Goo(T)' does not define type parameter 'U' // public override void Goo(T value) where U : struct { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "Derived.Goo(T)").WithLocation(9, 48)); @@ -8844,7 +8844,7 @@ class Derived : Base public override void Goo(T value) where U : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,48): error CS0699: 'Derived.Goo(T)' does not define type parameter 'U' // public override void Goo(T value) where U : class { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "Derived.Goo(T)").WithLocation(9, 48)); @@ -8864,7 +8864,7 @@ class C : I void I.Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -8881,7 +8881,7 @@ class C : I void I.Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -8898,7 +8898,7 @@ class C : I void I.Goo(T value) where U : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,34): error CS0699: 'C.I.Goo(T)' does not define type parameter 'U' // void I.Goo(T value) where U : struct { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "C.I.Goo(T)").WithLocation(9, 34)); @@ -8918,7 +8918,7 @@ class C : I void I.Goo(T value) where U : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,34): error CS0699: 'C.I.Goo(T)' does not define type parameter 'U' // void I.Goo(T value) where U : class { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "C.I.Goo(T)").WithLocation(9, 34)); @@ -8938,7 +8938,7 @@ class C : I void I.Goo(T value) where U : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,34): error CS0699: 'C.I.Goo(T)' does not define type parameter 'U' // void I.Goo(T value) where U : struct { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "C.I.Goo(T)").WithLocation(9, 34)); @@ -8958,7 +8958,7 @@ class C : I void I.Goo(T value) where U : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,34): error CS0699: 'C.I.Goo(T)' does not define type parameter 'U' // void I.Goo(T value) where U : class { } Diagnostic(ErrorCode.ERR_TyVarNotFoundInConstraint, "U").WithArguments("U", "C.I.Goo(T)").WithLocation(9, 34)); @@ -8978,7 +8978,7 @@ class C : I void I.Goo() where U : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,18): error CS0080: Constraints are not allowed on non-generic declarations // void I.Goo() where U : class { } Diagnostic(ErrorCode.ERR_ConstraintOnlyAllowedOnGenericDecl, "where").WithLocation(9, 18) @@ -8999,7 +8999,7 @@ class C : I void I.Goo(T? value) where T : struct where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,52): error CS0409: A constraint clause has already been specified for type parameter 'T'. All of the constraints for a type parameter must be specified in a single where clause. // void I.Goo(T? value) where T : struct where T : class { } Diagnostic(ErrorCode.ERR_DuplicateConstraintClause, "T").WithArguments("T").WithLocation(9, 52) @@ -9019,7 +9019,7 @@ class Derived : Base public override void Goo(T value) where T : struct, class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (8,26): error CS0115: 'Derived.Goo(T)': no suitable method found to override // public override void Goo(T value) where T : struct, class { } Diagnostic(ErrorCode.ERR_OverrideNotExpected, "Goo").WithArguments("Derived.Goo(T)").WithLocation(8, 26), @@ -9041,7 +9041,7 @@ class Derived : Base public override void Goo(T value) where T : class, struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (8,26): error CS0115: 'Derived.Goo(T)': no suitable method found to override // public override void Goo(T value) where T : class, struct { } Diagnostic(ErrorCode.ERR_OverrideNotExpected, "Goo").WithArguments("Derived.Goo(T)").WithLocation(8, 26), @@ -9064,7 +9064,7 @@ class Derived : Base public override void Goo(T value) where T : struct, class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,60): error CS0449: The 'class', 'struct', 'unmanaged', 'notnull', and 'default' constraints cannot be combined or duplicated, and must be specified first in the constraints list. // public override void Goo(T value) where T : struct, class { } Diagnostic(ErrorCode.ERR_TypeConstraintsMustBeUniqueAndFirst, "class").WithLocation(9, 60)); @@ -9083,7 +9083,7 @@ class C : I void I.Goo(T value) where T : struct, class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (8,12): error CS0539: 'C.Goo(T)' in explicit interface declaration is not found among members of the interface that can be implemented // void I.Goo(T value) where T : struct, class { } Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "Goo").WithArguments("C.Goo(T)").WithLocation(8, 12), @@ -9105,7 +9105,7 @@ class C : I void I.Goo(T value) where T : class, struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (8,12): error CS0539: 'C.Goo(T)' in explicit interface declaration is not found among members of the interface that can be implemented // void I.Goo(T value) where T : class, struct { } Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "Goo").WithArguments("C.Goo(T)").WithLocation(8, 12), @@ -9128,7 +9128,7 @@ class C : I void I.Goo(T value) where T : struct, class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,46): error CS0449: The 'class', 'struct', 'unmanaged', 'notnull', and 'default' constraints cannot be combined or duplicated, and must be specified first in the constraints list. // void I.Goo(T value) where T : struct, class { } Diagnostic(ErrorCode.ERR_TypeConstraintsMustBeUniqueAndFirst, "class").WithLocation(9, 46)); @@ -9149,7 +9149,7 @@ class Derived : Base public override void Goo(T value) where T : class? { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,52): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : class? { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "class?").WithLocation(10, 52)); @@ -9170,7 +9170,7 @@ class C : I void I.Goo(T value) where T : class? { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,38): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // void I.Goo(T value) where T : class? { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "class?").WithLocation(10, 38)); @@ -9191,7 +9191,7 @@ class Derived : Base public override void Goo(T value) where T : Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,52): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 52)); @@ -9212,7 +9212,7 @@ class Derived : Base public override void Goo(T value) where T : class, Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,59): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : class, Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 59)); @@ -9233,7 +9233,7 @@ class Derived : Base public override void Goo(T value) where T : class where U : Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,71): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : class where U Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 71)); @@ -9254,7 +9254,7 @@ class C : I void I.Goo(T value) where T : Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,38): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // void I.Goo(T value) where T : Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 38)); @@ -9275,7 +9275,7 @@ class C : I void I.Goo(T value) where T : class, Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,45): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // void I.Goo(T value) where T : class, Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 45)); @@ -9296,7 +9296,7 @@ class C : I void I.Goo(T value) where T : class where U : Stream { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,57): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // void I.Goo(T value) where T : class where U : Stream { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "Stream").WithLocation(10, 57)); @@ -9316,7 +9316,7 @@ class C : I void I.Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,16): error CS8666: Method 'C.I.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'U' of overridden or explicitly implemented method 'I.Goo(U)' is not a non-nullable value type. // void I.Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "U", "I.Goo(U)").WithLocation(9, 16) @@ -9337,7 +9337,7 @@ class C : I void I.Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,16): error CS8666: Method 'C.I.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'I.Goo(T)' is not a non-nullable value type. // void I.Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "T", "I.Goo(T)").WithLocation(9, 16) @@ -9359,7 +9359,7 @@ class C : I void I.Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,16): error CS8666: Method 'C.I.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'I.Goo(T)' is not a non-nullable value type. // void I.Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "T", "I.Goo(T)").WithLocation(10, 16) @@ -9380,7 +9380,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,30): error CS8666: Method 'Derived.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a non-nullable value type. // public override void Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(9, 30) @@ -9401,7 +9401,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,30): error CS8666: Method 'Derived.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a non-nullable value type. // public override void Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(9, 30) @@ -9423,7 +9423,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,30): error CS8666: Method 'Derived.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a non-nullable value type. // public override void Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(10, 30) @@ -9444,7 +9444,7 @@ class C : I void I.Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,16): error CS8665: Method 'C.I.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'U' of overridden or explicitly implemented method 'I.Goo(U)' is not a reference type. // void I.Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "U", "I.Goo(U)").WithLocation(9, 16) @@ -9465,7 +9465,7 @@ class C : I void I.Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,16): error CS8665: Method 'C.I.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'I.Goo(T)' is not a reference type. // void I.Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "T", "I.Goo(T)").WithLocation(9, 16) @@ -9487,7 +9487,7 @@ class C : I void I.Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,16): error CS8665: Method 'C.I.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'I.Goo(T)' is not a reference type. // void I.Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("C.I.Goo(T)", "T", "T", "I.Goo(T)").WithLocation(10, 16) @@ -9508,7 +9508,7 @@ class Derived : Base public override void Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,30): error CS8665: Method 'Derived.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a reference type. // public override void Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(9, 30) @@ -9529,7 +9529,7 @@ class Derived : Base public override void Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,30): error CS8665: Method 'Derived.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a reference type. // public override void Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(9, 30) @@ -9551,7 +9551,7 @@ class Derived : Base public override void Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,30): error CS8665: Method 'Derived.Goo(T)' specifies a 'class' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a reference type. // public override void Goo(T value) where T : class { } Diagnostic(ErrorCode.ERR_OverrideRefConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(10, 30) @@ -9573,7 +9573,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,30): error CS8666: Method 'Derived.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a non-nullable value type. // public override void Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(10, 30) @@ -9594,7 +9594,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,30): error CS8666: Method 'Derived.Goo(T)' specifies a 'struct' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'Base.Goo(T)' is not a non-nullable value type. // public override void Goo(T value) where T : struct { } Diagnostic(ErrorCode.ERR_OverrideValConstraintNotSatisfied, "T").WithArguments("Derived.Goo(T)", "T", "T", "Base.Goo(T)").WithLocation(9, 30) @@ -9615,7 +9615,7 @@ class Derived : Base public override void Goo(T value) where T : struct { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -9633,7 +9633,7 @@ class Derived : Base public override void Goo(T value) where T : class { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -9650,7 +9650,7 @@ class Derived : Base public override void Goo(T value) where T : new() { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,52): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : new() { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "new()").WithLocation(9, 52) @@ -9671,7 +9671,7 @@ class Derived : Base public override void Goo(T value) where T : class, new() { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,59): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : class, new() { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "new()").WithLocation(9, 59) @@ -9692,7 +9692,7 @@ class Derived : Base public override void Goo(T value) where T : unmanaged { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,52): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : unmanaged { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "unmanaged").WithLocation(9, 52) @@ -9715,7 +9715,7 @@ class Derived : Base public override void Goo(T value) where T : unmanaged, I { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (11,52): error CS0460: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly, except for either a 'class', or a 'struct' constraint. // public override void Goo(T value) where T : unmanaged, I { } Diagnostic(ErrorCode.ERR_OverrideWithConstraints, "unmanaged").WithLocation(11, 52) @@ -9742,7 +9742,7 @@ class C2 : I void I.Goo(T? value) {} } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } } } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs index 62cc043b27220..375c6ed641df9 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs @@ -269,7 +269,7 @@ Expression> M(dynamic d) { }"; string expectedOutput = @"<> "; - var verifier = CompileAndVerify(source, new[] { CSharpRef }, expectedOutput: expectedOutput).VerifyDiagnostics(); + _ = CompileAndVerify(source, new[] { CSharpRef }, expectedOutput: expectedOutput).VerifyDiagnostics(); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs index c73417b967423..40b293e0841e1 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs @@ -1597,7 +1597,7 @@ public static void Method(Expression> expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (8,40): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'Struct1'. // Method((Class1 c) => c.Method2(default(Struct1))); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "default(Struct1)").WithArguments("Struct1").WithLocation(8, 40)); @@ -1623,7 +1623,7 @@ public static void Method(Expression> expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (8,40): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'Struct1'. // Method((Class1 c) => c.Method2(default)); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "default").WithArguments("Struct1").WithLocation(8, 40)); @@ -1649,7 +1649,7 @@ public static void Method(Expression> expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (8,50): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'Struct1'. // Method((Class1 c) => c.Method2((Struct1) default)); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "default").WithArguments("Struct1").WithLocation(8, 50)); @@ -1675,7 +1675,7 @@ public static void Method(Expression> expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (8,40): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'Struct1'. // Method((Class1 c) => c.Method2(new Struct1())); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "new Struct1()").WithArguments("Struct1").WithLocation(8, 40)); @@ -1702,7 +1702,7 @@ public static void Method(Expression expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (9,25): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'Struct1'. // Method((Struct1 s) => Method2()); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "s").WithArguments("Struct1").WithLocation(9, 25)); @@ -1727,7 +1727,7 @@ public static void Method(Delegate1 expression) { } public ref struct Struct1 { } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics(); + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics(); } [Fact, WorkItem(30776, "https://github.com/dotnet/roslyn/issues/30776")] @@ -1748,7 +1748,7 @@ public void Method2(TypedReference tr) { } public static void Method(Expression expression) { } } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (8,30): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'TypedReference'. // Method(() => Method2(default)); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "default").WithArguments("TypedReference").WithLocation(8, 30)); @@ -1773,7 +1773,7 @@ public void Method2() { } public static void Method(Expression expression) { } } "; - var compilation = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( + _ = CreateCompilationWithMscorlib40AndSystemCore(text).VerifyDiagnostics( // (9,32): error CS8640: Expression tree cannot contain value of ref struct or restricted type 'TypedReference'. // Method((TypedReference tr) => Method2()); Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainRefStruct, "tr").WithArguments("TypedReference").WithLocation(9, 32)); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs index c7db163d93d9d..50ef05efd9944 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs @@ -1616,7 +1616,7 @@ void M() public void GenericNameLookup() { var source = @"using A = List;"; - var compilation = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (1,11): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?) // using A = List; Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "List").WithArguments("List<>").WithLocation(1, 11), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/MultiDimensionalArrayTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/MultiDimensionalArrayTests.cs index 6733658fdca88..984e8d4fa188f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/MultiDimensionalArrayTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/MultiDimensionalArrayTests.cs @@ -94,8 +94,7 @@ static void V(bool b) A24B25C26t A27B28C29t A30B31C32t"; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } [Fact] @@ -138,8 +137,7 @@ static void Main() string expected = @"123456789101112 1234588899989101112 888888888999999999999888999101112"; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } @@ -159,8 +157,7 @@ public static void Main() } }"; string expected = @"102030405060"; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } [WorkItem(544081, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544081")] @@ -180,8 +177,7 @@ static void Main(string[] args) } }"; string expected = @""; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } [WorkItem(544364, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544364")] @@ -1209,8 +1205,7 @@ static void Main() Assert.Equal(1, array.Rank); Assert.Equal(new[] { 5 }, array.Sizes); Assert.Equal(new[] { 1 }, array.LowerBounds); - - var verifier = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"Test1 Test2 Test3 @@ -1537,7 +1532,7 @@ public override void Test16(double[,] x) } "; var compilation = CreateCompilationWithILAndMscorlib40(source, ilSource, options: TestOptions.ReleaseExe); - var verifier = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"Test1 Test2 Test3 diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs index 0a0dc8c945aac..a2d9973eeeffd 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs @@ -146,7 +146,7 @@ interface I3 : I1, I2 int Test(string arg = nameof(M), string arg2 = ""N"" /* nameof(N) */); } "; - var comp = CompileAndVerify(source, expectedOutput: @" + _ = CompileAndVerify(source, expectedOutput: @" var2 nameof var1 @@ -656,7 +656,7 @@ static void Main(string[] args) nameof(N); } }"; - var compilation = CreateCompilation( + _ = CreateCompilation( source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6)).VerifyDiagnostics( @@ -678,7 +678,7 @@ static void Main(string[] args) nameof(N); } }"; - var compilation = CreateCompilation( + _ = CreateCompilation( source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp5)).VerifyDiagnostics( @@ -1156,7 +1156,7 @@ public static void Main() } }"; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe); - var comp = CompileAndVerify(compilation, expectedOutput: @"N1N2"); + _ = CompileAndVerify(compilation, expectedOutput: @"N1N2"); } [Fact, WorkItem(42, "github.com/dotnet/roslyn")] @@ -1169,7 +1169,7 @@ void M( string s = nameof(T) // ok ) { } }"; - var compilation = CreateCompilationWithMscorlib45(source).VerifyDiagnostics(); + _ = CreateCompilationWithMscorlib45(source).VerifyDiagnostics(); } [Fact, WorkItem(10467, "https://github.com/dotnet/roslyn/issues/10467")] @@ -1249,7 +1249,7 @@ public static string GetFromExternal() { } } }"; - var compilation = CreateCompilationWithMscorlib45(source, null, + _ = CreateCompilationWithMscorlib45(source, null, TestOptions.UnsafeDebugDll).VerifyDiagnostics( // (14,19): error CS1666: You cannot use fixed size buffers contained in unfixed expressions. Try using the fixed statement. // return nameof(MessageType); @@ -1409,7 +1409,7 @@ public static void Verify(this string actual, string expected) var compilation = CreateCompilationWithMscorlib40AndSystemCore(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"passed"); + _ = CompileAndVerify(compilation, expectedOutput: @"passed"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs index 32b8f8f77aa9d..3cde8a1cd984c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs @@ -3495,7 +3495,7 @@ static void Main() void verify(CSharpCompilation comp) { - var verifier = CompileAndVerify(comp, expectedOutput: + _ = CompileAndVerify(comp, expectedOutput: @"System.Int16 System.Object"); var method = comp.GetMember("Program.F"); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableConversionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableConversionTests.cs index 98bbe0e41adf4..04ec78274e409 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableConversionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableConversionTests.cs @@ -33,7 +33,7 @@ static void Main() } } "; - var verifier = CompileAndVerify(source: source, expectedOutput: "AB"); + _ = CompileAndVerify(source: source, expectedOutput: "AB"); } [Fact] @@ -82,7 +82,7 @@ static void V(bool b) "; string expectedOutput = @"tttttttfft"; - var verifier = CompileAndVerify(source: source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source: source, expectedOutput: expectedOutput); } [Fact] @@ -145,7 +145,7 @@ static void V(bool f) "; string expectedOutput = @"tttttttttt"; - var verifier = CompileAndVerify(source: source, expectedOutput: expectedOutput); + _ = CompileAndVerify(source: source, expectedOutput: expectedOutput); } [Fact, WorkItem(529279, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529279")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 555afcb943e27..b0f7f41c2a6cb 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -87333,8 +87333,7 @@ public override void F2(T22 t2) } } "; - - var comp2 = CreateCompilation(new[] { source2 }, options: WithNullableEnable(), references: new[] { comp1.EmitToImageReference() }) + _ = CreateCompilation(new[] { source2 }, options: WithNullableEnable(), references: new[] { comp1.EmitToImageReference() }) .VerifyDiagnostics( // (4,26): error CS0115: 'B.F1(T11?)': no suitable method found to override // public override void F1(T11? t1) @@ -87375,8 +87374,7 @@ public override void F2(T22 t2) } } "; - - var comp3 = CreateCompilation(new[] { source3 }, options: WithNullableEnable(), + _ = CreateCompilation(new[] { source3 }, options: WithNullableEnable(), references: new[] { comp1.EmitToImageReference() }, parseOptions: TestOptions.Regular8).VerifyDiagnostics( // (4,26): error CS0115: 'B.F1(T11?)': no suitable method found to override @@ -116020,14 +116018,13 @@ public void TestMeetForNullableFlowStatesIsAssociative() [Fact] public void TestEnsureCompatibleIsAssociative() { - Func identity = x => x; foreach (var a in s_AllNullableAnnotations) { foreach (var b in s_AllNullableAnnotations) { foreach (var c in s_AllNullableAnnotations) { - foreach (bool isPossiblyNullableReferenceTypeTypeParameter in new[] { true, false }) + foreach (var _ in new[] { true, false }) { var leftFirst = a.EnsureCompatible(b).EnsureCompatible(c); var rightFirst = a.EnsureCompatible(b.EnsureCompatible(c)); @@ -116055,7 +116052,6 @@ public void TestJoinForNullableAnnotationsIsCommutative() [Fact] public void TestJoinForNullableFlowStatesIsCommutative() { - Func identity = x => x; foreach (var a in s_AllNullableFlowStates) { foreach (var b in s_AllNullableFlowStates) @@ -126846,7 +126842,7 @@ class C2 : I void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (13,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(13, 12), @@ -126879,7 +126875,7 @@ class C2 : I void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (13,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T)").WithLocation(13, 12), @@ -126912,7 +126908,7 @@ class C2 : I void I.Goo(T value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (10,17): warning CS8767: Nullability of reference types in type of parameter 'value' of 'void C1.Goo(T value)' doesn't match implicitly implemented member 'void I.Goo(T? value)' (possibly because of nullability attributes). // public void Goo(T value) where T : class { } Diagnostic(ErrorCode.WRN_TopLevelNullabilityMismatchInParameterTypeOnImplicitImplementation, "Goo").WithArguments("value", "void C1.Goo(T value)", "void I.Goo(T? value)").WithLocation(10, 17), @@ -126944,7 +126940,7 @@ void I.Goo(T value) { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -126970,7 +126966,7 @@ void I.Goo(T value) { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -126997,7 +126993,7 @@ void I.Goo(T value) { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -127024,7 +127020,7 @@ class C2 : I where U : class U? I.Goo(T? value) => default; } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (11,15): warning CS8766: Nullability of reference types in return type of 'U? C1.Goo(T value)' doesn't match implicitly implemented member 'U I.Goo(T value)' (possibly because of nullability attributes). // public U? Goo(T value) => default; Diagnostic(ErrorCode.WRN_TopLevelNullabilityMismatchInReturnTypeOnImplicitImplementation, "Goo").WithArguments("U? C1.Goo(T value)", "U I.Goo(T value)").WithLocation(11, 15), @@ -127065,7 +127061,7 @@ class C2 : I where U : class "; //As a result of https://github.com/dotnet/roslyn/issues/34583 these don't test anything useful at the moment - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (11,15): warning CS8766: Nullability of reference types in return type of 'U? C1.Goo(T value)' doesn't match implicitly implemented member 'U I.Goo(T value)' (possibly because of nullability attributes). // public U? Goo(T value) => default; Diagnostic(ErrorCode.WRN_TopLevelNullabilityMismatchInReturnTypeOnImplicitImplementation, "Goo").WithArguments("U? C1.Goo(T value)", "U I.Goo(T value)").WithLocation(11, 15), @@ -127097,7 +127093,7 @@ class C2 : I void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(9, 12)); @@ -127121,7 +127117,7 @@ public void Goo(T? value) where T : struct { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(9, 12)); @@ -127145,7 +127141,7 @@ public void Goo(T? value) where T : class { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -127166,7 +127162,7 @@ public void Goo(T? value) where T : struct { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(9, 12)); @@ -127190,7 +127186,7 @@ public void Goo(T? value) where T : class { } void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [Fact] @@ -127210,7 +127206,7 @@ class C2 : I void I.Goo(T? value) { } } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(9, 12)); @@ -127234,7 +127230,7 @@ class C2 : I string I.Goo(T? value) => ""42""; } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,12): error CS0535: 'C2' does not implement interface member 'I.Goo(T?)' // class C2 : I Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("C2", "I.Goo(T?)").WithLocation(9, 12), @@ -127264,7 +127260,7 @@ class C2 : I object? I.Goo(T? value) => 42; } "; - var comp = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (9,7): error CS8646: 'I.Goo(T?)' is explicitly implemented more than once. // class C2 : I Diagnostic(ErrorCode.ERR_DuplicateExplicitImpl, "C2").WithArguments("I.Goo(T?)").WithLocation(9, 7), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableTests.cs index b4c682930ec83..d0580cf781b10 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableTests.cs @@ -210,7 +210,7 @@ static void Main() }"; verifier = CompileAndVerify(source: source3, expectedOutput: "1", verify: Verification.Fails); - verifier = CompileAndVerify(source: source3, expectedOutput: "1", parseOptions: TestOptions.Regular.WithPEVerifyCompatFeature()); + _ = CompileAndVerify(source: source3, expectedOutput: "1", parseOptions: TestOptions.Regular.WithPEVerifyCompatFeature()); } [Fact, WorkItem(543954, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543954")] @@ -326,7 +326,7 @@ static void F(int line, bool b) foreach (string type in new[] { "uint", "short", "sbyte", "ulong", "double", "decimal" }) { string expected = "0"; - var verifier = CompileAndVerify(source: source.Replace("TYPE", type), expectedOutput: expected); + _ = CompileAndVerify(source: source.Replace("TYPE", type), expectedOutput: expected); } } @@ -386,7 +386,7 @@ static void F(int line, bool b) } "; - var verifier = CompileAndVerify(source: source, expectedOutput: "1"); + _ = CompileAndVerify(source: source, expectedOutput: "1"); } [Fact] @@ -539,8 +539,7 @@ static void Test(bool b) -TTFF1TTFF2TTFF3TTFF4TTFF +TFTF1TTF2TFTF3TTF4TFTF5TFTF6TFTF ~TTF1TTF2TTF3TTF4TTF"; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } [Fact] @@ -605,8 +604,7 @@ static void Test(bool b) TF!x TF+x TF-x"; - - var verifier = CompileAndVerify(source: source, expectedOutput: expected); + _ = CompileAndVerify(source: source, expectedOutput: expected); } [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7803")] @@ -753,7 +751,7 @@ static void Test(bool b) foreach (string t in types) { string s = source.Replace("TYPE", t).Replace("OP", oper).Replace("ZERO", zeros[t]).Replace("ONE", ones[t]); - var verifier = CompileAndVerify(source: s, expectedOutput: expected); + _ = CompileAndVerify(source: s, expectedOutput: expected); } } @@ -1315,8 +1313,7 @@ static void METHOD_TYPEX_NAME_TYPEY() source.Append(main); source.Append("} }"); - - var verifier = CompileAndVerify(source: source.ToString(), expectedOutput: ""); + _ = CompileAndVerify(source: source.ToString(), expectedOutput: ""); } [Fact] @@ -1410,9 +1407,7 @@ static void Main() F((sxnn << null).HasValue);"; source += "}}"; - - - var verifier = CompileAndVerify(source: source, expectedOutput: ""); + _ = CompileAndVerify(source: source, expectedOutput: ""); } [Fact] @@ -1610,8 +1605,7 @@ static void Main() } }"; - - var verifier = CompileAndVerify(source: source, expectedOutput: ""); + _ = CompileAndVerify(source: source, expectedOutput: ""); } [Fact] @@ -1655,8 +1649,7 @@ static void Main() static void T(int x, bool b) { if (!b) throw new Exception(x.ToString()); } static void F(int x, bool b) { if (b) throw new Exception(x.ToString()); } }"; - - var verifier = CompileAndVerify(source: source, expectedOutput: "123"); + _ = CompileAndVerify(source: source, expectedOutput: "123"); } #region "Regression" @@ -1674,7 +1667,7 @@ static void Main() Console.WriteLine(0); } }"; - var verifier = CompileAndVerify(source: source2, expectedOutput: "0"); + _ = CompileAndVerify(source: source2, expectedOutput: "0"); } [Fact, WorkItem(544001, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544001")] @@ -1771,8 +1764,7 @@ static void Main() } "; string expected = @"0: 1:1.11 2:2 3: 4:4 5:0 6:6 7: 8:"; - - var verifier = CompileAndVerify(source, expectedOutput: expected); + _ = CompileAndVerify(source, expectedOutput: expected); } [Fact, WorkItem(544006, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544006")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs index 3e106a36789ee..80967ce195aa3 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs @@ -4808,7 +4808,7 @@ public static D Dynamic_b_not_null_a_nullable(int? c) } } "; - var compilation = CreateCompilation(source).VerifyDiagnostics(); + _ = CreateCompilation(source).VerifyDiagnostics(); } [WorkItem(541147, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541147")] @@ -11019,7 +11019,7 @@ public static void Main(string[] args) } } "; - var compilation = CreateCompilation(source) + _ = CreateCompilation(source) .VerifyDiagnostics( // (6,17): warning CS0183: The given expression is always of the provided ('string') type // var x = d is string; @@ -11042,7 +11042,7 @@ public static void Main(string[] args) if (t is ValueTuple) { } // goldilocks } }"; - var compilation = CreateCompilationWithMscorlib40(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }) + _ = CreateCompilationWithMscorlib40(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }) .VerifyDiagnostics( // (7,13): warning CS0184: The given expression is never of the provided ('(long, int)') type // if (t is ValueTuple) { } // too big diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs index 99740a7cd5898..aa5675a309a53 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs @@ -17832,7 +17832,7 @@ static void Test(out int x) ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); Assert.False(GetOutVarDeclarations(tree).Any()); } @@ -17893,7 +17893,7 @@ static void Test(out System.Collections.Generic.IEnumerable x) ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); Assert.False(GetOutVarDeclarations(tree).Any()); } @@ -22995,7 +22995,7 @@ public static void Main() ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); Assert.False(GetOutVarDeclarations(tree, "x3").Any()); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs index 3b592a4aab8f7..8ed94fa7a76f6 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs @@ -372,7 +372,6 @@ protected static void VerifyModelNotSupported( Assert.Null(model.GetDeclaredSymbol(designation)); var symbol = (ISymbol)model.GetDeclaredSymbol(designation); - if (designation.Parent is DeclarationPatternSyntax decl) { Assert.Null(model.GetSymbolInfo(decl.Type).Symbol); @@ -394,7 +393,7 @@ protected static void VerifyModelNotSupported( Assert.Equal(typeInfo, ((CSharpSemanticModel)model).GetTypeInfo(decl.Type)); Assert.True(model.GetConversion(decl.Type).IsIdentity); } - else if (designation.Parent is VarPatternSyntax varp) + else if (designation.Parent is VarPatternSyntax) { // Do we want to add any tests for the var pattern? } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs index 1275d10afbd0e..73443cc34f047 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs @@ -123,7 +123,7 @@ 4. 12 // Console.WriteLine("7. {0}", (x is bool is bool)); Diagnostic(ErrorCode.WRN_IsAlwaysTrue, "x is bool is bool").WithArguments("bool") ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -261,7 +261,7 @@ public D(object o) : this(o is int x && x >= 5) {} @"False True False"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -3418,7 +3418,7 @@ public static void Main(string[] args) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: "whatever"); + _ = CompileAndVerify(compilation, expectedOutput: "whatever"); } [Fact, WorkItem(12996, "https://github.com/dotnet/roslyn/issues/12996")] @@ -3851,7 +3851,7 @@ static int Ver(string s) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"0123 123 goo throws"); } @@ -3884,7 +3884,7 @@ static int M(int? data) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"1 thrown"); } @@ -3917,7 +3917,7 @@ static string M(object data) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"1 thrown"); } @@ -3966,7 +3966,7 @@ static async Task Bar(int i) references: new[] { MscorlibRef_v4_0_30316_17626, SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929 }); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"making exception 2 thrown 2"); } @@ -3996,7 +3996,7 @@ public static void Main(string[] args) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"blue"); } @@ -4033,7 +4033,7 @@ public MyException(string message) : base(message) {} var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"green"); } @@ -4068,7 +4068,7 @@ class B public static int operator +(bool left, B right) => 8; } "; - var compilation = CreateCompilation(source, options: TestOptions.DebugExe, + _ = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular6).VerifyDiagnostics( // (15,27): error CS8059: Feature 'pattern matching' is not available in C# 6. Please use language version 7.0 or greater. // Console.WriteLine(3 is One + 2); // should print True @@ -4089,7 +4089,7 @@ class B 7 True True"; - compilation = CreateCompilation(source, options: TestOptions.DebugExe); + CSharpCompilation compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( // (15,27): warning CS8417: The given expression always matches the provided constant. // Console.WriteLine(3 is One + 2); // should print True @@ -4098,7 +4098,7 @@ class B // Console.WriteLine(One + 2 is 3); // should print True Diagnostic(ErrorCode.WRN_GivenExpressionAlwaysMatchesConstant, "One + 2 is 3").WithLocation(16, 27) ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(10492, "https://github.com/dotnet/roslyn/issues/10492")] @@ -4145,7 +4145,7 @@ class D {} yes"; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(10492, "https://github.com/dotnet/roslyn/issues/10492")] @@ -4227,7 +4227,7 @@ class nameof { } True"; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(14825, "https://github.com/dotnet/roslyn/issues/14825")] @@ -4543,7 +4543,7 @@ override public bool Equals(object other) "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: @"False + _ = CompileAndVerify(compilation, expectedOutput: @"False False True"); } @@ -4570,7 +4570,7 @@ public static void Main() "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: "True"); + _ = CompileAndVerify(compilation, expectedOutput: "True"); } [Fact] @@ -4600,7 +4600,7 @@ public class Color "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: "True"); + _ = CompileAndVerify(compilation, expectedOutput: "True"); } [Fact] @@ -4851,7 +4851,7 @@ public static void Main(string[] args) if (((int?)1) is {} and 1) { } } }"; - var compilation = CreateCompilation(program, parseOptions: TestOptions.RegularWithPatternCombinators).VerifyDiagnostics( + _ = CreateCompilation(program, parseOptions: TestOptions.RegularWithPatternCombinators).VerifyDiagnostics( ); } @@ -4867,7 +4867,7 @@ public static void Main(string[] args) } private static object M() => null; }"; - var compilation = CreateCompilation(program, parseOptions: TestOptions.RegularWithPatternCombinators).VerifyDiagnostics( + _ = CreateCompilation(program, parseOptions: TestOptions.RegularWithPatternCombinators).VerifyDiagnostics( // (6,13): error CS0841: Cannot use local variable 'NotFound' before it is declared // if (NotFound is var (M, not int _ or NotFound _) { }) {} Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "NotFound").WithArguments("NotFound").WithLocation(6, 13), @@ -5097,7 +5097,7 @@ class Derived : Base "; var compilation = CreateCompilation(program, options: TestOptions.DebugExe).VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"TBase + _ = CompileAndVerify(compilation, expectedOutput: @"TBase TDerived Neither TBase @@ -5138,7 +5138,7 @@ class Derived : Base { } "; - var compilation = CreateCompilation(program).VerifyDiagnostics( + _ = CreateCompilation(program).VerifyDiagnostics( // (12,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match. // case TDerived td: Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "TDerived td").WithLocation(12, 18) @@ -5164,7 +5164,7 @@ private static void Pattern(T thing) where T : class } } "; - var compilation = CreateCompilation(program).VerifyDiagnostics( + _ = CreateCompilation(program).VerifyDiagnostics( // (11,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match. // case IEnumerable s: Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "IEnumerable s").WithLocation(11, 18) @@ -5219,7 +5219,7 @@ public static void Main(string[] args) var compilation = CreateCompilation(program, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"1 + _ = CompileAndVerify(compilation, expectedOutput: @"1 2 3 1 @@ -5295,7 +5295,7 @@ public static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(17103, "https://github.com/dotnet/roslyn/issues/17103")] @@ -5594,7 +5594,7 @@ void M15() var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -5764,7 +5764,7 @@ public static void Main(string[] args) } "; var compilation = CreateCompilation(source, references: new MetadataReference[] { CSharpRef }, options: TestOptions.ReleaseExe); - var comp = CompileAndVerify(compilation, expectedOutput: "roslyn"); + _ = CompileAndVerify(compilation, expectedOutput: "roslyn"); } [Fact, WorkItem(16195, "https://github.com/dotnet/roslyn/issues/16195")] @@ -6061,7 +6061,7 @@ static void M(object x) var compilation = CreateCompilation(program, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"TnT"); + _ = CompileAndVerify(compilation, expectedOutput: @"TnT"); } [Fact, WorkItem(19038, "https://github.com/dotnet/roslyn/issues/19038")] @@ -6094,7 +6094,7 @@ static void M(T? x) where T : struct var compilation = CreateCompilation(program, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"TnT"); + _ = CompileAndVerify(compilation, expectedOutput: @"TnT"); } [Fact, WorkItem(16195, "https://github.com/dotnet/roslyn/issues/16195")] @@ -6122,7 +6122,7 @@ static void Main() var compilation = CreateCompilation(program, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular7_1); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"FalseTrueFalseFalse"); + _ = CompileAndVerify(compilation, expectedOutput: @"FalseTrueFalseFalse"); } [Fact, WorkItem(19038, "https://github.com/dotnet/roslyn/issues/19038")] @@ -6213,7 +6213,7 @@ static int CopyRefInt(ref int z) var compilation = CreateCompilation(program, options: TestOptions.DebugExe.WithAllowUnsafe(true)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: "ok"); + _ = CompileAndVerify(compilation, expectedOutput: "ok"); } [Fact] @@ -6466,7 +6466,7 @@ private static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(23100, "https://github.com/dotnet/roslyn/issues/23100")] @@ -6645,7 +6645,7 @@ public static void M(bool e) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"True False True @@ -6697,7 +6697,7 @@ public static bool M2(bool e) var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"True False True diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests2.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests2.cs index 27e9b44e66d2d..382cd489080c2 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests2.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests2.cs @@ -37,7 +37,7 @@ public static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"1"); + _ = CompileAndVerify(compilation, expectedOutput: @"1"); } [Fact] @@ -79,7 +79,7 @@ public void Deconstruct(out int X, out int Y) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: ""); + _ = CompileAndVerify(compilation, expectedOutput: ""); } [Fact] @@ -125,7 +125,7 @@ public static void Deconstruct(this Point p, out int X, out int Y) var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularWithRecursivePatterns); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: ""); + _ = CompileAndVerify(compilation, expectedOutput: ""); } [Fact] @@ -198,7 +198,7 @@ private static bool Check(T expected, T actual) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: ""); + _ = CompileAndVerify(compilation, expectedOutput: ""); } [Fact] @@ -240,7 +240,7 @@ public void Deconstruct(out int X, out int Y) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: ""); + _ = CompileAndVerify(compilation, expectedOutput: ""); } [Fact] @@ -331,7 +331,7 @@ public void Deconstruct(out int X, out int Y) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: "True"); + _ = CompileAndVerify(compilation, expectedOutput: "True"); } [Fact] @@ -794,7 +794,7 @@ private static void Check(T expected, T actual) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @""); + _ = CompileAndVerify(compilation, expectedOutput: @""); } [Fact] @@ -895,7 +895,7 @@ public ValueTuple(T1 item1, T2 item2) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"0123"); + _ = CompileAndVerify(compilation, expectedOutput: @"0123"); } [Fact] @@ -991,7 +991,7 @@ public ValueTuple(T1 item1, T2 item2) var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"0123"); + _ = CompileAndVerify(compilation, expectedOutput: @"0123"); } [Fact] @@ -1040,7 +1040,7 @@ public static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"9 + _ = CompileAndVerify(compilation, expectedOutput: @"9 9 9"); } @@ -1103,7 +1103,7 @@ class Frog var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"12345678"); + _ = CompileAndVerify(compilation, expectedOutput: @"12345678"); } [Fact] @@ -1420,7 +1420,7 @@ public static void Main() compilation.VerifyDiagnostics(); var expectedOutput = @"True 3"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1508,7 +1508,7 @@ class Cat {} var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"Fox Cat"); + _ = CompileAndVerify(compilation, expectedOutput: @"Fox Cat"); } [Fact, WorkItem(25934, "https://github.com/dotnet/roslyn/issues/25934")] @@ -1585,7 +1585,7 @@ static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"111"); + _ = CompileAndVerify(compilation, expectedOutput: @"111"); } [Fact, WorkItem(25934, "https://github.com/dotnet/roslyn/issues/25934")] @@ -1754,7 +1754,7 @@ class T var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"111"); + _ = CompileAndVerify(compilation, expectedOutput: @"111"); } [Fact, WorkItem(25934, "https://github.com/dotnet/roslyn/issues/25934")] @@ -1790,7 +1790,7 @@ static class Extensions var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"111"); + _ = CompileAndVerify(compilation, expectedOutput: @"111"); } [Fact, WorkItem(25934, "https://github.com/dotnet/roslyn/issues/25934")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests3.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests3.cs index c683ac336649b..97206ed6af933 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests3.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests3.cs @@ -420,7 +420,7 @@ public static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(35278, "https://github.com/dotnet/roslyn/issues/35278")] @@ -470,7 +470,7 @@ public static RGBColor FromRainbow(Rainbow colorBand) => var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(35278, "https://github.com/dotnet/roslyn/issues/35278")] @@ -592,7 +592,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -635,7 +635,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -678,7 +678,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -721,7 +721,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -745,7 +745,7 @@ static void Main(string[] args) var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -768,7 +768,7 @@ static void Main(string[] args) var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -811,7 +811,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -853,7 +853,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1035,7 +1035,7 @@ class TargetSubtype : Target var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1088,7 +1088,7 @@ class Ultimate var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1141,7 +1141,7 @@ class Ultimate var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1194,7 +1194,7 @@ class Ultimate var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(NullableContextOptions.Disable)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1695,7 +1695,7 @@ class Source2 var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [WorkItem(40295, "https://github.com/dotnet/roslyn/issues/40295")] @@ -2092,7 +2092,7 @@ class G { } var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(40149, "https://github.com/dotnet/roslyn/issues/40149")] @@ -2164,7 +2164,7 @@ class G { } var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(40149, "https://github.com/dotnet/roslyn/issues/40149")] @@ -2236,7 +2236,7 @@ class G { } var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(40149, "https://github.com/dotnet/roslyn/issues/40149")] @@ -2285,7 +2285,7 @@ public class D { } var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(40149, "https://github.com/dotnet/roslyn/issues/40149")] @@ -2334,7 +2334,7 @@ public class D { } var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -2540,7 +2540,7 @@ static void M1({typeName} i) var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } } @@ -2578,7 +2578,7 @@ static void M1({typeName} i) var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } } @@ -2649,7 +2649,7 @@ static void M1(object i) var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9), options: TestOptions.DebugExe); compilation.VerifyDiagnostics( ); - var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } } @@ -2813,7 +2813,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } } @@ -2872,7 +2872,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } } @@ -3277,7 +3277,7 @@ class Q: System.Runtime.CompilerServices.ITuple var compilation = CreateCompilation(source + _iTupleSource, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(43377, "https://github.com/dotnet/roslyn/issues/43377")] @@ -3365,7 +3365,7 @@ class X : IIn, IOut { } var compilation = CreateCompilation(source + _iTupleSource, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -4968,7 +4968,7 @@ void runTest() var compilation = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } void shuffle(ArrayBuilder cases) @@ -5252,7 +5252,7 @@ public static void Equal(T expected, T value) var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9)); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: "Done"); + _ = CompileAndVerify(compilation, expectedOutput: "Done"); } [InlineData("nint", "int")] @@ -5541,7 +5541,7 @@ static void Main() // str = x switch // does not handle zero Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("0").WithLocation(15, 17) ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -6013,7 +6013,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.RegularWithPatternCombinators); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -6034,7 +6034,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.RegularWithPatternCombinators); compilation.VerifyDiagnostics( ); - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests4.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests4.cs index b070426011afd..0f36d2e3b543e 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests4.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests4.cs @@ -197,7 +197,7 @@ public static void Main() False False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -290,7 +290,7 @@ public static void Main() True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -321,7 +321,7 @@ public static void Main() True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -352,7 +352,7 @@ public static void Main() True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -384,7 +384,7 @@ public void Deconstruct() {} True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -415,7 +415,7 @@ public static void Main() True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -447,7 +447,7 @@ public void Deconstruct() {} True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -481,7 +481,7 @@ public static void M(T t) where T: C True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -515,7 +515,7 @@ public static void M(T t) where T: ITuple True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -603,7 +603,7 @@ public void Deconstruct() {} True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -637,7 +637,7 @@ public static void M(T t) where T: C True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -704,7 +704,7 @@ public static void M(T t) where T: C True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -742,7 +742,7 @@ public static void M(T t) where T: C True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -777,7 +777,7 @@ static class Extensions True False False"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -813,7 +813,7 @@ static class Extensions False True True"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -924,7 +924,7 @@ public static void Main() Diagnostic(ErrorCode.WRN_DeprecatedSymbolStr, "System.Runtime.CompilerServices.ITuple").WithArguments("System.Runtime.CompilerServices.ITuple", "WarningOnly").WithLocation(11, 18) ); var expectedOutput = @"True"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1037,7 +1037,7 @@ static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics(); var expectedOutput = @"1 1 2; 2 3 4; "; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1072,7 +1072,7 @@ static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics(); var expectedOutput = @"1 1 2; 2 3 4; "; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1138,7 +1138,7 @@ object ITuple.this[int index] compilation.VerifyDiagnostics(); var expectedOutput = @"0 a b; 1 1 2; 2 3 4; "; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1203,7 +1203,7 @@ object ITuple.this[int index] var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics(); var expectedOutput = @"0 a b; 1 1 2; 2 3 4; "; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1254,7 +1254,7 @@ public struct ValueTuple var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics(); var expectedOutput = @""; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1294,7 +1294,7 @@ static void Main() var compilation = CreatePatternCompilation(source); compilation.VerifyDiagnostics(); var expectedOutput = @"1 1 2; 2 3 4; "; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -2963,7 +2963,7 @@ static unsafe void M(int i, int* p) compilation.VerifyDiagnostics( ); var expectedOutput = @"12"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); } // https://github.com/dotnet/roslyn/issues/35032: Handle switch expressions correctly @@ -2990,7 +2990,7 @@ static unsafe void M(int i, int* p) compilation.VerifyDiagnostics( ); var expectedOutput = @"12"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); } [Fact] @@ -3016,7 +3016,7 @@ static unsafe void M(int i, int* p) compilation.VerifyDiagnostics( ); var expectedOutput = @"1"; - var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput, verify: Verification.Skipped); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs index 1ea2d6a668273..08acfc12158c3 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs @@ -5935,7 +5935,7 @@ class H ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); @@ -6107,7 +6107,7 @@ class H ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); @@ -6193,7 +6193,7 @@ class H ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); @@ -6318,7 +6318,7 @@ public static void Dummy(params object[] x) {} var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); @@ -6347,7 +6347,7 @@ public static void Dummy(params object[] x) {} ); var tree = compilation.SyntaxTrees.Single(); - var model = compilation.GetSemanticModel(tree); + _ = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternSwitchTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternSwitchTests.cs index b1c1e8157c1eb..7d47a2d385b30 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternSwitchTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternSwitchTests.cs @@ -401,7 +401,7 @@ public static void M(bool? b) @"True False null"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(10601, "https://github.com/dotnet/roslyn/issues/10601")] @@ -848,7 +848,7 @@ public static void Main() Diagnostic(ErrorCode.WRN_GotoCaseShouldConvert, "goto case 1;").WithArguments("Color").WithLocation(17, 17) ); var expectedOutput = @"done"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -893,7 +893,7 @@ public static void M(object o) var expectedOutput = @"1 sasquatch"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -999,7 +999,7 @@ public static void M(object o) decimal {2.1m} 1.0m ! null"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [ConditionalFact(typeof(IsEnglishLocal))] @@ -1190,7 +1190,7 @@ public static double MakeNaN(int x) double.NaN double.NaN float.NaN"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(12573, "https://github.com/dotnet/roslyn/issues/12573")] @@ -1248,7 +1248,7 @@ public enum EnumA (byte)0 EnumA.ValueA Default"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(10446, "https://github.com/dotnet/roslyn/issues/10446")] @@ -1324,7 +1324,7 @@ public static bool IsB(char value) compilation.VerifyDiagnostics(); var expectedOutput = @"True"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(13520, "https://github.com/dotnet/roslyn/issues/13520")] @@ -1715,7 +1715,7 @@ bool Local(object o2) False True False"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1756,7 +1756,7 @@ static bool BP(bool b, int print) 4 Correct 4"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact, WorkItem(14707, "https://github.com/dotnet/roslyn/issues/14707")] @@ -1854,7 +1854,7 @@ class A{} var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); var expectedOutput = "A"; - var comp = CompileAndVerify(compilation, expectedOutput: expectedOutput); + _ = CompileAndVerify(compilation, expectedOutput: expectedOutput); } [Fact] @@ -1900,7 +1900,7 @@ static void Main(string[] args) "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 case 2: 2 case 1: 3 @@ -1962,7 +1962,7 @@ static System.Collections.Generic.IEnumerable Test() "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 case 2: 2 case 1: 3 @@ -2018,7 +2018,7 @@ static System.Collections.Generic.IEnumerable Test() "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 1 case 2: 2 @@ -2076,7 +2076,7 @@ static System.Collections.Generic.IEnumerable Test() "; var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 1 case 2: 2 @@ -2125,7 +2125,7 @@ static bool TakeOutVar(out int x) "; var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case: 3 3"); } @@ -2189,7 +2189,7 @@ static async Task GetTask(string val) // Use a compilation profile that supports Task. var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 case 2: 2 case 1: 3 @@ -2254,7 +2254,7 @@ static async Task GetTask(string val) // Use a compilation profile that supports Task. var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 1 case 2: 2 @@ -2314,7 +2314,7 @@ static async Task Test() // Use a compilation profile that supports Task. var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case 1: 1 1 case 2: 2 @@ -2370,7 +2370,7 @@ static async Task GetTask(string val) // Use a compilation profile that supports Task. var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"case: 3 3"); } @@ -2411,7 +2411,7 @@ public static async Task SendMessageAsync(object response) // public static async Task SendMessageAsync(object response) Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "SendMessageAsync").WithLocation(12, 38) ); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"T default"); } @@ -2450,7 +2450,7 @@ public static string SendMessage(object input) "; var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"T default"); } @@ -2492,7 +2492,7 @@ public static System.Collections.Generic.IEnumerable SendMessage(obje "; var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: + _ = CompileAndVerify(compilation, expectedOutput: @"T default"); } @@ -2554,7 +2554,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"pass"); + _ = CompileAndVerify(compilation, expectedOutput: @"pass"); } [Fact] @@ -2582,7 +2582,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"pass"); + _ = CompileAndVerify(compilation, expectedOutput: @"pass"); } [Fact] @@ -2610,7 +2610,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"1"); + _ = CompileAndVerify(compilation, expectedOutput: @"1"); } [Fact] @@ -2701,7 +2701,7 @@ static void Main() var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( ); - var comp = CompileAndVerify(compilation, expectedOutput: @"pass"); + _ = CompileAndVerify(compilation, expectedOutput: @"pass"); } [Fact] @@ -2920,7 +2920,7 @@ static void Main(string[] args) var compilation = CreateCompilationWithMscorlib40( source, options: TestOptions.ReleaseExe, references: new[] { SystemRuntimeFacadeRef, ValueTupleRef }); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation, expectedOutput: "Main"); + _ = CompileAndVerify(compilation, expectedOutput: "Main"); } [Fact, WorkItem(18948, "https://github.com/dotnet/roslyn/issues/18948")] @@ -2950,7 +2950,7 @@ public static async Task SwitchWithAwaitInPatternFails(Task self, T defaul var compilation = CreateCompilationWithMscorlib45( source, options: TestOptions.ReleaseDll.WithOptimizationLevel(OptimizationLevel.Release), references: new[] { SystemCoreRef, CSharpRef }); compilation.VerifyDiagnostics(); - var comp = CompileAndVerify(compilation); + _ = CompileAndVerify(compilation); } [Fact, WorkItem(388743, "https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=388743")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/QueryTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/QueryTests.cs index 0476d3b9dddde..9e990d6a2b166 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/QueryTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/QueryTests.cs @@ -3162,7 +3162,7 @@ public static void Main () var index = source.IndexOf("join int delegate in expr2 on i equals delegate", StringComparison.Ordinal); var joinNode = tree.GetCompilationUnitRoot().FindToken(index).Parent as JoinClauseSyntax; var model = compilation.GetSemanticModel(tree); - var queryInfo = model.GetQueryClauseInfo(joinNode); + _ = model.GetQueryClauseInfo(joinNode); // https://github.com/dotnet/roslyn/issues/38509 // Assert.NotEqual(default, queryInfo); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs index 4fe37305c5c55..f14260707c963 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs @@ -101,7 +101,7 @@ public static void Main() Console.WriteLine(s1.Equals(new S(1, 0))); } }"; - var verifier = CompileAndVerify(src, expectedOutput: @"0 + _ = CompileAndVerify(src, expectedOutput: @"0 1 True False").VerifyDiagnostics(); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs index 9d48894caf363..ae0dcd51e234c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs @@ -8441,7 +8441,7 @@ public static void Main() Console.WriteLine((c with { X = (int)s }).X); } }"; - var verifier = CompileAndVerify(src, expectedOutput: @" + _ = CompileAndVerify(src, expectedOutput: @" conversion 11").VerifyDiagnostics(); } @@ -9613,7 +9613,7 @@ public static void Main() Console.WriteLine(c3.X); } }"; - var verifier = CompileAndVerify(src, expectedOutput: @" + _ = CompileAndVerify(src, expectedOutput: @" True False 1 @@ -22077,7 +22077,7 @@ public static void Main() var c = new C(1); } }"; - var verifier = CompileAndVerify(src, expectedOutput: @"1").VerifyDiagnostics(); + _ = CompileAndVerify(src, expectedOutput: @"1").VerifyDiagnostics(); } [Fact] @@ -24768,7 +24768,7 @@ public static void Main() Console.WriteLine(c.Z()); } }"; - var verifier = CompileAndVerify(src, expectedOutput: @" + _ = CompileAndVerify(src, expectedOutput: @" 101 202 303 diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index 42cd3670adbfe..8d8a8f531276f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -3256,7 +3256,7 @@ public class MyClass : Outer.base1 "; var comp = CreateCompilation(text); var type1 = comp.SourceModule.GlobalNamespace.GetMembers("MyClass").Single() as NamedTypeSymbol; - var b = type1.BaseType(); + _ = type1.BaseType(); var errs = comp.GetDiagnostics(); Assert.Equal(1, errs.Count()); Assert.Equal(122, errs.First().Code); @@ -11267,7 +11267,7 @@ void M(B b) [Fact()] public void CS0571ERR_CantCallSpecialMethod04() { - var compilation = CreateCompilation( + _ = CreateCompilation( @"public class MyClass { public static MyClass operator ++(MyClass c) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedConditionalOperatorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedConditionalOperatorTests.cs index 4966e95dab2a7..6419b1915e5db 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedConditionalOperatorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedConditionalOperatorTests.cs @@ -204,7 +204,7 @@ static void Main() "; foreach (var langVersion in new[] { LanguageVersion.CSharp8, MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion() }) { - var comp = CreateCompilation( + _ = CreateCompilation( source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(langVersion)) .VerifyDiagnostics(); @@ -226,7 +226,7 @@ static void Main() "; foreach (var langVersion in new[] { LanguageVersion.CSharp8, MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion() }) { - var comp = CreateCompilation( + _ = CreateCompilation( source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(langVersion)) .VerifyDiagnostics( diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedDefaultTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedDefaultTests.cs index ebf0618a26854..7845c419ad285 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedDefaultTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedDefaultTests.cs @@ -2425,7 +2425,7 @@ static void Main() var tree = comp.SyntaxTrees.First(); var model = comp.GetSemanticModel(tree); - var nodes = tree.GetCompilationUnitRoot().DescendantNodes(); + _ = tree.GetCompilationUnitRoot().DescendantNodes(); var digit = tree.GetCompilationUnitRoot().FindToken(source.IndexOf('2')); var expressionSyntax = SyntaxFactory.ParseExpression("default"); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs index 6bfae21029249..0cc28d5f7b9d7 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs @@ -8453,8 +8453,7 @@ unsafe static void Main() var model = comp.GetSemanticModel(tree); var parameterSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType().Single(); - - var info = model.GetSemanticInfoSummary(parameterSyntax.Type); + _ = model.GetSemanticInfoSummary(parameterSyntax.Type); } [Fact] @@ -9052,7 +9051,7 @@ unsafe static void Load() // Only compile this as its intentionally writing outside of fixed buffer boundaries and // this doesn't warn but causes flakiness when executed. - var comp3 = CompileAndVerify(s3, + _ = CompileAndVerify(s3, options: TestOptions.UnsafeReleaseDll, verify: Verification.Fails, references: new MetadataReference[] { MetadataReference.CreateFromImage(comp1.EmitToArray()) }).Compilation; } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UserDefinedConversionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UserDefinedConversionTests.cs index b7cb6641e57b9..f2084c70654dc 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UserDefinedConversionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UserDefinedConversionTests.cs @@ -1156,7 +1156,7 @@ public static void Main() // lifted operators, nullable conversions and unsafe code so only generate code for // the straightforward intptr/number conversions: - var verifier = CompileAndVerify(source: source1 + source3 + source5, options: TestOptions.UnsafeReleaseExe, expectedOutput: ""); + _ = CompileAndVerify(source: source1 + source3 + source5, options: TestOptions.UnsafeReleaseExe, expectedOutput: ""); } [Fact, WorkItem(543427, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543427")] @@ -1282,9 +1282,7 @@ public static implicit operator D(C x) return null; } }"; - - - var verifier = CompileAndVerify(source, expectedOutput: "23"); + _ = CompileAndVerify(source, expectedOutput: "23"); } [Fact, WorkItem(543436, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543436")] @@ -1309,8 +1307,7 @@ static void Main() Console.WriteLine(c.str); } }"; - - var verifier = CompileAndVerify(source, expectedOutput: "a"); + _ = CompileAndVerify(source, expectedOutput: "a"); } [Fact, WorkItem(543439, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543439")] @@ -1343,7 +1340,7 @@ static void Main() System.Console.WriteLine(c.str); } }"; - var verifier = CompileAndVerify(source, expectedOutput: "b"); + _ = CompileAndVerify(source, expectedOutput: "b"); } [Fact, WorkItem(543440, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543440")] @@ -1369,7 +1366,7 @@ public static implicit operator C(byte s) return c; } }"; - var verifier = CompileAndVerify(source, expectedOutput: "1"); + _ = CompileAndVerify(source, expectedOutput: "1"); } [Fact, WorkItem(543441, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543441")] @@ -1438,8 +1435,7 @@ static void Main() Console.WriteLine(c.str); } }"; - - var verifier = CompileAndVerify(source, expectedOutput: "a"); + _ = CompileAndVerify(source, expectedOutput: "a"); } [Fact, WorkItem(543595, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543595")] @@ -1470,8 +1466,7 @@ static void Main() var comp = CreateCompilation(source1); comp.VerifyDiagnostics(); - - var verifier = CompileAndVerify(source: source1, expectedOutput: ""); + _ = CompileAndVerify(source: source1, expectedOutput: ""); } [Fact, WorkItem(543598, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543598")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs index 1c6e6423ed72b..113b399d77da3 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs @@ -842,7 +842,7 @@ static void Main() } } }"; - var compilation = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15) @@ -871,8 +871,7 @@ static void Main() } } }"; - - var compilation = CreateCompilation(source).VerifyDiagnostics( + _ = CreateCompilation(source).VerifyDiagnostics( // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15), @@ -1129,7 +1128,7 @@ static async Task Main() } } }"; - var compilation = CreateCompilationWithTasksExtensions(new[] { source, IAsyncDisposableDefinition }).VerifyDiagnostics( + _ = CreateCompilationWithTasksExtensions(new[] { source, IAsyncDisposableDefinition }).VerifyDiagnostics( // (16,22): error CS4012: Parameters or locals of type 'S1' cannot be declared in async methods or async lambda expressions. // await using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_BadSpecialByRefLocal, "S1").WithArguments("S1").WithLocation(16, 22) diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs index 49a62ab5fc23f..62fdb28e09ddc 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs @@ -222,7 +222,7 @@ class GeneratedClass { } GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { testGenerator }, parseOptions: parseOptions); driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation1, out _); driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation2, out _); - driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation3, out _); + _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation3, out _); Assert.Equal(2, outputCompilation1.SyntaxTrees.Count()); Assert.Equal(2, outputCompilation2.SyntaxTrees.Count()); @@ -279,7 +279,7 @@ class C { } GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { testGenerator }, parseOptions: parseOptions); // try apply edits should fail if we've not run a full compilation yet - driver = driver.TryApplyEdits(compilation, out var outputCompilation, out var succeeded); + _ = driver.TryApplyEdits(compilation, out var outputCompilation, out var succeeded); Assert.False(succeeded); Assert.Equal(compilation, outputCompilation); } @@ -305,7 +305,7 @@ class C { } Assert.Single(outputCompilation.SyntaxTrees); // now try apply edits (which should succeed, but do nothing) - driver = driver.TryApplyEdits(compilation, out var editedCompilation, out var succeeded); + _ = driver.TryApplyEdits(compilation, out var editedCompilation, out var succeeded); Assert.True(succeeded); Assert.Equal(outputCompilation, editedCompilation); } @@ -334,7 +334,7 @@ class C { } driver = driver.WithPendingEdits(ImmutableArray.Create(edit)); // now try apply edits (which will fail) - driver = driver.TryApplyEdits(compilation, out var editedCompilation, out var succeeded); + _ = driver.TryApplyEdits(compilation, out var editedCompilation, out var succeeded); Assert.False(succeeded); Assert.Single(editedCompilation.SyntaxTrees); Assert.Equal(compilation, editedCompilation); @@ -365,7 +365,7 @@ class C { } driver = driver.WithPendingEdits(ImmutableArray.Create(edit)); // now try apply edits - driver = driver.TryApplyEdits(compilation, out outputCompilation, out var succeeded); + _ = driver.TryApplyEdits(compilation, out outputCompilation, out var succeeded); Assert.True(succeeded); Assert.Equal(2, outputCompilation.SyntaxTrees.Count()); } @@ -411,7 +411,7 @@ class C { } new AdditionalFileAddedEdit(new InMemoryAdditionalText("a\\file4.cs", "")), new AdditionalFileAddedEdit(new InMemoryAdditionalText("a\\file5.cs", "")))); // now try apply edits - driver = driver.TryApplyEdits(compilation, out editedCompilation, out succeeded); + _ = driver.TryApplyEdits(compilation, out editedCompilation, out succeeded); Assert.True(succeeded); Assert.Equal(6, editedCompilation.SyntaxTrees.Count()); } @@ -429,7 +429,7 @@ class C { } Assert.Single(compilation.SyntaxTrees); AdditionalFileAddedGenerator testGenerator = new AdditionalFileAddedGenerator(); - var text = new InMemoryAdditionalText("a\\file1.cs", ""); + _ = new InMemoryAdditionalText("a\\file1.cs", ""); GeneratorDriver driver = CSharpGeneratorDriver.Create(parseOptions: parseOptions, generators: ImmutableArray.Create(testGenerator), @@ -459,7 +459,7 @@ class C { } Assert.Equal(3, editedCompilation.SyntaxTrees.Count()); // if we run a full compilation again, we should still get 3 syntax trees - driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out outputCompilation, out _); + _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out outputCompilation, out _); Assert.Equal(3, outputCompilation.SyntaxTrees.Count()); } @@ -476,7 +476,7 @@ class C { } Assert.Single(compilation.SyntaxTrees); AdditionalFileAddedGenerator testGenerator = new AdditionalFileAddedGenerator(); - var text = new InMemoryAdditionalText("a\\file1.cs", ""); + _ = new InMemoryAdditionalText("a\\file1.cs", ""); GeneratorDriver driver = CSharpGeneratorDriver.Create(parseOptions: parseOptions, generators: ImmutableArray.Create(testGenerator), From 29528f95924c6c0f8aaaa5d000c7f7070dced945 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 19:46:25 -0700 Subject: [PATCH 25/63] Fix IDE0059: Unnecessary assignment --- .../Core/Portable/CodeGen/ILBuilder.cs | 4 +-- .../Portable/Collections/SmallDictionary.cs | 3 +- .../AnalyzerConfig.SectionNameMatching.cs | 2 +- src/Compilers/Core/Portable/CvtRes.cs | 2 +- .../DesktopAssemblyIdentityComparer.cs | 4 +-- .../SuppressMessageAttributeState.cs | 6 ++-- .../EditAndContinue/DeltaMetadataWriter.cs | 9 ++---- .../MetadataReader/MetadataDecoder.cs | 32 ++++++------------- .../MetadataReader/MetadataHelpers.cs | 3 +- .../Core/Portable/MetadataReader/PEModule.cs | 3 +- .../MetadataReader/TypeNameDecoder.cs | 3 +- .../AssemblyIdentity.DisplayName.cs | 2 +- .../MetadataReference/AssemblyIdentityMap.cs | 3 +- .../Operations/ControlFlowGraphBuilder.cs | 2 +- .../Core/Portable/PEWriter/MetadataWriter.cs | 3 +- src/Compilers/Core/Portable/RealParser.cs | 6 ++-- .../SourceGeneration/GeneratorDriver.cs | 4 +-- .../Portable/StrongName/CryptoBlobParser.cs | 14 ++++---- .../Core/Portable/Text/ChangedText.cs | 3 +- .../Core/Portable/Text/SourceTextStream.cs | 3 +- src/Compilers/Core/Portable/Text/TextLine.cs | 3 +- src/Compilers/Core/Portable/VersionHelper.cs | 2 +- 22 files changed, 43 insertions(+), 73 deletions(-) diff --git a/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs b/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs index 920d2e5e60c53..a621821b9a7f2 100644 --- a/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs +++ b/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs @@ -1003,7 +1003,7 @@ private void RealizeSequencePoints() /// internal void DefineSequencePoint(SyntaxTree syntaxTree, TextSpan span) { - var curBlock = GetCurrentBlock(); + _ = GetCurrentBlock(); _lastSeqPointTree = syntaxTree; if (this.SeqPointsOpt == null) @@ -1106,7 +1106,7 @@ internal void OpenLocalScope(ScopeType scopeType = ScopeType.Variable, Cci.IType } EndBlock(); //blocks should not cross scope boundaries. - var scope = _scopeManager.OpenScope(scopeType, exceptionType); + _ = _scopeManager.OpenScope(scopeType, exceptionType); // Exception handler scopes must have a leader block, even // if the exception handler is empty, and created before any diff --git a/src/Compilers/Core/Portable/Collections/SmallDictionary.cs b/src/Compilers/Core/Portable/Collections/SmallDictionary.cs index 2f3e636e8e75b..2e254c26127c2 100644 --- a/src/Compilers/Core/Portable/Collections/SmallDictionary.cs +++ b/src/Compilers/Core/Portable/Collections/SmallDictionary.cs @@ -105,8 +105,7 @@ public V this[K key] public bool ContainsKey(K key) { - V value; - return TryGetValue(key, out value!); + return TryGetValue(key, out _); } [Conditional("DEBUG")] diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs index 339cf6b54cc58..722bba10bbf3f 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs @@ -442,7 +442,7 @@ public SectionNameLexer(string sectionName) public TokenKind Lex() { - int lexemeStart = Position; + _ = Position; switch (_sectionName[Position]) { case '*': diff --git a/src/Compilers/Core/Portable/CvtRes.cs b/src/Compilers/Core/Portable/CvtRes.cs index ccf71f106b2a6..6da514b605975 100644 --- a/src/Compilers/Core/Portable/CvtRes.cs +++ b/src/Compilers/Core/Portable/CvtRes.cs @@ -706,7 +706,7 @@ private static void WriteVersionString(KeyValuePair keyValuePair ushort cbBlock = SizeofVerString(keyValuePair.Key, keyValuePair.Value); int cbKey = (keyValuePair.Key.Length + 1) * 2; // includes terminating NUL - int cbVal = (keyValuePair.Value.Length + 1) * 2; // includes terminating NUL + _ = (keyValuePair.Value.Length + 1) * 2; // includes terminating NUL var startPos = writer.BaseStream.Position; Debug.Assert((startPos & 3) == 0); diff --git a/src/Compilers/Core/Portable/Desktop/DesktopAssemblyIdentityComparer.cs b/src/Compilers/Core/Portable/Desktop/DesktopAssemblyIdentityComparer.cs index 431b106f2896f..ec351a41a4e69 100644 --- a/src/Compilers/Core/Portable/Desktop/DesktopAssemblyIdentityComparer.cs +++ b/src/Compilers/Core/Portable/Desktop/DesktopAssemblyIdentityComparer.cs @@ -179,8 +179,8 @@ private static bool IsFrameworkAssembly(AssemblyIdentity identity) private static bool IsRetargetableAssembly(AssemblyIdentity identity) { - bool retargetable, portable; - IsRetargetableAssembly(identity, out retargetable, out portable); + bool retargetable; + IsRetargetableAssembly(identity, out retargetable, out _); return retargetable; } diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs index 36055bc5db13a..a9d344f0d1597 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/SuppressMessageAttributeState.cs @@ -112,8 +112,7 @@ public Diagnostic ApplySourceSuppressions(Diagnostic diagnostic) return diagnostic; } - SuppressMessageInfo info; - if (IsDiagnosticSuppressed(diagnostic, out info)) + if (IsDiagnosticSuppressed(diagnostic, out SuppressMessageInfo _)) { // Attach the suppression info to the diagnostic. diagnostic = diagnostic.WithIsSuppressed(true); @@ -297,8 +296,7 @@ private static void AddOrUpdate(SuppressMessageInfo info, IDictionary 0) { - bool refersToNoPiaLocalType; - type = GetSymbolForTypeHandleOrThrow(sigReader.ReadTypeHandle(), out refersToNoPiaLocalType, allowTypeSpec: true, requireShortForm: true); + type = GetSymbolForTypeHandleOrThrow(sigReader.ReadTypeHandle(), out _, allowTypeSpec: true, requireShortForm: true); if (GetEnumUnderlyingType(type)?.SpecialType != specialType) { @@ -1303,9 +1296,7 @@ private void DecodeCustomAttributeParameterTypeOrThrow(ref BlobReader sigReader, throw new UnsupportedSignatureContent(); } - SerializationTypeCode unusedElementTypeCode; - TypeSymbol unusedElementType; - DecodeCustomAttributeParameterTypeOrThrow(ref sigReader, out elementTypeCode, out elementType, out unusedElementTypeCode, out unusedElementType, isElementType: true); + DecodeCustomAttributeParameterTypeOrThrow(ref sigReader, out elementTypeCode, out elementType, out _, out _, isElementType: true); type = GetSZArrayTypeSymbol(elementType, customModifiers: default(ImmutableArray>)); typeCode = SerializationTypeCode.SZArray; return; @@ -1397,9 +1388,7 @@ private void DecodeCustomAttributeFieldOrPropTypeOrThrow(ref BlobReader argReade throw new UnsupportedSignatureContent(); } - SerializationTypeCode unusedElementTypeCode; - TypeSymbol unusedElementType; - DecodeCustomAttributeFieldOrPropTypeOrThrow(ref argReader, out elementTypeCode, out elementType, out unusedElementTypeCode, out unusedElementType, isElementType: true); + DecodeCustomAttributeFieldOrPropTypeOrThrow(ref argReader, out elementTypeCode, out elementType, out _, out _, isElementType: true); type = GetSZArrayTypeSymbol(elementType, customModifiers: default(ImmutableArray>)); return; } @@ -1815,8 +1804,7 @@ private TypeSymbol[] DecodeMethodSpecTypeArgumentsOrThrow(BlobHandle signature) var result = new TypeSymbol[argumentCount]; for (int i = 0; i < result.Length; i++) { - bool refersToNoPiaLocalType; - result[i] = DecodeTypeOrThrow(ref signatureReader, out refersToNoPiaLocalType); + result[i] = DecodeTypeOrThrow(ref signatureReader, out _); } return result; diff --git a/src/Compilers/Core/Portable/MetadataReader/MetadataHelpers.cs b/src/Compilers/Core/Portable/MetadataReader/MetadataHelpers.cs index fa2721e6fce14..d1a47a93254de 100644 --- a/src/Compilers/Core/Portable/MetadataReader/MetadataHelpers.cs +++ b/src/Compilers/Core/Portable/MetadataReader/MetadataHelpers.cs @@ -485,8 +485,7 @@ internal static string ComposeAritySuffixedMetadataName(string name, int arity) internal static int InferTypeArityFromMetadataName(string emittedTypeName) { - int suffixStartsAt; - return InferTypeArityFromMetadataName(emittedTypeName, out suffixStartsAt); + return InferTypeArityFromMetadataName(emittedTypeName, out _); } private static short InferTypeArityFromMetadataName(string emittedTypeName, out int suffixStartsAt) diff --git a/src/Compilers/Core/Portable/MetadataReader/PEModule.cs b/src/Compilers/Core/Portable/MetadataReader/PEModule.cs index b6c1f6ac999d0..1544843af78c1 100644 --- a/src/Compilers/Core/Portable/MetadataReader/PEModule.cs +++ b/src/Compilers/Core/Portable/MetadataReader/PEModule.cs @@ -963,8 +963,7 @@ internal TypeLayout GetTypeLayout(TypeDefinitionHandle typeDef) internal bool IsNoPiaLocalType(TypeDefinitionHandle typeDef) { - AttributeInfo attributeInfo; - return IsNoPiaLocalType(typeDef, out attributeInfo); + return IsNoPiaLocalType(typeDef, out _); } internal bool HasParamsAttribute(EntityHandle token) diff --git a/src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs b/src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs index 952ff9618bc52..d255e42b0d590 100644 --- a/src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs +++ b/src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs @@ -53,8 +53,7 @@ internal TypeSymbol GetTypeSymbolForSerializedType(string s) } MetadataHelpers.AssemblyQualifiedTypeName fullName = MetadataHelpers.DecodeTypeName(s); - bool refersToNoPiaLocalType; - return GetTypeSymbol(fullName, out refersToNoPiaLocalType); + return GetTypeSymbol(fullName, out _); } protected TypeSymbol GetUnsupportedMetadataTypeSymbol(BadImageFormatException exception = null) diff --git a/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentity.DisplayName.cs b/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentity.DisplayName.cs index d33ece993669c..4dc3fd663d751 100644 --- a/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentity.DisplayName.cs +++ b/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentity.DisplayName.cs @@ -68,7 +68,7 @@ internal static string PublicKeyToString(ImmutableArray key) } PooledStringBuilder sb = PooledStringBuilder.GetInstance(); - StringBuilder builder = sb.Builder; + _ = sb.Builder; AppendKey(sb, key); return sb.ToStringAndFree(); } diff --git a/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentityMap.cs b/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentityMap.cs index 2bdf07b561a8d..34659c04ca888 100644 --- a/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentityMap.cs +++ b/src/Compilers/Core/Portable/MetadataReference/AssemblyIdentityMap.cs @@ -26,8 +26,7 @@ public AssemblyIdentityMap() public bool Contains(AssemblyIdentity identity, bool allowHigherVersion = true) { - TValue value; - return TryGetValue(identity, out value, allowHigherVersion); + return TryGetValue(identity, out _, allowHigherVersion); } public bool TryGetValue(AssemblyIdentity identity, out TValue value, bool allowHigherVersion = true) diff --git a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs index 80be5b90c7f02..8c3c28d36003a 100644 --- a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs +++ b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs @@ -3363,7 +3363,7 @@ public override IOperation VisitConditionalAccessInstance(IConditionalAccessInst private IOperation VisitConditionalAccessTestExpression(IOperation testExpression) { Debug.Assert(!_currentConditionalAccessTracker.IsDefault); - SyntaxNode testExpressionSyntax = testExpression.Syntax; + _ = testExpression.Syntax; ITypeSymbol? testExpressionType = testExpression.Type; var frame = PushStackFrame(); diff --git a/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs b/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs index 96e49d321b22f..dfe7ca4b78e59 100644 --- a/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs +++ b/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs @@ -1120,8 +1120,7 @@ private BlobHandle GetMemberReferenceSignatureHandle(ITypeMemberReference member internal BlobHandle GetMethodSignatureHandle(IMethodReference methodReference) { - ImmutableArray signatureBlob; - return GetMethodSignatureHandleAndBlob(methodReference, out signatureBlob); + return GetMethodSignatureHandleAndBlob(methodReference, out _); } internal byte[] GetMethodSignature(IMethodReference methodReference) diff --git a/src/Compilers/Core/Portable/RealParser.cs b/src/Compilers/Core/Portable/RealParser.cs index f4f7eb58eed28..c2182b7a9e7ea 100644 --- a/src/Compilers/Core/Portable/RealParser.cs +++ b/src/Compilers/Core/Portable/RealParser.cs @@ -345,8 +345,7 @@ public static DecimalFloatingPointString FromSource(string source) int lastExponent = i; while (i < source.Length && source[i] >= '0' && source[i] <= '9') lastExponent = ++i; - int exponentMagnitude = 0; - + int exponentMagnitude; if (int.TryParse(source.Substring(firstExponent, lastExponent - firstExponent), out exponentMagnitude) && exponentMagnitude <= MAX_EXP) { @@ -681,8 +680,7 @@ private static uint CountSignificantBits(BigInteger data, out byte[] dataBytes) /// private static uint CountSignificantBits(BigInteger data) { - byte[] dataBytes; - return CountSignificantBits(data, out dataBytes); + return CountSignificantBits(data, out _); } /// diff --git a/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs b/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs index e100917237d3a..d7d3a73e98f28 100644 --- a/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs +++ b/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs @@ -323,7 +323,7 @@ private GeneratorDriverState ApplyPartialEdit(GeneratorDriverState state, Pendin var initialState = state; // see if any generators accept this particular edit - var stateBuilder = PooledDictionary.GetInstance(); + _ = PooledDictionary.GetInstance(); for (int i = 0; i < initialState.Generators.Length; i++) { var generator = initialState.Generators[i]; @@ -387,7 +387,7 @@ private static Compilation RemoveGeneratedSyntaxTrees(GeneratorDriverState state private ImmutableArray ParseAdditionalSources(ISourceGenerator generator, ImmutableArray generatedSources, CancellationToken cancellationToken) { var trees = ArrayBuilder.GetInstance(generatedSources.Length); - var type = generator.GetType(); + _ = generator.GetType(); var prefix = GetFilePathPrefixForGenerator(generator); foreach (var source in generatedSources) { diff --git a/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs b/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs index 47a4d5ad6a07e..d0d2e12ed7eb4 100644 --- a/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs +++ b/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs @@ -257,14 +257,12 @@ public static bool TryParseKey(ImmutableArray blob, out ImmutableArray cspBlob, bool includePrivateParameters) { var br = new LittleEndianReader(cspBlob); - - byte bType = br.ReadByte(); // BLOBHEADER.bType: Expected to be 0x6 (PUBLICKEYBLOB) or 0x7 (PRIVATEKEYBLOB), though there's no check for backward compat reasons. - byte bVersion = br.ReadByte(); // BLOBHEADER.bVersion: Expected to be 0x2, though there's no check for backward compat reasons. - br.ReadUInt16(); // BLOBHEADER.wReserved - int algId = br.ReadInt32(); // BLOBHEADER.aiKeyAlg - - int magic = br.ReadInt32(); // RSAPubKey.magic: Expected to be 0x31415352 ('RSA1') or 0x32415352 ('RSA2') - int bitLen = br.ReadInt32(); // RSAPubKey.bitLen + _ = br.ReadByte(); // BLOBHEADER.bType: Expected to be 0x6 (PUBLICKEYBLOB) or 0x7 (PRIVATEKEYBLOB), though there's no check for backward compat reasons. + _ = br.ReadByte(); // BLOBHEADER.bVersion: Expected to be 0x2, though there's no check for backward compat reasons. + br.ReadUInt16(); // BLOBHEADER.wReserved + _ = br.ReadInt32(); // BLOBHEADER.aiKeyAlg + _ = br.ReadInt32(); // RSAPubKey.magic: Expected to be 0x31415352 ('RSA1') or 0x32415352 ('RSA2') + int bitLen = br.ReadInt32(); // RSAPubKey.bitLen int modulusLength = bitLen / 8; int halfModulusLength = (modulusLength + 1) / 2; diff --git a/src/Compilers/Core/Portable/Text/ChangedText.cs b/src/Compilers/Core/Portable/Text/ChangedText.cs index 090d3dae0f9a9..42169c814d5cd 100644 --- a/src/Compilers/Core/Portable/Text/ChangedText.cs +++ b/src/Compilers/Core/Portable/Text/ChangedText.cs @@ -82,8 +82,7 @@ private void Clean() ChangeInfo? lastInfo = this; for (ChangeInfo? info = this; info != null; info = info.Previous) { - SourceText? tmp; - if (info.WeakOldText.TryGetTarget(out tmp)) + if (info.WeakOldText.TryGetTarget(out _)) { lastInfo = info; } diff --git a/src/Compilers/Core/Portable/Text/SourceTextStream.cs b/src/Compilers/Core/Portable/Text/SourceTextStream.cs index 4d7de75c6a379..c1605ac926d0c 100644 --- a/src/Compilers/Core/Portable/Text/SourceTextStream.cs +++ b/src/Compilers/Core/Portable/Text/SourceTextStream.cs @@ -102,8 +102,7 @@ public override int Read(byte[] buffer, int offset, int count) } int charsUsed, bytesUsed; - bool ignored; - _encoder.Convert(_charBuffer, _bufferOffset, _bufferUnreadChars, buffer, offset, count, flush: false, charsUsed: out charsUsed, bytesUsed: out bytesUsed, completed: out ignored); + _encoder.Convert(_charBuffer, _bufferOffset, _bufferUnreadChars, buffer, offset, count, flush: false, charsUsed: out charsUsed, bytesUsed: out bytesUsed, completed: out _); _position += charsUsed; _bufferOffset += charsUsed; _bufferUnreadChars -= charsUsed; diff --git a/src/Compilers/Core/Portable/Text/TextLine.cs b/src/Compilers/Core/Portable/Text/TextLine.cs index df575962c0364..e4d7b3b9f25b5 100644 --- a/src/Compilers/Core/Portable/Text/TextLine.cs +++ b/src/Compilers/Core/Portable/Text/TextLine.cs @@ -125,9 +125,8 @@ private int LineBreakLength return 0; } - int startLineBreak; int lineBreakLength; - TextUtilities.GetStartAndLengthOfLineBreakEndingAt(_text, _endIncludingBreaks - 1, out startLineBreak, out lineBreakLength); + TextUtilities.GetStartAndLengthOfLineBreakEndingAt(_text, _endIncludingBreaks - 1, out _, out lineBreakLength); return lineBreakLength; } } diff --git a/src/Compilers/Core/Portable/VersionHelper.cs b/src/Compilers/Core/Portable/VersionHelper.cs index f97df2da7596c..984eb9e95b834 100644 --- a/src/Compilers/Core/Portable/VersionHelper.cs +++ b/src/Compilers/Core/Portable/VersionHelper.cs @@ -104,7 +104,7 @@ private static bool TryParse(string s, bool allowWildcard, ushort maxValue, bool } bool invalidFormat = false; - System.Numerics.BigInteger number = 0; + _ = 0; //There could be an invalid character in the input so check for the presence of one and //parse up to that point. examples of invalid characters are alphas and punctuation From 8a853109364dd03dc2f44a4f58cb83c6c0b24dce Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 19:49:30 -0700 Subject: [PATCH 26/63] Fix IDE0059: Unnecessary assignment --- .../ResultProvider/CSharpFormatter.Values.cs | 8 ++--- .../CustomResultProviderTests.cs | 6 ++-- .../Test/ResultProvider/DynamicTests.cs | 3 +- .../Test/ResultProvider/ExpansionTests.cs | 18 +++------- .../Test/ResultProvider/FullNameTests.cs | 36 +++++++------------ .../ResultProvider/TypeNameFormatterTests.cs | 3 +- .../TypeVariablesExpansionTests.cs | 3 +- .../Core/Source/ResultProvider/Formatter.cs | 3 +- src/Test/Perf/Utilities/Benchview.cs | 2 +- .../IOperationClassWriter.cs | 2 +- 10 files changed, 28 insertions(+), 56 deletions(-) diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs index b1f861f6b9fa5..38d80d7a57b8c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpFormatter.Values.cs @@ -23,7 +23,6 @@ private void AppendEnumTypeAndName(StringBuilder builder, Type typeToDisplayOpt, if (typeToDisplayOpt != null) { // We're showing the type of a value, so "dynamic" does not apply. - bool unused; int index1 = 0; int index2 = 0; AppendQualifiedTypeName( @@ -34,9 +33,9 @@ private void AppendEnumTypeAndName(StringBuilder builder, Type typeToDisplayOpt, null, ref index2, escapeKeywordIdentifiers: true, - sawInvalidIdentifier: out unused); + sawInvalidIdentifier: out _); builder.Append('.'); - AppendIdentifierEscapingPotentialKeywords(builder, name, sawInvalidIdentifier: out unused); + AppendIdentifierEscapingPotentialKeywords(builder, name, sawInvalidIdentifier: out _); } else { @@ -61,8 +60,7 @@ internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type l builder.Append('{'); // We're showing the type of a value, so "dynamic" does not apply. - bool unused; - builder.Append(GetTypeName(new TypeAndCustomInfo(DkmClrType.Create(appDomain, lmrType)), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused)); // NOTE: call our impl directly, since we're coupled anyway. + builder.Append(GetTypeName(new TypeAndCustomInfo(DkmClrType.Create(appDomain, lmrType)), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out _)); // NOTE: call our impl directly, since we're coupled anyway. var numSizes = sizes.Count; diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs index 4361c7b14c6ad..9fd27b7e5ea36 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/CustomResultProviderTests.cs @@ -54,8 +54,7 @@ ldsflda int32 s_val } }"; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CommonTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CommonTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var type = assembly.GetType("C"); var value = CreateDkmClrValue(type.Instantiate()).GetMemberValue("P", (int)MemberTypes.Property, "C", DefaultInspectionContext); @@ -83,8 +82,7 @@ ldsflda int32 s_val } }"; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CommonTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CommonTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var type = assembly.GetType("C"); var value = CreateDkmClrValue(type.Instantiate(), type); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DynamicTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DynamicTests.cs index 5d3bda1ff610a..3a42c860f4b47 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DynamicTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DynamicTests.cs @@ -249,8 +249,7 @@ public void TypeVariables() .method public hidebysig specialname rtspecialname instance void .ctor() { ret } }"; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CommonTestBase.EmitILToArray(intrinsicSource, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CommonTestBase.EmitILToArray(intrinsicSource, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var reflectionType = assembly.GetType(ExpressionCompilerConstants.TypeVariablesClassName).MakeGenericType(new[] { typeof(object), typeof(object), typeof(object[]) }); var value = CreateDkmClrValue(value: null, type: reflectionType, valueFlags: DkmClrValueFlags.Synthetic); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs index e5d7237d4e135..1cfb3bc505ca5 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs @@ -353,9 +353,7 @@ class C : I> var evalResult = (DkmSuccessEvaluationResult)FormatResult(rootExpr, value); Verify(evalResult, EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable)); - - DkmEvaluationResultEnumContext enumContext; - var children = GetChildren(evalResult, 2, null, out enumContext); + var children = GetChildren(evalResult, 2, null, out _); Verify(children, EvalResult("I>.P2", "2", "int", "((I>)(new C())).P2", DkmEvaluationResultFlags.ReadOnly), EvalResult("P1", "1", "int", "(new C()).P1", DkmEvaluationResultFlags.ReadOnly | DkmEvaluationResultFlags.CanFavorite)); @@ -384,9 +382,7 @@ class C : I, I var evalResult = (DkmSuccessEvaluationResult)FormatResult(rootExpr, value); Verify(evalResult, EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable)); - - DkmEvaluationResultEnumContext enumContext; - var children = GetChildren(evalResult, 3, null, out enumContext); + var children = GetChildren(evalResult, 3, null, out _); Verify(children, EvalResult("I.P2", "2", "int", "((I)(new C())).P2", DkmEvaluationResultFlags.ReadOnly), EvalResult("I.P2", "3", "int", "((I)(new C())).P2", DkmEvaluationResultFlags.ReadOnly), @@ -437,8 +433,7 @@ .property instance int32 Q() } // end of class C "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var type = assembly.GetType("C"); var rootExpr = "new C()"; @@ -446,9 +441,7 @@ .property instance int32 Q() var evalResult = (DkmSuccessEvaluationResult)FormatResult(rootExpr, value); Verify(evalResult, EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable)); - - DkmEvaluationResultEnumContext enumContext; - var children = GetChildren(evalResult, 3, null, out enumContext); + var children = GetChildren(evalResult, 3, null, out _); Verify(children, EvalResult("Q", "1", "int", "(new C()).Q", DkmEvaluationResultFlags.ReadOnly | DkmEvaluationResultFlags.CanFavorite)); } @@ -1323,8 +1316,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() { ret } .property object 'CS$7'() { .get object B::'7__get'() } }"; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(source, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var type = assembly.GetType("A"); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FullNameTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FullNameTests.cs index 79d4af226b5d8..849d1a1ccc72c 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FullNameTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FullNameTests.cs @@ -431,8 +431,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("NotMangled").Instantiate()); @@ -473,8 +472,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var baseValue = CreateDkmClrValue(assembly.GetType("<>Mangled").Instantiate()); @@ -547,8 +545,7 @@ .property instance int32 P() "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("C").Instantiate()); @@ -594,8 +591,7 @@ instance void .ctor() cil managed "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("NotMangled").Instantiate()); @@ -626,8 +622,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var baseValue = CreateDkmClrValue(assembly.GetType("<>Mangled.C").Instantiate()); @@ -663,8 +658,7 @@ instance void .ctor(int64 arg) cil managed "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); unsafe @@ -731,8 +725,7 @@ instance void .ctor(class Type s) cil managed "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("Type").Instantiate()); @@ -766,8 +759,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("C").MakeGenericType(typeof(int)).Instantiate()); @@ -798,8 +790,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("C`1").Instantiate()); @@ -830,8 +821,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("C`1").MakeGenericType(typeof(int)).Instantiate()); @@ -864,8 +854,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("C").Instantiate()); @@ -896,8 +885,7 @@ .method public hidebysig specialname rtspecialname instance void .ctor() cil ma "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var value = CreateDkmClrValue(assembly.GetType("`1").MakeGenericType(typeof(int)).Instantiate()); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeNameFormatterTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeNameFormatterTests.cs index 00f1c016e65f2..a966cbf24a0cb 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeNameFormatterTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeNameFormatterTests.cs @@ -423,8 +423,7 @@ instance void .ctor() cil managed "; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(il, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly = ReflectionUtilities.Load(assemblyBytes); var type = assembly.GetType("Type`1"); var typeName = type.GetTypeName(); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeVariablesExpansionTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeVariablesExpansionTests.cs index aa5f792454780..55eb136384059 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeVariablesExpansionTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/TypeVariablesExpansionTests.cs @@ -33,8 +33,7 @@ class B : A .method public hidebysig specialname rtspecialname instance void .ctor() { ret } }"; ImmutableArray assemblyBytes; - ImmutableArray pdbBytes; - CSharpTestBase.EmitILToArray(source1, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out pdbBytes); + CSharpTestBase.EmitILToArray(source1, appendDefaultHeader: true, includePdb: false, assemblyBytes: out assemblyBytes, pdbBytes: out _); var assembly1 = ReflectionUtilities.Load(assemblyBytes); var type1 = assembly1.GetType(ExpressionCompilerConstants.TypeVariablesClassName).MakeGenericType(new[] { typeof(int), type0 }); var value = CreateDkmClrValue(value: null, type: type1, valueFlags: DkmClrValueFlags.Synthetic); diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs index 4e065bf34ae16..2a82fef1a363b 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs @@ -47,8 +47,7 @@ string IDkmClrFormatter.GetValueString(DkmClrValue value, DkmInspectionContext i string IDkmClrFormatter.GetTypeName(DkmInspectionContext inspectionContext, DkmClrType type, DkmClrCustomTypeInfo typeInfo, ReadOnlyCollection formatSpecifiers) { - bool unused; - return GetTypeName(new TypeAndCustomInfo(type, typeInfo), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused); + return GetTypeName(new TypeAndCustomInfo(type, typeInfo), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out _); } bool IDkmClrFormatter.HasUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext) diff --git a/src/Test/Perf/Utilities/Benchview.cs b/src/Test/Perf/Utilities/Benchview.cs index e4d2efe28b9ac..ccabff223fd58 100644 --- a/src/Test/Perf/Utilities/Benchview.cs +++ b/src/Test/Perf/Utilities/Benchview.cs @@ -84,7 +84,7 @@ public static void UploadBenchviewReport(string submissionName) public static void UploadBenchviewReport(string filepath, string submissionName) { - var consumptionXml = Path.Combine(GetCPCDirectoryPath(), "consumptionTempResults.xml"); + _ = Path.Combine(GetCPCDirectoryPath(), "consumptionTempResults.xml"); var result = ConvertConsumptionToMeasurementJson(filepath); if (result) diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.cs b/src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.cs index a894d43850f08..b219d59b7e1b5 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.cs @@ -898,7 +898,7 @@ public virtual void DefaultVisit(IOperation operation) { /* no-op */ } WriteObsoleteIfNecessary(type.Obsolete); var accessibility = type.IsInternal ? "internal" : "public"; - var baseName = GetSubName(type.Name); + _ = GetSubName(type.Name); WriteLine($"{accessibility} virtual void {GetVisitorName(type)}({type.Name} operation) => DefaultVisit(operation);"); } From 8f39de65f5a996fb76a939d6fc073c5bc9a7d08b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 19:51:05 -0700 Subject: [PATCH 27/63] Fix IDE0059: Unnecessary assignment --- src/Compilers/Core/Portable/CodeGen/SequencePointList.cs | 7 +++---- .../Core/Portable/DiaSymReader/SymUnmanagedFactory.cs | 2 +- .../Core/Portable/Operations/ControlFlowGraphBuilder.cs | 6 ++---- src/Compilers/Core/Portable/RuleSet/RuleSetProcessor.cs | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Compilers/Core/Portable/CodeGen/SequencePointList.cs b/src/Compilers/Core/Portable/CodeGen/SequencePointList.cs index 355f4a2598614..942a93654a5ee 100644 --- a/src/Compilers/Core/Portable/CodeGen/SequencePointList.cs +++ b/src/Compilers/Core/Portable/CodeGen/SequencePointList.cs @@ -111,8 +111,6 @@ public void GetSequencePoints( DebugDocumentProvider documentProvider, ArrayBuilder builder) { - bool lastPathIsMapped = false; - string lastPath = null; Cci.DebugSourceDocument lastDebugDocument = null; FileLinePositionSpan? firstReal = FindFirstRealSequencePoint(); @@ -120,8 +118,9 @@ public void GetSequencePoints( { return; } - lastPath = firstReal.Value.Path; - lastPathIsMapped = firstReal.Value.HasMappedPath; + + string lastPath = firstReal.Value.Path; + bool lastPathIsMapped = firstReal.Value.HasMappedPath; lastDebugDocument = documentProvider(lastPath, basePath: lastPathIsMapped ? this._tree.FilePath : null); SequencePointList current = this; diff --git a/src/Compilers/Core/Portable/DiaSymReader/SymUnmanagedFactory.cs b/src/Compilers/Core/Portable/DiaSymReader/SymUnmanagedFactory.cs index 583a06894dbc4..cdd8138a2eaba 100644 --- a/src/Compilers/Core/Portable/DiaSymReader/SymUnmanagedFactory.cs +++ b/src/Compilers/Core/Portable/DiaSymReader/SymUnmanagedFactory.cs @@ -156,12 +156,12 @@ private static Type GetComTypeType(ref Type lazyType, Guid clsid) internal static object CreateObject(bool createReader, bool useAlternativeLoadPath, bool useComRegistry, out string moduleName, out Exception loadException) { - object instance = null; loadException = null; moduleName = null; var clsid = new Guid(createReader ? SymReaderClsid : SymWriterClsid); + object instance; try { try diff --git a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs index 8c3c28d36003a..14156e1420b45 100644 --- a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs +++ b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs @@ -4119,15 +4119,13 @@ private IOperation ConvertToIDisposable(IOperation operand, ITypeSymbol iDisposa EnterRegion(new RegionBuilder(ControlFlowRegionKind.TryAndFinally)); EnterRegion(new RegionBuilder(ControlFlowRegionKind.Try)); - - IOperation? lockTaken = null; if (!legacyMode) { // Monitor.Enter($lock, ref $lockTaken); Debug.Assert(lockStatement.LockTakenSymbol is not null); Debug.Assert(enterMethod is not null); - lockTaken = new LocalReferenceOperation(lockStatement.LockTakenSymbol, isDeclaration: true, semanticModel: null, lockedValue.Syntax, - lockStatement.LockTakenSymbol.Type, constantValue: null, isImplicit: true); + IOperation? lockTaken = new LocalReferenceOperation(lockStatement.LockTakenSymbol, isDeclaration: true, semanticModel: null, lockedValue.Syntax, + lockStatement.LockTakenSymbol.Type, constantValue: null, isImplicit: true); AddStatement(new InvocationOperation(enterMethod, instance: null, isVirtual: false, ImmutableArray.Create( new ArgumentOperation(ArgumentKind.Explicit, diff --git a/src/Compilers/Core/Portable/RuleSet/RuleSetProcessor.cs b/src/Compilers/Core/Portable/RuleSet/RuleSetProcessor.cs index ac6e03a4dbd3f..a743b08b5078f 100644 --- a/src/Compilers/Core/Portable/RuleSet/RuleSetProcessor.cs +++ b/src/Compilers/Core/Portable/RuleSet/RuleSetProcessor.cs @@ -62,13 +62,13 @@ public static RuleSet LoadFromFile(string filePath) // First read the file without doing any validation filePath = FileUtilities.NormalizeAbsolutePath(filePath); XmlReaderSettings settings = GetDefaultXmlReaderSettings(); - - XDocument? ruleSetDocument = null; XElement? ruleSetNode = null; using (Stream stream = FileUtilities.OpenRead(filePath)) using (XmlReader xmlReader = XmlReader.Create(stream, settings)) { + + XDocument? ruleSetDocument; try { ruleSetDocument = XDocument.Load(xmlReader); From 3db709e48d51a2297cab315be9dcbb11918e92e0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 19:53:17 -0700 Subject: [PATCH 28/63] Fix IDE0059: Unnecessary assignment --- .../GlobalAssemblyCacheHelpers/FusionAssemblyIdentity.cs | 3 +-- .../Shared/GlobalAssemblyCacheHelpers/GlobalAssemblyCache.cs | 3 +-- .../GlobalAssemblyCacheHelpers/MonoGlobalAssemblyCache.cs | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/FusionAssemblyIdentity.cs b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/FusionAssemblyIdentity.cs index f0ff63473baaf..d105e88f6d6f0 100644 --- a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/FusionAssemblyIdentity.cs +++ b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/FusionAssemblyIdentity.cs @@ -412,10 +412,9 @@ internal static AssemblyIdentity ToAssemblyIdentity(IAssemblyName nameObject) byte[] publicKey = GetPublicKey(nameObject); bool hasPublicKey = publicKey != null && publicKey.Length != 0; - AssemblyIdentityParts versionParts; return new AssemblyIdentity( GetName(nameObject), - GetVersion(nameObject, out versionParts), + GetVersion(nameObject, out _), GetCulture(nameObject) ?? "", (hasPublicKey ? publicKey : GetPublicKeyToken(nameObject)).AsImmutableOrNull(), hasPublicKey: hasPublicKey, diff --git a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/GlobalAssemblyCache.cs b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/GlobalAssemblyCache.cs index 41fa6efd1aaaf..140180d0ad387 100644 --- a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/GlobalAssemblyCache.cs +++ b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/GlobalAssemblyCache.cs @@ -74,8 +74,7 @@ public AssemblyIdentity ResolvePartialName( ImmutableArray architectureFilter = default(ImmutableArray), CultureInfo preferredCulture = null) { - string location; - return ResolvePartialName(displayName, out location, architectureFilter, preferredCulture); + return ResolvePartialName(displayName, out _, architectureFilter, preferredCulture); } /// diff --git a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/MonoGlobalAssemblyCache.cs b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/MonoGlobalAssemblyCache.cs index aabb94b3ca4cb..862a2ab282572 100644 --- a/src/Compilers/Shared/GlobalAssemblyCacheHelpers/MonoGlobalAssemblyCache.cs +++ b/src/Compilers/Shared/GlobalAssemblyCacheHelpers/MonoGlobalAssemblyCache.cs @@ -176,8 +176,6 @@ public override AssemblyIdentity ResolvePartialName( AssemblyIdentity assemblyIdentity = null; location = null; - bool isBestMatch = false; - foreach (var identityAndPath in GetAssemblyIdentitiesAndPaths(assemblyName, architectureFilter)) { var assemblyPath = identityAndPath.Path; @@ -189,7 +187,7 @@ public override AssemblyIdentity ResolvePartialName( var gacAssemblyName = CreateAssemblyNameFromFile(assemblyPath); - isBestMatch = cultureName == null || gacAssemblyName.CultureName == cultureName; + bool isBestMatch = cultureName == null || gacAssemblyName.CultureName == cultureName; bool isBetterMatch = location == null || isBestMatch; if (isBetterMatch) From 33bdc7a8ba0d4b6fb75c1f24a9f98ac61e7819d3 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 8 Jun 2021 20:00:43 -0700 Subject: [PATCH 29/63] Fix IDE0059: Unnecessary assignment --- .../Test/Syntax/Diagnostics/DiagnosticTest.cs | 5 +- .../IncrementalParsing/GrammarAmbiguities.cs | 2 +- .../IncrementalParsingTests.cs | 20 +- .../Test/Syntax/LexicalAndXml/LexicalTests.cs | 5 +- .../CSharp/Test/Syntax/ParentChecker.cs | 7 +- .../Syntax/Parsing/DeclarationParsingTests.cs | 28 +- .../Syntax/Parsing/DeconstructionTests.cs | 58 ++-- .../Syntax/Parsing/ExpressionParsingTests.cs | 4 +- .../Syntax/Parsing/ParserRegressionTests.cs | 18 +- .../Parsing/ParsingErrorRecoveryTests.cs | 2 +- .../Test/Syntax/Parsing/ScriptParsingTests.cs | 300 +++++++++--------- .../SeparatedSyntaxListParsingTests.cs | 4 +- ...ssNullableWarningExpressionParsingTests.cs | 2 +- .../Test/Syntax/Parsing/ValueTupleTests.cs | 10 +- .../Syntax/Syntax/ChildSyntaxListTests.cs | 4 +- .../Test/Syntax/Syntax/SerializationTests.cs | 2 +- .../Test/Syntax/Syntax/SyntaxNodeTests.cs | 10 +- .../Test/Syntax/Syntax/SyntaxRewriterTests.cs | 2 +- .../CSharp/Test/Syntax/Syntax/SyntaxTests.cs | 2 +- .../CSharp/Test/Syntax/TextExtensions.cs | 2 +- 20 files changed, 241 insertions(+), 246 deletions(-) diff --git a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs index a9fd8d4db6ab2..4950f54e15094 100644 --- a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs +++ b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs @@ -137,8 +137,7 @@ static int[] goo() return new int[0]; } }"; - - var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, + _ = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, new ErrorDescription { Code = (int)ErrorCode.ERR_BadIndexLHS, Line = 6, Column = 27 }); text = @" @@ -153,7 +152,7 @@ void goo(object o) System.Console.WriteLine(o.GetType().GetMethods[0].Name); } }"; - comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, + _ = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, new ErrorDescription { Code = (int)ErrorCode.ERR_BadIndexLHS, Line = 10, Column = 34 }); } diff --git a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/GrammarAmbiguities.cs b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/GrammarAmbiguities.cs index d052996a5fa70..f0320f86e3a11 100644 --- a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/GrammarAmbiguities.cs +++ b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/GrammarAmbiguities.cs @@ -94,7 +94,7 @@ private void VerifyReplace(string codeBefore, string codeToBeReplaced, string co var incrementalTree = originalTree.WithReplace(start, length, replacement); dynamic r = incrementalTree.GetCompilationUnitRoot(); - var args = r.Members[0].Members[0].Body.Statements[0].Expression.ArgumentList.Arguments; + _ = r.Members[0].Members[0].Body.Statements[0].Expression.ArgumentList.Arguments; VerifyIdenticalStructure(incrementalTree); } diff --git a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs index e6d26e31e0e5f..06521652ad052 100644 --- a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs @@ -139,7 +139,7 @@ public void TestChangeClassNameToMatchDestructor() [Fact] public void TestChangeFromClassToInterface() { - var interfaceKeyword = SyntaxFactory.ParseToken("interface"); // prime the memoizer + _ = SyntaxFactory.ParseToken("interface"); // prime the memoizer var text = "class goo { public void m() { } }"; var oldTree = this.Parse(text); @@ -157,7 +157,7 @@ public void TestChangeFromClassToInterface() [Fact] public void TestChangeFromClassToStruct() { - var interfaceKeyword = SyntaxFactory.ParseToken("struct"); // prime the memoizer + _ = SyntaxFactory.ParseToken("struct"); // prime the memoizer var text = "class goo { public void m() { } }"; var oldTree = this.Parse(text); @@ -547,7 +547,7 @@ public void Bug896262() { var text = SourceText.From(@"partial class C{}"); var startTree = SyntaxFactory.ParseSyntaxTree(text); - var finalString = startTree.GetCompilationUnitRoot().ToFullString(); + _ = startTree.GetCompilationUnitRoot().ToFullString(); var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); var newTree = startTree.WithChangedText(newText); @@ -561,7 +561,7 @@ public void RemovePartialFromClassWithCorrectSpan() { var text = SourceText.From(@"partial class C{}"); var startTree = SyntaxFactory.ParseSyntaxTree(text); - var finalString = startTree.GetCompilationUnitRoot().ToFullString(); + _ = startTree.GetCompilationUnitRoot().ToFullString(); var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); var newTree = startTree.WithChangedText(newText); @@ -1016,7 +1016,7 @@ void goo() SyntaxTree oldTree = SyntaxFactory.ParseSyntaxTree(oldText); // The bug was that this would simply assert - SyntaxTree newTree = oldTree.WithInsertAt(locationOfInsert, ";"); + _ = oldTree.WithInsertAt(locationOfInsert, ";"); } [WorkItem(536635, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/536635")] @@ -1029,7 +1029,7 @@ public void AddSemicolonAfterStartOfVerbatimString() } "; var oldTree = SyntaxFactory.ParseSyntaxTree(oldText); - var newTree = oldTree.WithInsertAt(oldText.IndexOf('@'), ";"); + _ = oldTree.WithInsertAt(oldText.IndexOf('@'), ";"); } [WorkItem(536717, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/536717")] @@ -1159,8 +1159,7 @@ public void CommentClassWithDelegateDecl() int locationOfChange = oldText.ToString().IndexOf("class", StringComparison.Ordinal), widthOfChange = 5; SyntaxTree incrementalTree; SyntaxTree parsedTree; - - var oldTree = SyntaxFactory.ParseSyntaxTree(oldText); + _ = SyntaxFactory.ParseSyntaxTree(oldText); // This function will update "class" to "/*class*/" in oldText CommentOutText(oldText, locationOfChange, widthOfChange, out incrementalTree, out parsedTree); @@ -1565,8 +1564,7 @@ public static int Goo SyntaxTree incrementalTree; SyntaxTree parsedTree; - - var oldTree = SyntaxFactory.ParseSyntaxTree(oldText); + _ = SyntaxFactory.ParseSyntaxTree(oldText); // This function will add the '/' character to the end of oldText CharByCharIncrementalParse(oldText, '/', out incrementalTree, out parsedTree); @@ -2703,7 +2701,7 @@ public void DontReuseLambdaParameterAsMethodParameter() [Fact] public void TestRescanInterpolatedString() { - var interfaceKeyword = SyntaxFactory.ParseToken("interface"); // prime the memoizer + _ = SyntaxFactory.ParseToken("interface"); // prime the memoizer var text = @"class goo { public void m() { string s = $""{1} world"" ; } }"; var oldTree = this.Parse6(text); diff --git a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs index 1a33dd7845880..4b5987eacd7b3 100644 --- a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs @@ -1217,7 +1217,7 @@ public void TestVerbatimIdentifierWithNoCharactersAndTrivia() Assert.Equal(1, errors.Length); Assert.Equal((int)ErrorCode.ERR_ExpectedVerbatimLiteral, errors[0].Code); Assert.Equal(text, token.ToFullString()); - var trivia = token.GetTrailingTrivia().ToList(); + _ = token.GetTrailingTrivia().ToList(); } [Fact] @@ -1399,8 +1399,7 @@ public void TestNumericLiteralWithExponentAndDecimalSpecifier01() Assert.NotEqual(default, token); Assert.Equal(SyntaxKind.NumericLiteralToken, token.Kind()); var errors = token.Errors(); - decimal d; - if (decimal.TryParse("0E1", System.Globalization.NumberStyles.AllowExponent, null, out d)) + if (decimal.TryParse("0E1", System.Globalization.NumberStyles.AllowExponent, null, out _)) { Assert.Equal(0, errors.Length); } diff --git a/src/Compilers/CSharp/Test/Syntax/ParentChecker.cs b/src/Compilers/CSharp/Test/Syntax/ParentChecker.cs index c40ca9b9f490b..440e97e2ede27 100644 --- a/src/Compilers/CSharp/Test/Syntax/ParentChecker.cs +++ b/src/Compilers/CSharp/Test/Syntax/ParentChecker.cs @@ -16,15 +16,14 @@ public static class ParentChecker public static void CheckParents(SyntaxNodeOrToken nodeOrToken, SyntaxTree expectedSyntaxTree) { Assert.Equal(expectedSyntaxTree, nodeOrToken.SyntaxTree); - - var span = nodeOrToken.Span; + _ = nodeOrToken.Span; if (nodeOrToken.IsToken) { var token = nodeOrToken.AsToken(); foreach (var trivia in token.LeadingTrivia) { - var tspan = trivia.Span; + _ = trivia.Span; var parentToken = trivia.Token; Assert.Equal(parentToken, token); if (trivia.HasStructure) @@ -37,7 +36,7 @@ public static void CheckParents(SyntaxNodeOrToken nodeOrToken, SyntaxTree expect foreach (var trivia in token.TrailingTrivia) { - var tspan = trivia.Span; + _ = trivia.Span; var parentToken = trivia.Token; Assert.Equal(parentToken, token); if (trivia.HasStructure) diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs index a43d90daffd80..ee9bf78223bc6 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs @@ -6499,7 +6499,7 @@ class C [Fact] public void ParseOutVar() { - var tree = UsingTree(@" + _ = UsingTree(@" class C { void Goo() @@ -6573,7 +6573,7 @@ void Goo() [Fact] public void TestPartiallyWrittenConstraintClauseInBaseList1() { - var tree = UsingTree(@" + _ = UsingTree(@" class C : where "); N(SyntaxKind.CompilationUnit); @@ -6613,7 +6613,7 @@ class C : where [Fact] public void TestPartiallyWrittenConstraintClauseInBaseList2() { - var tree = UsingTree(@" + _ = UsingTree(@" class C : where T "); N(SyntaxKind.CompilationUnit); @@ -6661,7 +6661,7 @@ class C : where T [Fact] public void TestPartiallyWrittenConstraintClauseInBaseList3() { - var tree = UsingTree(@" + _ = UsingTree(@" class C : where T : "); N(SyntaxKind.CompilationUnit); @@ -6717,7 +6717,7 @@ class C : where T : [Fact] public void TestPartiallyWrittenConstraintClauseInBaseList4() { - var tree = UsingTree(@" + _ = UsingTree(@" class C : where T : X "); N(SyntaxKind.CompilationUnit); @@ -6901,7 +6901,7 @@ event System.EventHandler E [Fact] public void NullableClassConstraint_01() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : class {} "); @@ -6944,7 +6944,7 @@ class C where T : class {} [Fact] public void NullableClassConstraint_02() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : struct {} "); @@ -6987,7 +6987,7 @@ class C where T : struct {} [Fact] public void NullableClassConstraint_03() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : class? {} "); @@ -7031,7 +7031,7 @@ class C where T : class? {} [Fact] public void NullableClassConstraint_04() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : struct? {} ", TestOptions.Regular, // (2,28): error CS1073: Unexpected token '?' @@ -7079,7 +7079,7 @@ class C where T : struct? {} [Fact] public void NullableClassConstraint_05() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : class? {} ", TestOptions.Regular7_3); @@ -7123,7 +7123,7 @@ class C where T : class? {} [Fact] public void NullableClassConstraint_06() { - var tree = UsingNode(@" + _ = UsingNode(@" class C where T : struct? {} ", TestOptions.Regular7_3, // (2,28): error CS1073: Unexpected token '?' @@ -7171,7 +7171,7 @@ class C where T : struct? {} [Fact, WorkItem(30102, "https://github.com/dotnet/roslyn/issues/30102")] public void IncompleteGenericInBaseList1() { - var tree = UsingNode(@" + _ = UsingNode(@" class B : A : A : A @default $ retVal @assembly += c void .Member & -= ; @typeof "; - var tree = SyntaxFactory.ParseSyntaxTree(test); + _ = SyntaxFactory.ParseSyntaxTree(test); } [WorkItem(540007, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540007")] @@ -104,7 +104,7 @@ public void c03() var test = @"/// /// else int OPERATOR @uint $ ) { - static ? operator :: ] @readonly = @on async int? , [ return ] { 1 ! , @property & 3 ! @case % partial += ;/*[] bug*/ // YES [] int % ] endregion var = ]]> @for |= @struct , 3, lock 4 @on % 5 goto } @stackalloc } /*,;*/ int %= i = @fixed ?> int << a base <= 1] default ; "; - var tree = SyntaxFactory.ParseSyntaxTree(test); + _ = SyntaxFactory.ParseSyntaxTree(test); } [WorkItem(540007, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540007")] @@ -114,7 +114,7 @@ public void c04() var test = @"/// /// internal do OPERATOR || ) { int?[] a = new int? \u14DB\u0849 [5] { 1, 2, 3, 4, @using } /= /*[] bug*/ // YES [] int[] var = { 1, 2, 3, 4, 5 } $ /*,;*/ int i = ; int)a[1];/*[]*/ i = i <<= @__arglist - i @sbyte * @extern / i % i ++ % i || @checked ^ i; /*+ - * / % & | ^*/ "; - var tree = SyntaxFactory.ParseSyntaxTree(test); + _ = SyntaxFactory.ParseSyntaxTree(test); } [WorkItem(540007, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540007")] @@ -124,7 +124,7 @@ public void c000138() var test = @"int?[] /// a = new int? . @string ] { 1, typeof $ 3, 4, 5 } static ; @partial /*[] bug*/ // YES [] int[] var = { 1, else , 3 i;/*< && >*/ "; - var tree = SyntaxFactory.ParseSyntaxTree(test); + _ = SyntaxFactory.ParseSyntaxTree(test); } [WorkItem(540007, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540007")] @@ -134,7 +134,7 @@ public void c000241() var test = @"/// /// const by TYPES ascending / ) $ { @let int @byte @by | 0 ; "; - var tree = SyntaxFactory.ParseSyntaxTree(test); + _ = SyntaxFactory.ParseSyntaxTree(test); } [WorkItem(540007, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540007")] @@ -144,7 +144,7 @@ public void c024928() var test = @"/// /// internal int OPERATOR() { // int?[ * @method ! new int explicit , [ 5 -- { \uDD48\uEF5C , 2, @ascending , @foreach \uD17B\u21A8 . 5 ; { /*[] bug*/ // YES [] int :: ( <= var /> { @readonly 1