From 38f644f873afcf9ccae289b3888ccf41b8f5638a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 15:38:21 -0800 Subject: [PATCH 01/43] Move IndentationService down to Feature layer. --- .../CSharpEditorFormattingService.cs | 2 +- .../SmartTokenFormatterCommandHandler.cs | 1 + .../Indentation/WhitespaceExtensions.cs | 15 ---- ...ingLiteralCommandHandler.StringSplitter.cs | 5 +- .../CSharpBinaryExpressionWrapper.cs | 2 +- ...bstractCSharpSeparatedSyntaxListWrapper.cs | 3 +- .../SmartIndenterEnterOnTokenTests.cs | 2 +- ...stractSmartTokenFormatterCommandHandler.cs | 3 +- .../IBlankLineIndentationService.cs | 23 ------ .../SmartIndent/IIndentationService.cs | 7 ++ .../Implementation/SmartIndent/SmartIndent.cs | 36 ++++++++-- .../Extensions/SmartIndentExtensions.cs | 2 +- .../Shared/Options/FeatureOnOffOptions.cs | 5 -- .../Core/Wrapping/AbstractWrapper.cs | 4 +- .../AbstractBinaryExpressionWrapper.cs | 3 +- .../AbstractSeparatedSyntaxListWrapper.cs | 3 +- .../Formatting/CoreFormatterTestsBase.cs | 4 +- .../TestUtilities/TestExportProvider.cs | 4 +- .../SmartTokenFormatterCommandHandler.vb | 3 +- .../VisualBasicBinaryExpressionWrapper.vb | 2 +- ...ctVisualBasicSeparatedSyntaxListWrapper.vb | 2 +- .../SmartTokenFormatter_FormatTokenTests.vb | 1 + .../CSharpIndentationService.Indenter.cs | 6 +- .../Indentation/CSharpIndentationService.cs | 12 ++-- ...ractIndentationService.AbstractIndenter.cs | 3 +- .../AbstractIndentationService.cs | 6 +- .../Indentation/IIndentationService.cs | 70 +++++++++++++++++++ .../Indentation/SpecialFormattingOperation.vb | 3 +- .../VisualBasicIndentationService.Indenter.vb | 4 +- .../VisualBasicIndentationService.vb | 7 +- .../Portable/Formatting/FormattingOptions.cs | 3 + 31 files changed, 147 insertions(+), 99 deletions(-) delete mode 100644 src/EditorFeatures/CSharp/Formatting/Indentation/WhitespaceExtensions.cs delete mode 100644 src/EditorFeatures/Core/Implementation/SmartIndent/IBlankLineIndentationService.cs rename src/{EditorFeatures/CSharp/Formatting => Features/CSharp/Portable}/Indentation/CSharpIndentationService.Indenter.cs (98%) rename src/{EditorFeatures/CSharp/Formatting => Features/CSharp/Portable}/Indentation/CSharpIndentationService.cs (94%) rename src/{EditorFeatures/Core/Implementation/SmartIndent => Features/Core/Portable/Indentation}/AbstractIndentationService.AbstractIndenter.cs (98%) rename src/{EditorFeatures/Core/Implementation/SmartIndent => Features/Core/Portable/Indentation}/AbstractIndentationService.cs (96%) create mode 100644 src/Features/Core/Portable/Indentation/IIndentationService.cs rename src/{EditorFeatures/VisualBasic/Formatting => Features/VisualBasic/Portable}/Indentation/SpecialFormattingOperation.vb (99%) rename src/{EditorFeatures/VisualBasic/Formatting => Features/VisualBasic/Portable}/Indentation/VisualBasicIndentationService.Indenter.vb (99%) rename src/{EditorFeatures/VisualBasic/Formatting => Features/VisualBasic/Portable}/Indentation/VisualBasicIndentationService.vb (94%) diff --git a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs index 1887ee71c238b..3cbcb7753ff71 100644 --- a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs +++ b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs @@ -131,7 +131,7 @@ private IEnumerable GetFormattingRules(Document document public async Task> GetFormattingChangesOnReturnAsync(Document document, int caretPosition, CancellationToken cancellationToken) { var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); - if (!options.GetOption(FeatureOnOffOptions.AutoFormattingOnReturn)) + if (!options.GetOption(FormattingOptions.AutoFormattingOnReturn)) { return null; } diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index c975c06356144..2190453da05b9 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Formatting; diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/WhitespaceExtensions.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/WhitespaceExtensions.cs deleted file mode 100644 index bf7ffc4dc0e3f..0000000000000 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/WhitespaceExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - -namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation -{ - internal static class WhitespaceExtensions - { -#if false - public static bool IsFirstTokenOnLine(this SyntaxToken token, ITextSnapshot snapshot) - { - return token.IsFirstTokenOnLine(snapshot); - } -#endif - } -} diff --git a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs index 2c69c027a2659..a537b55afc02a 100644 --- a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs +++ b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -150,7 +149,7 @@ private string GetIndentString(SyntaxNode newRoot) { var newDocument = Document.WithSyntaxRoot(newRoot); - var indentationService = (IBlankLineIndentationService)newDocument.GetLanguageService(); + var indentationService = newDocument.GetLanguageService(); var originalLineNumber = SourceText.Lines.GetLineFromPosition(CursorPosition).LineNumber; var desiredIndentation = indentationService.GetBlankLineIndentation( diff --git a/src/EditorFeatures/CSharp/Wrapping/BinaryExpression/CSharpBinaryExpressionWrapper.cs b/src/EditorFeatures/CSharp/Wrapping/BinaryExpression/CSharpBinaryExpressionWrapper.cs index 79ea92f7410c5..fa7207af4a405 100644 --- a/src/EditorFeatures/CSharp/Wrapping/BinaryExpression/CSharpBinaryExpressionWrapper.cs +++ b/src/EditorFeatures/CSharp/Wrapping/BinaryExpression/CSharpBinaryExpressionWrapper.cs @@ -2,7 +2,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression; namespace Microsoft.CodeAnalysis.Editor.CSharp.Wrapping.BinaryExpression diff --git a/src/EditorFeatures/CSharp/Wrapping/SeparatedSyntaxList/AbstractCSharpSeparatedSyntaxListWrapper.cs b/src/EditorFeatures/CSharp/Wrapping/SeparatedSyntaxList/AbstractCSharpSeparatedSyntaxListWrapper.cs index e824e4cbb7d34..acaaaaf8e60a7 100644 --- a/src/EditorFeatures/CSharp/Wrapping/SeparatedSyntaxList/AbstractCSharpSeparatedSyntaxListWrapper.cs +++ b/src/EditorFeatures/CSharp/Wrapping/SeparatedSyntaxList/AbstractCSharpSeparatedSyntaxListWrapper.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.CodeAnalysis.Editor; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.Editor.Wrapping.SeparatedSyntaxList; namespace Microsoft.CodeAnalysis.CSharp.Editor.Wrapping.SeparatedSyntaxList diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs index ebca590cbcfe7..2ff3e51c083c3 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs @@ -3,8 +3,8 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Test.Utilities; diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index 4b2570d4eb0fc..78a6f5f2c3430 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -8,6 +8,7 @@ using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -139,7 +140,7 @@ internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken return; } - var indentationService = document.GetLanguageService(); + var indentationService = document.GetLanguageService(); var indentation = indentationService.GetDesiredIndentation(document, currentPosition.GetContainingLine().LineNumber, cancellationToken); diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/IBlankLineIndentationService.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/IBlankLineIndentationService.cs deleted file mode 100644 index 1d4c36a6f3193..0000000000000 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/IBlankLineIndentationService.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Threading; -using Microsoft.CodeAnalysis.Formatting; - -namespace Microsoft.CodeAnalysis.Editor -{ - internal interface IBlankLineIndentationService - { - /// - /// Determines indentation for a blank line (i.e. after hitting enter at the end of a line, - /// or after moving to a blank line). - /// - /// Specifically, this function operates as if the line specified by - /// is blank. The actual contents of the line do not matter. All indentation information is - /// determined from the previous lines in the document. - /// - /// This function will always succeed. - /// - IndentationResult GetBlankLineIndentation( - Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken); - } -} diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs index 92ff2e89b03c1..4997c593a575d 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; @@ -18,6 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor /// current line. With this tuple, both forms can be expressed, and the implementor does not /// have to convert from one to the other. /// + [Obsolete("Use Microsoft.CodeAnalysis.Indentation.IndentationResult instead.")] internal struct IndentationResult { /// @@ -36,13 +38,18 @@ public IndentationResult(int basePosition, int offset) : this() this.BasePosition = basePosition; this.Offset = offset; } + + public static implicit operator Indentation.IndentationResult(IndentationResult result) + => new Indentation.IndentationResult(result.BasePosition, result.Offset); } + [Obsolete("Use Microsoft.CodeAnalysis.Indentation.IIndentationService instead.")] internal interface IIndentationService : ILanguageService { Task GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken); } + [Obsolete("Use Microsoft.CodeAnalysis.Indentation.IIndentationService instead.")] internal interface ISynchronousIndentationService : ILanguageService { /// diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs index 72f0c9cc59b16..bb44edc20585f 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs @@ -2,7 +2,7 @@ using System; using System.Threading; -using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -10,6 +10,10 @@ using Microsoft.VisualStudio.Text.Editor; using Roslyn.Utilities; +using NewIndentationService = Microsoft.CodeAnalysis.Indentation.IIndentationService; +using OldIndentationService = Microsoft.CodeAnalysis.Editor.IIndentationService; +using OldSynchronousIndentationService = Microsoft.CodeAnalysis.Editor.ISynchronousIndentationService; + namespace Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent { internal partial class SmartIndent : ISmartIndent @@ -40,21 +44,39 @@ public void Dispose() using (Logger.LogBlock(FunctionId.SmartIndentation_Start, cancellationToken)) { var document = lineToBeIndented.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); - var syncService = document?.GetLanguageService(); + if (document == null) + { + return null; + } - if (syncService != null) + // First, try to go through the normal feature-layer indentation service. + var newService = document.GetLanguageService(); + if (newService != null) { - var result = syncService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken); + var result = newService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken); return result?.GetIndentation(_textView, lineToBeIndented); } - var asyncService = document?.GetLanguageService(); - if (asyncService != null) + // If we don't have a feature-layer service, try to fall back to the legacy + // editor-feature-layer interfaces. + +#pragma warning disable CS0618 // Type or member is obsolete + var oldSyncService = document.GetLanguageService(); + if (oldSyncService != null) { - var result = asyncService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken).WaitAndGetResult(cancellationToken); + var result = (Indentation.IndentationResult?)oldSyncService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken); return result?.GetIndentation(_textView, lineToBeIndented); } + var oldAsyncService = document.GetLanguageService(); + if (oldAsyncService != null) + { + var result = (Indentation.IndentationResult?)oldAsyncService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken).WaitAndGetResult(cancellationToken); + return result?.GetIndentation(_textView, lineToBeIndented); + } +#pragma warning restore CS0618 // Type or member is obsolete + + return null; } } diff --git a/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs index 4a94941bffae1..390c8f101bd20 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs @@ -4,7 +4,7 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; -namespace Microsoft.CodeAnalysis.Editor.Shared.Extensions +namespace Microsoft.CodeAnalysis.Indentation { internal static class SmartIndentExtensions { diff --git a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs index ebe63805e47f9..796966c6c71eb 100644 --- a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs +++ b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs @@ -44,10 +44,6 @@ internal static class FeatureOnOffOptions nameof(FeatureOnOffOptions), nameof(AutoFormattingOnTyping), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Typing")); - public static readonly PerLanguageOption AutoFormattingOnReturn = new PerLanguageOption( - nameof(FeatureOnOffOptions), nameof(AutoFormattingOnReturn), defaultValue: true, - storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Return")); - public static readonly PerLanguageOption AutoFormattingOnCloseBrace = new PerLanguageOption( nameof(FeatureOnOffOptions), nameof(AutoFormattingOnCloseBrace), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Close Brace")); @@ -107,7 +103,6 @@ internal class FeatureOnOffOptionsProvider : IOptionProvider FeatureOnOffOptions.AutoInsertBlockCommentStartString, FeatureOnOffOptions.PrettyListing, FeatureOnOffOptions.AutoFormattingOnTyping, - FeatureOnOffOptions.AutoFormattingOnReturn, FeatureOnOffOptions.AutoFormattingOnCloseBrace, FeatureOnOffOptions.AutoFormattingOnSemicolon, FeatureOnOffOptions.RenameTrackingPreview, diff --git a/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs b/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs index d464f3b15688f..e4f4aa2f79d0d 100644 --- a/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs @@ -21,9 +21,9 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping /// internal abstract partial class AbstractSyntaxWrapper : ISyntaxWrapper { - protected IBlankLineIndentationService IndentationService { get; } + protected Indentation.IIndentationService IndentationService { get; } - protected AbstractSyntaxWrapper(IBlankLineIndentationService indentationService) + protected AbstractSyntaxWrapper(Indentation.IIndentationService indentationService) { this.IndentationService = indentationService; } diff --git a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs index 8fb66c6d5a17e..d17ee495c5e9b 100644 --- a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression { @@ -17,7 +16,7 @@ internal abstract partial class AbstractBinaryExpressionWrapper(); + var blankLineIndenter = document.GetLanguageService(); var indentStyle = workspace.Options.GetOption(FormattingOptions.SmartIndent, GetLanguageName()); var blankLineIndentResult = blankLineIndenter.GetBlankLineIndentation( document, indentationLine, indentStyle, CancellationToken.None); diff --git a/src/EditorFeatures/TestUtilities/TestExportProvider.cs b/src/EditorFeatures/TestUtilities/TestExportProvider.cs index 5c845a5af3c60..53b000f086da9 100644 --- a/src/EditorFeatures/TestUtilities/TestExportProvider.cs +++ b/src/EditorFeatures/TestUtilities/TestExportProvider.cs @@ -57,8 +57,8 @@ private static Type[] GetNeutralAndCSharpAndVisualBasicTypes() typeof(CodeAnalysis.VisualBasic.IntroduceVariable.VisualBasicIntroduceVariableService), // Ensures that BasicFeatures is included in the composition typeof(CSharp.ContentType.ContentTypeDefinitions), // CSharp Content Type typeof(VisualBasic.ContentType.ContentTypeDefinitions), // VB Content Type - typeof(VisualBasic.Formatting.Indentation.VisualBasicIndentationService), - typeof(CSharp.Formatting.Indentation.CSharpIndentationService), + typeof(CodeAnalysis.VisualBasic.Indentation.VisualBasicIndentationService), + typeof(CodeAnalysis.CSharp.Indentation.CSharpIndentationService), typeof(CodeAnalysis.CSharp.CSharpCompilationFactoryService), typeof(CodeAnalysis.VisualBasic.VisualBasicCompilationFactoryService), typeof(CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory), // CSharpServicesCore diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb index 06f4d3f4ac7da..8de480da9e827 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb @@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text +Imports Microsoft.CodeAnalysis.VisualBasic.Indentation Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.VisualStudio.Text.Operations Imports Microsoft.VisualStudio.Utilities @@ -20,8 +21,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Friend Class SmartTokenFormatterCommandHandler Inherits AbstractSmartTokenFormatterCommandHandler - Private ReadOnly _formattingRules As IEnumerable(Of AbstractFormattingRule) - Public Sub New(undoHistoryRegistry As ITextUndoHistoryRegistry, editorOperationsFactoryService As IEditorOperationsFactoryService) diff --git a/src/EditorFeatures/VisualBasic/Wrapping/BinaryExpression/VisualBasicBinaryExpressionWrapper.vb b/src/EditorFeatures/VisualBasic/Wrapping/BinaryExpression/VisualBasicBinaryExpressionWrapper.vb index 8e46ef06f72dc..139c7b523ecc2 100644 --- a/src/EditorFeatures/VisualBasic/Wrapping/BinaryExpression/VisualBasicBinaryExpressionWrapper.vb +++ b/src/EditorFeatures/VisualBasic/Wrapping/BinaryExpression/VisualBasicBinaryExpressionWrapper.vb @@ -1,7 +1,7 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Imports Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression +Imports Microsoft.CodeAnalysis.VisualBasic.Indentation Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Wrapping.BinaryExpression diff --git a/src/EditorFeatures/VisualBasic/Wrapping/SeparatedSyntaxList/AbstractVisualBasicSeparatedSyntaxListWrapper.vb b/src/EditorFeatures/VisualBasic/Wrapping/SeparatedSyntaxList/AbstractVisualBasicSeparatedSyntaxListWrapper.vb index a74cb0c02101c..2e74317421e5b 100644 --- a/src/EditorFeatures/VisualBasic/Wrapping/SeparatedSyntaxList/AbstractVisualBasicSeparatedSyntaxListWrapper.vb +++ b/src/EditorFeatures/VisualBasic/Wrapping/SeparatedSyntaxList/AbstractVisualBasicSeparatedSyntaxListWrapper.vb @@ -1,7 +1,7 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Imports Microsoft.CodeAnalysis.Editor.Wrapping.SeparatedSyntaxList +Imports Microsoft.CodeAnalysis.VisualBasic.Indentation Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Wrapping.SeparatedSyntaxList Partial Friend MustInherit Class AbstractVisualBasicSeparatedSyntaxListWrapper( diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb index 79e3fc25f4fdb..be675cc951360 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb @@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.Text.Shared.Extensions +Imports Microsoft.CodeAnalysis.VisualBasic.Indentation Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.VisualStudio.Text.Editor Imports Moq diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.Indenter.cs b/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs similarity index 98% rename from src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.Indenter.cs rename to src/Features/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index 7336f917f43a6..e1aa2f1b11b0a 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -4,21 +4,19 @@ using System.Diagnostics; using System.Linq; using System.Threading; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation +namespace Microsoft.CodeAnalysis.CSharp.Indentation { internal partial class CSharpIndentationService { diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.cs b/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.cs similarity index 94% rename from src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.cs rename to src/Features/CSharp/Portable/Indentation/CSharpIndentationService.cs index 58755397ba091..4f8e934907908 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/CSharpIndentationService.cs +++ b/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -4,25 +4,21 @@ using System.Composition; using System.Diagnostics; using System.Threading; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; -using Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent; -using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation +namespace Microsoft.CodeAnalysis.CSharp.Indentation { - [ExportLanguageService(typeof(ISynchronousIndentationService), LanguageNames.CSharp), Shared] + [ExportLanguageService(typeof(IIndentationService), LanguageNames.CSharp), Shared] internal sealed partial class CSharpIndentationService : AbstractIndentationService { public static readonly CSharpIndentationService Instance = new CSharpIndentationService(); @@ -52,7 +48,7 @@ public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( Contract.ThrowIfNull(formattingRules); Contract.ThrowIfNull(root); - if (!optionSet.GetOption(FeatureOnOffOptions.AutoFormattingOnReturn, LanguageNames.CSharp)) + if (!optionSet.GetOption(FormattingOptions.AutoFormattingOnReturn, LanguageNames.CSharp)) { return false; } diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.AbstractIndenter.cs b/src/Features/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs similarity index 98% rename from src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.AbstractIndenter.cs rename to src/Features/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 69aaf6808067a..20fb4f5739657 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Features/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -11,9 +11,8 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; -namespace Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent +namespace Microsoft.CodeAnalysis.Indentation { internal abstract partial class AbstractIndentationService { diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.cs b/src/Features/Core/Portable/Indentation/AbstractIndentationService.cs similarity index 96% rename from src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.cs rename to src/Features/Core/Portable/Indentation/AbstractIndentationService.cs index 44b9109fe79db..768a620b96a6c 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/AbstractIndentationService.cs +++ b/src/Features/Core/Portable/Indentation/AbstractIndentationService.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -12,10 +11,9 @@ using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent +namespace Microsoft.CodeAnalysis.Indentation { - internal abstract partial class AbstractIndentationService - : ISynchronousIndentationService, IBlankLineIndentationService + internal abstract partial class AbstractIndentationService : IIndentationService where TSyntaxRoot : SyntaxNode, ICompilationUnitSyntax { protected abstract AbstractFormattingRule GetSpecializedIndentationFormattingRule(); diff --git a/src/Features/Core/Portable/Indentation/IIndentationService.cs b/src/Features/Core/Portable/Indentation/IIndentationService.cs new file mode 100644 index 0000000000000..ea63fc2a81904 --- /dev/null +++ b/src/Features/Core/Portable/Indentation/IIndentationService.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis.Indentation +{ + /// + /// An indentation result represents where the indent should be placed. It conveys this through + /// a pair of values. A position in the existing document where the indent should be relative, + /// and the number of columns after that the indent should be placed at. + /// + /// This pairing provides flexibility to the implementor to compute the indentation results in + /// a variety of ways. For example, one implementation may wish to express indentation of a + /// newline as being four columns past the start of the first token on a previous line. Another + /// may wish to simply express the indentation as an absolute amount from the start of the + /// current line. With this tuple, both forms can be expressed, and the implementor does not + /// have to convert from one to the other. + /// + internal struct IndentationResult + { + /// + /// The base position in the document that the indent should be relative to. This position + /// can occur on any line (including the current line, or a previous line). + /// + public int BasePosition { get; } + + /// + /// The number of columns the indent should be at relative to the BasePosition's column. + /// + public int Offset { get; } + + public IndentationResult(int basePosition, int offset) : this() + { + this.BasePosition = basePosition; + this.Offset = offset; + } + } + + internal interface IIndentationService : ILanguageService + { + /// + /// Determines the desired indentation of a given line. May return if the + /// does not want any sort of automatic indentation. May also return + /// if the line in question is not blank and thus indentation should + /// be deferred to the formatting command handler to handle. + /// + IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken); + + /// + /// Determines indentation for a blank line (i.e. after hitting enter at the end of a line, + /// or after moving to a blank line). + /// + /// Specifically, this function operates as if the line specified by + /// is blank. The actual contents of the line do not matter. All indentation information is + /// determined from the previous lines in the document. + /// + /// This is often useful for features which want to insert new code at a certain + /// location, indented to the appropriate amount. This allows those features to + /// figure out that position, without having to care about what might already be + /// at that line (or further on in the document). + /// + /// This function will always succeed. + /// + IndentationResult GetBlankLineIndentation( + Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken); + } +} diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SpecialFormattingOperation.vb b/src/Features/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb similarity index 99% rename from src/EditorFeatures/VisualBasic/Formatting/Indentation/SpecialFormattingOperation.vb rename to src/Features/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb index be6a2c92fd817..4af9bf4307691 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SpecialFormattingOperation.vb +++ b/src/Features/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb @@ -7,8 +7,7 @@ Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation - +Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Friend Class SpecialFormattingRule Inherits CompatAbstractFormattingRule diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb similarity index 99% rename from src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.Indenter.vb rename to src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index 1d9e0a3403e24..ddc6bdc70cb4b 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -3,14 +3,14 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules +Imports Microsoft.CodeAnalysis.Indentation Imports Microsoft.CodeAnalysis.LanguageServices Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text -Imports Microsoft.CodeAnalysis.Text.Shared.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Formatting Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation +Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Partial Friend Class VisualBasicIndentationService Private Class Indenter Inherits AbstractIndenter diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.vb b/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb similarity index 94% rename from src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.vb rename to src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index 5344e028d967f..00eb191d00df0 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/VisualBasicIndentationService.vb +++ b/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -2,17 +2,16 @@ Imports System.Composition Imports System.Threading -Imports Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.Host.Mef +Imports Microsoft.CodeAnalysis.Indentation Imports Microsoft.CodeAnalysis.LanguageServices Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text -Imports Microsoft.CodeAnalysis.Text.Shared.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation - +Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation + Partial Friend NotInheritable Class VisualBasicIndentationService Inherits AbstractIndentationService(Of CompilationUnitSyntax) diff --git a/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs b/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs index 69548e1b239e2..ced6ef0c9c6f9 100644 --- a/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs +++ b/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs @@ -99,6 +99,9 @@ private static string GetEndOfLineEditorConfigString(string option) internal static Option AllowDisjointSpanMerging { get; } = CreateOption(OptionGroup.Default, nameof(AllowDisjointSpanMerging), defaultValue: false); + internal static readonly PerLanguageOption AutoFormattingOnReturn = CreatePerLanguageOption(OptionGroup.Default, nameof(AutoFormattingOnReturn), defaultValue: true, + storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Return")); + static FormattingOptions() { // Note that the static constructor executes after all the static field initializers for the options have executed, From c5fa15b6819d8468495d07cb9020e06b6b78c519 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 15:43:26 -0800 Subject: [PATCH 02/43] MOve to workspaces --- .../Portable/Indentation/CSharpIndentationService.Indenter.cs | 0 .../CSharp/Portable/Indentation/CSharpIndentationService.cs | 0 .../Indentation/AbstractIndentationService.AbstractIndenter.cs | 0 .../Core/Portable/Indentation/AbstractIndentationService.cs | 0 .../Core/Portable/Indentation/IIndentationService.cs | 0 .../Portable/Indentation/SpecialFormattingOperation.vb | 0 .../Indentation/VisualBasicIndentationService.Indenter.vb | 0 .../Portable/Indentation/VisualBasicIndentationService.vb | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename src/{Features => Workspaces}/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs (100%) rename src/{Features => Workspaces}/CSharp/Portable/Indentation/CSharpIndentationService.cs (100%) rename src/{Features => Workspaces}/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs (100%) rename src/{Features => Workspaces}/Core/Portable/Indentation/AbstractIndentationService.cs (100%) rename src/{Features => Workspaces}/Core/Portable/Indentation/IIndentationService.cs (100%) rename src/{Features => Workspaces}/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb (100%) rename src/{Features => Workspaces}/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb (100%) rename src/{Features => Workspaces}/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb (100%) diff --git a/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs similarity index 100% rename from src/Features/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs rename to src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs diff --git a/src/Features/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs similarity index 100% rename from src/Features/CSharp/Portable/Indentation/CSharpIndentationService.cs rename to src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs diff --git a/src/Features/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs similarity index 100% rename from src/Features/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs rename to src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs diff --git a/src/Features/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs similarity index 100% rename from src/Features/Core/Portable/Indentation/AbstractIndentationService.cs rename to src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs diff --git a/src/Features/Core/Portable/Indentation/IIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs similarity index 100% rename from src/Features/Core/Portable/Indentation/IIndentationService.cs rename to src/Workspaces/Core/Portable/Indentation/IIndentationService.cs diff --git a/src/Features/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb b/src/Workspaces/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb similarity index 100% rename from src/Features/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb rename to src/Workspaces/VisualBasic/Portable/Indentation/SpecialFormattingOperation.vb diff --git a/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb similarity index 100% rename from src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb rename to src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb diff --git a/src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb similarity index 100% rename from src/Features/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb rename to src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb From 6864d02c248f5b741511823b2b7d93a3677ba166 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 15:48:53 -0800 Subject: [PATCH 03/43] Cleanup --- .../Core/Implementation/SmartIndent/SmartIndent.cs | 2 +- .../Core/Shared/Extensions/SmartIndentExtensions.cs | 6 +++--- .../TestUtilities/Formatting/CoreFormatterTestsBase.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs index bb44edc20585f..77e594d4b4e0e 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs @@ -2,7 +2,7 @@ using System; using System.Threading; -using Microsoft.CodeAnalysis.Indentation; +using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; diff --git a/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs index 390c8f101bd20..27969fbddbe67 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/SmartIndentExtensions.cs @@ -4,11 +4,11 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; -namespace Microsoft.CodeAnalysis.Indentation +namespace Microsoft.CodeAnalysis.Editor.Shared.Extensions { - internal static class SmartIndentExtensions + internal static class IndentationResultExtensions { - public static int GetIndentation(this IndentationResult result, ITextView textView, ITextSnapshotLine lineToBeIndented) + public static int GetIndentation(this Indentation.IndentationResult result, ITextView textView, ITextSnapshotLine lineToBeIndented) { var position = new SnapshotPoint(lineToBeIndented.Snapshot, result.BasePosition); var pointInSurfaceSnapshot = textView.BufferGraph.MapUpToSnapshot(position, PointTrackingMode.Positive, PositionAffinity.Successor, textView.TextSnapshot); diff --git a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs index 2254250b949ef..282809244a442 100644 --- a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs +++ b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs @@ -4,11 +4,11 @@ using System.Threading; using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent; +using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.UnitTests.Utilities; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; From fcafe8221e5b63ffd9c15510deffb3cb26363d4e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 15:52:11 -0800 Subject: [PATCH 04/43] Fix. --- .../Options/Formatting/FormattingOptionPageControl.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs index 378a4c2631de0..edff2823c8df1 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs @@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Options; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.VisualStudio.LanguageServices.Implementation.Options; namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options @@ -24,7 +25,7 @@ public FormattingOptionPageControl(OptionStore optionStore) : base(optionStore) BindToOption(FormatWhenTypingCheckBox, FeatureOnOffOptions.AutoFormattingOnTyping, LanguageNames.CSharp); BindToOption(FormatOnCloseBraceCheckBox, FeatureOnOffOptions.AutoFormattingOnCloseBrace, LanguageNames.CSharp); BindToOption(FormatOnSemicolonCheckBox, FeatureOnOffOptions.AutoFormattingOnSemicolon, LanguageNames.CSharp); - BindToOption(FormatOnReturnCheckBox, FeatureOnOffOptions.AutoFormattingOnReturn, LanguageNames.CSharp); + BindToOption(FormatOnReturnCheckBox, FormattingOptions.AutoFormattingOnReturn, LanguageNames.CSharp); BindToOption(FormatOnPasteCheckBox, FeatureOnOffOptions.FormatOnPaste, LanguageNames.CSharp); } } From 461f34225379f1c5bc0e539b3dda00e2fcde7b1e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 18:51:08 -0800 Subject: [PATCH 05/43] Share more code --- .../SmartTokenFormatterCommandHandler.cs | 7 +++++-- .../SmartIndenterEnterOnTokenTests.cs | 6 ++++-- ...AbstractSmartTokenFormatterCommandHandler.cs | 16 +++++++--------- .../SmartTokenFormatterCommandHandler.vb | 3 ++- .../SmartTokenFormatter_FormatTokenTests.vb | 3 ++- .../CSharpIndentationService.Indenter.cs | 2 +- .../Indentation/CSharpIndentationService.cs | 17 ++++++++++++++++- .../VisualBasicIndentationService.Indenter.vb | 2 +- .../VisualBasicIndentationService.vb | 16 ++++++++++++++-- 9 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index 2190453da05b9..0628883d29b34 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -41,9 +41,12 @@ protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet opti return new SmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); } - protected override bool UseSmartTokenFormatter(SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, CancellationToken cancellationToken) + protected override bool UseSmartTokenFormatter( + SyntaxNode root, TextLine line, IEnumerable formattingRules, + OptionSet options, out SyntaxToken token, CancellationToken cancellationToken) { - return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter(formattingRules, (CompilationUnitSyntax)root, line, options, cancellationToken); + return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( + formattingRules, (CompilationUnitSyntax)root, line, options, out token, cancellationToken); } protected override IEnumerable GetFormattingRules(Document document, int position) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs index 2ff3e51c083c3..8bec6f7945725 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs @@ -1367,7 +1367,8 @@ private async Task AssertIndentUsingSmartTokenFormatterAsync( Assert.True( CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( Formatter.GetDefaultFormattingRules(workspace, root.Language), - root, line.AsTextLine(), await document.GetOptionsAsync(), CancellationToken.None)); + root, line.AsTextLine(), await document.GetOptionsAsync(), + out _, CancellationToken.None)); var actualIndentation = await GetSmartTokenFormatterIndentationWorkerAsync(workspace, buffer, indentationLine, ch); Assert.Equal(expectedIndentation.Value, actualIndentation); @@ -1397,7 +1398,8 @@ private async Task AssertIndentNotUsingSmartTokenFormatterButUsingIndenterAsync( Assert.False( CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( Formatter.GetDefaultFormattingRules(workspace, root.Language), - root, line.AsTextLine(), await document.GetOptionsAsync(), CancellationToken.None)); + root, line.AsTextLine(), await document.GetOptionsAsync(), + out _, CancellationToken.None)); TestIndentation( workspace, indentationLine, diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index 78a6f5f2c3430..e49d213723bef 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -42,7 +42,10 @@ public AbstractSmartTokenFormatterCommandHandler( protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - protected abstract bool UseSmartTokenFormatter(SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, CancellationToken cancellationToken); + protected abstract bool UseSmartTokenFormatter( + SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, + out SyntaxToken token, CancellationToken cancellationToken); + protected abstract bool IsInvalidToken(SyntaxToken token); protected abstract IEnumerable GetFormattingRules(Document document, int position); @@ -307,14 +310,9 @@ private bool TryFormatUsingTokenFormatter(ITextView view, ITextBuffer subjectBuf var line = position.GetContainingLine().AsTextLine(); var root = document.GetSyntaxRootSynchronously(cancellationToken); var options = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - if (!UseSmartTokenFormatter(root, line, formattingRules, options, cancellationToken)) - { - return false; - } - - var firstNonWhitespacePosition = line.GetFirstNonWhitespacePosition(); - var token = root.FindToken(firstNonWhitespacePosition.Value); - if (IsInvalidToken(token)) + if (!UseSmartTokenFormatter( + root, line, formattingRules, options, + out var token, cancellationToken)) { return false; } diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb index 8de480da9e827..c4e581f086de4 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb @@ -43,9 +43,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation line As TextLine, formattingRules As IEnumerable(Of AbstractFormattingRule), options As OptionSet, + ByRef token As SyntaxToken, cancellationToken As CancellationToken) As Boolean Return VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( - formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, cancellationToken, neverUseWhenHavingMissingToken:=False) + formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, token, cancellationToken, neverUseWhenHavingMissingToken:=False) End Function Protected Overrides Function IsInvalidToken(token As SyntaxToken) As Boolean diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb index be675cc951360..ac16ecb35d263 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb @@ -197,7 +197,8 @@ End Class Dim ignoreMissingToken = previousToken.IsMissing AndAlso line.Start.Position = position Assert.True(VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( - formattingRules, root, line.AsTextLine, workspace.Options, Nothing, ignoreMissingToken)) + formattingRules, root, line.AsTextLine, workspace.Options, + Nothing, Nothing, ignoreMissingToken)) Dim smartFormatter = New SmartTokenFormatter(Await document.GetOptionsAsync(CancellationToken.None), formattingRules, root) Dim changes = Await smartFormatter.FormatTokenAsync(workspace, token, Nothing) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index e1aa2f1b11b0a..2ad8100e93f90 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -35,7 +35,7 @@ public Indenter( public override bool ShouldUseFormatterIfAvailable() => ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, Root, LineToBeIndented, OptionSet, CancellationToken); + Rules, Root, LineToBeIndented, OptionSet, out _, CancellationToken); protected override IndentationResult GetDesiredIndentationWorker( SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs index 4f8e934907908..4628e8f980d4d 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -43,11 +43,13 @@ public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( CompilationUnitSyntax root, TextLine line, OptionSet optionSet, + out SyntaxToken token, CancellationToken cancellationToken) { Contract.ThrowIfNull(formattingRules); Contract.ThrowIfNull(root); + token = default; if (!optionSet.GetOption(FormattingOptions.AutoFormattingOnReturn, LanguageNames.CSharp)) { return false; @@ -64,7 +66,12 @@ public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( return false; } - var token = root.FindToken(firstNonWhitespacePosition.Value); + token = root.FindToken(firstNonWhitespacePosition.Value); + if (IsInvalidToken(token)) + { + return false; + } + if (token.IsKind(SyntaxKind.None) || token.SpanStart != firstNonWhitespacePosition) { @@ -92,6 +99,14 @@ public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( return true; } + private static bool IsInvalidToken(SyntaxToken token) + { + // invalid token to be formatted + return token.IsKind(SyntaxKind.None) || + token.IsKind(SyntaxKind.EndOfDirectiveToken) || + token.IsKind(SyntaxKind.EndOfFileToken); + } + private class FormattingRule : AbstractFormattingRule { public override void AddIndentBlockOperations(List list, SyntaxNode node, OptionSet optionSet, in NextIndentBlockOperationAction nextOperation) diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index ddc6bdc70cb4b..358be2c568e7e 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -26,7 +26,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Public Overrides Function ShouldUseFormatterIfAvailable() As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, CancellationToken) + Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, Nothing, CancellationToken) End Function Protected Overrides Function GetDesiredIndentationWorker( diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index 00eb191d00df0..4265d20d96ade 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -46,6 +46,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation root As CompilationUnitSyntax, line As TextLine, optionSet As OptionSet, + ByRef token As SyntaxToken, CancellationToken As CancellationToken, Optional neverUseWhenHavingMissingToken As Boolean = True) As Boolean @@ -56,7 +57,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation End If ' enter on token only works when first token on line is first text on line - Dim token = root.FindToken(firstNonWhitespacePosition.Value) + token = root.FindToken(firstNonWhitespacePosition.Value) + If IsInvalidToken(token) Then + Return False + End If + If token.Kind = SyntaxKind.None OrElse token.SpanStart <> firstNonWhitespacePosition Then Return False End If @@ -97,6 +102,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Dim startNode = token.Parent Dim currentNode = startNode + Dim localToken = token Do While currentNode IsNot Nothing Dim operations = FormattingOperations.GetAlignTokensOperations( formattingRules, currentNode, optionSet:=optionSet) @@ -107,7 +113,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation End If ' make sure we have the given token as one of tokens to be aligned to the base token - Dim match = operations.FirstOrDefault(Function(o) o.Tokens.Contains(token)) + Dim match = operations.FirstOrDefault(Function(o) o.Tokens.Contains(localToken)) If match IsNot Nothing Then Return True End If @@ -118,5 +124,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation ' no indentation operation, nothing to do for smart token formatter Return False End Function + + Private Shared Function IsInvalidToken(token As SyntaxToken) As Boolean + ' invalid token to be formatted + Return token.Kind = SyntaxKind.None OrElse + token.Kind = SyntaxKind.EndOfFileToken + End Function End Class End Namespace From 551f2ea5b6fb54350077ea6eb1d7328f26b0c4e3 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 18:52:48 -0800 Subject: [PATCH 06/43] Remove unused methods --- .../Indentation/SmartTokenFormatterCommandHandler.cs | 8 -------- .../AbstractSmartTokenFormatterCommandHandler.cs | 2 -- .../Indentation/SmartTokenFormatterCommandHandler.vb | 6 ------ 3 files changed, 16 deletions(-) diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index 0628883d29b34..ee0fa0063e6f1 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -55,13 +55,5 @@ protected override IEnumerable GetFormattingRules(Docume var formattingRuleFactory = workspace.Services.GetService(); return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); } - - protected override bool IsInvalidToken(SyntaxToken token) - { - // invalid token to be formatted - return token.IsKind(SyntaxKind.None) || - token.IsKind(SyntaxKind.EndOfDirectiveToken) || - token.IsKind(SyntaxKind.EndOfFileToken); - } } } diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index e49d213723bef..95acf6e97d42b 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -46,8 +46,6 @@ protected abstract bool UseSmartTokenFormatter( SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, out SyntaxToken token, CancellationToken cancellationToken); - protected abstract bool IsInvalidToken(SyntaxToken token); - protected abstract IEnumerable GetFormattingRules(Document document, int position); /// True if any change is made. diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb index c4e581f086de4..1712d173abbbe 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb @@ -48,11 +48,5 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Return VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, token, cancellationToken, neverUseWhenHavingMissingToken:=False) End Function - - Protected Overrides Function IsInvalidToken(token As SyntaxToken) As Boolean - ' invalid token to be formatted - Return token.Kind = SyntaxKind.None OrElse - token.Kind = SyntaxKind.EndOfFileToken - End Function End Class End Namespace From fa2c5d618d6093cc7133b7289afa850d516bfc73 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 18:59:59 -0800 Subject: [PATCH 07/43] Rename method --- .../Portable/Indentation/CSharpIndentationService.Indenter.cs | 2 +- .../Indentation/AbstractIndentationService.AbstractIndenter.cs | 2 +- .../Core/Portable/Indentation/AbstractIndentationService.cs | 2 +- .../Indentation/VisualBasicIndentationService.Indenter.vb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index 2ad8100e93f90..f93eb2473950b 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -33,7 +33,7 @@ public Indenter( { } - public override bool ShouldUseFormatterIfAvailable() + public override bool ShouldUseTokenFormatter() => ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, Root, LineToBeIndented, OptionSet, out _, CancellationToken); diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 20fb4f5739657..07a0ef15217d5 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -57,7 +57,7 @@ public AbstractIndenter( tokenStream: null); } - public abstract bool ShouldUseFormatterIfAvailable(); + public abstract bool ShouldUseTokenFormatter(); public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle indentStyle) { diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 768a620b96a6c..b2428ab1d2052 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -47,7 +47,7 @@ private IEnumerable GetFormattingRules(Document document // the next line). If we're in the latter case, we defer to the Formatting engine // as we need it to use all its rules to determine where the appropriate location is // for the following tokens to go. - if (indenter.ShouldUseFormatterIfAvailable()) + if (indenter.ShouldUseTokenFormatter()) { return null; } diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index 358be2c568e7e..e8f68950fb785 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -24,7 +24,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation MyBase.New(syntaxFacts, syntaxTree, rules, optionSet, line, cancellationToken) End Sub - Public Overrides Function ShouldUseFormatterIfAvailable() As Boolean + Public Overrides Function ShouldUseTokenFormatter() As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, Nothing, CancellationToken) End Function From ed863d08f57ecf074a87336fba4a8600867e7f91 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:10:29 -0800 Subject: [PATCH 08/43] Work --- .../CSharpIndentationService.Indenter.cs | 2 +- ...ractIndentationService.AbstractIndenter.cs | 2 +- .../Indentation/AbstractIndentationService.cs | 31 +++++++++++++++++-- .../VisualBasicIndentationService.Indenter.vb | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index f93eb2473950b..efe0ebcf6370c 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -33,7 +33,7 @@ public Indenter( { } - public override bool ShouldUseTokenFormatter() + public override bool ShouldUseTokenIndenter() => ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, Root, LineToBeIndented, OptionSet, out _, CancellationToken); diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 07a0ef15217d5..ada4df3560cf0 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -57,7 +57,7 @@ public AbstractIndenter( tokenStream: null); } - public abstract bool ShouldUseTokenFormatter(); + public abstract bool ShouldUseTokenIndenter(); public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle indentStyle) { diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index b2428ab1d2052..1cc90c551a2e4 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -47,14 +48,40 @@ private IEnumerable GetFormattingRules(Document document // the next line). If we're in the latter case, we defer to the Formatting engine // as we need it to use all its rules to determine where the appropriate location is // for the following tokens to go. - if (indenter.ShouldUseTokenFormatter()) + if (indenter.ShouldUseTokenIndenter(out var token)) { - return null; + return UseTokenIndenter(document, token, cancellationToken); } return indenter.GetDesiredIndentation(indentStyle); } + private IndentationResult UseTokenIndenter( + Document document, SyntaxToken token, CancellationToken cancellationToken) + { + var formattingRules = this.GetFormattingRules(document, currentPosition.Position); + + var root = document.GetSyntaxRootSynchronously(cancellationToken); + var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); + var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); + var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); + if (changes.Count == 0) + { + return false; + } + } + + protected abstract AbstractTokenIndenter CreateTokenIndenter(AbstractIndenter indenter); + + protected abstract class AbstractTokenIndenter + { + public IndentationResult GetDesiredIndentation() + { + + throw new NotImplementedException(); + } + } + public IndentationResult GetBlankLineIndentation( Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken) { diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index e8f68950fb785..c32581253b562 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -24,7 +24,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation MyBase.New(syntaxFacts, syntaxTree, rules, optionSet, line, cancellationToken) End Sub - Public Overrides Function ShouldUseTokenFormatter() As Boolean + Public Overrides Function ShouldUseTokenIndenter() As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, Nothing, CancellationToken) End Function From 3aefaa901b72031b98d03c6085077addcd5e6e84 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:11:28 -0800 Subject: [PATCH 09/43] work --- .../Indentation/AbstractIndentationService.AbstractIndenter.cs | 2 +- .../Core/Portable/Indentation/AbstractIndentationService.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index ada4df3560cf0..6b554163ff6b5 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -57,7 +57,7 @@ public AbstractIndenter( tokenStream: null); } - public abstract bool ShouldUseTokenIndenter(); + public abstract bool ShouldUseTokenIndenter(out SyntaxToken token); public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle indentStyle) { diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 1cc90c551a2e4..350749d6997ed 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -71,6 +71,8 @@ private IndentationResult UseTokenIndenter( } } + protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); + protected abstract AbstractTokenIndenter CreateTokenIndenter(AbstractIndenter indenter); protected abstract class AbstractTokenIndenter From 5505579cbade966a68dbe340e1cea902905ce248 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:22:25 -0800 Subject: [PATCH 10/43] move ISmartTokenFormatter down as well --- .../CSharp/Formatting/CSharpEditorFormattingService.cs | 6 ++++-- .../Indentation/SmartTokenFormatterCommandHandler.cs | 3 ++- .../Formatting/Indentation/CSharpFormatterTestsBase.cs | 3 ++- .../Indentation/SmartTokenFormatterFormatRangeTests.cs | 3 ++- .../Indentation/SmartTokenFormatterCommandHandler.vb | 3 ++- .../Indentation/SmartTokenFormatter_FormatTokenTests.vb | 2 +- .../Portable/Indentation/CSharpSmartTokenFormatter.cs} | 9 ++++----- .../Core/Portable}/Indentation/ISmartTokenFormatter.cs | 2 +- .../Indentation/VisualBasicSmartTokenFormatter.vb} | 6 +++--- 9 files changed, 21 insertions(+), 16 deletions(-) rename src/{EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs => Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs} (96%) rename src/{EditorFeatures/Core/Implementation/Formatting => Workspaces/Core/Portable}/Indentation/ISmartTokenFormatter.cs (85%) rename src/{EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatter.vb => Workspaces/VisualBasic/Portable/Indentation/VisualBasicSmartTokenFormatter.vb} (90%) diff --git a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs index 3cbcb7753ff71..ae0a7a3fd374f 100644 --- a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs +++ b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; @@ -18,6 +19,7 @@ using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -322,7 +324,7 @@ private async Task> FormatTokenAsync(Document document, Syntax private ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) { - return new SmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); + return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); } private async Task> FormatRangeAsync( @@ -348,7 +350,7 @@ private async Task> FormatRangeAsync( var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); - var formatter = new SmartTokenFormatter(options, formattingRules, (CompilationUnitSyntax)root); + var formatter = new CSharpSmartTokenFormatter(options, formattingRules, (CompilationUnitSyntax)root); var changes = formatter.FormatRange(document.Project.Solution.Workspace, tokenRange.Value.Item1, tokenRange.Value.Item2, cancellationToken); return changes; diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index 2190453da05b9..37a3dda8d8d40 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Text.Operations; @@ -38,7 +39,7 @@ public SmartTokenFormatterCommandHandler( protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) { - return new SmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); + return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); } protected override bool UseSmartTokenFormatter(SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, CancellationToken cancellationToken) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs index 370169208ba22..01a1ae57a8bb2 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; @@ -87,7 +88,7 @@ private static async Task TokenFormatWorkerAsync(TestWorkspace workspace, ITextB var rules = formattingRuleProvider.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); var documentOptions = await document.GetOptionsAsync(); - var formatter = new SmartTokenFormatter(documentOptions, rules, root); + var formatter = new CSharpSmartTokenFormatter(documentOptions, rules, root); var changes = await formatter.FormatTokenAsync(workspace, token, CancellationToken.None); ApplyChanges(buffer, changes); diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs index 20bd16e4d82fd..3ad86728b76f3 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; @@ -3493,7 +3494,7 @@ private async Task AutoFormatOnMarkerAsync(string initialMarkup, string expected } Assert.Equal(tokenKind, endToken.Kind()); - var formatter = new SmartTokenFormatter(tuple.Item1, tuple.Item2, root); + var formatter = new CSharpSmartTokenFormatter(tuple.Item1, tuple.Item2, root); var tokenRange = FormattingRangeHelper.FindAppropriateRange(endToken); if (tokenRange == null) diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb index 8de480da9e827..e058298dd3195 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb @@ -5,6 +5,7 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules +Imports Microsoft.CodeAnalysis.Indentation Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Indentation @@ -36,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation End Function Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter - Return New SmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) + Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) End Function Protected Overrides Function UseSmartTokenFormatter(root As SyntaxNode, diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb index be675cc951360..08064993d473d 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb @@ -199,7 +199,7 @@ End Class Assert.True(VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( formattingRules, root, line.AsTextLine, workspace.Options, Nothing, ignoreMissingToken)) - Dim smartFormatter = New SmartTokenFormatter(Await document.GetOptionsAsync(CancellationToken.None), formattingRules, root) + Dim smartFormatter = New VisualBasicSmartTokenFormatter(Await document.GetOptionsAsync(CancellationToken.None), formattingRules, root) Dim changes = Await smartFormatter.FormatTokenAsync(workspace, token, Nothing) Using edit = buffer.CreateEdit() diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs similarity index 96% rename from src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs rename to src/Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs index d7c6696581dd0..b5477280ae394 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs @@ -4,28 +4,27 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; +using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation +namespace Microsoft.CodeAnalysis.CSharp.Indentation { - internal class SmartTokenFormatter : ISmartTokenFormatter + internal class CSharpSmartTokenFormatter : ISmartTokenFormatter { private readonly OptionSet _optionSet; private readonly IEnumerable _formattingRules; private readonly CompilationUnitSyntax _root; - public SmartTokenFormatter( + public CSharpSmartTokenFormatter( OptionSet optionSet, IEnumerable formattingRules, CompilationUnitSyntax root) diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/ISmartTokenFormatter.cs b/src/Workspaces/Core/Portable/Indentation/ISmartTokenFormatter.cs similarity index 85% rename from src/EditorFeatures/Core/Implementation/Formatting/Indentation/ISmartTokenFormatter.cs rename to src/Workspaces/Core/Portable/Indentation/ISmartTokenFormatter.cs index 952d40e89f291..b0aaf9fd45125 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/ISmartTokenFormatter.cs +++ b/src/Workspaces/Core/Portable/Indentation/ISmartTokenFormatter.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Text; -namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation +namespace Microsoft.CodeAnalysis.Indentation { internal interface ISmartTokenFormatter { diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicSmartTokenFormatter.vb similarity index 90% rename from src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatter.vb rename to src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicSmartTokenFormatter.vb index 749448f0cbfc3..e75e177fc5f78 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicSmartTokenFormatter.vb @@ -1,15 +1,15 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. Imports System.Threading -Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules +Imports Microsoft.CodeAnalysis.Indentation Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation - Friend Class SmartTokenFormatter +Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation + Friend Class VisualBasicSmartTokenFormatter Implements ISmartTokenFormatter Private ReadOnly _optionSet As OptionSet From 88d7ba0c46bbd2ffa38018249b1720a4874579dd Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:34:06 -0800 Subject: [PATCH 11/43] Pass token all the way back out --- .../CSharpIndentationService.Indenter.cs | 4 +- .../Indentation/AbstractIndentationService.cs | 41 ++++++++----------- .../VisualBasicIndentationService.Indenter.vb | 4 +- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index efe0ebcf6370c..e144cf560a9f4 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -33,9 +33,9 @@ public Indenter( { } - public override bool ShouldUseTokenIndenter() + public override bool ShouldUseTokenIndenter(out SyntaxToken syntaxToken) => ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, Root, LineToBeIndented, OptionSet, out _, CancellationToken); + Rules, Root, LineToBeIndented, OptionSet, out syntaxToken, CancellationToken); protected override IndentationResult GetDesiredIndentationWorker( SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 350749d6997ed..69ac67f805c8f 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -50,39 +50,30 @@ private IEnumerable GetFormattingRules(Document document // for the following tokens to go. if (indenter.ShouldUseTokenIndenter(out var token)) { - return UseTokenIndenter(document, token, cancellationToken); + return null; // UseTokenIndenter(document, token, cancellationToken); } return indenter.GetDesiredIndentation(indentStyle); } - private IndentationResult UseTokenIndenter( - Document document, SyntaxToken token, CancellationToken cancellationToken) - { - var formattingRules = this.GetFormattingRules(document, currentPosition.Position); - - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); - var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - if (changes.Count == 0) - { - return false; - } - } + //private IndentationResult UseTokenIndenter( + // Document document, SyntaxToken token, CancellationToken cancellationToken) + //{ + // var formattingRules = this.GetFormattingRules(document, currentPosition.Position); - protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); + // var root = document.GetSyntaxRootSynchronously(cancellationToken); + // var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); + // var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); + // var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); + // if (changes.Count == 0) + // { + // return false; + // } + //} - protected abstract AbstractTokenIndenter CreateTokenIndenter(AbstractIndenter indenter); + //protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - protected abstract class AbstractTokenIndenter - { - public IndentationResult GetDesiredIndentation() - { - - throw new NotImplementedException(); - } - } + // protected abstract AbstractTokenIndenter CreateTokenIndenter(AbstractIndenter indenter); public IndentationResult GetBlankLineIndentation( Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken) diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index c32581253b562..663673074b72c 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -24,9 +24,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation MyBase.New(syntaxFacts, syntaxTree, rules, optionSet, line, cancellationToken) End Sub - Public Overrides Function ShouldUseTokenIndenter() As Boolean + Public Overrides Function ShouldUseTokenIndenter(ByRef token As SyntaxToken) As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, Nothing, CancellationToken) + Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, token, CancellationToken) End Function Protected Overrides Function GetDesiredIndentationWorker( From ca7cf85fef560e87c62b185d7c3dd78adea6f921 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:39:05 -0800 Subject: [PATCH 12/43] simplify --- .../Indentation/SmartTokenFormatterCommandHandler.cs | 2 +- .../Indentation/SmartIndenterEnterOnTokenTests.cs | 6 ++---- .../Indentation/CSharpIndentationService.Indenter.cs | 2 +- .../CSharp/Portable/Indentation/CSharpIndentationService.cs | 3 +-- .../Indentation/VisualBasicIndentationService.Indenter.vb | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index 45ab7c7fbdc0a..04f8b3bbaeb36 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -47,7 +47,7 @@ protected override bool UseSmartTokenFormatter( OptionSet options, out SyntaxToken token, CancellationToken cancellationToken) { return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( - formattingRules, (CompilationUnitSyntax)root, line, options, out token, cancellationToken); + formattingRules, (CompilationUnitSyntax)root, line, options, out token); } protected override IEnumerable GetFormattingRules(Document document, int position) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs index 8bec6f7945725..b052f10380671 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterEnterOnTokenTests.cs @@ -1367,8 +1367,7 @@ private async Task AssertIndentUsingSmartTokenFormatterAsync( Assert.True( CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( Formatter.GetDefaultFormattingRules(workspace, root.Language), - root, line.AsTextLine(), await document.GetOptionsAsync(), - out _, CancellationToken.None)); + root, line.AsTextLine(), await document.GetOptionsAsync(), out _)); var actualIndentation = await GetSmartTokenFormatterIndentationWorkerAsync(workspace, buffer, indentationLine, ch); Assert.Equal(expectedIndentation.Value, actualIndentation); @@ -1398,8 +1397,7 @@ private async Task AssertIndentNotUsingSmartTokenFormatterButUsingIndenterAsync( Assert.False( CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( Formatter.GetDefaultFormattingRules(workspace, root.Language), - root, line.AsTextLine(), await document.GetOptionsAsync(), - out _, CancellationToken.None)); + root, line.AsTextLine(), await document.GetOptionsAsync(), out _)); TestIndentation( workspace, indentationLine, diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index e144cf560a9f4..9dd37e0e61545 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -35,7 +35,7 @@ public Indenter( public override bool ShouldUseTokenIndenter(out SyntaxToken syntaxToken) => ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, Root, LineToBeIndented, OptionSet, out syntaxToken, CancellationToken); + Rules, Root, LineToBeIndented, OptionSet, out syntaxToken); protected override IndentationResult GetDesiredIndentationWorker( SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs index 4628e8f980d4d..612338fa28991 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -43,8 +43,7 @@ public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( CompilationUnitSyntax root, TextLine line, OptionSet optionSet, - out SyntaxToken token, - CancellationToken cancellationToken) + out SyntaxToken token) { Contract.ThrowIfNull(formattingRules); Contract.ThrowIfNull(root); diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index 663673074b72c..4622bf6e5632b 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -26,7 +26,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Public Overrides Function ShouldUseTokenIndenter(ByRef token As SyntaxToken) As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( - Rules, DirectCast(Root, CompilationUnitSyntax), LineToBeIndented, OptionSet, token, CancellationToken) + Rules, Root, LineToBeIndented, OptionSet, token, CancellationToken) End Function Protected Overrides Function GetDesiredIndentationWorker( From 3b0b6b417a5d1d2f14c6d670e27d95da50a7997c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 19:55:45 -0800 Subject: [PATCH 13/43] Move code from command handler into indentation service --- .../CSharpEditorFormattingService.cs | 1 - .../SmartTokenFormatterCommandHandler.cs | 110 +-- ...stractSmartTokenFormatterCommandHandler.cs | 700 +++++++++--------- .../SmartTokenFormatterCommandHandler.vb | 92 +-- .../Indentation/CSharpIndentationService.cs | 13 + .../Indentation/AbstractIndentationService.cs | 40 +- .../VisualBasicIndentationService.vb | 11 + 7 files changed, 498 insertions(+), 469 deletions(-) diff --git a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs index b5ccd45641df8..244050bea8f99 100644 --- a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs +++ b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs index 04f8b3bbaeb36..7e692ba22748a 100644 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs @@ -1,60 +1,60 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +//// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Generic; -using System.ComponentModel.Composition; -using System.Linq; -using System.Threading; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Indentation; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; -using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Indentation; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.Text.Operations; -using Microsoft.VisualStudio.Utilities; -using Roslyn.Utilities; -using VSCommanding = Microsoft.VisualStudio.Commanding; +//using System.Collections.Generic; +//using System.ComponentModel.Composition; +//using System.Linq; +//using System.Threading; +//using Microsoft.CodeAnalysis.CSharp; +//using Microsoft.CodeAnalysis.CSharp.Indentation; +//using Microsoft.CodeAnalysis.CSharp.Syntax; +//using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; +//using Microsoft.CodeAnalysis.Formatting; +//using Microsoft.CodeAnalysis.Formatting.Rules; +//using Microsoft.CodeAnalysis.Indentation; +//using Microsoft.CodeAnalysis.Options; +//using Microsoft.CodeAnalysis.Text; +//using Microsoft.VisualStudio.Text.Operations; +//using Microsoft.VisualStudio.Utilities; +//using Roslyn.Utilities; +//using VSCommanding = Microsoft.VisualStudio.Commanding; -namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation -{ - [Export(typeof(VSCommanding.ICommandHandler))] - [ContentType(ContentTypeNames.CSharpContentType)] - [Name(PredefinedCommandHandlerNames.Indent)] - [Order(After = PredefinedCommandHandlerNames.Rename)] - [Order(Before = PredefinedCommandHandlerNames.Completion)] - internal class SmartTokenFormatterCommandHandler : - AbstractSmartTokenFormatterCommandHandler - { - [ImportingConstructor] - public SmartTokenFormatterCommandHandler( - ITextUndoHistoryRegistry undoHistoryRegistry, - IEditorOperationsFactoryService editorOperationsFactoryService) : - base(undoHistoryRegistry, - editorOperationsFactoryService) - { - } +//namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation +//{ +// [Export(typeof(VSCommanding.ICommandHandler))] +// [ContentType(ContentTypeNames.CSharpContentType)] +// [Name(PredefinedCommandHandlerNames.Indent)] +// [Order(After = PredefinedCommandHandlerNames.Rename)] +// [Order(Before = PredefinedCommandHandlerNames.Completion)] +// internal class SmartTokenFormatterCommandHandler : +// AbstractSmartTokenFormatterCommandHandler +// { +// [ImportingConstructor] +// public SmartTokenFormatterCommandHandler( +// ITextUndoHistoryRegistry undoHistoryRegistry, +// IEditorOperationsFactoryService editorOperationsFactoryService) : +// base(undoHistoryRegistry, +// editorOperationsFactoryService) +// { +// } - protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) - { - return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); - } +// protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) +// { +// return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); +// } - protected override bool UseSmartTokenFormatter( - SyntaxNode root, TextLine line, IEnumerable formattingRules, - OptionSet options, out SyntaxToken token, CancellationToken cancellationToken) - { - return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( - formattingRules, (CompilationUnitSyntax)root, line, options, out token); - } +// protected override bool UseSmartTokenFormatter( +// SyntaxNode root, TextLine line, IEnumerable formattingRules, +// OptionSet options, out SyntaxToken token, CancellationToken cancellationToken) +// { +// return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( +// formattingRules, (CompilationUnitSyntax)root, line, options, out token); +// } - protected override IEnumerable GetFormattingRules(Document document, int position) - { - var workspace = document.Project.Solution.Workspace; - var formattingRuleFactory = workspace.Services.GetService(); - return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); - } - } -} +// protected override IEnumerable GetFormattingRules(Document document, int position) +// { +// var workspace = document.Project.Solution.Workspace; +// var formattingRuleFactory = workspace.Services.GetService(); +// return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); +// } +// } +//} diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index 95acf6e97d42b..4c2da6a19e3d4 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -1,350 +1,350 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using Microsoft.CodeAnalysis.Editor.Shared.Extensions; -using Microsoft.CodeAnalysis.Editor.Shared.Utilities; -using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Indentation; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; -using Microsoft.VisualStudio.Commanding; -using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods; -using Microsoft.VisualStudio.Text.Operations; -using Roslyn.Utilities; -using VSCommanding = Microsoft.VisualStudio.Commanding; - -namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -{ - internal abstract class AbstractSmartTokenFormatterCommandHandler : - IChainedCommandHandler - { - private readonly ITextUndoHistoryRegistry _undoHistoryRegistry; - private readonly IEditorOperationsFactoryService _editorOperationsFactoryService; - - public string DisplayName => EditorFeaturesResources.Smart_Token_Formatter; - - public AbstractSmartTokenFormatterCommandHandler( - ITextUndoHistoryRegistry undoHistoryRegistry, - IEditorOperationsFactoryService editorOperationsFactoryService) - { - _undoHistoryRegistry = undoHistoryRegistry; - _editorOperationsFactoryService = editorOperationsFactoryService; - } - - protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - - protected abstract bool UseSmartTokenFormatter( - SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, - out SyntaxToken token, CancellationToken cancellationToken); - - protected abstract IEnumerable GetFormattingRules(Document document, int position); - - /// True if any change is made. - protected bool FormatToken(ITextView view, Document document, SyntaxToken token, IEnumerable formattingRules, CancellationToken cancellationToken) - { - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); - var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - if (changes.Count == 0) - { - return false; - } - - using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Format_Token)) - { - transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance; - - document.Project.Solution.Workspace.ApplyTextChanges(document.Id, changes, cancellationToken); - transaction.Complete(); - } - - return true; - } - - public VSCommanding.CommandState GetCommandState(ReturnKeyCommandArgs args, Func nextHandler) - { - return nextHandler(); - } - - public void ExecuteCommand(ReturnKeyCommandArgs args, Action nextHandler, CommandExecutionContext context) - { - var textView = args.TextView; - var oldCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); - - nextHandler(); - - // A feature like completion handled the return key but did not pass it on to the editor. - var newCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); - if (textView.Selection.IsEmpty && oldCaretPoint.HasValue && newCaretPoint.HasValue && - oldCaretPoint.Value.GetContainingLine().LineNumber == newCaretPoint.Value.GetContainingLine().LineNumber) - { - return; - } - - if (args.SubjectBuffer.CanApplyChangeDocumentToWorkspace()) - { - ExecuteCommandWorker(args, CancellationToken.None); - } - } - - internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken cancellationToken) - { - var textView = args.TextView; - var caretPoint = textView.GetCaretPoint(args.SubjectBuffer); - - if (!caretPoint.HasValue) - { - return; - } - - var currentPosition = caretPoint.Value; - var document = currentPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); - if (document == null) - { - return; - } - - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - if (documentOptions.GetOption(FormattingOptions.SmartIndent) != FormattingOptions.IndentStyle.Smart) - { - return; - } - - var formattingRules = this.GetFormattingRules(document, currentPosition.Position); - - // see whether we should use token formatter - if (TryFormatUsingTokenFormatter(textView, args.SubjectBuffer, document, formattingRules, cancellationToken)) - { - return; - } - - // check whether editor would have used smart indenter - if (EditorHandled(textView) && !RequireReadjustment(textView, args.SubjectBuffer)) - { - // editor already took care of smart indentation. - return; - } - - // check whether we can do it ourselves - if (!CanHandleOurselves(textView, args.SubjectBuffer)) - { - return; - } - - var indentationService = document.GetLanguageService(); - var indentation = indentationService.GetDesiredIndentation(document, - currentPosition.GetContainingLine().LineNumber, cancellationToken); - - // looks like we can't. - if (!indentation.HasValue) - { - return; - } - - HandleOurselves(textView, args.SubjectBuffer, indentation.Value.GetIndentation(textView, currentPosition.GetContainingLine()), documentOptions); - } - - private bool RequireReadjustment(ITextView view, ITextBuffer subjectBuffer) - { - var caretInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value; - var lineInSubjectBuffer = caretInSubjectBuffer.GetContainingLine(); - - var currentOffset = caretInSubjectBuffer - lineInSubjectBuffer.Start; - var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); - if (!firstNonWhitespaceIndex.HasValue || currentOffset >= firstNonWhitespaceIndex.Value) - { - return false; - } - - // there are whitespace after caret position (which smart indentation has put), - // we might need to re-adjust indentation - return true; - } - - private void HandleOurselves(ITextView view, ITextBuffer subjectBuffer, int indentation, DocumentOptionSet options) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - var lengthOfLine = lineInSubjectBuffer.GetColumnFromLineOffset(lineInSubjectBuffer.Length, view.Options); - - // check whether we are dealing with virtual space or real space - if (indentation > lengthOfLine) - { - // we are dealing with virtual space - var caretPosition = view.GetVirtualCaretPoint(subjectBuffer); - var positionInVirtualSpace = new VirtualSnapshotPoint(caretPosition.Value.Position, indentation - lineInSubjectBuffer.Length); - view.TryMoveCaretToAndEnsureVisible(positionInVirtualSpace); - return; - } - - // we are dealing with real space. check whether we need to just set caret position or move text - var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); - - if (firstNonWhitespaceIndex.HasValue) - { - // if leading whitespace is not what we expect, re-adjust indentation - var columnOfFirstNonWhitespace = lineInSubjectBuffer.GetColumnFromLineOffset(firstNonWhitespaceIndex.Value, view.Options); - if (columnOfFirstNonWhitespace != indentation) - { - ReadjustIndentation(view, subjectBuffer, firstNonWhitespaceIndex.Value, indentation, options); - return; - } - } - - // okay, it is an empty line with some whitespaces - Debug.Assert(indentation <= lineInSubjectBuffer.Length); - - var offset = GetOffsetFromIndentation(indentation, view.Options); - view.TryMoveCaretToAndEnsureVisible(lineInSubjectBuffer.Start.Add(offset)); - } - - private int GetOffsetFromIndentation(int indentation, IEditorOptions option) - { - int numberOfTabs = 0; - int numberOfSpaces = Math.Max(0, indentation); - - if (!option.IsConvertTabsToSpacesEnabled()) - { - var tabSize = option.GetTabSize(); - - numberOfTabs = indentation / tabSize; - numberOfSpaces -= numberOfTabs * tabSize; - } - - return numberOfTabs + numberOfSpaces; - } - - /// - /// re-adjust caret position to be the beginning of first text on the line. and make sure the text start at the given indentation - /// - private static void ReadjustIndentation(ITextView view, ITextBuffer subjectBuffer, int firstNonWhitespaceIndex, int indentation, DocumentOptionSet options) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - - // first set the caret at the beginning of the text on the line - view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(lineInSubjectBuffer.Snapshot, lineInSubjectBuffer.Start + firstNonWhitespaceIndex)); - - var document = lineInSubjectBuffer.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); - if (document == null) - { - return; - } - - // and then, insert the text - document.Project.Solution.Workspace.ApplyTextChanges(document.Id, - new TextChange( - new TextSpan( - lineInSubjectBuffer.Start.Position, firstNonWhitespaceIndex), - indentation.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize))), - CancellationToken.None); - } - - /// - /// check whether we can smart indent ourselves. we only attempt to smart indent ourselves - /// if the line in subject buffer we do smart indenting maps back to the view as it is and - /// if it starts from the beginning of the line - /// - private bool CanHandleOurselves(ITextView view, ITextBuffer subjectBuffer) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - - // first, make sure whole line is map back to the view - if (view.GetSpanInView(lineInSubjectBuffer.ExtentIncludingLineBreak).Count != 1) - { - return false; - } - - // now check, start position of the line is start position in the view - var caretPosition = view.GetPositionInView(view.GetVirtualCaretPoint(subjectBuffer).Value.Position); - var containingLineCaret = caretPosition.Value.GetContainingLine(); - - var startPositionSubjectBuffer = view.GetPositionInView(lineInSubjectBuffer.Start); - var startPositionCaret = view.GetPositionInView(containingLineCaret.Start); - if (!startPositionSubjectBuffer.HasValue || - !startPositionCaret.HasValue || - startPositionCaret.Value != startPositionSubjectBuffer.Value) - { - // if start position of subject buffer is not equal to start position of view line, - // we can't use the indenter - return false; - } - - // get containing line in view from start position of the caret in view - var containingLineView = startPositionCaret.Value.GetContainingLine(); - - // make sure line start at the beginning of the line - if (containingLineView.Start != startPositionCaret.Value) - { - return false; - } - - return true; - } - - /// - /// check whether editor smart indenter mechanism handled this case already - /// - private bool EditorHandled(ITextView view) - { - var caretPosition = view.Caret.Position.VirtualBufferPosition; - return caretPosition.IsInVirtualSpace || (caretPosition.Position != view.Caret.Position.BufferPosition.GetContainingLine().Start); - } - - /// - /// check whether we can do automatic formatting using token formatter instead of smart indenter for the "enter" key - /// - private bool TryFormatUsingTokenFormatter(ITextView view, ITextBuffer subjectBuffer, Document document, IEnumerable formattingRules, CancellationToken cancellationToken) - { - var position = view.GetCaretPoint(subjectBuffer).Value; - var line = position.GetContainingLine().AsTextLine(); - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var options = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - if (!UseSmartTokenFormatter( - root, line, formattingRules, options, - out var token, cancellationToken)) - { - return false; - } - - // when undo, make sure it undo the caret movement I did below - using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Smart_Indenting)) - { - // if caret position is before the token, make sure we put caret at the beginning of the token so that caret - // is at the right position after formatting - var currentSnapshot = subjectBuffer.CurrentSnapshot; - if (position.Position < token.SpanStart) - { - view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(currentSnapshot, token.SpanStart)); - } - - if (FormatToken(view, document, token, formattingRules, cancellationToken)) - { - transaction.Complete(); - } - else - { - transaction.Cancel(); - } - } - - return true; - } - - /// - /// create caret preserving edit transaction - /// - protected CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description) - { - return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); - } - } -} +//// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +//using System; +//using System.Collections.Generic; +//using System.Diagnostics; +//using System.Threading; +//using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +//using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +//using Microsoft.CodeAnalysis.Formatting; +//using Microsoft.CodeAnalysis.Formatting.Rules; +//using Microsoft.CodeAnalysis.Indentation; +//using Microsoft.CodeAnalysis.Options; +//using Microsoft.CodeAnalysis.Shared.Extensions; +//using Microsoft.CodeAnalysis.Text; +//using Microsoft.CodeAnalysis.Text.Shared.Extensions; +//using Microsoft.VisualStudio.Commanding; +//using Microsoft.VisualStudio.Text; +//using Microsoft.VisualStudio.Text.Editor; +//using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; +//using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods; +//using Microsoft.VisualStudio.Text.Operations; +//using Roslyn.Utilities; +//using VSCommanding = Microsoft.VisualStudio.Commanding; + +//namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation +//{ +// internal abstract class AbstractSmartTokenFormatterCommandHandler : +// IChainedCommandHandler +// { +// private readonly ITextUndoHistoryRegistry _undoHistoryRegistry; +// private readonly IEditorOperationsFactoryService _editorOperationsFactoryService; + +// public string DisplayName => EditorFeaturesResources.Smart_Token_Formatter; + +// public AbstractSmartTokenFormatterCommandHandler( +// ITextUndoHistoryRegistry undoHistoryRegistry, +// IEditorOperationsFactoryService editorOperationsFactoryService) +// { +// _undoHistoryRegistry = undoHistoryRegistry; +// _editorOperationsFactoryService = editorOperationsFactoryService; +// } + +// protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); + +// protected abstract bool UseSmartTokenFormatter( +// SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, +// out SyntaxToken token, CancellationToken cancellationToken); + +// protected abstract IEnumerable GetFormattingRules(Document document, int position); + +// /// True if any change is made. +// protected bool FormatToken(ITextView view, Document document, SyntaxToken token, IEnumerable formattingRules, CancellationToken cancellationToken) +// { +// var root = document.GetSyntaxRootSynchronously(cancellationToken); +// var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); +// var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); +// var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); +// if (changes.Count == 0) +// { +// return false; +// } + +// using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Format_Token)) +// { +// transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance; + +// document.Project.Solution.Workspace.ApplyTextChanges(document.Id, changes, cancellationToken); +// transaction.Complete(); +// } + +// return true; +// } + +// public VSCommanding.CommandState GetCommandState(ReturnKeyCommandArgs args, Func nextHandler) +// { +// return nextHandler(); +// } + +// public void ExecuteCommand(ReturnKeyCommandArgs args, Action nextHandler, CommandExecutionContext context) +// { +// var textView = args.TextView; +// var oldCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); + +// nextHandler(); + +// // A feature like completion handled the return key but did not pass it on to the editor. +// var newCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); +// if (textView.Selection.IsEmpty && oldCaretPoint.HasValue && newCaretPoint.HasValue && +// oldCaretPoint.Value.GetContainingLine().LineNumber == newCaretPoint.Value.GetContainingLine().LineNumber) +// { +// return; +// } + +// if (args.SubjectBuffer.CanApplyChangeDocumentToWorkspace()) +// { +// ExecuteCommandWorker(args, CancellationToken.None); +// } +// } + +// internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken cancellationToken) +// { +// var textView = args.TextView; +// var caretPoint = textView.GetCaretPoint(args.SubjectBuffer); + +// if (!caretPoint.HasValue) +// { +// return; +// } + +// var currentPosition = caretPoint.Value; +// var document = currentPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); +// if (document == null) +// { +// return; +// } + +// var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); +// if (documentOptions.GetOption(FormattingOptions.SmartIndent) != FormattingOptions.IndentStyle.Smart) +// { +// return; +// } + +// var formattingRules = this.GetFormattingRules(document, currentPosition.Position); + +// // see whether we should use token formatter +// if (TryFormatUsingTokenFormatter(textView, args.SubjectBuffer, document, formattingRules, cancellationToken)) +// { +// return; +// } + +// // check whether editor would have used smart indenter +// if (EditorHandled(textView) && !RequireReadjustment(textView, args.SubjectBuffer)) +// { +// // editor already took care of smart indentation. +// return; +// } + +// // check whether we can do it ourselves +// if (!CanHandleOurselves(textView, args.SubjectBuffer)) +// { +// return; +// } + +// var indentationService = document.GetLanguageService(); +// var indentation = indentationService.GetDesiredIndentation(document, +// currentPosition.GetContainingLine().LineNumber, cancellationToken); + +// // looks like we can't. +// if (!indentation.HasValue) +// { +// return; +// } + +// HandleOurselves(textView, args.SubjectBuffer, indentation.Value.GetIndentation(textView, currentPosition.GetContainingLine()), documentOptions); +// } + +// private bool RequireReadjustment(ITextView view, ITextBuffer subjectBuffer) +// { +// var caretInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value; +// var lineInSubjectBuffer = caretInSubjectBuffer.GetContainingLine(); + +// var currentOffset = caretInSubjectBuffer - lineInSubjectBuffer.Start; +// var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); +// if (!firstNonWhitespaceIndex.HasValue || currentOffset >= firstNonWhitespaceIndex.Value) +// { +// return false; +// } + +// // there are whitespace after caret position (which smart indentation has put), +// // we might need to re-adjust indentation +// return true; +// } + +// private void HandleOurselves(ITextView view, ITextBuffer subjectBuffer, int indentation, DocumentOptionSet options) +// { +// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); +// var lengthOfLine = lineInSubjectBuffer.GetColumnFromLineOffset(lineInSubjectBuffer.Length, view.Options); + +// // check whether we are dealing with virtual space or real space +// if (indentation > lengthOfLine) +// { +// // we are dealing with virtual space +// var caretPosition = view.GetVirtualCaretPoint(subjectBuffer); +// var positionInVirtualSpace = new VirtualSnapshotPoint(caretPosition.Value.Position, indentation - lineInSubjectBuffer.Length); +// view.TryMoveCaretToAndEnsureVisible(positionInVirtualSpace); +// return; +// } + +// // we are dealing with real space. check whether we need to just set caret position or move text +// var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); + +// if (firstNonWhitespaceIndex.HasValue) +// { +// // if leading whitespace is not what we expect, re-adjust indentation +// var columnOfFirstNonWhitespace = lineInSubjectBuffer.GetColumnFromLineOffset(firstNonWhitespaceIndex.Value, view.Options); +// if (columnOfFirstNonWhitespace != indentation) +// { +// ReadjustIndentation(view, subjectBuffer, firstNonWhitespaceIndex.Value, indentation, options); +// return; +// } +// } + +// // okay, it is an empty line with some whitespaces +// Debug.Assert(indentation <= lineInSubjectBuffer.Length); + +// var offset = GetOffsetFromIndentation(indentation, view.Options); +// view.TryMoveCaretToAndEnsureVisible(lineInSubjectBuffer.Start.Add(offset)); +// } + +// private int GetOffsetFromIndentation(int indentation, IEditorOptions option) +// { +// int numberOfTabs = 0; +// int numberOfSpaces = Math.Max(0, indentation); + +// if (!option.IsConvertTabsToSpacesEnabled()) +// { +// var tabSize = option.GetTabSize(); + +// numberOfTabs = indentation / tabSize; +// numberOfSpaces -= numberOfTabs * tabSize; +// } + +// return numberOfTabs + numberOfSpaces; +// } + +// /// +// /// re-adjust caret position to be the beginning of first text on the line. and make sure the text start at the given indentation +// /// +// private static void ReadjustIndentation(ITextView view, ITextBuffer subjectBuffer, int firstNonWhitespaceIndex, int indentation, DocumentOptionSet options) +// { +// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); + +// // first set the caret at the beginning of the text on the line +// view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(lineInSubjectBuffer.Snapshot, lineInSubjectBuffer.Start + firstNonWhitespaceIndex)); + +// var document = lineInSubjectBuffer.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); +// if (document == null) +// { +// return; +// } + +// // and then, insert the text +// document.Project.Solution.Workspace.ApplyTextChanges(document.Id, +// new TextChange( +// new TextSpan( +// lineInSubjectBuffer.Start.Position, firstNonWhitespaceIndex), +// indentation.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize))), +// CancellationToken.None); +// } + +// /// +// /// check whether we can smart indent ourselves. we only attempt to smart indent ourselves +// /// if the line in subject buffer we do smart indenting maps back to the view as it is and +// /// if it starts from the beginning of the line +// /// +// private bool CanHandleOurselves(ITextView view, ITextBuffer subjectBuffer) +// { +// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); + +// // first, make sure whole line is map back to the view +// if (view.GetSpanInView(lineInSubjectBuffer.ExtentIncludingLineBreak).Count != 1) +// { +// return false; +// } + +// // now check, start position of the line is start position in the view +// var caretPosition = view.GetPositionInView(view.GetVirtualCaretPoint(subjectBuffer).Value.Position); +// var containingLineCaret = caretPosition.Value.GetContainingLine(); + +// var startPositionSubjectBuffer = view.GetPositionInView(lineInSubjectBuffer.Start); +// var startPositionCaret = view.GetPositionInView(containingLineCaret.Start); +// if (!startPositionSubjectBuffer.HasValue || +// !startPositionCaret.HasValue || +// startPositionCaret.Value != startPositionSubjectBuffer.Value) +// { +// // if start position of subject buffer is not equal to start position of view line, +// // we can't use the indenter +// return false; +// } + +// // get containing line in view from start position of the caret in view +// var containingLineView = startPositionCaret.Value.GetContainingLine(); + +// // make sure line start at the beginning of the line +// if (containingLineView.Start != startPositionCaret.Value) +// { +// return false; +// } + +// return true; +// } + +// /// +// /// check whether editor smart indenter mechanism handled this case already +// /// +// private bool EditorHandled(ITextView view) +// { +// var caretPosition = view.Caret.Position.VirtualBufferPosition; +// return caretPosition.IsInVirtualSpace || (caretPosition.Position != view.Caret.Position.BufferPosition.GetContainingLine().Start); +// } + +// /// +// /// check whether we can do automatic formatting using token formatter instead of smart indenter for the "enter" key +// /// +// private bool TryFormatUsingTokenFormatter(ITextView view, ITextBuffer subjectBuffer, Document document, IEnumerable formattingRules, CancellationToken cancellationToken) +// { +// var position = view.GetCaretPoint(subjectBuffer).Value; +// var line = position.GetContainingLine().AsTextLine(); +// var root = document.GetSyntaxRootSynchronously(cancellationToken); +// var options = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); +// if (!UseSmartTokenFormatter( +// root, line, formattingRules, options, +// out var token, cancellationToken)) +// { +// return false; +// } + +// // when undo, make sure it undo the caret movement I did below +// using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Smart_Indenting)) +// { +// // if caret position is before the token, make sure we put caret at the beginning of the token so that caret +// // is at the right position after formatting +// var currentSnapshot = subjectBuffer.CurrentSnapshot; +// if (position.Position < token.SpanStart) +// { +// view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(currentSnapshot, token.SpanStart)); +// } + +// if (FormatToken(view, document, token, formattingRules, cancellationToken)) +// { +// transaction.Complete(); +// } +// else +// { +// transaction.Cancel(); +// } +// } + +// return true; +// } + +// /// +// /// create caret preserving edit transaction +// /// +// protected CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description) +// { +// return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); +// } +// } +//} diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb index 7e3aaa4ace9d3..7d5e77a534c82 100644 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb @@ -1,53 +1,53 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +'' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -Imports System.ComponentModel.Composition -Imports System.Threading -Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -Imports Microsoft.CodeAnalysis.Formatting -Imports Microsoft.CodeAnalysis.Formatting.Rules -Imports Microsoft.CodeAnalysis.Indentation -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.CodeAnalysis.Text -Imports Microsoft.CodeAnalysis.VisualBasic.Indentation -Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Imports Microsoft.VisualStudio.Text.Operations -Imports Microsoft.VisualStudio.Utilities -Imports VSCommanding = Microsoft.VisualStudio.Commanding +'Imports System.ComponentModel.Composition +'Imports System.Threading +'Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation +'Imports Microsoft.CodeAnalysis.Formatting +'Imports Microsoft.CodeAnalysis.Formatting.Rules +'Imports Microsoft.CodeAnalysis.Indentation +'Imports Microsoft.CodeAnalysis.Options +'Imports Microsoft.CodeAnalysis.Text +'Imports Microsoft.CodeAnalysis.VisualBasic.Indentation +'Imports Microsoft.CodeAnalysis.VisualBasic.Syntax +'Imports Microsoft.VisualStudio.Text.Operations +'Imports Microsoft.VisualStudio.Utilities +'Imports VSCommanding = Microsoft.VisualStudio.Commanding -Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation - - - - - Friend Class SmartTokenFormatterCommandHandler - Inherits AbstractSmartTokenFormatterCommandHandler +'Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation +' +' +' +' +' Friend Class SmartTokenFormatterCommandHandler +' Inherits AbstractSmartTokenFormatterCommandHandler - - Public Sub New(undoHistoryRegistry As ITextUndoHistoryRegistry, - editorOperationsFactoryService As IEditorOperationsFactoryService) +' +' Public Sub New(undoHistoryRegistry As ITextUndoHistoryRegistry, +' editorOperationsFactoryService As IEditorOperationsFactoryService) - MyBase.New(undoHistoryRegistry, - editorOperationsFactoryService) - End Sub +' MyBase.New(undoHistoryRegistry, +' editorOperationsFactoryService) +' End Sub - Protected Overrides Function GetFormattingRules(document As Document, position As Integer) As IEnumerable(Of AbstractFormattingRule) - Dim ws = document.Project.Solution.Workspace - Dim formattingRuleFactory = ws.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() - Return {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(document, position)}.Concat(Formatter.GetDefaultFormattingRules(document)) - End Function +' Protected Overrides Function GetFormattingRules(document As Document, position As Integer) As IEnumerable(Of AbstractFormattingRule) +' Dim ws = document.Project.Solution.Workspace +' Dim formattingRuleFactory = ws.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() +' Return {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(document, position)}.Concat(Formatter.GetDefaultFormattingRules(document)) +' End Function - Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter - Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) - End Function +' Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter +' Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) +' End Function - Protected Overrides Function UseSmartTokenFormatter(root As SyntaxNode, - line As TextLine, - formattingRules As IEnumerable(Of AbstractFormattingRule), - options As OptionSet, - ByRef token As SyntaxToken, - cancellationToken As CancellationToken) As Boolean - Return VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( - formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, token, cancellationToken, neverUseWhenHavingMissingToken:=False) - End Function - End Class -End Namespace +' Protected Overrides Function UseSmartTokenFormatter(root As SyntaxNode, +' line As TextLine, +' formattingRules As IEnumerable(Of AbstractFormattingRule), +' options As OptionSet, +' ByRef token As SyntaxToken, +' cancellationToken As CancellationToken) As Boolean +' Return VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( +' formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, token, cancellationToken, neverUseWhenHavingMissingToken:=False) +' End Function +' End Class +'End Namespace diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs index 612338fa28991..6677b4db3b316 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -106,6 +106,19 @@ private static bool IsInvalidToken(SyntaxToken token) token.IsKind(SyntaxKind.EndOfFileToken); } + protected override IEnumerable GetTokenFormattingRules( + Document document, int position) + { + var workspace = document.Project.Solution.Workspace; + var formattingRuleFactory = workspace.Services.GetService(); + return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); + } + + protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) + { + return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); + } + private class FormattingRule : AbstractFormattingRule { public override void AddIndentBlockOperations(List list, SyntaxNode node, OptionSet optionSet, in NextIndentBlockOperationAction nextOperation) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 69ac67f805c8f..b3668dd674e6d 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -19,6 +19,8 @@ internal abstract partial class AbstractIndentationService : IInden { protected abstract AbstractFormattingRule GetSpecializedIndentationFormattingRule(); + protected abstract IEnumerable GetTokenFormattingRules(Document document, int position); + private IEnumerable GetFormattingRules(Document document, int position) { var workspace = document.Project.Solution.Workspace; @@ -29,7 +31,7 @@ private IEnumerable GetFormattingRules(Document document return formattingRules; } - public virtual IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) + public IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) { var indenter = GetIndenter(document, lineNumber, cancellationToken); @@ -50,30 +52,34 @@ private IEnumerable GetFormattingRules(Document document // for the following tokens to go. if (indenter.ShouldUseTokenIndenter(out var token)) { - return null; // UseTokenIndenter(document, token, cancellationToken); + return UseTokenIndenter(document, lineNumber, token, cancellationToken); } return indenter.GetDesiredIndentation(indentStyle); } - //private IndentationResult UseTokenIndenter( - // Document document, SyntaxToken token, CancellationToken cancellationToken) - //{ - // var formattingRules = this.GetFormattingRules(document, currentPosition.Position); + private IndentationResult UseTokenIndenter( + Document document, int lineNumber, SyntaxToken token, CancellationToken cancellationToken) + { + var root = document.GetSyntaxRootSynchronously(cancellationToken); + var sourceText = root.SyntaxTree.GetText(cancellationToken); + var lineToBeIndented = sourceText.Lines[lineNumber]; - // var root = document.GetSyntaxRootSynchronously(cancellationToken); - // var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - // var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); - // var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - // if (changes.Count == 0) - // { - // return false; - // } - //} + var formattingRules = this.GetTokenFormattingRules(document, lineToBeIndented.Start); - //protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); + var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); + var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); + var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); + if (changes.Count == 0) + { + var indentation = lineToBeIndented.GetFirstNonWhitespacePosition(); + return new IndentationResult(0, indentation ?? lineToBeIndented.End); + } + + return new IndentationResult(0, lineToBeIndented.End); + } - // protected abstract AbstractTokenIndenter CreateTokenIndenter(AbstractIndenter indenter); + protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); public IndentationResult GetBlankLineIndentation( Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken) diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index 4265d20d96ade..f3e7f190e1726 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -2,6 +2,7 @@ Imports System.Composition Imports System.Threading +Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.Indentation @@ -130,5 +131,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Return token.Kind = SyntaxKind.None OrElse token.Kind = SyntaxKind.EndOfFileToken End Function + + Protected Overrides Function GetTokenFormattingRules(document As Document, position As Integer) As IEnumerable(Of AbstractFormattingRule) + Dim ws = document.Project.Solution.Workspace + Dim formattingRuleFactory = ws.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() + Return {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(document, position)}.Concat(Formatter.GetDefaultFormattingRules(document)) + End Function + + Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter + Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) + End Function End Class End Namespace From c1ce3793a6c003b884c44ec3c3de30925ec47f34 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 20:05:58 -0800 Subject: [PATCH 14/43] apply and determine indentation --- .../Indentation/AbstractIndentationService.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index b3668dd674e6d..5a0f01de43450 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -70,13 +70,19 @@ private IndentationResult UseTokenIndenter( var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - if (changes.Count == 0) + + var updatedSourceText = sourceText.WithChanges(changes); + if (lineNumber < updatedSourceText.Lines.Count) { - var indentation = lineToBeIndented.GetFirstNonWhitespacePosition(); - return new IndentationResult(0, indentation ?? lineToBeIndented.End); + var updatedLine = updatedSourceText.Lines[lineNumber]; + var offset = updatedLine.GetFirstNonWhitespaceOffset(); + if (offset != null) + { + return new IndentationResult(basePosition: 0, offset.Value); + } } - return new IndentationResult(0, lineToBeIndented.End); + return default; } protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); From 943afa2e6ee7b22e28d649bda31ec26f63d2e3b2 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 20:16:04 -0800 Subject: [PATCH 15/43] Update tests --- .../Indentation/CSharpFormatterTestsBase.cs | 13 ------------- .../Indentation/SmartIndenterTests.cs | 2 +- .../SmartTokenFormatterFormatRangeTests.cs | 3 --- .../Formatting/CoreFormatterTestsBase.cs | 18 ++---------------- .../Indentation/SmartIndenterTests.vb | 10 ---------- .../SmartTokenFormatter_FormatTokenTests.vb | 1 - .../Formatting/VisualBasicFormatterTestBase.vb | 9 +-------- 7 files changed, 4 insertions(+), 52 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs index 01a1ae57a8bb2..0e73680644517 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/CSharpFormatterTestsBase.cs @@ -7,10 +7,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; -using Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent; -using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.UnitTests.Formatting; using Microsoft.CodeAnalysis.Editor.UnitTests.Utilities; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; @@ -21,13 +17,7 @@ using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Operations; -using Microsoft.VisualStudio.Text.Projection; -using Moq; using Xunit; -using static Microsoft.CodeAnalysis.Formatting.FormattingOptions; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Formatting.Indentation { @@ -44,9 +34,6 @@ public class CSharpFormatterTestsBase : CoreFormatterTestsBase internal override string GetLanguageName() => LanguageNames.CSharp; - internal override AbstractSmartTokenFormatterCommandHandler CreateSmartTokenFormatterCommandHandler(ITextUndoHistoryRegistry registry, IEditorOperationsFactoryService operations) - => new SmartTokenFormatterCommandHandler(registry, operations); - protected static async Task GetSmartTokenFormatterIndentationWorkerAsync( TestWorkspace workspace, ITextBuffer buffer, diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs index df3a6fb03232f..e9b4fbd455806 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs @@ -418,7 +418,7 @@ void Method() AssertSmartIndent( code, indentationLine: 7, - expectedIndentation: null, + expectedIndentation: 4, expectedBlankLineIndentation: 8); } diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs index 3ad86728b76f3..c182dd1269177 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs @@ -5,12 +5,10 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; -using Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Implementation.Formatting; using Microsoft.CodeAnalysis.Editor.UnitTests.Utilities; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; @@ -22,7 +20,6 @@ using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Operations; using Roslyn.Test.Utilities; using Xunit; diff --git a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs index 282809244a442..f3ac3af6a654c 100644 --- a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs +++ b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs @@ -24,8 +24,6 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.Formatting public abstract class CoreFormatterTestsBase { internal abstract string GetLanguageName(); - internal abstract AbstractSmartTokenFormatterCommandHandler CreateSmartTokenFormatterCommandHandler( - ITextUndoHistoryRegistry registry, IEditorOperationsFactoryService operations); protected void TestIndentation( TestWorkspace workspace, int point, @@ -40,20 +38,8 @@ protected void TestIndentation( var snapshot = subjectDocument.TextBuffer.CurrentSnapshot; var indentationLineFromBuffer = snapshot.GetLineFromPosition(point); - var commandHandler = CreateSmartTokenFormatterCommandHandler(textUndoHistory.Object, editorOperationsFactory.Object); - commandHandler.ExecuteCommandWorker(new ReturnKeyCommandArgs(textView, subjectDocument.TextBuffer), CancellationToken.None); - var newSnapshot = subjectDocument.TextBuffer.CurrentSnapshot; - - int? actualIndentation; - if (newSnapshot.Version.VersionNumber > snapshot.Version.VersionNumber) - { - actualIndentation = newSnapshot.GetLineFromLineNumber(indentationLineFromBuffer.LineNumber).GetFirstNonWhitespaceOffset(); - } - else - { - var provider = new SmartIndent(textView); - actualIndentation = provider.GetDesiredIndentation(indentationLineFromBuffer); - } + var provider = new SmartIndent(textView); + var actualIndentation = provider.GetDesiredIndentation(indentationLineFromBuffer); Assert.Equal(expectedIndentation, actualIndentation.Value); diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb index 02792668a4e0e..193b4854ae3fb 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb @@ -1,21 +1,11 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -Imports System.Threading Imports Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent Imports Microsoft.CodeAnalysis.Editor.UnitTests.Extensions -Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces -Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules -Imports Microsoft.CodeAnalysis.Text -Imports Microsoft.CodeAnalysis.Text.Shared.Extensions Imports Microsoft.VisualStudio.Text -Imports Microsoft.VisualStudio.Text.Editor -Imports Microsoft.VisualStudio.Text.Editor.Commanding.Commands -Imports Microsoft.VisualStudio.Text.Operations -Imports Microsoft.VisualStudio.Text.Projection -Imports Moq Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Formatting.Indentation <[UseExportProvider]> diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb index d1543a69665e6..032b51888bd73 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartTokenFormatter_FormatTokenTests.vb @@ -3,7 +3,6 @@ Imports System.Threading Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces -Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.Text.Shared.Extensions diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/VisualBasicFormatterTestBase.vb b/src/EditorFeatures/VisualBasicTest/Formatting/VisualBasicFormatterTestBase.vb index 140ff97219cb8..8536d925ff90a 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/VisualBasicFormatterTestBase.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/VisualBasicFormatterTestBase.vb @@ -2,6 +2,7 @@ Imports System.Threading Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Editor.UnitTests.Formatting Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules @@ -9,10 +10,6 @@ Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.Text.Shared.Extensions Imports Microsoft.VisualStudio.Text Imports Roslyn.Test.EditorUtilities -Imports Microsoft.CodeAnalysis.Editor.UnitTests.Formatting -Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -Imports Microsoft.VisualStudio.Text.Operations -Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Formatting <[UseExportProvider]> @@ -23,10 +20,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Formatting Return LanguageNames.VisualBasic End Function - Friend Overrides Function CreateSmartTokenFormatterCommandHandler(registry As ITextUndoHistoryRegistry, operations As IEditorOperationsFactoryService) As AbstractSmartTokenFormatterCommandHandler - Return New SmartTokenFormatterCommandHandler(registry, operations) - End Function - Protected Async Function AssertFormatSpanAsync(content As String, expected As String, Optional baseIndentation As Integer? = Nothing, Optional span As TextSpan = Nothing) As Tasks.Task Using workspace = TestWorkspace.CreateVisualBasic(content) Dim hostdoc = workspace.Documents.First() From 60b860e11e6ea4d1f65a11711e181e1945c13b5b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 20:26:09 -0800 Subject: [PATCH 16/43] correct offset --- .../Core/Portable/Indentation/AbstractIndentationService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 5a0f01de43450..f79b6a503ccc3 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -78,7 +78,9 @@ private IndentationResult UseTokenIndenter( var offset = updatedLine.GetFirstNonWhitespaceOffset(); if (offset != null) { - return new IndentationResult(basePosition: 0, offset.Value); + return new IndentationResult( + basePosition: lineToBeIndented.Start, + offset: offset.Value); } } From a226a9cca26228d151157cf82f8c3480ccfd5003 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 20:27:37 -0800 Subject: [PATCH 17/43] remove old code --- .../SmartTokenFormatterCommandHandler.cs | 60 --- ...stractSmartTokenFormatterCommandHandler.cs | 350 ------------------ .../Indentation/WhitespaceExtensions.cs | 19 - .../SmartTokenFormatterCommandHandler.vb | 53 --- 4 files changed, 482 deletions(-) delete mode 100644 src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs delete mode 100644 src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs delete mode 100644 src/EditorFeatures/Core/Implementation/Formatting/Indentation/WhitespaceExtensions.cs delete mode 100644 src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb diff --git a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs deleted file mode 100644 index 7e692ba22748a..0000000000000 --- a/src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatterCommandHandler.cs +++ /dev/null @@ -1,60 +0,0 @@ -//// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -//using System.Collections.Generic; -//using System.ComponentModel.Composition; -//using System.Linq; -//using System.Threading; -//using Microsoft.CodeAnalysis.CSharp; -//using Microsoft.CodeAnalysis.CSharp.Indentation; -//using Microsoft.CodeAnalysis.CSharp.Syntax; -//using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; -//using Microsoft.CodeAnalysis.Formatting; -//using Microsoft.CodeAnalysis.Formatting.Rules; -//using Microsoft.CodeAnalysis.Indentation; -//using Microsoft.CodeAnalysis.Options; -//using Microsoft.CodeAnalysis.Text; -//using Microsoft.VisualStudio.Text.Operations; -//using Microsoft.VisualStudio.Utilities; -//using Roslyn.Utilities; -//using VSCommanding = Microsoft.VisualStudio.Commanding; - -//namespace Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation -//{ -// [Export(typeof(VSCommanding.ICommandHandler))] -// [ContentType(ContentTypeNames.CSharpContentType)] -// [Name(PredefinedCommandHandlerNames.Indent)] -// [Order(After = PredefinedCommandHandlerNames.Rename)] -// [Order(Before = PredefinedCommandHandlerNames.Completion)] -// internal class SmartTokenFormatterCommandHandler : -// AbstractSmartTokenFormatterCommandHandler -// { -// [ImportingConstructor] -// public SmartTokenFormatterCommandHandler( -// ITextUndoHistoryRegistry undoHistoryRegistry, -// IEditorOperationsFactoryService editorOperationsFactoryService) : -// base(undoHistoryRegistry, -// editorOperationsFactoryService) -// { -// } - -// protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) -// { -// return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); -// } - -// protected override bool UseSmartTokenFormatter( -// SyntaxNode root, TextLine line, IEnumerable formattingRules, -// OptionSet options, out SyntaxToken token, CancellationToken cancellationToken) -// { -// return CSharpIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( -// formattingRules, (CompilationUnitSyntax)root, line, options, out token); -// } - -// protected override IEnumerable GetFormattingRules(Document document, int position) -// { -// var workspace = document.Project.Solution.Workspace; -// var formattingRuleFactory = workspace.Services.GetService(); -// return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); -// } -// } -//} diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs deleted file mode 100644 index 4c2da6a19e3d4..0000000000000 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ /dev/null @@ -1,350 +0,0 @@ -//// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -//using System; -//using System.Collections.Generic; -//using System.Diagnostics; -//using System.Threading; -//using Microsoft.CodeAnalysis.Editor.Shared.Extensions; -//using Microsoft.CodeAnalysis.Editor.Shared.Utilities; -//using Microsoft.CodeAnalysis.Formatting; -//using Microsoft.CodeAnalysis.Formatting.Rules; -//using Microsoft.CodeAnalysis.Indentation; -//using Microsoft.CodeAnalysis.Options; -//using Microsoft.CodeAnalysis.Shared.Extensions; -//using Microsoft.CodeAnalysis.Text; -//using Microsoft.CodeAnalysis.Text.Shared.Extensions; -//using Microsoft.VisualStudio.Commanding; -//using Microsoft.VisualStudio.Text; -//using Microsoft.VisualStudio.Text.Editor; -//using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -//using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods; -//using Microsoft.VisualStudio.Text.Operations; -//using Roslyn.Utilities; -//using VSCommanding = Microsoft.VisualStudio.Commanding; - -//namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -//{ -// internal abstract class AbstractSmartTokenFormatterCommandHandler : -// IChainedCommandHandler -// { -// private readonly ITextUndoHistoryRegistry _undoHistoryRegistry; -// private readonly IEditorOperationsFactoryService _editorOperationsFactoryService; - -// public string DisplayName => EditorFeaturesResources.Smart_Token_Formatter; - -// public AbstractSmartTokenFormatterCommandHandler( -// ITextUndoHistoryRegistry undoHistoryRegistry, -// IEditorOperationsFactoryService editorOperationsFactoryService) -// { -// _undoHistoryRegistry = undoHistoryRegistry; -// _editorOperationsFactoryService = editorOperationsFactoryService; -// } - -// protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - -// protected abstract bool UseSmartTokenFormatter( -// SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, -// out SyntaxToken token, CancellationToken cancellationToken); - -// protected abstract IEnumerable GetFormattingRules(Document document, int position); - -// /// True if any change is made. -// protected bool FormatToken(ITextView view, Document document, SyntaxToken token, IEnumerable formattingRules, CancellationToken cancellationToken) -// { -// var root = document.GetSyntaxRootSynchronously(cancellationToken); -// var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); -// var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); -// var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); -// if (changes.Count == 0) -// { -// return false; -// } - -// using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Format_Token)) -// { -// transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance; - -// document.Project.Solution.Workspace.ApplyTextChanges(document.Id, changes, cancellationToken); -// transaction.Complete(); -// } - -// return true; -// } - -// public VSCommanding.CommandState GetCommandState(ReturnKeyCommandArgs args, Func nextHandler) -// { -// return nextHandler(); -// } - -// public void ExecuteCommand(ReturnKeyCommandArgs args, Action nextHandler, CommandExecutionContext context) -// { -// var textView = args.TextView; -// var oldCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); - -// nextHandler(); - -// // A feature like completion handled the return key but did not pass it on to the editor. -// var newCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); -// if (textView.Selection.IsEmpty && oldCaretPoint.HasValue && newCaretPoint.HasValue && -// oldCaretPoint.Value.GetContainingLine().LineNumber == newCaretPoint.Value.GetContainingLine().LineNumber) -// { -// return; -// } - -// if (args.SubjectBuffer.CanApplyChangeDocumentToWorkspace()) -// { -// ExecuteCommandWorker(args, CancellationToken.None); -// } -// } - -// internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken cancellationToken) -// { -// var textView = args.TextView; -// var caretPoint = textView.GetCaretPoint(args.SubjectBuffer); - -// if (!caretPoint.HasValue) -// { -// return; -// } - -// var currentPosition = caretPoint.Value; -// var document = currentPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); -// if (document == null) -// { -// return; -// } - -// var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); -// if (documentOptions.GetOption(FormattingOptions.SmartIndent) != FormattingOptions.IndentStyle.Smart) -// { -// return; -// } - -// var formattingRules = this.GetFormattingRules(document, currentPosition.Position); - -// // see whether we should use token formatter -// if (TryFormatUsingTokenFormatter(textView, args.SubjectBuffer, document, formattingRules, cancellationToken)) -// { -// return; -// } - -// // check whether editor would have used smart indenter -// if (EditorHandled(textView) && !RequireReadjustment(textView, args.SubjectBuffer)) -// { -// // editor already took care of smart indentation. -// return; -// } - -// // check whether we can do it ourselves -// if (!CanHandleOurselves(textView, args.SubjectBuffer)) -// { -// return; -// } - -// var indentationService = document.GetLanguageService(); -// var indentation = indentationService.GetDesiredIndentation(document, -// currentPosition.GetContainingLine().LineNumber, cancellationToken); - -// // looks like we can't. -// if (!indentation.HasValue) -// { -// return; -// } - -// HandleOurselves(textView, args.SubjectBuffer, indentation.Value.GetIndentation(textView, currentPosition.GetContainingLine()), documentOptions); -// } - -// private bool RequireReadjustment(ITextView view, ITextBuffer subjectBuffer) -// { -// var caretInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value; -// var lineInSubjectBuffer = caretInSubjectBuffer.GetContainingLine(); - -// var currentOffset = caretInSubjectBuffer - lineInSubjectBuffer.Start; -// var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); -// if (!firstNonWhitespaceIndex.HasValue || currentOffset >= firstNonWhitespaceIndex.Value) -// { -// return false; -// } - -// // there are whitespace after caret position (which smart indentation has put), -// // we might need to re-adjust indentation -// return true; -// } - -// private void HandleOurselves(ITextView view, ITextBuffer subjectBuffer, int indentation, DocumentOptionSet options) -// { -// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); -// var lengthOfLine = lineInSubjectBuffer.GetColumnFromLineOffset(lineInSubjectBuffer.Length, view.Options); - -// // check whether we are dealing with virtual space or real space -// if (indentation > lengthOfLine) -// { -// // we are dealing with virtual space -// var caretPosition = view.GetVirtualCaretPoint(subjectBuffer); -// var positionInVirtualSpace = new VirtualSnapshotPoint(caretPosition.Value.Position, indentation - lineInSubjectBuffer.Length); -// view.TryMoveCaretToAndEnsureVisible(positionInVirtualSpace); -// return; -// } - -// // we are dealing with real space. check whether we need to just set caret position or move text -// var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); - -// if (firstNonWhitespaceIndex.HasValue) -// { -// // if leading whitespace is not what we expect, re-adjust indentation -// var columnOfFirstNonWhitespace = lineInSubjectBuffer.GetColumnFromLineOffset(firstNonWhitespaceIndex.Value, view.Options); -// if (columnOfFirstNonWhitespace != indentation) -// { -// ReadjustIndentation(view, subjectBuffer, firstNonWhitespaceIndex.Value, indentation, options); -// return; -// } -// } - -// // okay, it is an empty line with some whitespaces -// Debug.Assert(indentation <= lineInSubjectBuffer.Length); - -// var offset = GetOffsetFromIndentation(indentation, view.Options); -// view.TryMoveCaretToAndEnsureVisible(lineInSubjectBuffer.Start.Add(offset)); -// } - -// private int GetOffsetFromIndentation(int indentation, IEditorOptions option) -// { -// int numberOfTabs = 0; -// int numberOfSpaces = Math.Max(0, indentation); - -// if (!option.IsConvertTabsToSpacesEnabled()) -// { -// var tabSize = option.GetTabSize(); - -// numberOfTabs = indentation / tabSize; -// numberOfSpaces -= numberOfTabs * tabSize; -// } - -// return numberOfTabs + numberOfSpaces; -// } - -// /// -// /// re-adjust caret position to be the beginning of first text on the line. and make sure the text start at the given indentation -// /// -// private static void ReadjustIndentation(ITextView view, ITextBuffer subjectBuffer, int firstNonWhitespaceIndex, int indentation, DocumentOptionSet options) -// { -// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - -// // first set the caret at the beginning of the text on the line -// view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(lineInSubjectBuffer.Snapshot, lineInSubjectBuffer.Start + firstNonWhitespaceIndex)); - -// var document = lineInSubjectBuffer.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); -// if (document == null) -// { -// return; -// } - -// // and then, insert the text -// document.Project.Solution.Workspace.ApplyTextChanges(document.Id, -// new TextChange( -// new TextSpan( -// lineInSubjectBuffer.Start.Position, firstNonWhitespaceIndex), -// indentation.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize))), -// CancellationToken.None); -// } - -// /// -// /// check whether we can smart indent ourselves. we only attempt to smart indent ourselves -// /// if the line in subject buffer we do smart indenting maps back to the view as it is and -// /// if it starts from the beginning of the line -// /// -// private bool CanHandleOurselves(ITextView view, ITextBuffer subjectBuffer) -// { -// var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - -// // first, make sure whole line is map back to the view -// if (view.GetSpanInView(lineInSubjectBuffer.ExtentIncludingLineBreak).Count != 1) -// { -// return false; -// } - -// // now check, start position of the line is start position in the view -// var caretPosition = view.GetPositionInView(view.GetVirtualCaretPoint(subjectBuffer).Value.Position); -// var containingLineCaret = caretPosition.Value.GetContainingLine(); - -// var startPositionSubjectBuffer = view.GetPositionInView(lineInSubjectBuffer.Start); -// var startPositionCaret = view.GetPositionInView(containingLineCaret.Start); -// if (!startPositionSubjectBuffer.HasValue || -// !startPositionCaret.HasValue || -// startPositionCaret.Value != startPositionSubjectBuffer.Value) -// { -// // if start position of subject buffer is not equal to start position of view line, -// // we can't use the indenter -// return false; -// } - -// // get containing line in view from start position of the caret in view -// var containingLineView = startPositionCaret.Value.GetContainingLine(); - -// // make sure line start at the beginning of the line -// if (containingLineView.Start != startPositionCaret.Value) -// { -// return false; -// } - -// return true; -// } - -// /// -// /// check whether editor smart indenter mechanism handled this case already -// /// -// private bool EditorHandled(ITextView view) -// { -// var caretPosition = view.Caret.Position.VirtualBufferPosition; -// return caretPosition.IsInVirtualSpace || (caretPosition.Position != view.Caret.Position.BufferPosition.GetContainingLine().Start); -// } - -// /// -// /// check whether we can do automatic formatting using token formatter instead of smart indenter for the "enter" key -// /// -// private bool TryFormatUsingTokenFormatter(ITextView view, ITextBuffer subjectBuffer, Document document, IEnumerable formattingRules, CancellationToken cancellationToken) -// { -// var position = view.GetCaretPoint(subjectBuffer).Value; -// var line = position.GetContainingLine().AsTextLine(); -// var root = document.GetSyntaxRootSynchronously(cancellationToken); -// var options = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); -// if (!UseSmartTokenFormatter( -// root, line, formattingRules, options, -// out var token, cancellationToken)) -// { -// return false; -// } - -// // when undo, make sure it undo the caret movement I did below -// using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Smart_Indenting)) -// { -// // if caret position is before the token, make sure we put caret at the beginning of the token so that caret -// // is at the right position after formatting -// var currentSnapshot = subjectBuffer.CurrentSnapshot; -// if (position.Position < token.SpanStart) -// { -// view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(currentSnapshot, token.SpanStart)); -// } - -// if (FormatToken(view, document, token, formattingRules, cancellationToken)) -// { -// transaction.Complete(); -// } -// else -// { -// transaction.Cancel(); -// } -// } - -// return true; -// } - -// /// -// /// create caret preserving edit transaction -// /// -// protected CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description) -// { -// return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); -// } -// } -//} diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/WhitespaceExtensions.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/WhitespaceExtensions.cs deleted file mode 100644 index 0a9a4664f88d0..0000000000000 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/WhitespaceExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis.Text.Shared.Extensions; -using Microsoft.VisualStudio.Text; -using Roslyn.Utilities; - -namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -{ - internal static class WhitespaceExtensions - { - public static bool IsFirstTokenOnLine(this SyntaxToken token, ITextSnapshot snapshot) - { - Contract.ThrowIfNull(snapshot); - - var baseLine = snapshot.GetLineFromPosition(token.SpanStart); - return baseLine.GetFirstNonWhitespacePosition() == token.SpanStart; - } - } -} diff --git a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb b/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb deleted file mode 100644 index 7d5e77a534c82..0000000000000 --- a/src/EditorFeatures/VisualBasic/Formatting/Indentation/SmartTokenFormatterCommandHandler.vb +++ /dev/null @@ -1,53 +0,0 @@ -'' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -'Imports System.ComponentModel.Composition -'Imports System.Threading -'Imports Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -'Imports Microsoft.CodeAnalysis.Formatting -'Imports Microsoft.CodeAnalysis.Formatting.Rules -'Imports Microsoft.CodeAnalysis.Indentation -'Imports Microsoft.CodeAnalysis.Options -'Imports Microsoft.CodeAnalysis.Text -'Imports Microsoft.CodeAnalysis.VisualBasic.Indentation -'Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -'Imports Microsoft.VisualStudio.Text.Operations -'Imports Microsoft.VisualStudio.Utilities -'Imports VSCommanding = Microsoft.VisualStudio.Commanding - -'Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation -' -' -' -' -' Friend Class SmartTokenFormatterCommandHandler -' Inherits AbstractSmartTokenFormatterCommandHandler - -' -' Public Sub New(undoHistoryRegistry As ITextUndoHistoryRegistry, -' editorOperationsFactoryService As IEditorOperationsFactoryService) - -' MyBase.New(undoHistoryRegistry, -' editorOperationsFactoryService) -' End Sub - -' Protected Overrides Function GetFormattingRules(document As Document, position As Integer) As IEnumerable(Of AbstractFormattingRule) -' Dim ws = document.Project.Solution.Workspace -' Dim formattingRuleFactory = ws.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() -' Return {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(document, position)}.Concat(Formatter.GetDefaultFormattingRules(document)) -' End Function - -' Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter -' Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) -' End Function - -' Protected Overrides Function UseSmartTokenFormatter(root As SyntaxNode, -' line As TextLine, -' formattingRules As IEnumerable(Of AbstractFormattingRule), -' options As OptionSet, -' ByRef token As SyntaxToken, -' cancellationToken As CancellationToken) As Boolean -' Return VisualBasicIndentationService.ShouldUseSmartTokenFormatterInsteadOfIndenter( -' formattingRules, DirectCast(root, CompilationUnitSyntax), line, options, token, cancellationToken, neverUseWhenHavingMissingToken:=False) -' End Function -' End Class -'End Namespace From 028dfa97ff2bf1c3705747aa78325394e05789f4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 20:29:29 -0800 Subject: [PATCH 18/43] Cleanup --- .../CSharp/Formatting/CSharpEditorFormattingService.cs | 1 - .../TestUtilities/Formatting/CoreFormatterTestsBase.cs | 2 -- .../Core/Portable/Indentation/AbstractIndentationService.cs | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs index 244050bea8f99..fe0147bcdb7fc 100644 --- a/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs +++ b/src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.CSharp.Indentation; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Formatting; diff --git a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs index f3ac3af6a654c..0804c3fe76e98 100644 --- a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs +++ b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading; -using Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation; using Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.UnitTests.Utilities; @@ -13,7 +12,6 @@ using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; using Microsoft.VisualStudio.Text.Operations; using Microsoft.VisualStudio.Text.Projection; using Moq; diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index f79b6a503ccc3..926d67e378c74 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -79,7 +79,7 @@ private IndentationResult UseTokenIndenter( if (offset != null) { return new IndentationResult( - basePosition: lineToBeIndented.Start, + basePosition: lineToBeIndented.Start, offset: offset.Value); } } From 9d28a1ab97bb160ff7677d4d11839283e099d811 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 Mar 2019 21:07:17 -0800 Subject: [PATCH 19/43] simplify --- .../Indentation/SmartIndenterTests.cs | 4 +- .../Implementation/SmartIndent/SmartIndent.cs | 2 +- .../Indentation/SmartIndenterTests.vb | 2 +- .../CSharpIndentationService.Indenter.cs | 15 ++++- .../Indentation/CSharpIndentationService.cs | 17 +----- ...ractIndentationService.AbstractIndenter.cs | 53 ++++++++++++++-- .../Indentation/AbstractIndentationService.cs | 60 ++----------------- .../Indentation/IIndentationService.cs | 11 ++-- .../VisualBasicIndentationService.Indenter.vb | 14 ++++- .../VisualBasicIndentationService.vb | 14 +---- 10 files changed, 90 insertions(+), 102 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs index e9b4fbd455806..7571691de4fed 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs @@ -115,7 +115,7 @@ class Class AssertSmartIndent( code, indentationLine: 6, - expectedIndentation: null, + expectedIndentation: 0, expectedBlankLineIndentation: 0, indentStyle: IndentStyle.None); } @@ -418,7 +418,7 @@ void Method() AssertSmartIndent( code, indentationLine: 7, - expectedIndentation: 4, + expectedIndentation: 8, expectedBlankLineIndentation: 8); } diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs index 77e594d4b4e0e..28de97aa95360 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/SmartIndent.cs @@ -54,7 +54,7 @@ public void Dispose() if (newService != null) { var result = newService.GetDesiredIndentation(document, lineToBeIndented.LineNumber, cancellationToken); - return result?.GetIndentation(_textView, lineToBeIndented); + return result.GetIndentation(_textView, lineToBeIndented); } // If we don't have a feature-layer service, try to fall back to the legacy diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb index 193b4854ae3fb..4a86b203d267a 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb @@ -2482,7 +2482,7 @@ End Namespace AssertSmartIndent( code, indentationLine:=3, - expectedIndentation:=Nothing, + expectedIndentation:=0, expectedBlankLineIndentation:=0, indentStyle:=FormattingOptions.IndentStyle.None) End Sub diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index 9dd37e0e61545..e9b91b60e96b7 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -23,20 +23,29 @@ internal partial class CSharpIndentationService internal class Indenter : AbstractIndenter { public Indenter( - ISyntaxFactsService syntaxFacts, + Document document, SyntaxTree syntaxTree, IEnumerable rules, OptionSet optionSet, TextLine line, CancellationToken cancellationToken) : - base(syntaxFacts, syntaxTree, rules, optionSet, line, cancellationToken) + base(document, syntaxTree, rules, optionSet, line, cancellationToken) { } - public override bool ShouldUseTokenIndenter(out SyntaxToken syntaxToken) + protected override bool ShouldUseTokenIndenter(out SyntaxToken syntaxToken) => ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, Root, LineToBeIndented, OptionSet, out syntaxToken); + protected override ISmartTokenFormatter CreateSmartTokenFormatter() + { + var workspace = Document.Project.Solution.Workspace; + var formattingRuleFactory = workspace.Services.GetService(); + var rules = formattingRuleFactory.CreateRule(Document, LineToBeIndented.Start).Concat(Formatter.GetDefaultFormattingRules(Document)); + + return new CSharpSmartTokenFormatter(OptionSet, rules, Root); + } + protected override IndentationResult GetDesiredIndentationWorker( SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition) { diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs index 6677b4db3b316..d47036c5c5e1d 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -31,10 +31,10 @@ protected override AbstractFormattingRule GetSpecializedIndentationFormattingRul } protected override AbstractIndenter GetIndenter( - ISyntaxFactsService syntaxFacts, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken) + Document document, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken) { return new Indenter( - syntaxFacts, syntaxTree, formattingRules, + document, syntaxTree, formattingRules, optionSet, lineToBeIndented, cancellationToken); } @@ -106,19 +106,6 @@ private static bool IsInvalidToken(SyntaxToken token) token.IsKind(SyntaxKind.EndOfFileToken); } - protected override IEnumerable GetTokenFormattingRules( - Document document, int position) - { - var workspace = document.Project.Solution.Workspace; - var formattingRuleFactory = workspace.Services.GetService(); - return formattingRuleFactory.CreateRule(document, position).Concat(Formatter.GetDefaultFormattingRules(document)); - } - - protected override ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root) - { - return new CSharpSmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root); - } - private class FormattingRule : AbstractFormattingRule { public override void AddIndentBlockOperations(List list, SyntaxNode node, OptionSet optionSet, in NextIndentBlockOperationAction nextOperation) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 6b554163ff6b5..d4106aa266262 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Indentation { @@ -19,10 +20,11 @@ internal abstract partial class AbstractIndentationService internal abstract class AbstractIndenter { public readonly OptionSet OptionSet; - protected readonly TextLine LineToBeIndented; + public readonly TextLine LineToBeIndented; protected readonly int TabSize; protected readonly CancellationToken CancellationToken; + protected readonly Document Document; protected readonly TSyntaxRoot Root; protected readonly SyntaxTree Tree; protected readonly IEnumerable Rules; @@ -30,10 +32,11 @@ internal abstract class AbstractIndenter private static readonly Func s_tokenHasDirective = tk => tk.ContainsDirectives && (tk.LeadingTrivia.Any(tr => tr.IsDirective) || tk.TrailingTrivia.Any(tr => tr.IsDirective)); + private readonly ISyntaxFactsService _syntaxFacts; public AbstractIndenter( - ISyntaxFactsService syntaxFacts, + Document document, SyntaxTree syntaxTree, IEnumerable rules, OptionSet optionSet, @@ -42,7 +45,8 @@ public AbstractIndenter( { this.Root = (TSyntaxRoot)syntaxTree.GetRoot(cancellationToken); - this._syntaxFacts = syntaxFacts; + Document = document; + this._syntaxFacts = document.GetLanguageService(); this.OptionSet = optionSet; this.Tree = syntaxTree; this.LineToBeIndented = lineToBeIndented; @@ -57,7 +61,11 @@ public AbstractIndenter( tokenStream: null); } - public abstract bool ShouldUseTokenIndenter(out SyntaxToken token); + protected abstract bool ShouldUseTokenIndenter(out SyntaxToken token); + protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(); + + protected abstract IndentationResult GetDesiredIndentationWorker( + SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition); public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle indentStyle) { @@ -67,6 +75,11 @@ public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle ind return new IndentationResult(basePosition: 0, offset: 0); } + if (this.TryGetSmartTokenIndentation(out var indentationResult)) + { + return indentationResult; + } + // find previous line that is not blank. this will skip over things like preprocessor // regions and inactive code. var previousLineOpt = GetPreviousNonBlankOrPreprocessorLine(); @@ -107,8 +120,36 @@ public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle ind token, previousNonWhitespaceOrPreprocessorLine, lastNonWhitespacePosition); } - protected abstract IndentationResult GetDesiredIndentationWorker( - SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition); + private bool TryGetSmartTokenIndentation(out IndentationResult indentationResult) + { + indentationResult = default; + if (!ShouldUseTokenIndenter(out var token)) + { + return false; + } + + // var root = document.GetSyntaxRootSynchronously(cancellationToken); + var sourceText = Tree.GetText(CancellationToken); + + var formatter = CreateSmartTokenFormatter(); + var changes = formatter.FormatTokenAsync(Document.Project.Solution.Workspace, token, CancellationToken) + .WaitAndGetResult(CancellationToken); + + var updatedSourceText = sourceText.WithChanges(changes); + if (LineToBeIndented.LineNumber < updatedSourceText.Lines.Count) + { + var updatedLine = updatedSourceText.Lines[LineToBeIndented.LineNumber]; + var offset = updatedLine.GetFirstNonWhitespaceOffset(); + if (offset != null) + { + indentationResult = new IndentationResult( + basePosition: updatedLine.Start, + offset: offset.Value); + } + } + + return true; + } protected IndentationResult IndentFromStartOfLine(int addedSpaces) => new IndentationResult(this.LineToBeIndented.Start, addedSpaces); diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 926d67e378c74..865cc76fb6fc4 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -19,8 +19,6 @@ internal abstract partial class AbstractIndentationService : IInden { protected abstract AbstractFormattingRule GetSpecializedIndentationFormattingRule(); - protected abstract IEnumerable GetTokenFormattingRules(Document document, int position); - private IEnumerable GetFormattingRules(Document document, int position) { var workspace = document.Project.Solution.Workspace; @@ -31,7 +29,7 @@ private IEnumerable GetFormattingRules(Document document return formattingRules; } - public IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) + public IndentationResult GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) { var indenter = GetIndenter(document, lineNumber, cancellationToken); @@ -39,56 +37,12 @@ private IEnumerable GetFormattingRules(Document document if (indentStyle == FormattingOptions.IndentStyle.None) { // If there is no indent style, then do nothing. - return null; - } - - // There are two important cases for indentation. The first is when we're simply - // trying to figure out the appropriate indentation on a blank line (i.e. after - // hitting enter at the end of a line, or after moving to a blank line). The - // second is when we're trying to figure out indentation for a non-blank line - // (i.e. after hitting enter in the middle of a line, causing tokens to move to - // the next line). If we're in the latter case, we defer to the Formatting engine - // as we need it to use all its rules to determine where the appropriate location is - // for the following tokens to go. - if (indenter.ShouldUseTokenIndenter(out var token)) - { - return UseTokenIndenter(document, lineNumber, token, cancellationToken); + return new IndentationResult(basePosition: 0, offset: 0); } return indenter.GetDesiredIndentation(indentStyle); } - private IndentationResult UseTokenIndenter( - Document document, int lineNumber, SyntaxToken token, CancellationToken cancellationToken) - { - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var sourceText = root.SyntaxTree.GetText(cancellationToken); - var lineToBeIndented = sourceText.Lines[lineNumber]; - - var formattingRules = this.GetTokenFormattingRules(document, lineToBeIndented.Start); - - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); - var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - - var updatedSourceText = sourceText.WithChanges(changes); - if (lineNumber < updatedSourceText.Lines.Count) - { - var updatedLine = updatedSourceText.Lines[lineNumber]; - var offset = updatedLine.GetFirstNonWhitespaceOffset(); - if (offset != null) - { - return new IndentationResult( - basePosition: lineToBeIndented.Start, - offset: offset.Value); - } - } - - return default; - } - - protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - public IndentationResult GetBlankLineIndentation( Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken) { @@ -106,14 +60,12 @@ private AbstractIndenter GetIndenter(Document document, int lineNumber, Cancella var formattingRules = GetFormattingRules(document, lineToBeIndented.Start); - var indenter = GetIndenter( - document.GetLanguageService(), - root.SyntaxTree, lineToBeIndented, formattingRules, - documentOptions, cancellationToken); - return indenter; + return GetIndenter( + document, root.SyntaxTree, lineToBeIndented, + formattingRules, documentOptions, cancellationToken); } protected abstract AbstractIndenter GetIndenter( - ISyntaxFactsService syntaxFacts, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken); + Document document, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken); } } diff --git a/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs index ea63fc2a81904..7d381511ffbf1 100644 --- a/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs @@ -42,12 +42,13 @@ public IndentationResult(int basePosition, int offset) : this() internal interface IIndentationService : ILanguageService { /// - /// Determines the desired indentation of a given line. May return if the - /// does not want any sort of automatic indentation. May also return - /// if the line in question is not blank and thus indentation should - /// be deferred to the formatting command handler to handle. + /// Determines the desired indentation of a given line. This is conceptually what indentation + /// would be provided if 'enter' was pressed in the middle of a line. It will determine what + /// position the remainder of the line should start at. This may differ from + /// if the language thinks the indentation should be + /// different if the line is completely blank, or if it contains text after the caret. /// - IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken); + IndentationResult GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken); /// /// Determines indentation for a blank line (i.e. after hitting enter at the end of a line, diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index 4622bf6e5632b..110f66c2d1678 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -15,20 +15,28 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Private Class Indenter Inherits AbstractIndenter - Public Sub New(syntaxFacts As ISyntaxFactsService, + Public Sub New(document As Document, syntaxTree As SyntaxTree, rules As IEnumerable(Of AbstractFormattingRule), optionSet As OptionSet, line As TextLine, cancellationToken As CancellationToken) - MyBase.New(syntaxFacts, syntaxTree, rules, optionSet, line, cancellationToken) + MyBase.New(document, syntaxTree, rules, optionSet, line, cancellationToken) End Sub - Public Overrides Function ShouldUseTokenIndenter(ByRef token As SyntaxToken) As Boolean + Protected Overrides Function ShouldUseTokenIndenter(ByRef token As SyntaxToken) As Boolean Return ShouldUseSmartTokenFormatterInsteadOfIndenter( Rules, Root, LineToBeIndented, OptionSet, token, CancellationToken) End Function + Protected Overrides Function CreateSmartTokenFormatter() As ISmartTokenFormatter + Dim workspace = Document.Project.Solution.Workspace + Dim formattingRuleFactory = workspace.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() + Dim rules = {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(Document, LineToBeIndented.Start)}.Concat(Formatter.GetDefaultFormattingRules(Document)) + + Return New VisualBasicSmartTokenFormatter(OptionSet, rules, Root) + End Function + Protected Overrides Function GetDesiredIndentationWorker( token As SyntaxToken, previousLine As TextLine, diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index f3e7f190e1726..4b115f81b45a7 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -33,13 +33,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Return _specializedIndentationRule End Function - Protected Overrides Function GetIndenter(syntaxFacts As ISyntaxFactsService, + Protected Overrides Function GetIndenter(document As Document, syntaxTree As SyntaxTree, lineToBeIndented As TextLine, formattingRules As IEnumerable(Of AbstractFormattingRule), optionSet As OptionSet, cancellationToken As CancellationToken) As AbstractIndenter - Return New Indenter(syntaxFacts, syntaxTree, formattingRules, optionSet, lineToBeIndented, cancellationToken) + Return New Indenter(document, syntaxTree, formattingRules, optionSet, lineToBeIndented, cancellationToken) End Function Public Overloads Shared Function ShouldUseSmartTokenFormatterInsteadOfIndenter( @@ -131,15 +131,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Return token.Kind = SyntaxKind.None OrElse token.Kind = SyntaxKind.EndOfFileToken End Function - - Protected Overrides Function GetTokenFormattingRules(document As Document, position As Integer) As IEnumerable(Of AbstractFormattingRule) - Dim ws = document.Project.Solution.Workspace - Dim formattingRuleFactory = ws.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() - Return {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(document, position)}.Concat(Formatter.GetDefaultFormattingRules(document)) - End Function - - Protected Overrides Function CreateSmartTokenFormatter(optionSet As OptionSet, formattingRules As IEnumerable(Of AbstractFormattingRule), root As SyntaxNode) As ISmartTokenFormatter - Return New VisualBasicSmartTokenFormatter(optionSet, formattingRules, DirectCast(root, CompilationUnitSyntax)) - End Function End Class End Namespace From 0c095687b997179b7d8d9d0f46e8489ee438de3c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 9 Mar 2019 01:00:42 -0800 Subject: [PATCH 20/43] Restore --- .../Formatting/Indentation/SmartIndenterTests.cs | 2 +- .../AbstractIndentationService.AbstractIndenter.cs | 7 +------ .../Portable/Indentation/AbstractIndentationService.cs | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs index 7571691de4fed..f9518539e8058 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs @@ -418,7 +418,7 @@ void Method() AssertSmartIndent( code, indentationLine: 7, - expectedIndentation: 8, + expectedIndentation: 4, expectedBlankLineIndentation: 8); } diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index d4106aa266262..0d5f6d8012e1f 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -75,11 +75,6 @@ public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle ind return new IndentationResult(basePosition: 0, offset: 0); } - if (this.TryGetSmartTokenIndentation(out var indentationResult)) - { - return indentationResult; - } - // find previous line that is not blank. this will skip over things like preprocessor // regions and inactive code. var previousLineOpt = GetPreviousNonBlankOrPreprocessorLine(); @@ -120,7 +115,7 @@ public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle ind token, previousNonWhitespaceOrPreprocessorLine, lastNonWhitespacePosition); } - private bool TryGetSmartTokenIndentation(out IndentationResult indentationResult) + public bool TryGetSmartTokenIndentation(out IndentationResult indentationResult) { indentationResult = default; if (!ShouldUseTokenIndenter(out var token)) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 865cc76fb6fc4..b465ab31a99f3 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -40,6 +40,12 @@ public IndentationResult GetDesiredIndentation(Document document, int lineNumber return new IndentationResult(basePosition: 0, offset: 0); } + if (indentStyle == FormattingOptions.IndentStyle.Smart && + indenter.TryGetSmartTokenIndentation(out var indentationResult)) + { + return indentationResult; + } + return indenter.GetDesiredIndentation(indentStyle); } From 426070b94c892c8c19e0927862e0bc6218758eca Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 9 Mar 2019 01:03:30 -0800 Subject: [PATCH 21/43] simplify --- .../Core/Portable/Indentation/AbstractIndentationService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index b465ab31a99f3..2dc70b864b7f6 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -40,8 +40,7 @@ public IndentationResult GetDesiredIndentation(Document document, int lineNumber return new IndentationResult(basePosition: 0, offset: 0); } - if (indentStyle == FormattingOptions.IndentStyle.Smart && - indenter.TryGetSmartTokenIndentation(out var indentationResult)) + if (indenter.TryGetSmartTokenIndentation(out var indentationResult)) { return indentationResult; } From 1ee0717e4b7353da138997dc67f2f326f08a7a06 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 9 Mar 2019 01:51:30 -0800 Subject: [PATCH 22/43] simplify --- src/Workspaces/Core/Portable/Indentation/IIndentationService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs index ea63fc2a81904..4d63ee1418640 100644 --- a/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/IIndentationService.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading; -using System.Threading.Tasks; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host; From a380b2197d63888eeab560d1e2c5b607eafb8ef0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 9 Mar 2019 02:46:08 -0800 Subject: [PATCH 23/43] Fix --- .../Indentation/AbstractIndentationService.AbstractIndenter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 0d5f6d8012e1f..3e7eeeae723ab 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -138,7 +138,7 @@ public bool TryGetSmartTokenIndentation(out IndentationResult indentationResult) if (offset != null) { indentationResult = new IndentationResult( - basePosition: updatedLine.Start, + basePosition: LineToBeIndented.Start, offset: offset.Value); } } From c429a5a23db20b6fa9ef4ad5995d02731430e068 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 9 Mar 2019 14:33:17 -0800 Subject: [PATCH 24/43] remove comment --- .../CSharpTest/Formatting/Indentation/SmartIndenterTests.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs index f9518539e8058..a6d152ba2592d 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs @@ -410,11 +410,6 @@ void Method() code, indentationLine: 6, expectedIndentation: 12); - - // This is the line after the method call. ISynchronousIndentationService will bail in - // this case as it thinks this is a case for "smart formatting". However, - // IBlankLineIndentationService appropriately picks 8 columns as the location to indent - // to. AssertSmartIndent( code, indentationLine: 7, From 22c389e46d21c197d7140b9d79dc917ac5be1a72 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 12 May 2019 11:08:50 -0700 Subject: [PATCH 25/43] Get building --- .../AsyncCompletion/CommitManager.cs | 2 +- .../PropertySubPatternCompletionProvider.cs | 2 +- .../FSharpSynchronousIndentationService.cs | 17 ++++++++++++----- .../VisualBasicHelpers/VisualBasicHelpers.vb | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs index f24d361cfd32c..7277465adfed2 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs @@ -153,7 +153,7 @@ public AsyncCompletionData.CommitResult TryCommit( AsyncCompletionLogger.LogCommitTypeImportCompletionItem(); } } - + if (session.TextView.Properties.TryGetProperty(CompletionSource.TargetTypeFilterExperimentEnabled, out bool isExperimentEnabled) && isExperimentEnabled) { // Capture the % of committed completion items that would have appeared in the "Target type matches" filter diff --git a/src/Features/CSharp/Portable/Completion/CompletionProviders/PropertySubPatternCompletionProvider.cs b/src/Features/CSharp/Portable/Completion/CompletionProviders/PropertySubPatternCompletionProvider.cs index 793aa76c2ac60..d58a8d9e31a63 100644 --- a/src/Features/CSharp/Portable/Completion/CompletionProviders/PropertySubPatternCompletionProvider.cs +++ b/src/Features/CSharp/Portable/Completion/CompletionProviders/PropertySubPatternCompletionProvider.cs @@ -43,7 +43,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context) IEnumerable members = semanticModel.LookupSymbols(position, type); members = members.Where(m => m.CanBeReferencedByName && IsFieldOrReadableProperty(m) && - !m.IsImplicitlyDeclared && + !m.IsImplicitlyDeclared && !m.IsStatic); // Filter out those members that have already been typed diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs b/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs index 907254f2ec1bc..ff86543602125 100644 --- a/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs +++ b/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs @@ -3,15 +3,16 @@ using System; using System.Composition; using System.Threading; -using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Indentation; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor { [Shared] - [ExportLanguageService(typeof(ISynchronousIndentationService), LanguageNames.FSharp)] - internal class FSharpSynchronousIndentationService : ISynchronousIndentationService + [ExportLanguageService(typeof(IIndentationService), LanguageNames.FSharp)] + internal class FSharpSynchronousIndentationService : IIndentationService { private readonly IFSharpSynchronousIndentationService _service; @@ -22,17 +23,23 @@ public FSharpSynchronousIndentationService(IFSharpSynchronousIndentationService _service = service; } - public CodeAnalysis.Editor.IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) + public IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) { var result = _service.GetDesiredIndentation(document, lineNumber, cancellationToken); if (result.HasValue) { - return new CodeAnalysis.Editor.IndentationResult(result.Value.BasePosition, result.Value.Offset); + return new IndentationResult(result.Value.BasePosition, result.Value.Offset); } else { return null; } } + + IndentationResult IIndentationService.GetBlankLineIndentation( + Document document, int lineNumber, FormattingOptions.IndentStyle indentStyle, CancellationToken cancellationToken) + { + return default; + } } } diff --git a/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb b/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb index bf6695bd413c8..893f1a0a15a19 100644 --- a/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb +++ b/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb @@ -21,7 +21,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Vi Public Function CreateVisualBasicProjectWithNullBinPath(environment As TestEnvironment, projectName As String) As VisualBasicProject Return New VisualBasicProject(projectName, MockCompilerHost.FullFrameworkCompilerHost, - environment.CreateHierarchy(projectName, projectBinPath:=Nothing, projectCapabilities:="VB"), + environment.CreateHierarchy(projectName, projectBinPath:=Nothing, projectRefPath:=Nothing, projectCapabilities:="VB"), environment.ServiceProvider, environment.ThreadingContext, commandLineParserServiceOpt:=New VisualBasicCommandLineParserService()) From d01d75a2ef402ef281ba93c7be30f23afe303ae6 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 12 May 2019 11:14:13 -0700 Subject: [PATCH 26/43] Update. --- .../FSharp/Editor/FSharpSynchronousIndentationService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs b/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs index ff86543602125..d4402168c4a3f 100644 --- a/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs +++ b/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs @@ -23,7 +23,7 @@ public FSharpSynchronousIndentationService(IFSharpSynchronousIndentationService _service = service; } - public IndentationResult? GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) + public IndentationResult GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) { var result = _service.GetDesiredIndentation(document, lineNumber, cancellationToken); if (result.HasValue) @@ -32,7 +32,7 @@ public FSharpSynchronousIndentationService(IFSharpSynchronousIndentationService } else { - return null; + return default; } } From 90f15a29ac5ddafe766ab375cecaaf3ec432f16b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 13:06:12 -0700 Subject: [PATCH 27/43] Update --- .../VisualBasicHelpers/VisualBasicHelpers.vb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb b/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb index c217f61e74209..8329044935080 100644 --- a/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb +++ b/src/VisualStudio/TestUtilities2/ProjectSystemShim/VisualBasicHelpers/VisualBasicHelpers.vb @@ -18,18 +18,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Vi commandLineParserServiceOpt:=New VisualBasicCommandLineParserService()) End Function -<<<<<<< HEAD - Public Function CreateVisualBasicProjectWithNullBinPath(environment As TestEnvironment, projectName As String) As VisualBasicProject - Return New VisualBasicProject(projectName, - MockCompilerHost.FullFrameworkCompilerHost, - environment.CreateHierarchy(projectName, projectBinPath:=Nothing, projectRefPath:=Nothing, projectCapabilities:="VB"), - environment.ServiceProvider, - environment.ThreadingContext, - commandLineParserServiceOpt:=New VisualBasicCommandLineParserService()) - End Function - -======= ->>>>>>> master Public Function CreateMinimalCompilerOptions(project As VisualBasicProject) As VBCompilerOptions Dim options As VBCompilerOptions = Nothing options.wszExeName = project.AssemblyName + ".exe" From 879201e305d504c4de0844e7e7c6650c5aee89fd Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 20:36:23 -0700 Subject: [PATCH 28/43] Move using inside --- .../AbstractSmartTokenFormatterCommandHandler.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index 78a6f5f2c3430..f23e6e8af6802 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -8,7 +8,6 @@ using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -24,6 +23,10 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation { + // Place this using inside the containing namespace so it takes precedence over + // the older Editor version with the same name. + using Microsoft.CodeAnalysis.Indentation; + internal abstract class AbstractSmartTokenFormatterCommandHandler : IChainedCommandHandler { @@ -140,7 +143,7 @@ internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken return; } - var indentationService = document.GetLanguageService(); + var indentationService = document.GetLanguageService(); var indentation = indentationService.GetDesiredIndentation(document, currentPosition.GetContainingLine().LineNumber, cancellationToken); From 2babee5889c6115a48a0ce6a643dbb2adbee3ddb Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 20:37:27 -0700 Subject: [PATCH 29/43] Move using inside --- .../BinaryExpression/AbstractBinaryExpressionWrapper.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs index d17ee495c5e9b..696d87d5a9582 100644 --- a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs @@ -9,6 +9,10 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression { + // Place this using inside the containing namespace so it takes precedence over + // the older Editor version with the same name. + using Microsoft.CodeAnalysis.Indentation; + internal abstract partial class AbstractBinaryExpressionWrapper : AbstractSyntaxWrapper where TBinaryExpressionSyntax : SyntaxNode { @@ -16,7 +20,7 @@ internal abstract partial class AbstractBinaryExpressionWrapper Date: Tue, 21 May 2019 20:38:21 -0700 Subject: [PATCH 30/43] Move using inside --- .../Indentation/AbstractSmartTokenFormatterCommandHandler.cs | 2 -- .../BinaryExpression/AbstractBinaryExpressionWrapper.cs | 2 -- .../AbstractSeparatedSyntaxListWrapper.cs | 5 +++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs index f23e6e8af6802..b6e2f60bdef05 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs @@ -23,8 +23,6 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation { - // Place this using inside the containing namespace so it takes precedence over - // the older Editor version with the same name. using Microsoft.CodeAnalysis.Indentation; internal abstract class AbstractSmartTokenFormatterCommandHandler : diff --git a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs index 696d87d5a9582..079fb588cabab 100644 --- a/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs @@ -9,8 +9,6 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression { - // Place this using inside the containing namespace so it takes precedence over - // the older Editor version with the same name. using Microsoft.CodeAnalysis.Indentation; internal abstract partial class AbstractBinaryExpressionWrapper : AbstractSyntaxWrapper diff --git a/src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/AbstractSeparatedSyntaxListWrapper.cs b/src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/AbstractSeparatedSyntaxListWrapper.cs index fe5b47b0bbb20..29ad6db0d3670 100644 --- a/src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/AbstractSeparatedSyntaxListWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/AbstractSeparatedSyntaxListWrapper.cs @@ -2,10 +2,11 @@ using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Indentation; namespace Microsoft.CodeAnalysis.Editor.Wrapping.SeparatedSyntaxList { + using Microsoft.CodeAnalysis.Indentation; + /// /// Base type for all wrappers that involve wrapping a comma-separated list of items. /// @@ -31,7 +32,7 @@ internal abstract partial class AbstractSeparatedSyntaxListWrapper< protected abstract string Wrap_every_item { get; } - protected AbstractSeparatedSyntaxListWrapper(Indentation.IIndentationService indentationService) + protected AbstractSeparatedSyntaxListWrapper(IIndentationService indentationService) : base(indentationService) { } From 0dc3b4f4b62647350fbacf78815599fac735a98b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 20:40:13 -0700 Subject: [PATCH 31/43] Move using inside --- .../SplitStringLiteralCommandHandler.StringSplitter.cs | 4 +++- src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs | 6 ++++-- .../TestUtilities/Formatting/CoreFormatterTestsBase.cs | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs index a537b55afc02a..f33425702ece2 100644 --- a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs +++ b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralCommandHandler.StringSplitter.cs @@ -9,6 +9,8 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.SplitStringLiteral { + using Microsoft.CodeAnalysis.Indentation; + internal partial class SplitStringLiteralCommandHandler { private abstract class StringSplitter @@ -149,7 +151,7 @@ private string GetIndentString(SyntaxNode newRoot) { var newDocument = Document.WithSyntaxRoot(newRoot); - var indentationService = newDocument.GetLanguageService(); + var indentationService = newDocument.GetLanguageService(); var originalLineNumber = SourceText.Lines.GetLineFromPosition(CursorPosition).LineNumber; var desiredIndentation = indentationService.GetBlankLineIndentation( diff --git a/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs b/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs index e4f4aa2f79d0d..08332f8296501 100644 --- a/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/AbstractWrapper.cs @@ -7,6 +7,8 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping { + using Microsoft.CodeAnalysis.Indentation; + /// /// Common implementation of all . This type takes care of a lot of common logic for /// all of them, including: @@ -21,9 +23,9 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping /// internal abstract partial class AbstractSyntaxWrapper : ISyntaxWrapper { - protected Indentation.IIndentationService IndentationService { get; } + protected IIndentationService IndentationService { get; } - protected AbstractSyntaxWrapper(Indentation.IIndentationService indentationService) + protected AbstractSyntaxWrapper(IIndentationService indentationService) { this.IndentationService = indentationService; } diff --git a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs index 282809244a442..ce2d8ee6e101a 100644 --- a/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs +++ b/src/EditorFeatures/TestUtilities/Formatting/CoreFormatterTestsBase.cs @@ -21,6 +21,8 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.Formatting { + using Microsoft.CodeAnalysis.Indentation; + public abstract class CoreFormatterTestsBase { internal abstract string GetLanguageName(); @@ -70,7 +72,7 @@ protected void TestBlankLineIndentationService( var indentationLineFromBuffer = snapshot.GetLineFromLineNumber(indentationLine); var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); - var blankLineIndenter = document.GetLanguageService(); + var blankLineIndenter = document.GetLanguageService(); var indentStyle = workspace.Options.GetOption(FormattingOptions.SmartIndent, GetLanguageName()); var blankLineIndentResult = blankLineIndenter.GetBlankLineIndentation( document, indentationLine, indentStyle, CancellationToken.None); From ad99a7b63f554b717ec55f36a8c16f39d23485d7 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 20:42:29 -0700 Subject: [PATCH 32/43] Add links --- .../Core/Implementation/SmartIndent/IIndentationService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs index 4997c593a575d..3c1d2d6abb721 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs @@ -43,12 +43,14 @@ public static implicit operator Indentation.IndentationResult(IndentationResult => new Indentation.IndentationResult(result.BasePosition, result.Offset); } + // Removal of this interface tracked with https://github.com/dotnet/roslyn/issues/35872 [Obsolete("Use Microsoft.CodeAnalysis.Indentation.IIndentationService instead.")] internal interface IIndentationService : ILanguageService { Task GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken); } + // Removal of this interface tracked with https://github.com/dotnet/roslyn/issues/35872 [Obsolete("Use Microsoft.CodeAnalysis.Indentation.IIndentationService instead.")] internal interface ISynchronousIndentationService : ILanguageService { From 73e52bd68760747011941f1a903832fb62fe1f4b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 22 May 2019 10:33:40 -0700 Subject: [PATCH 33/43] Remove file --- ...stractSmartTokenFormatterCommandHandler.cs | 355 ------------------ 1 file changed, 355 deletions(-) delete mode 100644 src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs diff --git a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs deleted file mode 100644 index b6e2f60bdef05..0000000000000 --- a/src/EditorFeatures/Core/Implementation/Formatting/Indentation/AbstractSmartTokenFormatterCommandHandler.cs +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using Microsoft.CodeAnalysis.Editor.Shared.Extensions; -using Microsoft.CodeAnalysis.Editor.Shared.Utilities; -using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; -using Microsoft.VisualStudio.Commanding; -using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods; -using Microsoft.VisualStudio.Text.Operations; -using Roslyn.Utilities; -using VSCommanding = Microsoft.VisualStudio.Commanding; - -namespace Microsoft.CodeAnalysis.Editor.Implementation.Formatting.Indentation -{ - using Microsoft.CodeAnalysis.Indentation; - - internal abstract class AbstractSmartTokenFormatterCommandHandler : - IChainedCommandHandler - { - private readonly ITextUndoHistoryRegistry _undoHistoryRegistry; - private readonly IEditorOperationsFactoryService _editorOperationsFactoryService; - - public string DisplayName => EditorFeaturesResources.Smart_Token_Formatter; - - public AbstractSmartTokenFormatterCommandHandler( - ITextUndoHistoryRegistry undoHistoryRegistry, - IEditorOperationsFactoryService editorOperationsFactoryService) - { - _undoHistoryRegistry = undoHistoryRegistry; - _editorOperationsFactoryService = editorOperationsFactoryService; - } - - protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable formattingRules, SyntaxNode root); - - protected abstract bool UseSmartTokenFormatter(SyntaxNode root, TextLine line, IEnumerable formattingRules, OptionSet options, CancellationToken cancellationToken); - protected abstract bool IsInvalidToken(SyntaxToken token); - - protected abstract IEnumerable GetFormattingRules(Document document, int position); - - /// True if any change is made. - protected bool FormatToken(ITextView view, Document document, SyntaxToken token, IEnumerable formattingRules, CancellationToken cancellationToken) - { - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - var formatter = CreateSmartTokenFormatter(documentOptions, formattingRules, root); - var changes = formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken).WaitAndGetResult(cancellationToken); - if (changes.Count == 0) - { - return false; - } - - using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Format_Token)) - { - transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance; - - document.Project.Solution.Workspace.ApplyTextChanges(document.Id, changes, cancellationToken); - transaction.Complete(); - } - - return true; - } - - public VSCommanding.CommandState GetCommandState(ReturnKeyCommandArgs args, Func nextHandler) - { - return nextHandler(); - } - - public void ExecuteCommand(ReturnKeyCommandArgs args, Action nextHandler, CommandExecutionContext context) - { - var textView = args.TextView; - var oldCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); - - nextHandler(); - - // A feature like completion handled the return key but did not pass it on to the editor. - var newCaretPoint = textView.GetCaretPoint(args.SubjectBuffer); - if (textView.Selection.IsEmpty && oldCaretPoint.HasValue && newCaretPoint.HasValue && - oldCaretPoint.Value.GetContainingLine().LineNumber == newCaretPoint.Value.GetContainingLine().LineNumber) - { - return; - } - - if (args.SubjectBuffer.CanApplyChangeDocumentToWorkspace()) - { - ExecuteCommandWorker(args, CancellationToken.None); - } - } - - internal void ExecuteCommandWorker(ReturnKeyCommandArgs args, CancellationToken cancellationToken) - { - var textView = args.TextView; - var caretPoint = textView.GetCaretPoint(args.SubjectBuffer); - - if (!caretPoint.HasValue) - { - return; - } - - var currentPosition = caretPoint.Value; - var document = currentPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); - if (document == null) - { - return; - } - - var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - if (documentOptions.GetOption(FormattingOptions.SmartIndent) != FormattingOptions.IndentStyle.Smart) - { - return; - } - - var formattingRules = this.GetFormattingRules(document, currentPosition.Position); - - // see whether we should use token formatter - if (TryFormatUsingTokenFormatter(textView, args.SubjectBuffer, document, formattingRules, cancellationToken)) - { - return; - } - - // check whether editor would have used smart indenter - if (EditorHandled(textView) && !RequireReadjustment(textView, args.SubjectBuffer)) - { - // editor already took care of smart indentation. - return; - } - - // check whether we can do it ourselves - if (!CanHandleOurselves(textView, args.SubjectBuffer)) - { - return; - } - - var indentationService = document.GetLanguageService(); - var indentation = indentationService.GetDesiredIndentation(document, - currentPosition.GetContainingLine().LineNumber, cancellationToken); - - // looks like we can't. - if (!indentation.HasValue) - { - return; - } - - HandleOurselves(textView, args.SubjectBuffer, indentation.Value.GetIndentation(textView, currentPosition.GetContainingLine()), documentOptions); - } - - private bool RequireReadjustment(ITextView view, ITextBuffer subjectBuffer) - { - var caretInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value; - var lineInSubjectBuffer = caretInSubjectBuffer.GetContainingLine(); - - var currentOffset = caretInSubjectBuffer - lineInSubjectBuffer.Start; - var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); - if (!firstNonWhitespaceIndex.HasValue || currentOffset >= firstNonWhitespaceIndex.Value) - { - return false; - } - - // there are whitespace after caret position (which smart indentation has put), - // we might need to re-adjust indentation - return true; - } - - private void HandleOurselves(ITextView view, ITextBuffer subjectBuffer, int indentation, DocumentOptionSet options) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - var lengthOfLine = lineInSubjectBuffer.GetColumnFromLineOffset(lineInSubjectBuffer.Length, view.Options); - - // check whether we are dealing with virtual space or real space - if (indentation > lengthOfLine) - { - // we are dealing with virtual space - var caretPosition = view.GetVirtualCaretPoint(subjectBuffer); - var positionInVirtualSpace = new VirtualSnapshotPoint(caretPosition.Value.Position, indentation - lineInSubjectBuffer.Length); - view.TryMoveCaretToAndEnsureVisible(positionInVirtualSpace); - return; - } - - // we are dealing with real space. check whether we need to just set caret position or move text - var firstNonWhitespaceIndex = lineInSubjectBuffer.GetFirstNonWhitespaceOffset(); - - if (firstNonWhitespaceIndex.HasValue) - { - // if leading whitespace is not what we expect, re-adjust indentation - var columnOfFirstNonWhitespace = lineInSubjectBuffer.GetColumnFromLineOffset(firstNonWhitespaceIndex.Value, view.Options); - if (columnOfFirstNonWhitespace != indentation) - { - ReadjustIndentation(view, subjectBuffer, firstNonWhitespaceIndex.Value, indentation, options); - return; - } - } - - // okay, it is an empty line with some whitespaces - Debug.Assert(indentation <= lineInSubjectBuffer.Length); - - var offset = GetOffsetFromIndentation(indentation, view.Options); - view.TryMoveCaretToAndEnsureVisible(lineInSubjectBuffer.Start.Add(offset)); - } - - private int GetOffsetFromIndentation(int indentation, IEditorOptions option) - { - int numberOfTabs = 0; - int numberOfSpaces = Math.Max(0, indentation); - - if (!option.IsConvertTabsToSpacesEnabled()) - { - var tabSize = option.GetTabSize(); - - numberOfTabs = indentation / tabSize; - numberOfSpaces -= numberOfTabs * tabSize; - } - - return numberOfTabs + numberOfSpaces; - } - - /// - /// re-adjust caret position to be the beginning of first text on the line. and make sure the text start at the given indentation - /// - private static void ReadjustIndentation(ITextView view, ITextBuffer subjectBuffer, int firstNonWhitespaceIndex, int indentation, DocumentOptionSet options) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - - // first set the caret at the beginning of the text on the line - view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(lineInSubjectBuffer.Snapshot, lineInSubjectBuffer.Start + firstNonWhitespaceIndex)); - - var document = lineInSubjectBuffer.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); - if (document == null) - { - return; - } - - // and then, insert the text - document.Project.Solution.Workspace.ApplyTextChanges(document.Id, - new TextChange( - new TextSpan( - lineInSubjectBuffer.Start.Position, firstNonWhitespaceIndex), - indentation.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize))), - CancellationToken.None); - } - - /// - /// check whether we can smart indent ourselves. we only attempt to smart indent ourselves - /// if the line in subject buffer we do smart indenting maps back to the view as it is and - /// if it starts from the beginning of the line - /// - private bool CanHandleOurselves(ITextView view, ITextBuffer subjectBuffer) - { - var lineInSubjectBuffer = view.GetCaretPoint(subjectBuffer).Value.GetContainingLine(); - - // first, make sure whole line is map back to the view - if (view.GetSpanInView(lineInSubjectBuffer.ExtentIncludingLineBreak).Count != 1) - { - return false; - } - - // now check, start position of the line is start position in the view - var caretPosition = view.GetPositionInView(view.GetVirtualCaretPoint(subjectBuffer).Value.Position); - var containingLineCaret = caretPosition.Value.GetContainingLine(); - - var startPositionSubjectBuffer = view.GetPositionInView(lineInSubjectBuffer.Start); - var startPositionCaret = view.GetPositionInView(containingLineCaret.Start); - if (!startPositionSubjectBuffer.HasValue || - !startPositionCaret.HasValue || - startPositionCaret.Value != startPositionSubjectBuffer.Value) - { - // if start position of subject buffer is not equal to start position of view line, - // we can't use the indenter - return false; - } - - // get containing line in view from start position of the caret in view - var containingLineView = startPositionCaret.Value.GetContainingLine(); - - // make sure line start at the beginning of the line - if (containingLineView.Start != startPositionCaret.Value) - { - return false; - } - - return true; - } - - /// - /// check whether editor smart indenter mechanism handled this case already - /// - private bool EditorHandled(ITextView view) - { - var caretPosition = view.Caret.Position.VirtualBufferPosition; - return caretPosition.IsInVirtualSpace || (caretPosition.Position != view.Caret.Position.BufferPosition.GetContainingLine().Start); - } - - /// - /// check whether we can do automatic formatting using token formatter instead of smart indenter for the "enter" key - /// - private bool TryFormatUsingTokenFormatter(ITextView view, ITextBuffer subjectBuffer, Document document, IEnumerable formattingRules, CancellationToken cancellationToken) - { - var position = view.GetCaretPoint(subjectBuffer).Value; - var line = position.GetContainingLine().AsTextLine(); - var root = document.GetSyntaxRootSynchronously(cancellationToken); - var options = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken); - if (!UseSmartTokenFormatter(root, line, formattingRules, options, cancellationToken)) - { - return false; - } - - var firstNonWhitespacePosition = line.GetFirstNonWhitespacePosition(); - var token = root.FindToken(firstNonWhitespacePosition.Value); - if (IsInvalidToken(token)) - { - return false; - } - - // when undo, make sure it undo the caret movement I did below - using (var transaction = CreateEditTransaction(view, EditorFeaturesResources.Smart_Indenting)) - { - // if caret position is before the token, make sure we put caret at the beginning of the token so that caret - // is at the right position after formatting - var currentSnapshot = subjectBuffer.CurrentSnapshot; - if (position.Position < token.SpanStart) - { - view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(currentSnapshot, token.SpanStart)); - } - - if (FormatToken(view, document, token, formattingRules, cancellationToken)) - { - transaction.Complete(); - } - else - { - transaction.Cancel(); - } - } - - return true; - } - - /// - /// create caret preserving edit transaction - /// - protected CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description) - { - return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); - } - } -} From 54fee0fd32121b2886e1eca2a29b6bc4d1674d34 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 28 May 2019 15:46:30 -0700 Subject: [PATCH 34/43] Use SyntacticDocument --- .../CSharpIndentationService.Indenter.cs | 9 ++++----- .../Indentation/CSharpIndentationService.cs | 9 ++------- .../AbstractIndentationService.AbstractIndenter.cs | 14 ++++++-------- .../Indentation/AbstractIndentationService.cs | 12 ++++-------- .../VisualBasicIndentationService.Indenter.vb | 7 +++---- .../Indentation/VisualBasicIndentationService.vb | 5 ++--- 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs index e9b91b60e96b7..510e6c0649d98 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs @@ -23,13 +23,12 @@ internal partial class CSharpIndentationService internal class Indenter : AbstractIndenter { public Indenter( - Document document, - SyntaxTree syntaxTree, + SyntacticDocument document, IEnumerable rules, OptionSet optionSet, TextLine line, - CancellationToken cancellationToken) : - base(document, syntaxTree, rules, optionSet, line, cancellationToken) + CancellationToken cancellationToken) + : base(document, rules, optionSet, line, cancellationToken) { } @@ -41,7 +40,7 @@ protected override ISmartTokenFormatter CreateSmartTokenFormatter() { var workspace = Document.Project.Solution.Workspace; var formattingRuleFactory = workspace.Services.GetService(); - var rules = formattingRuleFactory.CreateRule(Document, LineToBeIndented.Start).Concat(Formatter.GetDefaultFormattingRules(Document)); + var rules = formattingRuleFactory.CreateRule(Document.Document, LineToBeIndented.Start).Concat(Formatter.GetDefaultFormattingRules(Document.Document)); return new CSharpSmartTokenFormatter(OptionSet, rules, Root); } diff --git a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs index ce461cafff3a7..060b6e70af78c 100644 --- a/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs +++ b/src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs @@ -35,13 +35,8 @@ protected override AbstractFormattingRule GetSpecializedIndentationFormattingRul return s_instance; } - protected override AbstractIndenter GetIndenter( - Document document, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken) - { - return new Indenter( - document, syntaxTree, formattingRules, - optionSet, lineToBeIndented, cancellationToken); - } + protected override AbstractIndenter GetIndenter(SyntacticDocument document, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken) + => new Indenter(document, formattingRules, optionSet, lineToBeIndented, cancellationToken); public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter( IEnumerable formattingRules, diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 3e7eeeae723ab..428d2b3bd0a8e 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -24,9 +24,9 @@ internal abstract class AbstractIndenter protected readonly int TabSize; protected readonly CancellationToken CancellationToken; - protected readonly Document Document; + protected readonly SyntacticDocument Document; protected readonly TSyntaxRoot Root; - protected readonly SyntaxTree Tree; + protected SyntaxTree Tree => Document.SyntaxTree; protected readonly IEnumerable Rules; protected readonly BottomUpBaseIndentationFinder Finder; @@ -36,19 +36,17 @@ internal abstract class AbstractIndenter private readonly ISyntaxFactsService _syntaxFacts; public AbstractIndenter( - Document document, - SyntaxTree syntaxTree, + SyntacticDocument document, IEnumerable rules, OptionSet optionSet, TextLine lineToBeIndented, CancellationToken cancellationToken) { - this.Root = (TSyntaxRoot)syntaxTree.GetRoot(cancellationToken); - Document = document; - this._syntaxFacts = document.GetLanguageService(); + + this._syntaxFacts = document.Document.GetLanguageService(); this.OptionSet = optionSet; - this.Tree = syntaxTree; + this.Root = (TSyntaxRoot)document.Root; this.LineToBeIndented = lineToBeIndented; this.TabSize = this.OptionSet.GetOption(FormattingOptions.TabSize, Root.Language); this.CancellationToken = cancellationToken; diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs index 45105913713a8..bd4e0225dca29 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.cs @@ -5,9 +5,7 @@ using System.Threading; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; @@ -57,19 +55,17 @@ public IndentationResult GetBlankLineIndentation( private AbstractIndenter GetIndenter(Document document, int lineNumber, CancellationToken cancellationToken) { var documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult_CanCallOnBackground(cancellationToken); - var root = document.GetSyntaxRootSynchronously(cancellationToken); + var syntacticDoc = SyntacticDocument.CreateAsync(document, cancellationToken).WaitAndGetResult_CanCallOnBackground(cancellationToken); - var sourceText = root.SyntaxTree.GetText(cancellationToken); + var sourceText = syntacticDoc.Root.SyntaxTree.GetText(cancellationToken); var lineToBeIndented = sourceText.Lines[lineNumber]; var formattingRules = GetFormattingRules(document, lineToBeIndented.Start); - return GetIndenter( - document, root.SyntaxTree, lineToBeIndented, - formattingRules, documentOptions, cancellationToken); + return GetIndenter(syntacticDoc, lineToBeIndented, formattingRules, documentOptions, cancellationToken); } protected abstract AbstractIndenter GetIndenter( - Document document, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken); + SyntacticDocument document, TextLine lineToBeIndented, IEnumerable formattingRules, OptionSet optionSet, CancellationToken cancellationToken); } } diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index c12f6348aafe6..c36042e4ade49 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -15,13 +15,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Private Class Indenter Inherits AbstractIndenter - Public Sub New(document As Document, - syntaxTree As SyntaxTree, + Public Sub New(document As SyntacticDocument, rules As IEnumerable(Of AbstractFormattingRule), optionSet As OptionSet, line As TextLine, cancellationToken As CancellationToken) - MyBase.New(document, syntaxTree, rules, optionSet, line, cancellationToken) + MyBase.New(document, rules, optionSet, line, cancellationToken) End Sub Protected Overrides Function ShouldUseTokenIndenter(ByRef token As SyntaxToken) As Boolean @@ -32,7 +31,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Protected Overrides Function CreateSmartTokenFormatter() As ISmartTokenFormatter Dim workspace = Document.Project.Solution.Workspace Dim formattingRuleFactory = workspace.Services.GetService(Of IHostDependentFormattingRuleFactoryService)() - Dim rules = {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(Document, LineToBeIndented.Start)}.Concat(Formatter.GetDefaultFormattingRules(Document)) + Dim rules = {New SpecialFormattingRule(), formattingRuleFactory.CreateRule(Document.Document, LineToBeIndented.Start)}.Concat(Formatter.GetDefaultFormattingRules(Document.Document)) Return New VisualBasicSmartTokenFormatter(OptionSet, rules, Root) End Function diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index 88a4902569e4e..229ae4de2169d 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -32,13 +32,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Return _specializedIndentationRule End Function - Protected Overrides Function GetIndenter(document As Document, - syntaxTree As SyntaxTree, + Protected Overrides Function GetIndenter(document As SyntacticDocument, lineToBeIndented As TextLine, formattingRules As IEnumerable(Of AbstractFormattingRule), optionSet As OptionSet, cancellationToken As CancellationToken) As AbstractIndenter - Return New Indenter(document, syntaxTree, formattingRules, optionSet, lineToBeIndented, cancellationToken) + Return New Indenter(document, formattingRules, optionSet, lineToBeIndented, cancellationToken) End Function Public Overloads Shared Function ShouldUseSmartTokenFormatterInsteadOfIndenter( From 588392e9b35d422ac7303e99aefa0fc113dada8e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 28 May 2019 15:58:04 -0700 Subject: [PATCH 35/43] Docs --- .../AbstractIndentationService.AbstractIndenter.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 428d2b3bd0a8e..7e28ab060300d 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -59,6 +59,12 @@ public AbstractIndenter( tokenStream: null); } + /// + /// Returns if the language specific should be deferred to figure out indentatation. If + /// so, it will be asked to the + /// resultant provided by this method. + /// protected abstract bool ShouldUseTokenIndenter(out SyntaxToken token); protected abstract ISmartTokenFormatter CreateSmartTokenFormatter(); From 60791294ff7096f10845b35a4ea9b32ebf463c52 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 28 May 2019 16:22:41 -0700 Subject: [PATCH 36/43] Do not try to handle indentation if we can't compute an offset. --- ...ractIndentationService.AbstractIndenter.cs | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs index 7e28ab060300d..d653673cac95c 100644 --- a/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs +++ b/src/Workspaces/Core/Portable/Indentation/AbstractIndentationService.AbstractIndenter.cs @@ -121,33 +121,32 @@ public IndentationResult GetDesiredIndentation(FormattingOptions.IndentStyle ind public bool TryGetSmartTokenIndentation(out IndentationResult indentationResult) { - indentationResult = default; - if (!ShouldUseTokenIndenter(out var token)) + if (ShouldUseTokenIndenter(out var token)) { - return false; - } - - // var root = document.GetSyntaxRootSynchronously(cancellationToken); - var sourceText = Tree.GetText(CancellationToken); + // var root = document.GetSyntaxRootSynchronously(cancellationToken); + var sourceText = Tree.GetText(CancellationToken); - var formatter = CreateSmartTokenFormatter(); - var changes = formatter.FormatTokenAsync(Document.Project.Solution.Workspace, token, CancellationToken) - .WaitAndGetResult(CancellationToken); + var formatter = CreateSmartTokenFormatter(); + var changes = formatter.FormatTokenAsync(Document.Project.Solution.Workspace, token, CancellationToken) + .WaitAndGetResult(CancellationToken); - var updatedSourceText = sourceText.WithChanges(changes); - if (LineToBeIndented.LineNumber < updatedSourceText.Lines.Count) - { - var updatedLine = updatedSourceText.Lines[LineToBeIndented.LineNumber]; - var offset = updatedLine.GetFirstNonWhitespaceOffset(); - if (offset != null) + var updatedSourceText = sourceText.WithChanges(changes); + if (LineToBeIndented.LineNumber < updatedSourceText.Lines.Count) { - indentationResult = new IndentationResult( - basePosition: LineToBeIndented.Start, - offset: offset.Value); + var updatedLine = updatedSourceText.Lines[LineToBeIndented.LineNumber]; + var offset = updatedLine.GetFirstNonWhitespaceOffset(); + if (offset != null) + { + indentationResult = new IndentationResult( + basePosition: LineToBeIndented.Start, + offset: offset.Value); + return true; + } } } - return true; + indentationResult = default; + return false; } protected IndentationResult IndentFromStartOfLine(int addedSpaces) From f11ad89b93c1da9b3e7b4dd080d57a1bf3d01bae Mon Sep 17 00:00:00 2001 From: gnovack Date: Sat, 15 Jun 2019 10:19:56 -0400 Subject: [PATCH 37/43] MakeLocalFunctionStatic - preserve original trivia --- .../MakeLocalFunctionStaticTests.cs | 35 +++++++++++++++++++ .../MakeLocalFunctionStaticCodeFixProvider.cs | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs index db39584a931b7..15ebcd8a09b09 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs @@ -176,6 +176,41 @@ static async Task fibonacci(int n) } } }", +parseOptions: CSharp8ParseOptions); + } + + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + public async Task TestSurroundingTrivia() + { + await TestInRegularAndScriptAsync( +@"using System; + +class C +{ + void M() + { + + int [||]fibonacci(int n) + { + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + } + + } +}", +@"using System; + +class C +{ + void M() + { + + static int fibonacci(int n) + { + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + } + + } +}", parseOptions: CSharp8ParseOptions); } } diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs index 46c86cb91d064..2744c665af147 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs @@ -44,7 +44,7 @@ protected override Task FixAllAsync( localFunction, (current, generator) => generator.WithModifiers( current, - generator.GetModifiers(current).WithIsStatic(true))); + generator.GetModifiers(current).WithIsStatic(true)).WithTriviaFrom(localFunction)); } return Task.CompletedTask; From 9760868c28eba500f5e44c07e44ec63e2254d2aa Mon Sep 17 00:00:00 2001 From: gnovack Date: Tue, 18 Jun 2019 23:10:15 -0400 Subject: [PATCH 38/43] Removed previous changes to code fix provider; added a case for local functions following a semicolon in ElasticTriviaFormattingRule --- .../MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs | 6 +++--- .../MakeLocalFunctionStaticCodeFixProvider.cs | 2 +- .../Formatting/Rules/ElasticTriviaFormattingRule.cs | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs index 15ebcd8a09b09..7d58cb805ddde 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs @@ -180,7 +180,7 @@ static async Task fibonacci(int n) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] - public async Task TestSurroundingTrivia() + public async Task TestLeadingTriviaAfterSemicolon() { await TestInRegularAndScriptAsync( @"using System; @@ -189,12 +189,12 @@ class C { void M() { + int x; int [||]fibonacci(int n) { return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); } - } }", @"using System; @@ -203,12 +203,12 @@ class C { void M() { + int x; static int fibonacci(int n) { return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); } - } }", parseOptions: CSharp8ParseOptions); diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs index 2744c665af147..46c86cb91d064 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs @@ -44,7 +44,7 @@ protected override Task FixAllAsync( localFunction, (current, generator) => generator.WithModifiers( current, - generator.GetModifiers(current).WithIsStatic(true)).WithTriviaFrom(localFunction)); + generator.GetModifiers(current).WithIsStatic(true))); } return Task.CompletedTask; diff --git a/src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs b/src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs index be91f8265dfb0..13d9af649e547 100644 --- a/src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs +++ b/src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs @@ -424,6 +424,10 @@ private static int LineBreaksAfterSemicolon(SyntaxToken previousToken, SyntaxTok { return currentToken.Parent is ExternAliasDirectiveSyntax ? 1 : 2; } + else if (currentToken.Parent is LocalFunctionStatementSyntax) + { + return 2; + } else { return 1; From 39372a29df5b2a1ef1da836798ed5039e413c228 Mon Sep 17 00:00:00 2001 From: gnovack Date: Fri, 21 Jun 2019 21:00:52 -0400 Subject: [PATCH 39/43] Added additional test cases for Make Local Function Static --- .../MakeLocalFunctionStaticTests.cs | 152 +++++++++++++++++- 1 file changed, 149 insertions(+), 3 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs index 7d58cb805ddde..bb99ff2011db0 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs @@ -179,10 +179,26 @@ static async Task fibonacci(int n) parseOptions: CSharp8ParseOptions); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] - public async Task TestLeadingTriviaAfterSemicolon() + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("")] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaAfterSemicolon(string leadingTrivia) { await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{ + int x;{leadingTrivia} + int [||]fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", @"using System; class C @@ -191,19 +207,82 @@ void M() { int x; + static int fibonacci(int n) + { + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + } + } +}", +parseOptions: CSharp8ParseOptions); + } + + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("")] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaAfterOpenBrace(string leadingTrivia) + { + await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{{leadingTrivia} int [||]fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", +@"using System; + +class C +{ + void M() + { + static int fibonacci(int n) { return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); } } }", +parseOptions: CSharp8ParseOptions); + } + + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("")] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaAfterLocalFunction(string leadingTrivia) + { + await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{ + bool otherFunction() + {{ + return true; + }}{leadingTrivia} + int [||]fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", @"using System; class C { void M() { - int x; + bool otherFunction() + { + return true; + } static int fibonacci(int n) { @@ -211,6 +290,73 @@ static int fibonacci(int n) } } }", +parseOptions: CSharp8ParseOptions); + } + + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("")] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaAfterExpressionBodyLocalFunction(string leadingTrivia) + { + await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{ + bool otherFunction() => true;{leadingTrivia} + int [||]fibonacci(int n) => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} +}}", +@"using System; + +class C +{ + void M() + { + bool otherFunction() => true; + + static int fibonacci(int n) => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + } +}", +parseOptions: CSharp8ParseOptions); + } + + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("")] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaAfterComment(string leadingTrivia) + { + await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{ + //Local function comment{leadingTrivia} + int [||]fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", +$@"using System; + +class C +{{ + void M() + {{ + //Local function comment{leadingTrivia} + static int fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", parseOptions: CSharp8ParseOptions); } } From 79938ace82aa1518cfdce48501a21847dae3f3a3 Mon Sep 17 00:00:00 2001 From: gnovack Date: Mon, 24 Jun 2019 21:18:39 -0400 Subject: [PATCH 40/43] Added tests with blank space preceding comment --- .../MakeLocalFunctionStaticTests.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs index bb99ff2011db0..736c642d60ab0 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs @@ -357,6 +357,41 @@ static int fibonacci(int n) }} }} }}", +parseOptions: CSharp8ParseOptions); + } + + [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + [InlineData("\r\n")] + [InlineData("\r\n\r\n")] + public async Task TestLeadingTriviaBeforeComment(string leadingTrivia) + { + await TestInRegularAndScriptAsync( +$@"using System; + +class C +{{ + void M() + {{{leadingTrivia} + //Local function comment + int [||]fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", +$@"using System; + +class C +{{ + void M() + {{{leadingTrivia} + //Local function comment + static int fibonacci(int n) + {{ + return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); + }} + }} +}}", parseOptions: CSharp8ParseOptions); } } From c30fd2bb1751379e91d20a45aa70bc024f83740e Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Mon, 1 Jul 2019 15:18:13 -0700 Subject: [PATCH 41/43] Revert "Fix couple of false positives in unused parameter analyzer" (#36905) --- .../RemoveUnusedParametersTests.cs | 13 ---------- .../RemoveUnusedParametersTests.vb | 16 ------------- ...sDiagnosticAnalyzer.SymbolStartAnalyzer.cs | 24 ------------------- 3 files changed, 53 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs b/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs index 9fde37be0e66c..e93b30830c870 100644 --- a/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs +++ b/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs @@ -1305,18 +1305,5 @@ private void fooed() { } public void Dispose() => foo.Result.Fooed -= fooed; }", options); } - - [WorkItem(36817, "https://github.com/dotnet/roslyn/issues/36817")] - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedParameters)] - public async Task ParameterWithoutName_NoDiagnostic() - { - await TestDiagnosticMissingAsync( -@"public class C -{ - public void M[|(int )|] - { - } -}"); - } } } diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb b/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb index 24e366a0c7c8f..4605032331b8f 100644 --- a/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb @@ -95,22 +95,6 @@ End Class") $"Class C [|Sub M(_0 As Integer, _1 As Char, _3 As C)|] End Sub -End Class") - End Function - - - - Public Async Function PartialMethodParameter_NoDiagnostic() As Task - Await TestDiagnosticMissingAsync( -$"Class C - [|Partial Private Sub M(str As String)|] - End Sub -End Class - -Partial Class C - Private Sub M(str As String) - Dim x = str.ToString() - End Sub End Class") End Function End Class diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs index 072dbf0cf3e33..a18c8e84c6e5d 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs @@ -57,12 +57,6 @@ public static void CreateAndRegisterActions( var deserializationConstructorCheck = new DeserializationConstructorCheck(context.Compilation); context.RegisterSymbolStartAction(symbolStartContext => { - if (HasSyntaxErrors((INamedTypeSymbol)symbolStartContext.Symbol, symbolStartContext.CancellationToken)) - { - // Bail out on syntax errors. - return; - } - // Create a new SymbolStartAnalyzer instance for every named type symbol // to ensure there is no shared state (such as identified unused parameters within the type), // as that would lead to duplicate diagnostics being reported from symbol end action callbacks @@ -70,23 +64,6 @@ public static void CreateAndRegisterActions( var symbolAnalyzer = new SymbolStartAnalyzer(analyzer, eventsArgType, attributeSetForMethodsToIgnore, deserializationConstructorCheck); symbolAnalyzer.OnSymbolStart(symbolStartContext); }, SymbolKind.NamedType); - - return; - - // Local functions - static bool HasSyntaxErrors(INamedTypeSymbol namedTypeSymbol, CancellationToken cancellationToken) - { - foreach (var syntaxRef in namedTypeSymbol.DeclaringSyntaxReferences) - { - var syntax = syntaxRef.GetSyntax(cancellationToken); - if (syntax.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error)) - { - return true; - } - } - - return false; - } } private void OnSymbolStart(SymbolStartAnalysisContext context) @@ -213,7 +190,6 @@ private bool IsUnusedParameterCandidate(IParameterSymbol parameter) method.IsAbstract || method.IsVirtual || method.IsOverride || - method.PartialImplementationPart != null || !method.ExplicitOrImplicitInterfaceImplementations().IsEmpty || method.IsAccessor() || method.IsAnonymousFunction() || From 3699c84810132f473a19d5690a7671c236fcc71a Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Mon, 1 Jul 2019 17:03:30 -0700 Subject: [PATCH 42/43] Bring back "Fix couple of false positives in unused parameter analyzer (#36905)" This reverts commit c30fd2bb1751379e91d20a45aa70bc024f83740e. --- .../RemoveUnusedParametersTests.cs | 13 ++++++++++ .../RemoveUnusedParametersTests.vb | 16 +++++++++++++ ...sDiagnosticAnalyzer.SymbolStartAnalyzer.cs | 24 +++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs b/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs index e93b30830c870..9fde37be0e66c 100644 --- a/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs +++ b/src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.cs @@ -1305,5 +1305,18 @@ private void fooed() { } public void Dispose() => foo.Result.Fooed -= fooed; }", options); } + + [WorkItem(36817, "https://github.com/dotnet/roslyn/issues/36817")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedParameters)] + public async Task ParameterWithoutName_NoDiagnostic() + { + await TestDiagnosticMissingAsync( +@"public class C +{ + public void M[|(int )|] + { + } +}"); + } } } diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb b/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb index 4605032331b8f..24e366a0c7c8f 100644 --- a/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/RemoveUnusedParametersAndValues/RemoveUnusedParametersTests.vb @@ -95,6 +95,22 @@ End Class") $"Class C [|Sub M(_0 As Integer, _1 As Char, _3 As C)|] End Sub +End Class") + End Function + + + + Public Async Function PartialMethodParameter_NoDiagnostic() As Task + Await TestDiagnosticMissingAsync( +$"Class C + [|Partial Private Sub M(str As String)|] + End Sub +End Class + +Partial Class C + Private Sub M(str As String) + Dim x = str.ToString() + End Sub End Class") End Function End Class diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs index a18c8e84c6e5d..072dbf0cf3e33 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs @@ -57,6 +57,12 @@ public static void CreateAndRegisterActions( var deserializationConstructorCheck = new DeserializationConstructorCheck(context.Compilation); context.RegisterSymbolStartAction(symbolStartContext => { + if (HasSyntaxErrors((INamedTypeSymbol)symbolStartContext.Symbol, symbolStartContext.CancellationToken)) + { + // Bail out on syntax errors. + return; + } + // Create a new SymbolStartAnalyzer instance for every named type symbol // to ensure there is no shared state (such as identified unused parameters within the type), // as that would lead to duplicate diagnostics being reported from symbol end action callbacks @@ -64,6 +70,23 @@ public static void CreateAndRegisterActions( var symbolAnalyzer = new SymbolStartAnalyzer(analyzer, eventsArgType, attributeSetForMethodsToIgnore, deserializationConstructorCheck); symbolAnalyzer.OnSymbolStart(symbolStartContext); }, SymbolKind.NamedType); + + return; + + // Local functions + static bool HasSyntaxErrors(INamedTypeSymbol namedTypeSymbol, CancellationToken cancellationToken) + { + foreach (var syntaxRef in namedTypeSymbol.DeclaringSyntaxReferences) + { + var syntax = syntaxRef.GetSyntax(cancellationToken); + if (syntax.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error)) + { + return true; + } + } + + return false; + } } private void OnSymbolStart(SymbolStartAnalysisContext context) @@ -190,6 +213,7 @@ private bool IsUnusedParameterCandidate(IParameterSymbol parameter) method.IsAbstract || method.IsVirtual || method.IsOverride || + method.PartialImplementationPart != null || !method.ExplicitOrImplicitInterfaceImplementations().IsEmpty || method.IsAccessor() || method.IsAnonymousFunction() || From 939a21344060a950d968e3be3f52413dd96ac895 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 1 Jul 2019 18:39:03 -0700 Subject: [PATCH 43/43] Enable nullable for BoundNodes (#36896) --- .../CSharp/Portable/BoundTree/BoundNodes.xml | 235 +- .../Generated/BoundNodes.xml.Generated.cs | 4129 +++++++++-------- .../BoundNodeClassWriter.cs | 139 +- 3 files changed, 2353 insertions(+), 2150 deletions(-) diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml index 2a2046cea7ff4..7229b0856c69f 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml +++ b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml @@ -73,7 +73,7 @@ - + @@ -162,7 +162,7 @@ - + - + - + - + @@ -338,16 +338,16 @@ - + - - - + + + @@ -359,8 +359,8 @@ - - + + @@ -483,7 +483,7 @@ - + @@ -521,7 +521,7 @@ - + @@ -577,7 +577,7 @@ - + @@ -585,14 +585,14 @@ - + - - - + + + @@ -617,7 +617,7 @@ - + @@ -630,7 +630,7 @@ - + - + - + @@ -704,7 +704,7 @@ - + @@ -714,7 +714,7 @@ if Statement is null, a NOP may be emitted, to make sure the point is not associated with next statement (which could be a fairly random statement in random scope). --> - + - + @@ -787,8 +787,8 @@ - - + + @@ -808,7 +808,7 @@ - + - - + + @@ -834,7 +834,7 @@ - + @@ -844,7 +844,7 @@ - + @@ -867,7 +867,7 @@ - + @@ -897,13 +897,13 @@ - + - + @@ -926,19 +926,19 @@ - + - - + + - + @@ -948,15 +948,15 @@ - + - - + + @@ -971,12 +971,12 @@ - - + + - - + + @@ -993,14 +993,14 @@ - + - + - + - + - + - + @@ -1082,7 +1082,7 @@ - + @@ -1090,7 +1090,7 @@ - + @@ -1148,8 +1148,8 @@ - - + + - + - + @@ -1237,7 +1237,7 @@ - + @@ -1283,7 +1283,7 @@ - + @@ -1295,7 +1295,7 @@ we want to keep the System.Console type expression as the receiver, even though the spec says that the instance expression is null in this case. We'll add a helper property that gets the instance expression from the receiver should we need it. --> - + @@ -1374,9 +1374,9 @@ - + - + - + @@ -1438,7 +1438,7 @@ - + @@ -1448,7 +1448,7 @@ - + @@ -1456,7 +1456,7 @@ - + @@ -1484,11 +1484,11 @@ - - + + - + @@ -1511,7 +1511,7 @@ Ex: (a:=1, b:= (c:=1, d:=Nothing)) does not have a natural type, because "Nothing" does not have one --> - + @@ -1538,15 +1538,15 @@ - + - - + + @@ -1563,7 +1563,7 @@ - + @@ -1576,7 +1576,7 @@ - + @@ -1598,12 +1598,12 @@ - + - + @@ -1647,7 +1647,7 @@ - + @@ -1666,7 +1666,7 @@ extension method. --> - + @@ -1675,7 +1675,7 @@ - + @@ -1688,7 +1688,7 @@ - + @@ -1700,9 +1700,9 @@ - + - + @@ -1724,7 +1724,7 @@ - + @@ -1733,7 +1733,7 @@ - + @@ -1743,7 +1743,7 @@ - + @@ -1753,7 +1753,7 @@ - + @@ -1770,7 +1770,7 @@ - + @@ -1783,7 +1783,7 @@ - + @@ -1801,7 +1801,7 @@ - + @@ -1829,8 +1829,8 @@ - - + + @@ -1856,7 +1856,7 @@ - + - - + + - - + + - + - + @@ -1896,7 +1896,7 @@ - + @@ -1904,7 +1904,7 @@ - + @@ -1917,7 +1917,7 @@ - + @@ -1933,11 +1933,8 @@ - - - - - + + @@ -1945,13 +1942,13 @@ - + - + diff --git a/src/Compilers/CSharp/Portable/Generated/BoundNodes.xml.Generated.cs b/src/Compilers/CSharp/Portable/Generated/BoundNodes.xml.Generated.cs index b4362a839007b..0d2a44f0acbcb 100644 --- a/src/Compilers/CSharp/Portable/Generated/BoundNodes.xml.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/BoundNodes.xml.Generated.cs @@ -1,4 +1,5 @@ // +#nullable enable using System; using System.Collections; @@ -237,7 +238,7 @@ protected BoundEqualsValue(BoundKind kind, SyntaxNode syntax, ImmutableArray visitor.VisitFieldEqualsValue(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFieldEqualsValue(this); public BoundFieldEqualsValue Update(FieldSymbol field, ImmutableArray locals, BoundExpression value) { @@ -285,9 +286,9 @@ public BoundPropertyEqualsValue(SyntaxNode syntax, PropertySymbol property, Immu : base(BoundKind.PropertyEqualsValue, syntax, locals, value, hasErrors || value.HasErrors()) { - Debug.Assert((object)property != null, "Field 'property' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(property is object, "Field 'property' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Property = property; } @@ -295,7 +296,7 @@ public BoundPropertyEqualsValue(SyntaxNode syntax, PropertySymbol property, Immu public PropertySymbol Property { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyEqualsValue(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyEqualsValue(this); public BoundPropertyEqualsValue Update(PropertySymbol property, ImmutableArray locals, BoundExpression value) { @@ -315,9 +316,9 @@ public BoundParameterEqualsValue(SyntaxNode syntax, ParameterSymbol parameter, I : base(BoundKind.ParameterEqualsValue, syntax, locals, value, hasErrors || value.HasErrors()) { - Debug.Assert((object)parameter != null, "Field 'parameter' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(parameter is object, "Field 'parameter' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Parameter = parameter; } @@ -325,7 +326,7 @@ public BoundParameterEqualsValue(SyntaxNode syntax, ParameterSymbol parameter, I public ParameterSymbol Parameter { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitParameterEqualsValue(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitParameterEqualsValue(this); public BoundParameterEqualsValue Update(ParameterSymbol parameter, ImmutableArray locals, BoundExpression value) { @@ -345,7 +346,7 @@ public BoundGlobalStatementInitializer(SyntaxNode syntax, BoundStatement stateme : base(BoundKind.GlobalStatementInitializer, syntax, hasErrors || statement.HasErrors()) { - Debug.Assert((object)statement != null, "Field 'statement' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(statement is object, "Field 'statement' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Statement = statement; } @@ -353,7 +354,7 @@ public BoundGlobalStatementInitializer(SyntaxNode syntax, BoundStatement stateme public BoundStatement Statement { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitGlobalStatementInitializer(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitGlobalStatementInitializer(this); public BoundGlobalStatementInitializer Update(BoundStatement statement) { @@ -369,20 +370,20 @@ public BoundGlobalStatementInitializer Update(BoundStatement statement) internal abstract partial class BoundExpression : BoundNode { - protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol type, bool hasErrors) + protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol? type, bool hasErrors) : base(kind, syntax, hasErrors) { this.Type = type; } - protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol type) + protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol? type) : base(kind, syntax) { this.Type = type; } - public TypeSymbol Type { get; } + public TypeSymbol? Type { get; } } internal abstract partial class BoundValuePlaceholderBase : BoundExpression @@ -391,7 +392,7 @@ protected BoundValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbo : base(kind, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -399,10 +400,12 @@ protected BoundValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbo : base(kind, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; } internal sealed partial class BoundDeconstructValuePlaceholder : BoundValuePlaceholderBase @@ -411,7 +414,7 @@ public BoundDeconstructValuePlaceholder(SyntaxNode syntax, uint valEscape, TypeS : base(BoundKind.DeconstructValuePlaceholder, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ValEscape = valEscape; } @@ -420,7 +423,7 @@ public BoundDeconstructValuePlaceholder(SyntaxNode syntax, uint valEscape, TypeS : base(BoundKind.DeconstructValuePlaceholder, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ValEscape = valEscape; } @@ -428,7 +431,7 @@ public BoundDeconstructValuePlaceholder(SyntaxNode syntax, uint valEscape, TypeS public uint ValEscape { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructValuePlaceholder(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructValuePlaceholder(this); public BoundDeconstructValuePlaceholder Update(uint valEscape, TypeSymbol type) { @@ -455,7 +458,7 @@ public BoundTupleOperandPlaceholder(SyntaxNode syntax, TypeSymbol type, bool has : base(BoundKind.TupleOperandPlaceholder, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -463,12 +466,14 @@ public BoundTupleOperandPlaceholder(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.TupleOperandPlaceholder, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTupleOperandPlaceholder(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTupleOperandPlaceholder(this); public BoundTupleOperandPlaceholder Update(TypeSymbol type) { @@ -495,7 +500,7 @@ public BoundAwaitableValuePlaceholder(SyntaxNode syntax, TypeSymbol type, bool h : base(BoundKind.AwaitableValuePlaceholder, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -503,12 +508,12 @@ public BoundAwaitableValuePlaceholder(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.AwaitableValuePlaceholder, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAwaitableValuePlaceholder(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAwaitableValuePlaceholder(this); public BoundAwaitableValuePlaceholder Update(TypeSymbol type) { @@ -535,7 +540,7 @@ public BoundDisposableValuePlaceholder(SyntaxNode syntax, TypeSymbol type, bool : base(BoundKind.DisposableValuePlaceholder, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -543,12 +548,12 @@ public BoundDisposableValuePlaceholder(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.DisposableValuePlaceholder, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDisposableValuePlaceholder(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDisposableValuePlaceholder(this); public BoundDisposableValuePlaceholder Update(TypeSymbol type) { @@ -571,13 +576,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundDup : BoundExpression { - public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol type, bool hasErrors) + public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol? type, bool hasErrors) : base(BoundKind.Dup, syntax, type, hasErrors) { this.RefKind = refKind; } - public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol type) + public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol? type) : base(BoundKind.Dup, syntax, type) { this.RefKind = refKind; @@ -586,9 +591,9 @@ public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol type) public RefKind RefKind { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDup(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDup(this); - public BoundDup Update(RefKind refKind, TypeSymbol type) + public BoundDup Update(RefKind refKind, TypeSymbol? type) { if (refKind != this.RefKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -609,11 +614,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundPassByCopy : BoundExpression { - public BoundPassByCopy(SyntaxNode syntax, BoundExpression expression, TypeSymbol type, bool hasErrors = false) + public BoundPassByCopy(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.PassByCopy, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } @@ -621,9 +626,9 @@ public BoundPassByCopy(SyntaxNode syntax, BoundExpression expression, TypeSymbol public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPassByCopy(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPassByCopy(this); - public BoundPassByCopy Update(BoundExpression expression, TypeSymbol type) + public BoundPassByCopy Update(BoundExpression expression, TypeSymbol? type) { if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -644,7 +649,7 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundBadExpression : BoundExpression { - public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray symbols, ImmutableArray childBoundNodes, TypeSymbol type, bool hasErrors = false) + public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray symbols, ImmutableArray childBoundNodes, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.BadExpression, syntax, type, hasErrors || childBoundNodes.HasErrors()) { @@ -664,9 +669,9 @@ public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, Immuta public ImmutableArray ChildBoundNodes { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBadExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBadExpression(this); - public BoundBadExpression Update(LookupResultKind resultKind, ImmutableArray symbols, ImmutableArray childBoundNodes, TypeSymbol type) + public BoundBadExpression Update(LookupResultKind resultKind, ImmutableArray symbols, ImmutableArray childBoundNodes, TypeSymbol? type) { if (resultKind != this.ResultKind || symbols != this.Symbols || childBoundNodes != this.ChildBoundNodes || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -699,7 +704,7 @@ public BoundBadStatement(SyntaxNode syntax, ImmutableArray childBound public ImmutableArray ChildBoundNodes { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBadStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBadStatement(this); public BoundBadStatement Update(ImmutableArray childBoundNodes) { @@ -719,7 +724,7 @@ public BoundExtractedFinallyBlock(SyntaxNode syntax, BoundBlock finallyBlock, bo : base(BoundKind.ExtractedFinallyBlock, syntax, hasErrors || finallyBlock.HasErrors()) { - Debug.Assert((object)finallyBlock != null, "Field 'finallyBlock' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(finallyBlock is object, "Field 'finallyBlock' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.FinallyBlock = finallyBlock; } @@ -727,7 +732,7 @@ public BoundExtractedFinallyBlock(SyntaxNode syntax, BoundBlock finallyBlock, bo public BoundBlock FinallyBlock { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitExtractedFinallyBlock(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitExtractedFinallyBlock(this); public BoundExtractedFinallyBlock Update(BoundBlock finallyBlock) { @@ -743,7 +748,7 @@ public BoundExtractedFinallyBlock Update(BoundBlock finallyBlock) internal sealed partial class BoundTypeExpression : BoundExpression { - public BoundTypeExpression(SyntaxNode syntax, AliasSymbol aliasOpt, BoundTypeExpression boundContainingTypeOpt, ImmutableArray boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type, bool hasErrors = false) + public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.TypeExpression, syntax, type, hasErrors || boundContainingTypeOpt.HasErrors() || boundDimensionsOpt.HasErrors()) { this.AliasOpt = aliasOpt; @@ -753,17 +758,17 @@ public BoundTypeExpression(SyntaxNode syntax, AliasSymbol aliasOpt, BoundTypeExp } - public AliasSymbol AliasOpt { get; } + public AliasSymbol? AliasOpt { get; } - public BoundTypeExpression BoundContainingTypeOpt { get; } + public BoundTypeExpression? BoundContainingTypeOpt { get; } public ImmutableArray BoundDimensionsOpt { get; } public TypeWithAnnotations TypeWithAnnotations { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTypeExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTypeExpression(this); - public BoundTypeExpression Update(AliasSymbol aliasOpt, BoundTypeExpression boundContainingTypeOpt, ImmutableArray boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type) + public BoundTypeExpression Update(AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol? type) { if (aliasOpt != this.AliasOpt || boundContainingTypeOpt != this.BoundContainingTypeOpt || boundDimensionsOpt != this.BoundDimensionsOpt || typeWithAnnotations != this.TypeWithAnnotations || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -788,7 +793,7 @@ public BoundTypeOrValueExpression(SyntaxNode syntax, BoundTypeOrValueData data, : base(BoundKind.TypeOrValueExpression, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Data = data; } @@ -797,15 +802,17 @@ public BoundTypeOrValueExpression(SyntaxNode syntax, BoundTypeOrValueData data, : base(BoundKind.TypeOrValueExpression, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Data = data; } + public new TypeSymbol Type => base.Type!; + public BoundTypeOrValueData Data { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTypeOrValueExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTypeOrValueExpression(this); public BoundTypeOrValueExpression Update(BoundTypeOrValueData data, TypeSymbol type) { @@ -828,34 +835,36 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundNamespaceExpression : BoundExpression { - public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol aliasOpt, bool hasErrors) + public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol? aliasOpt, bool hasErrors) : base(BoundKind.NamespaceExpression, syntax, null, hasErrors) { - Debug.Assert((object)namespaceSymbol != null, "Field 'namespaceSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(namespaceSymbol is object, "Field 'namespaceSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.NamespaceSymbol = namespaceSymbol; this.AliasOpt = aliasOpt; } - public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol aliasOpt) + public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol? aliasOpt) : base(BoundKind.NamespaceExpression, syntax, null) { - Debug.Assert((object)namespaceSymbol != null, "Field 'namespaceSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(namespaceSymbol is object, "Field 'namespaceSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.NamespaceSymbol = namespaceSymbol; this.AliasOpt = aliasOpt; } + public new TypeSymbol Type => base.Type!; + public NamespaceSymbol NamespaceSymbol { get; } - public AliasSymbol AliasOpt { get; } + public AliasSymbol? AliasOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNamespaceExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNamespaceExpression(this); - public BoundNamespaceExpression Update(NamespaceSymbol namespaceSymbol, AliasSymbol aliasOpt) + public BoundNamespaceExpression Update(NamespaceSymbol namespaceSymbol, AliasSymbol? aliasOpt) { if (namespaceSymbol != this.NamespaceSymbol || aliasOpt != this.AliasOpt) { @@ -876,12 +885,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundUnaryOperator : BoundExpression { - public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue constantValueOpt, MethodSymbol methodOpt, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) + public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.UnaryOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.OperatorKind = operatorKind; this.Operand = operand; @@ -891,20 +900,22 @@ public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, Bou } + public new TypeSymbol Type => base.Type!; + public UnaryOperatorKind OperatorKind { get; } public BoundExpression Operand { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } - public MethodSymbol MethodOpt { get; } + public MethodSymbol? MethodOpt { get; } private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitUnaryOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitUnaryOperator(this); - public BoundUnaryOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue constantValueOpt, MethodSymbol methodOpt, LookupResultKind resultKind, TypeSymbol type) + public BoundUnaryOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, LookupResultKind resultKind, TypeSymbol type) { if (operatorKind != this.OperatorKind || operand != this.Operand || constantValueOpt != this.ConstantValueOpt || methodOpt != this.MethodOpt || resultKind != this.ResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -925,12 +936,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundIncrementOperator : BoundExpression { - public BoundIncrementOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, MethodSymbol methodOpt, Conversion operandConversion, Conversion resultConversion, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) + public BoundIncrementOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, MethodSymbol? methodOpt, Conversion operandConversion, Conversion resultConversion, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.IncrementOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.OperatorKind = operatorKind; this.Operand = operand; @@ -941,11 +952,13 @@ public BoundIncrementOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, } + public new TypeSymbol Type => base.Type!; + public UnaryOperatorKind OperatorKind { get; } public BoundExpression Operand { get; } - public MethodSymbol MethodOpt { get; } + public MethodSymbol? MethodOpt { get; } public Conversion OperandConversion { get; } @@ -954,9 +967,9 @@ public BoundIncrementOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIncrementOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIncrementOperator(this); - public BoundIncrementOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, MethodSymbol methodOpt, Conversion operandConversion, Conversion resultConversion, LookupResultKind resultKind, TypeSymbol type) + public BoundIncrementOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, MethodSymbol? methodOpt, Conversion operandConversion, Conversion resultConversion, LookupResultKind resultKind, TypeSymbol type) { if (operatorKind != this.OperatorKind || operand != this.Operand || methodOpt != this.MethodOpt || operandConversion != this.OperandConversion || resultConversion != this.ResultConversion || resultKind != this.ResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -981,19 +994,21 @@ public BoundAddressOfOperator(SyntaxNode syntax, BoundExpression operand, bool i : base(BoundKind.AddressOfOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.IsManaged = isManaged; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } public bool IsManaged { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAddressOfOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAddressOfOperator(this); public BoundAddressOfOperator Update(BoundExpression operand, bool isManaged, TypeSymbol type) { @@ -1020,16 +1035,18 @@ public BoundPointerIndirectionOperator(SyntaxNode syntax, BoundExpression operan : base(BoundKind.PointerIndirectionOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPointerIndirectionOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPointerIndirectionOperator(this); public BoundPointerIndirectionOperator Update(BoundExpression operand, TypeSymbol type) { @@ -1056,9 +1073,9 @@ public BoundPointerElementAccess(SyntaxNode syntax, BoundExpression expression, : base(BoundKind.PointerElementAccess, syntax, type, hasErrors || expression.HasErrors() || index.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)index != null, "Field 'index' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(index is object, "Field 'index' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.Index = index; @@ -1066,13 +1083,15 @@ public BoundPointerElementAccess(SyntaxNode syntax, BoundExpression expression, } + public new TypeSymbol Type => base.Type!; + public BoundExpression Expression { get; } public BoundExpression Index { get; } public bool Checked { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPointerElementAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPointerElementAccess(this); public BoundPointerElementAccess Update(BoundExpression expression, BoundExpression index, bool @checked, TypeSymbol type) { @@ -1095,25 +1114,27 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundRefTypeOperator : BoundExpression { - public BoundRefTypeOperator(SyntaxNode syntax, BoundExpression operand, MethodSymbol getTypeFromHandle, TypeSymbol type, bool hasErrors = false) + public BoundRefTypeOperator(SyntaxNode syntax, BoundExpression operand, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors = false) : base(BoundKind.RefTypeOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.GetTypeFromHandle = getTypeFromHandle; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } - public MethodSymbol GetTypeFromHandle { get; } + public MethodSymbol? GetTypeFromHandle { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitRefTypeOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitRefTypeOperator(this); - public BoundRefTypeOperator Update(BoundExpression operand, MethodSymbol getTypeFromHandle, TypeSymbol type) + public BoundRefTypeOperator Update(BoundExpression operand, MethodSymbol? getTypeFromHandle, TypeSymbol type) { if (operand != this.Operand || getTypeFromHandle != this.GetTypeFromHandle || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1138,16 +1159,18 @@ public BoundMakeRefOperator(SyntaxNode syntax, BoundExpression operand, TypeSymb : base(BoundKind.MakeRefOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMakeRefOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMakeRefOperator(this); public BoundMakeRefOperator Update(BoundExpression operand, TypeSymbol type) { @@ -1174,19 +1197,21 @@ public BoundRefValueOperator(SyntaxNode syntax, NullableAnnotation nullableAnnot : base(BoundKind.RefValueOperator, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.NullableAnnotation = nullableAnnotation; this.Operand = operand; } + public new TypeSymbol Type => base.Type!; + public NullableAnnotation NullableAnnotation { get; } public BoundExpression Operand { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitRefValueOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitRefValueOperator(this); public BoundRefValueOperator Update(NullableAnnotation nullableAnnotation, BoundExpression operand, TypeSymbol type) { @@ -1209,25 +1234,27 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundFromEndIndexExpression : BoundExpression { - public BoundFromEndIndexExpression(SyntaxNode syntax, BoundExpression operand, MethodSymbol methodOpt, TypeSymbol type, bool hasErrors = false) + public BoundFromEndIndexExpression(SyntaxNode syntax, BoundExpression operand, MethodSymbol? methodOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.FromEndIndexExpression, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.MethodOpt = methodOpt; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } - public MethodSymbol MethodOpt { get; } + public MethodSymbol? MethodOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitFromEndIndexExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFromEndIndexExpression(this); - public BoundFromEndIndexExpression Update(BoundExpression operand, MethodSymbol methodOpt, TypeSymbol type) + public BoundFromEndIndexExpression Update(BoundExpression operand, MethodSymbol? methodOpt, TypeSymbol type) { if (operand != this.Operand || methodOpt != this.MethodOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1248,11 +1275,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundRangeExpression : BoundExpression { - public BoundRangeExpression(SyntaxNode syntax, BoundExpression leftOperandOpt, BoundExpression rightOperandOpt, MethodSymbol methodOpt, TypeSymbol type, bool hasErrors = false) + public BoundRangeExpression(SyntaxNode syntax, BoundExpression? leftOperandOpt, BoundExpression? rightOperandOpt, MethodSymbol? methodOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.RangeExpression, syntax, type, hasErrors || leftOperandOpt.HasErrors() || rightOperandOpt.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LeftOperandOpt = leftOperandOpt; this.RightOperandOpt = rightOperandOpt; @@ -1260,15 +1287,17 @@ public BoundRangeExpression(SyntaxNode syntax, BoundExpression leftOperandOpt, B } - public BoundExpression LeftOperandOpt { get; } + public new TypeSymbol Type => base.Type!; - public BoundExpression RightOperandOpt { get; } + public BoundExpression? LeftOperandOpt { get; } - public MethodSymbol MethodOpt { get; } + public BoundExpression? RightOperandOpt { get; } + + public MethodSymbol? MethodOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitRangeExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitRangeExpression(this); - public BoundRangeExpression Update(BoundExpression leftOperandOpt, BoundExpression rightOperandOpt, MethodSymbol methodOpt, TypeSymbol type) + public BoundRangeExpression Update(BoundExpression? leftOperandOpt, BoundExpression? rightOperandOpt, MethodSymbol? methodOpt, TypeSymbol type) { if (leftOperandOpt != this.LeftOperandOpt || rightOperandOpt != this.RightOperandOpt || methodOpt != this.MethodOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1293,15 +1322,17 @@ protected BoundBinaryOperatorBase(BoundKind kind, SyntaxNode syntax, BoundExpres : base(kind, syntax, type, hasErrors) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Left = left; this.Right = right; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Left { get; } public BoundExpression Right { get; } @@ -1309,13 +1340,13 @@ protected BoundBinaryOperatorBase(BoundKind kind, SyntaxNode syntax, BoundExpres internal sealed partial class BoundBinaryOperator : BoundBinaryOperatorBase { - public BoundBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue constantValueOpt, MethodSymbol methodOpt, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false) + public BoundBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false) : base(BoundKind.BinaryOperator, syntax, left, right, type, hasErrors || left.HasErrors() || right.HasErrors()) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.OperatorKind = operatorKind; this.ConstantValueOpt = constantValueOpt; @@ -1326,16 +1357,16 @@ public BoundBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, C public BinaryOperatorKind OperatorKind { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } - public MethodSymbol MethodOpt { get; } + public MethodSymbol? MethodOpt { get; } private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBinaryOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBinaryOperator(this); - public BoundBinaryOperator Update(BinaryOperatorKind operatorKind, ConstantValue constantValueOpt, MethodSymbol methodOpt, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type) + public BoundBinaryOperator Update(BinaryOperatorKind operatorKind, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type) { if (operatorKind != this.OperatorKind || constantValueOpt != this.ConstantValueOpt || methodOpt != this.MethodOpt || resultKind != this.ResultKind || left != this.Left || right != this.Right || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1360,12 +1391,12 @@ public BoundTupleBinaryOperator(SyntaxNode syntax, BoundExpression left, BoundEx : base(BoundKind.TupleBinaryOperator, syntax, type, hasErrors || left.HasErrors() || right.HasErrors() || convertedLeft.HasErrors() || convertedRight.HasErrors()) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)convertedLeft != null, "Field 'convertedLeft' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)convertedRight != null, "Field 'convertedRight' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)operators != null, "Field 'operators' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(convertedLeft is object, "Field 'convertedLeft' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(convertedRight is object, "Field 'convertedRight' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(operators is object, "Field 'operators' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Left = left; this.Right = right; @@ -1376,6 +1407,8 @@ public BoundTupleBinaryOperator(SyntaxNode syntax, BoundExpression left, BoundEx } + public new TypeSymbol Type => base.Type!; + public BoundExpression Left { get; } public BoundExpression Right { get; } @@ -1388,7 +1421,7 @@ public BoundTupleBinaryOperator(SyntaxNode syntax, BoundExpression left, BoundEx public TupleBinaryOperatorInfo.Multiple Operators { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTupleBinaryOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTupleBinaryOperator(this); public BoundTupleBinaryOperator Update(BoundExpression left, BoundExpression right, BoundExpression convertedLeft, BoundExpression convertedRight, BinaryOperatorKind operatorKind, TupleBinaryOperatorInfo.Multiple operators, TypeSymbol type) { @@ -1415,12 +1448,12 @@ public BoundUserDefinedConditionalLogicalOperator(SyntaxNode syntax, BinaryOpera : base(BoundKind.UserDefinedConditionalLogicalOperator, syntax, left, right, type, hasErrors || left.HasErrors() || right.HasErrors()) { - Debug.Assert((object)logicalOperator != null, "Field 'logicalOperator' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)trueOperator != null, "Field 'trueOperator' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)falseOperator != null, "Field 'falseOperator' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(logicalOperator is object, "Field 'logicalOperator' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(trueOperator is object, "Field 'trueOperator' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(falseOperator is object, "Field 'falseOperator' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.OperatorKind = operatorKind; this.LogicalOperator = logicalOperator; @@ -1441,7 +1474,7 @@ public BoundUserDefinedConditionalLogicalOperator(SyntaxNode syntax, BinaryOpera private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitUserDefinedConditionalLogicalOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitUserDefinedConditionalLogicalOperator(this); public BoundUserDefinedConditionalLogicalOperator Update(BinaryOperatorKind operatorKind, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type) { @@ -1468,9 +1501,9 @@ public BoundCompoundAssignmentOperator(SyntaxNode syntax, BinaryOperatorSignatur : base(BoundKind.CompoundAssignmentOperator, syntax, type, hasErrors || left.HasErrors() || right.HasErrors()) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operator = @operator; this.Left = left; @@ -1481,6 +1514,8 @@ public BoundCompoundAssignmentOperator(SyntaxNode syntax, BinaryOperatorSignatur } + public new TypeSymbol Type => base.Type!; + public BinaryOperatorSignature Operator { get; } public BoundExpression Left { get; } @@ -1494,7 +1529,7 @@ public BoundCompoundAssignmentOperator(SyntaxNode syntax, BinaryOperatorSignatur private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitCompoundAssignmentOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitCompoundAssignmentOperator(this); public BoundCompoundAssignmentOperator Update(BinaryOperatorSignature @operator, BoundExpression left, BoundExpression right, Conversion leftConversion, Conversion finalConversion, LookupResultKind resultKind, TypeSymbol type) { @@ -1517,11 +1552,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundAssignmentOperator : BoundExpression { - public BoundAssignmentOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right, bool isRef, TypeSymbol type, bool hasErrors = false) + public BoundAssignmentOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right, bool isRef, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.AssignmentOperator, syntax, type, hasErrors || left.HasErrors() || right.HasErrors()) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Left = left; this.Right = right; @@ -1535,9 +1570,9 @@ public BoundAssignmentOperator(SyntaxNode syntax, BoundExpression left, BoundExp public bool IsRef { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAssignmentOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAssignmentOperator(this); - public BoundAssignmentOperator Update(BoundExpression left, BoundExpression right, bool isRef, TypeSymbol type) + public BoundAssignmentOperator Update(BoundExpression left, BoundExpression right, bool isRef, TypeSymbol? type) { if (left != this.Left || right != this.Right || isRef != this.IsRef || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1562,9 +1597,9 @@ public BoundDeconstructionAssignmentOperator(SyntaxNode syntax, BoundTupleExpres : base(BoundKind.DeconstructionAssignmentOperator, syntax, type, hasErrors || left.HasErrors() || right.HasErrors()) { - Debug.Assert((object)left != null, "Field 'left' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)right != null, "Field 'right' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(left is object, "Field 'left' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(right is object, "Field 'right' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Left = left; this.Right = right; @@ -1572,13 +1607,15 @@ public BoundDeconstructionAssignmentOperator(SyntaxNode syntax, BoundTupleExpres } + public new TypeSymbol Type => base.Type!; + public BoundTupleExpression Left { get; } public BoundConversion Right { get; } public bool IsUsed { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructionAssignmentOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructionAssignmentOperator(this); public BoundDeconstructionAssignmentOperator Update(BoundTupleExpression left, BoundConversion right, bool isUsed, TypeSymbol type) { @@ -1601,12 +1638,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundNullCoalescingOperator : BoundExpression { - public BoundNullCoalescingOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, Conversion leftConversion, BoundNullCoalescingOperatorResultKind operatorResultKind, TypeSymbol type, bool hasErrors = false) + public BoundNullCoalescingOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, Conversion leftConversion, BoundNullCoalescingOperatorResultKind operatorResultKind, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.NullCoalescingOperator, syntax, type, hasErrors || leftOperand.HasErrors() || rightOperand.HasErrors()) { - Debug.Assert((object)leftOperand != null, "Field 'leftOperand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)rightOperand != null, "Field 'rightOperand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(leftOperand is object, "Field 'leftOperand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(rightOperand is object, "Field 'rightOperand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LeftOperand = leftOperand; this.RightOperand = rightOperand; @@ -1623,9 +1660,9 @@ public BoundNullCoalescingOperator(SyntaxNode syntax, BoundExpression leftOperan public BoundNullCoalescingOperatorResultKind OperatorResultKind { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNullCoalescingOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNullCoalescingOperator(this); - public BoundNullCoalescingOperator Update(BoundExpression leftOperand, BoundExpression rightOperand, Conversion leftConversion, BoundNullCoalescingOperatorResultKind operatorResultKind, TypeSymbol type) + public BoundNullCoalescingOperator Update(BoundExpression leftOperand, BoundExpression rightOperand, Conversion leftConversion, BoundNullCoalescingOperatorResultKind operatorResultKind, TypeSymbol? type) { if (leftOperand != this.LeftOperand || rightOperand != this.RightOperand || leftConversion != this.LeftConversion || operatorResultKind != this.OperatorResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1646,12 +1683,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundNullCoalescingAssignmentOperator : BoundExpression { - public BoundNullCoalescingAssignmentOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, TypeSymbol type, bool hasErrors = false) + public BoundNullCoalescingAssignmentOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.NullCoalescingAssignmentOperator, syntax, type, hasErrors || leftOperand.HasErrors() || rightOperand.HasErrors()) { - Debug.Assert((object)leftOperand != null, "Field 'leftOperand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)rightOperand != null, "Field 'rightOperand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(leftOperand is object, "Field 'leftOperand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(rightOperand is object, "Field 'rightOperand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LeftOperand = leftOperand; this.RightOperand = rightOperand; @@ -1662,9 +1699,9 @@ public BoundNullCoalescingAssignmentOperator(SyntaxNode syntax, BoundExpression public BoundExpression RightOperand { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNullCoalescingAssignmentOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNullCoalescingAssignmentOperator(this); - public BoundNullCoalescingAssignmentOperator Update(BoundExpression leftOperand, BoundExpression rightOperand, TypeSymbol type) + public BoundNullCoalescingAssignmentOperator Update(BoundExpression leftOperand, BoundExpression rightOperand, TypeSymbol? type) { if (leftOperand != this.LeftOperand || rightOperand != this.RightOperand || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1685,14 +1722,14 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundConditionalOperator : BoundExpression { - public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false) + public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.ConditionalOperator, syntax, type, hasErrors || condition.HasErrors() || consequence.HasErrors() || alternative.HasErrors()) { - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)consequence != null, "Field 'consequence' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)alternative != null, "Field 'alternative' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(consequence is object, "Field 'consequence' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(alternative is object, "Field 'alternative' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.IsRef = isRef; this.Condition = condition; @@ -1702,6 +1739,8 @@ public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression c } + public new TypeSymbol Type => base.Type!; + public bool IsRef { get; } public BoundExpression Condition { get; } @@ -1710,11 +1749,11 @@ public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression c public BoundExpression Alternative { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalOperator(this); - public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue constantValueOpt, TypeSymbol type) + public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol type) { if (isRef != this.IsRef || condition != this.Condition || consequence != this.Consequence || alternative != this.Alternative || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1739,20 +1778,22 @@ public BoundArrayAccess(SyntaxNode syntax, BoundExpression expression, Immutable : base(BoundKind.ArrayAccess, syntax, type, hasErrors || expression.HasErrors() || indices.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!indices.IsDefault, "Field 'indices' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.Indices = indices; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Expression { get; } public ImmutableArray Indices { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArrayAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArrayAccess(this); public BoundArrayAccess Update(BoundExpression expression, ImmutableArray indices, TypeSymbol type) { @@ -1779,16 +1820,18 @@ public BoundArrayLength(SyntaxNode syntax, BoundExpression expression, TypeSymbo : base(BoundKind.ArrayLength, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArrayLength(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArrayLength(this); public BoundArrayLength Update(BoundExpression expression, TypeSymbol type) { @@ -1815,20 +1858,22 @@ public BoundAwaitExpression(SyntaxNode syntax, BoundExpression expression, Await : base(BoundKind.AwaitExpression, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)awaitableInfo != null, "Field 'awaitableInfo' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(awaitableInfo is object, "Field 'awaitableInfo' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.AwaitableInfo = awaitableInfo; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Expression { get; } public AwaitableInfo AwaitableInfo { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAwaitExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAwaitExpression(this); public BoundAwaitExpression Update(BoundExpression expression, AwaitableInfo awaitableInfo, TypeSymbol type) { @@ -1851,36 +1896,38 @@ protected override BoundExpression ShallowClone() internal abstract partial class BoundTypeOf : BoundExpression { - protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol getTypeFromHandle, TypeSymbol type, bool hasErrors) + protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors) : base(kind, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.GetTypeFromHandle = getTypeFromHandle; } - protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol getTypeFromHandle, TypeSymbol type) + protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol? getTypeFromHandle, TypeSymbol type) : base(kind, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.GetTypeFromHandle = getTypeFromHandle; } - public MethodSymbol GetTypeFromHandle { get; } + public new TypeSymbol Type => base.Type!; + + public MethodSymbol? GetTypeFromHandle { get; } } internal sealed partial class BoundTypeOfOperator : BoundTypeOf { - public BoundTypeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, MethodSymbol getTypeFromHandle, TypeSymbol type, bool hasErrors = false) + public BoundTypeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors = false) : base(BoundKind.TypeOfOperator, syntax, getTypeFromHandle, type, hasErrors || sourceType.HasErrors()) { - Debug.Assert((object)sourceType != null, "Field 'sourceType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(sourceType is object, "Field 'sourceType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.SourceType = sourceType; } @@ -1888,9 +1935,9 @@ public BoundTypeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, Me public BoundTypeExpression SourceType { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTypeOfOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTypeOfOperator(this); - public BoundTypeOfOperator Update(BoundTypeExpression sourceType, MethodSymbol getTypeFromHandle, TypeSymbol type) + public BoundTypeOfOperator Update(BoundTypeExpression sourceType, MethodSymbol? getTypeFromHandle, TypeSymbol type) { if (sourceType != this.SourceType || getTypeFromHandle != this.GetTypeFromHandle || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -1915,8 +1962,8 @@ public BoundMethodDefIndex(SyntaxNode syntax, MethodSymbol method, TypeSymbol ty : base(BoundKind.MethodDefIndex, syntax, type, hasErrors) { - Debug.Assert((object)method != null, "Field 'method' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(method is object, "Field 'method' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Method = method; } @@ -1925,16 +1972,18 @@ public BoundMethodDefIndex(SyntaxNode syntax, MethodSymbol method, TypeSymbol ty : base(BoundKind.MethodDefIndex, syntax, type) { - Debug.Assert((object)method != null, "Field 'method' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(method is object, "Field 'method' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Method = method; } + public new TypeSymbol Type => base.Type!; + public MethodSymbol Method { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMethodDefIndex(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMethodDefIndex(this); public BoundMethodDefIndex Update(MethodSymbol method, TypeSymbol type) { @@ -1961,7 +2010,7 @@ public BoundMaximumMethodDefIndex(SyntaxNode syntax, TypeSymbol type, bool hasEr : base(BoundKind.MaximumMethodDefIndex, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -1969,12 +2018,14 @@ public BoundMaximumMethodDefIndex(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.MaximumMethodDefIndex, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMaximumMethodDefIndex(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMaximumMethodDefIndex(this); public BoundMaximumMethodDefIndex Update(TypeSymbol type) { @@ -2001,7 +2052,7 @@ public BoundInstrumentationPayloadRoot(SyntaxNode syntax, int analysisKind, Type : base(BoundKind.InstrumentationPayloadRoot, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.AnalysisKind = analysisKind; } @@ -2010,15 +2061,17 @@ public BoundInstrumentationPayloadRoot(SyntaxNode syntax, int analysisKind, Type : base(BoundKind.InstrumentationPayloadRoot, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.AnalysisKind = analysisKind; } public int AnalysisKind { get; } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitInstrumentationPayloadRoot(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitInstrumentationPayloadRoot(this); public BoundInstrumentationPayloadRoot Update(int analysisKind, TypeSymbol type) { @@ -2045,7 +2098,7 @@ public BoundModuleVersionId(SyntaxNode syntax, TypeSymbol type, bool hasErrors) : base(BoundKind.ModuleVersionId, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -2053,12 +2106,14 @@ public BoundModuleVersionId(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.ModuleVersionId, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitModuleVersionId(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitModuleVersionId(this); public BoundModuleVersionId Update(TypeSymbol type) { @@ -2085,7 +2140,7 @@ public BoundModuleVersionIdString(SyntaxNode syntax, TypeSymbol type, bool hasEr : base(BoundKind.ModuleVersionIdString, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -2093,12 +2148,14 @@ public BoundModuleVersionIdString(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.ModuleVersionIdString, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitModuleVersionIdString(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitModuleVersionIdString(this); public BoundModuleVersionIdString Update(TypeSymbol type) { @@ -2125,8 +2182,8 @@ public BoundSourceDocumentIndex(SyntaxNode syntax, Cci.DebugSourceDocument docum : base(BoundKind.SourceDocumentIndex, syntax, type, hasErrors) { - Debug.Assert((object)document != null, "Field 'document' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(document is object, "Field 'document' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Document = document; } @@ -2135,16 +2192,18 @@ public BoundSourceDocumentIndex(SyntaxNode syntax, Cci.DebugSourceDocument docum : base(BoundKind.SourceDocumentIndex, syntax, type) { - Debug.Assert((object)document != null, "Field 'document' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(document is object, "Field 'document' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Document = document; } + public new TypeSymbol Type => base.Type!; + public Cci.DebugSourceDocument Document { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSourceDocumentIndex(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSourceDocumentIndex(this); public BoundSourceDocumentIndex Update(Cci.DebugSourceDocument document, TypeSymbol type) { @@ -2167,36 +2226,38 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundMethodInfo : BoundExpression { - public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol getMethodFromHandle, TypeSymbol type, bool hasErrors) + public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol? getMethodFromHandle, TypeSymbol type, bool hasErrors) : base(BoundKind.MethodInfo, syntax, type, hasErrors) { - Debug.Assert((object)method != null, "Field 'method' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(method is object, "Field 'method' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Method = method; this.GetMethodFromHandle = getMethodFromHandle; } - public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol getMethodFromHandle, TypeSymbol type) + public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol? getMethodFromHandle, TypeSymbol type) : base(BoundKind.MethodInfo, syntax, type) { - Debug.Assert((object)method != null, "Field 'method' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(method is object, "Field 'method' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Method = method; this.GetMethodFromHandle = getMethodFromHandle; } + public new TypeSymbol Type => base.Type!; + public MethodSymbol Method { get; } - public MethodSymbol GetMethodFromHandle { get; } + public MethodSymbol? GetMethodFromHandle { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMethodInfo(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMethodInfo(this); - public BoundMethodInfo Update(MethodSymbol method, MethodSymbol getMethodFromHandle, TypeSymbol type) + public BoundMethodInfo Update(MethodSymbol method, MethodSymbol? getMethodFromHandle, TypeSymbol type) { if (method != this.Method || getMethodFromHandle != this.GetMethodFromHandle || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2217,36 +2278,38 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundFieldInfo : BoundExpression { - public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol getFieldFromHandle, TypeSymbol type, bool hasErrors) + public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol? getFieldFromHandle, TypeSymbol type, bool hasErrors) : base(BoundKind.FieldInfo, syntax, type, hasErrors) { - Debug.Assert((object)field != null, "Field 'field' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(field is object, "Field 'field' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Field = field; this.GetFieldFromHandle = getFieldFromHandle; } - public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol getFieldFromHandle, TypeSymbol type) + public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol? getFieldFromHandle, TypeSymbol type) : base(BoundKind.FieldInfo, syntax, type) { - Debug.Assert((object)field != null, "Field 'field' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(field is object, "Field 'field' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Field = field; this.GetFieldFromHandle = getFieldFromHandle; } + public new TypeSymbol Type => base.Type!; + public FieldSymbol Field { get; } - public MethodSymbol GetFieldFromHandle { get; } + public MethodSymbol? GetFieldFromHandle { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitFieldInfo(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFieldInfo(this); - public BoundFieldInfo Update(FieldSymbol field, MethodSymbol getFieldFromHandle, TypeSymbol type) + public BoundFieldInfo Update(FieldSymbol field, MethodSymbol? getFieldFromHandle, TypeSymbol type) { if (field != this.Field || getFieldFromHandle != this.GetFieldFromHandle || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2267,7 +2330,7 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundDefaultExpression : BoundExpression { - public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression targetType, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false) + public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.DefaultExpression, syntax, type, hasErrors || targetType.HasErrors()) { this.TargetType = targetType; @@ -2275,13 +2338,15 @@ public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression targetType, } - public BoundTypeExpression TargetType { get; } + public new TypeSymbol? Type => base.Type!; - public ConstantValue ConstantValueOpt { get; } + public BoundTypeExpression? TargetType { get; } + + public ConstantValue? ConstantValueOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDefaultExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDefaultExpression(this); - public BoundDefaultExpression Update(BoundTypeExpression targetType, ConstantValue constantValueOpt, TypeSymbol type) + public BoundDefaultExpression Update(BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol? type) { if (targetType != this.TargetType || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2306,9 +2371,9 @@ public BoundIsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpr : base(BoundKind.IsOperator, syntax, type, hasErrors || operand.HasErrors() || targetType.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)targetType != null, "Field 'targetType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(targetType is object, "Field 'targetType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.TargetType = targetType; @@ -2316,13 +2381,15 @@ public BoundIsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpr } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } public BoundTypeExpression TargetType { get; } public Conversion Conversion { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIsOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIsOperator(this); public BoundIsOperator Update(BoundExpression operand, BoundTypeExpression targetType, Conversion conversion, TypeSymbol type) { @@ -2349,9 +2416,9 @@ public BoundAsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpr : base(BoundKind.AsOperator, syntax, type, hasErrors || operand.HasErrors() || targetType.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)targetType != null, "Field 'targetType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(targetType is object, "Field 'targetType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.TargetType = targetType; @@ -2359,13 +2426,15 @@ public BoundAsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpr } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } public BoundTypeExpression TargetType { get; } public Conversion Conversion { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAsOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAsOperator(this); public BoundAsOperator Update(BoundExpression operand, BoundTypeExpression targetType, Conversion conversion, TypeSymbol type) { @@ -2388,25 +2457,27 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundSizeOfOperator : BoundExpression { - public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false) + public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.SizeOfOperator, syntax, type, hasErrors || sourceType.HasErrors()) { - Debug.Assert((object)sourceType != null, "Field 'sourceType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(sourceType is object, "Field 'sourceType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.SourceType = sourceType; this.ConstantValueOpt = constantValueOpt; } + public new TypeSymbol Type => base.Type!; + public BoundTypeExpression SourceType { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSizeOfOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSizeOfOperator(this); - public BoundSizeOfOperator Update(BoundTypeExpression sourceType, ConstantValue constantValueOpt, TypeSymbol type) + public BoundSizeOfOperator Update(BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type) { if (sourceType != this.SourceType || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2427,12 +2498,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundConversion : BoundExpression { - public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue constantValueOpt, ConversionGroup conversionGroupOpt, TypeSymbol type, bool hasErrors = false) + public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.Conversion, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.Conversion = conversion; @@ -2444,6 +2515,8 @@ public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion co } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } public Conversion Conversion { get; } @@ -2454,13 +2527,13 @@ public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion co public bool ExplicitCastInCode { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } - public ConversionGroup ConversionGroupOpt { get; } + public ConversionGroup? ConversionGroupOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConversion(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConversion(this); - public BoundConversion Update(BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue constantValueOpt, ConversionGroup conversionGroupOpt, TypeSymbol type) + public BoundConversion Update(BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, TypeSymbol type) { if (operand != this.Operand || conversion != this.Conversion || isBaseConversion != this.IsBaseConversion || @checked != this.Checked || explicitCastInCode != this.ExplicitCastInCode || constantValueOpt != this.ConstantValueOpt || conversionGroupOpt != this.ConversionGroupOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2485,20 +2558,22 @@ public BoundReadOnlySpanFromArray(SyntaxNode syntax, BoundExpression operand, Me : base(BoundKind.ReadOnlySpanFromArray, syntax, type, hasErrors || operand.HasErrors()) { - Debug.Assert((object)operand != null, "Field 'operand' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)conversionMethod != null, "Field 'conversionMethod' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(operand is object, "Field 'operand' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(conversionMethod is object, "Field 'conversionMethod' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Operand = operand; this.ConversionMethod = conversionMethod; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Operand { get; } public MethodSymbol ConversionMethod { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitReadOnlySpanFromArray(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitReadOnlySpanFromArray(this); public BoundReadOnlySpanFromArray Update(BoundExpression operand, MethodSymbol conversionMethod, TypeSymbol type) { @@ -2525,7 +2600,7 @@ public BoundArgList(SyntaxNode syntax, TypeSymbol type, bool hasErrors) : base(BoundKind.ArgList, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -2533,12 +2608,14 @@ public BoundArgList(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.ArgList, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArgList(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArgList(this); public BoundArgList Update(TypeSymbol type) { @@ -2561,7 +2638,7 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundArgListOperator : BoundExpression { - public BoundArgListOperator(SyntaxNode syntax, ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, TypeSymbol type, bool hasErrors = false) + public BoundArgListOperator(SyntaxNode syntax, ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.ArgListOperator, syntax, type, hasErrors || arguments.HasErrors()) { @@ -2572,13 +2649,15 @@ public BoundArgListOperator(SyntaxNode syntax, ImmutableArray a } + public new TypeSymbol? Type => base.Type!; + public ImmutableArray Arguments { get; } public ImmutableArray ArgumentRefKindsOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArgListOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArgListOperator(this); - public BoundArgListOperator Update(ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, TypeSymbol type) + public BoundArgListOperator Update(ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, TypeSymbol? type) { if (arguments != this.Arguments || argumentRefKindsOpt != this.ArgumentRefKindsOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2599,13 +2678,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundFixedLocalCollectionInitializer : BoundExpression { - public BoundFixedLocalCollectionInitializer(SyntaxNode syntax, TypeSymbol elementPointerType, Conversion elementPointerTypeConversion, BoundExpression expression, MethodSymbol getPinnableOpt, TypeSymbol type, bool hasErrors = false) + public BoundFixedLocalCollectionInitializer(SyntaxNode syntax, TypeSymbol elementPointerType, Conversion elementPointerTypeConversion, BoundExpression expression, MethodSymbol? getPinnableOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.FixedLocalCollectionInitializer, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)elementPointerType != null, "Field 'elementPointerType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(elementPointerType is object, "Field 'elementPointerType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ElementPointerType = elementPointerType; this.ElementPointerTypeConversion = elementPointerTypeConversion; @@ -2614,17 +2693,19 @@ public BoundFixedLocalCollectionInitializer(SyntaxNode syntax, TypeSymbol elemen } + public new TypeSymbol Type => base.Type!; + public TypeSymbol ElementPointerType { get; } public Conversion ElementPointerTypeConversion { get; } public BoundExpression Expression { get; } - public MethodSymbol GetPinnableOpt { get; } + public MethodSymbol? GetPinnableOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitFixedLocalCollectionInitializer(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFixedLocalCollectionInitializer(this); - public BoundFixedLocalCollectionInitializer Update(TypeSymbol elementPointerType, Conversion elementPointerTypeConversion, BoundExpression expression, MethodSymbol getPinnableOpt, TypeSymbol type) + public BoundFixedLocalCollectionInitializer Update(TypeSymbol elementPointerType, Conversion elementPointerTypeConversion, BoundExpression expression, MethodSymbol? getPinnableOpt, TypeSymbol type) { if (!TypeSymbol.Equals(elementPointerType, this.ElementPointerType, TypeCompareKind.ConsiderEverything) || elementPointerTypeConversion != this.ElementPointerTypeConversion || expression != this.Expression || getPinnableOpt != this.GetPinnableOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -2659,18 +2740,18 @@ protected BoundStatement(BoundKind kind, SyntaxNode syntax) internal sealed partial class BoundSequencePoint : BoundStatement { - public BoundSequencePoint(SyntaxNode syntax, BoundStatement statementOpt, bool hasErrors = false) + public BoundSequencePoint(SyntaxNode syntax, BoundStatement? statementOpt, bool hasErrors = false) : base(BoundKind.SequencePoint, syntax, hasErrors || statementOpt.HasErrors()) { this.StatementOpt = statementOpt; } - public BoundStatement StatementOpt { get; } + public BoundStatement? StatementOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePoint(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePoint(this); - public BoundSequencePoint Update(BoundStatement statementOpt) + public BoundSequencePoint Update(BoundStatement? statementOpt) { if (statementOpt != this.StatementOpt) { @@ -2684,7 +2765,7 @@ public BoundSequencePoint Update(BoundStatement statementOpt) internal sealed partial class BoundSequencePointWithSpan : BoundStatement { - public BoundSequencePointWithSpan(SyntaxNode syntax, BoundStatement statementOpt, TextSpan span, bool hasErrors = false) + public BoundSequencePointWithSpan(SyntaxNode syntax, BoundStatement? statementOpt, TextSpan span, bool hasErrors = false) : base(BoundKind.SequencePointWithSpan, syntax, hasErrors || statementOpt.HasErrors()) { this.StatementOpt = statementOpt; @@ -2692,13 +2773,13 @@ public BoundSequencePointWithSpan(SyntaxNode syntax, BoundStatement statementOpt } - public BoundStatement StatementOpt { get; } + public BoundStatement? StatementOpt { get; } public TextSpan Span { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePointWithSpan(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePointWithSpan(this); - public BoundSequencePointWithSpan Update(BoundStatement statementOpt, TextSpan span) + public BoundSequencePointWithSpan Update(BoundStatement? statementOpt, TextSpan span) { if (statementOpt != this.StatementOpt || span != this.Span) { @@ -2729,7 +2810,7 @@ public BoundBlock(SyntaxNode syntax, ImmutableArray locals, Immutab public ImmutableArray LocalFunctions { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBlock(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBlock(this); public BoundBlock Update(ImmutableArray locals, ImmutableArray localFunctions, ImmutableArray statements) { @@ -2758,7 +2839,7 @@ public BoundScope(SyntaxNode syntax, ImmutableArray locals, Immutab public ImmutableArray Locals { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitScope(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitScope(this); public BoundScope Update(ImmutableArray locals, ImmutableArray statements) { @@ -2779,7 +2860,7 @@ public BoundStateMachineScope(SyntaxNode syntax, ImmutableArray visitor.VisitStateMachineScope(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitStateMachineScope(this); public BoundStateMachineScope Update(ImmutableArray fields, BoundStatement statement) { @@ -2806,11 +2887,11 @@ public BoundStateMachineScope Update(ImmutableArray fie internal sealed partial class BoundLocalDeclaration : BoundStatement { - public BoundLocalDeclaration(SyntaxNode syntax, LocalSymbol localSymbol, BoundTypeExpression declaredTypeOpt, BoundExpression initializerOpt, ImmutableArray argumentsOpt, bool inferredType, bool hasErrors = false) + public BoundLocalDeclaration(SyntaxNode syntax, LocalSymbol localSymbol, BoundTypeExpression? declaredTypeOpt, BoundExpression? initializerOpt, ImmutableArray argumentsOpt, bool inferredType, bool hasErrors = false) : base(BoundKind.LocalDeclaration, syntax, hasErrors || declaredTypeOpt.HasErrors() || initializerOpt.HasErrors() || argumentsOpt.HasErrors()) { - Debug.Assert((object)localSymbol != null, "Field 'localSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(localSymbol is object, "Field 'localSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LocalSymbol = localSymbol; this.DeclaredTypeOpt = declaredTypeOpt; @@ -2822,17 +2903,17 @@ public BoundLocalDeclaration(SyntaxNode syntax, LocalSymbol localSymbol, BoundTy public LocalSymbol LocalSymbol { get; } - public BoundTypeExpression DeclaredTypeOpt { get; } + public BoundTypeExpression? DeclaredTypeOpt { get; } - public BoundExpression InitializerOpt { get; } + public BoundExpression? InitializerOpt { get; } public ImmutableArray ArgumentsOpt { get; } public bool InferredType { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLocalDeclaration(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLocalDeclaration(this); - public BoundLocalDeclaration Update(LocalSymbol localSymbol, BoundTypeExpression declaredTypeOpt, BoundExpression initializerOpt, ImmutableArray argumentsOpt, bool inferredType) + public BoundLocalDeclaration Update(LocalSymbol localSymbol, BoundTypeExpression? declaredTypeOpt, BoundExpression? initializerOpt, ImmutableArray argumentsOpt, bool inferredType) { if (localSymbol != this.LocalSymbol || declaredTypeOpt != this.DeclaredTypeOpt || initializerOpt != this.InitializerOpt || argumentsOpt != this.ArgumentsOpt || inferredType != this.InferredType) { @@ -2867,7 +2948,7 @@ public BoundMultipleLocalDeclarations(SyntaxNode syntax, ImmutableArray LocalDeclarations { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMultipleLocalDeclarations(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMultipleLocalDeclarations(this); public BoundMultipleLocalDeclarations Update(ImmutableArray localDeclarations) { @@ -2883,7 +2964,7 @@ public BoundMultipleLocalDeclarations Update(ImmutableArray localDeclarations, bool hasErrors = false) + public BoundUsingLocalDeclarations(SyntaxNode syntax, MethodSymbol disposeMethodOpt, Conversion iDisposableConversion, AwaitableInfo? awaitOpt, ImmutableArray localDeclarations, bool hasErrors = false) : base(BoundKind.UsingLocalDeclarations, syntax, localDeclarations, hasErrors || localDeclarations.HasErrors()) { @@ -2899,11 +2980,11 @@ public BoundUsingLocalDeclarations(SyntaxNode syntax, MethodSymbol disposeMethod public Conversion IDisposableConversion { get; } - public AwaitableInfo AwaitOpt { get; } + public AwaitableInfo? AwaitOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitUsingLocalDeclarations(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitUsingLocalDeclarations(this); - public BoundUsingLocalDeclarations Update(MethodSymbol disposeMethodOpt, Conversion iDisposableConversion, AwaitableInfo awaitOpt, ImmutableArray localDeclarations) + public BoundUsingLocalDeclarations Update(MethodSymbol disposeMethodOpt, Conversion iDisposableConversion, AwaitableInfo? awaitOpt, ImmutableArray localDeclarations) { if (disposeMethodOpt != this.DisposeMethodOpt || iDisposableConversion != this.IDisposableConversion || awaitOpt != this.AwaitOpt || localDeclarations != this.LocalDeclarations) { @@ -2917,11 +2998,11 @@ public BoundUsingLocalDeclarations Update(MethodSymbol disposeMethodOpt, Convers internal sealed partial class BoundLocalFunctionStatement : BoundStatement { - public BoundLocalFunctionStatement(SyntaxNode syntax, LocalFunctionSymbol symbol, BoundBlock blockBody, BoundBlock expressionBody, bool hasErrors = false) + public BoundLocalFunctionStatement(SyntaxNode syntax, LocalFunctionSymbol symbol, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false) : base(BoundKind.LocalFunctionStatement, syntax, hasErrors || blockBody.HasErrors() || expressionBody.HasErrors()) { - Debug.Assert((object)symbol != null, "Field 'symbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(symbol is object, "Field 'symbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Symbol = symbol; this.BlockBody = blockBody; @@ -2931,13 +3012,13 @@ public BoundLocalFunctionStatement(SyntaxNode syntax, LocalFunctionSymbol symbol public LocalFunctionSymbol Symbol { get; } - public BoundBlock BlockBody { get; } + public BoundBlock? BlockBody { get; } - public BoundBlock ExpressionBody { get; } + public BoundBlock? ExpressionBody { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLocalFunctionStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLocalFunctionStatement(this); - public BoundLocalFunctionStatement Update(LocalFunctionSymbol symbol, BoundBlock blockBody, BoundBlock expressionBody) + public BoundLocalFunctionStatement Update(LocalFunctionSymbol symbol, BoundBlock? blockBody, BoundBlock? expressionBody) { if (symbol != this.Symbol || blockBody != this.BlockBody || expressionBody != this.ExpressionBody) { @@ -2966,7 +3047,7 @@ public BoundNoOpStatement(SyntaxNode syntax, NoOpStatementFlavor flavor) public NoOpStatementFlavor Flavor { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNoOpStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNoOpStatement(this); public BoundNoOpStatement Update(NoOpStatementFlavor flavor) { @@ -2982,7 +3063,7 @@ public BoundNoOpStatement Update(NoOpStatementFlavor flavor) internal sealed partial class BoundReturnStatement : BoundStatement { - public BoundReturnStatement(SyntaxNode syntax, RefKind refKind, BoundExpression expressionOpt, bool hasErrors = false) + public BoundReturnStatement(SyntaxNode syntax, RefKind refKind, BoundExpression? expressionOpt, bool hasErrors = false) : base(BoundKind.ReturnStatement, syntax, hasErrors || expressionOpt.HasErrors()) { this.RefKind = refKind; @@ -2992,11 +3073,11 @@ public BoundReturnStatement(SyntaxNode syntax, RefKind refKind, BoundExpression public RefKind RefKind { get; } - public BoundExpression ExpressionOpt { get; } + public BoundExpression? ExpressionOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitReturnStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitReturnStatement(this); - public BoundReturnStatement Update(RefKind refKind, BoundExpression expressionOpt) + public BoundReturnStatement Update(RefKind refKind, BoundExpression? expressionOpt) { if (refKind != this.RefKind || expressionOpt != this.ExpressionOpt) { @@ -3014,7 +3095,7 @@ public BoundYieldReturnStatement(SyntaxNode syntax, BoundExpression expression, : base(BoundKind.YieldReturnStatement, syntax, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } @@ -3022,7 +3103,7 @@ public BoundYieldReturnStatement(SyntaxNode syntax, BoundExpression expression, public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitYieldReturnStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitYieldReturnStatement(this); public BoundYieldReturnStatement Update(BoundExpression expression) { @@ -3049,23 +3130,23 @@ public BoundYieldBreakStatement(SyntaxNode syntax) } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitYieldBreakStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitYieldBreakStatement(this); } internal sealed partial class BoundThrowStatement : BoundStatement { - public BoundThrowStatement(SyntaxNode syntax, BoundExpression expressionOpt, bool hasErrors = false) + public BoundThrowStatement(SyntaxNode syntax, BoundExpression? expressionOpt, bool hasErrors = false) : base(BoundKind.ThrowStatement, syntax, hasErrors || expressionOpt.HasErrors()) { this.ExpressionOpt = expressionOpt; } - public BoundExpression ExpressionOpt { get; } + public BoundExpression? ExpressionOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitThrowStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitThrowStatement(this); - public BoundThrowStatement Update(BoundExpression expressionOpt) + public BoundThrowStatement Update(BoundExpression? expressionOpt) { if (expressionOpt != this.ExpressionOpt) { @@ -3083,7 +3164,7 @@ public BoundExpressionStatement(SyntaxNode syntax, BoundExpression expression, b : base(BoundKind.ExpressionStatement, syntax, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } @@ -3091,7 +3172,7 @@ public BoundExpressionStatement(SyntaxNode syntax, BoundExpression expression, b public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitExpressionStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitExpressionStatement(this); public BoundExpressionStatement Update(BoundExpression expression) { @@ -3111,7 +3192,7 @@ public BoundBreakStatement(SyntaxNode syntax, GeneratedLabelSymbol label, bool h : base(BoundKind.BreakStatement, syntax, hasErrors) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -3120,7 +3201,7 @@ public BoundBreakStatement(SyntaxNode syntax, GeneratedLabelSymbol label) : base(BoundKind.BreakStatement, syntax) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -3128,7 +3209,7 @@ public BoundBreakStatement(SyntaxNode syntax, GeneratedLabelSymbol label) public GeneratedLabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBreakStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBreakStatement(this); public BoundBreakStatement Update(GeneratedLabelSymbol label) { @@ -3148,7 +3229,7 @@ public BoundContinueStatement(SyntaxNode syntax, GeneratedLabelSymbol label, boo : base(BoundKind.ContinueStatement, syntax, hasErrors) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -3157,7 +3238,7 @@ public BoundContinueStatement(SyntaxNode syntax, GeneratedLabelSymbol label) : base(BoundKind.ContinueStatement, syntax) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -3165,7 +3246,7 @@ public BoundContinueStatement(SyntaxNode syntax, GeneratedLabelSymbol label) public GeneratedLabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitContinueStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitContinueStatement(this); public BoundContinueStatement Update(GeneratedLabelSymbol label) { @@ -3181,16 +3262,16 @@ public BoundContinueStatement Update(GeneratedLabelSymbol label) internal sealed partial class BoundSwitchStatement : BoundStatement { - public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, ImmutableArray innerLocals, ImmutableArray innerLocalFunctions, ImmutableArray switchSections, BoundDecisionDag decisionDag, BoundSwitchLabel defaultLabel, GeneratedLabelSymbol breakLabel, bool hasErrors = false) + public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, ImmutableArray innerLocals, ImmutableArray innerLocalFunctions, ImmutableArray switchSections, BoundDecisionDag decisionDag, BoundSwitchLabel? defaultLabel, GeneratedLabelSymbol breakLabel, bool hasErrors = false) : base(BoundKind.SwitchStatement, syntax, hasErrors || expression.HasErrors() || switchSections.HasErrors() || decisionDag.HasErrors() || defaultLabel.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!innerLocals.IsDefault, "Field 'innerLocals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!innerLocalFunctions.IsDefault, "Field 'innerLocalFunctions' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!switchSections.IsDefault, "Field 'switchSections' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)decisionDag != null, "Field 'decisionDag' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(decisionDag is object, "Field 'decisionDag' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.InnerLocals = innerLocals; @@ -3212,13 +3293,13 @@ public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, Immut public BoundDecisionDag DecisionDag { get; } - public BoundSwitchLabel DefaultLabel { get; } + public BoundSwitchLabel? DefaultLabel { get; } public GeneratedLabelSymbol BreakLabel { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchStatement(this); - public BoundSwitchStatement Update(BoundExpression expression, ImmutableArray innerLocals, ImmutableArray innerLocalFunctions, ImmutableArray switchSections, BoundDecisionDag decisionDag, BoundSwitchLabel defaultLabel, GeneratedLabelSymbol breakLabel) + public BoundSwitchStatement Update(BoundExpression expression, ImmutableArray innerLocals, ImmutableArray innerLocalFunctions, ImmutableArray switchSections, BoundDecisionDag decisionDag, BoundSwitchLabel? defaultLabel, GeneratedLabelSymbol breakLabel) { if (expression != this.Expression || innerLocals != this.InnerLocals || innerLocalFunctions != this.InnerLocalFunctions || switchSections != this.SwitchSections || decisionDag != this.DecisionDag || defaultLabel != this.DefaultLabel || breakLabel != this.BreakLabel) { @@ -3232,13 +3313,13 @@ public BoundSwitchStatement Update(BoundExpression expression, ImmutableArray cases, LabelSymbol defaultLabel, MethodSymbol equalityMethod, bool hasErrors = false) + public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, MethodSymbol? equalityMethod, bool hasErrors = false) : base(BoundKind.SwitchDispatch, syntax, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!cases.IsDefault, "Field 'cases' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)defaultLabel != null, "Field 'defaultLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(defaultLabel is object, "Field 'defaultLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.Cases = cases; @@ -3253,11 +3334,11 @@ public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, Immuta public LabelSymbol DefaultLabel { get; } - public MethodSymbol EqualityMethod { get; } + public MethodSymbol? EqualityMethod { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchDispatch(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchDispatch(this); - public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, MethodSymbol equalityMethod) + public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, MethodSymbol? equalityMethod) { if (expression != this.Expression || cases != this.Cases || defaultLabel != this.DefaultLabel || equalityMethod != this.EqualityMethod) { @@ -3271,12 +3352,12 @@ public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(Co internal sealed partial class BoundIfStatement : BoundStatement { - public BoundIfStatement(SyntaxNode syntax, BoundExpression condition, BoundStatement consequence, BoundStatement alternativeOpt, bool hasErrors = false) + public BoundIfStatement(SyntaxNode syntax, BoundExpression condition, BoundStatement consequence, BoundStatement? alternativeOpt, bool hasErrors = false) : base(BoundKind.IfStatement, syntax, hasErrors || condition.HasErrors() || consequence.HasErrors() || alternativeOpt.HasErrors()) { - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)consequence != null, "Field 'consequence' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(consequence is object, "Field 'consequence' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Condition = condition; this.Consequence = consequence; @@ -3288,11 +3369,11 @@ public BoundIfStatement(SyntaxNode syntax, BoundExpression condition, BoundState public BoundStatement Consequence { get; } - public BoundStatement AlternativeOpt { get; } + public BoundStatement? AlternativeOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIfStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIfStatement(this); - public BoundIfStatement Update(BoundExpression condition, BoundStatement consequence, BoundStatement alternativeOpt) + public BoundIfStatement Update(BoundExpression condition, BoundStatement consequence, BoundStatement? alternativeOpt) { if (condition != this.Condition || consequence != this.Consequence || alternativeOpt != this.AlternativeOpt) { @@ -3310,8 +3391,8 @@ protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, GeneratedLabelSy : base(kind, syntax, hasErrors) { - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.BreakLabel = breakLabel; this.ContinueLabel = continueLabel; @@ -3321,8 +3402,8 @@ protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, GeneratedLabelSy : base(kind, syntax) { - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.BreakLabel = breakLabel; this.ContinueLabel = continueLabel; @@ -3341,10 +3422,10 @@ protected BoundConditionalLoopStatement(BoundKind kind, SyntaxNode syntax, Immut { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.Condition = condition; @@ -3366,15 +3447,15 @@ public BoundDoStatement(SyntaxNode syntax, ImmutableArray locals, B { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDoStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDoStatement(this); public BoundDoStatement Update(ImmutableArray locals, BoundExpression condition, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) { @@ -3395,15 +3476,15 @@ public BoundWhileStatement(SyntaxNode syntax, ImmutableArray locals { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitWhileStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitWhileStatement(this); public BoundWhileStatement Update(ImmutableArray locals, BoundExpression condition, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) { @@ -3419,15 +3500,15 @@ public BoundWhileStatement Update(ImmutableArray locals, BoundExpre internal sealed partial class BoundForStatement : BoundLoopStatement { - public BoundForStatement(SyntaxNode syntax, ImmutableArray outerLocals, BoundStatement initializer, ImmutableArray innerLocals, BoundExpression condition, BoundStatement increment, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false) + public BoundForStatement(SyntaxNode syntax, ImmutableArray outerLocals, BoundStatement? initializer, ImmutableArray innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false) : base(BoundKind.ForStatement, syntax, breakLabel, continueLabel, hasErrors || initializer.HasErrors() || condition.HasErrors() || increment.HasErrors() || body.HasErrors()) { Debug.Assert(!outerLocals.IsDefault, "Field 'outerLocals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!innerLocals.IsDefault, "Field 'innerLocals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.OuterLocals = outerLocals; this.Initializer = initializer; @@ -3440,19 +3521,19 @@ public BoundForStatement(SyntaxNode syntax, ImmutableArray outerLoc public ImmutableArray OuterLocals { get; } - public BoundStatement Initializer { get; } + public BoundStatement? Initializer { get; } public ImmutableArray InnerLocals { get; } - public BoundExpression Condition { get; } + public BoundExpression? Condition { get; } - public BoundStatement Increment { get; } + public BoundStatement? Increment { get; } public BoundStatement Body { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitForStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitForStatement(this); - public BoundForStatement Update(ImmutableArray outerLocals, BoundStatement initializer, ImmutableArray innerLocals, BoundExpression condition, BoundStatement increment, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) + public BoundForStatement Update(ImmutableArray outerLocals, BoundStatement? initializer, ImmutableArray innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) { if (outerLocals != this.OuterLocals || initializer != this.Initializer || innerLocals != this.InnerLocals || condition != this.Condition || increment != this.Increment || body != this.Body || breakLabel != this.BreakLabel || continueLabel != this.ContinueLabel) { @@ -3466,16 +3547,16 @@ public BoundForStatement Update(ImmutableArray outerLocals, BoundSt internal sealed partial class BoundForEachStatement : BoundLoopStatement { - public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfoOpt, Conversion elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray iterationVariables, BoundExpression iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep deconstructionOpt, AwaitableInfo awaitOpt, BoundStatement body, bool @checked, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false) + public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo? enumeratorInfoOpt, Conversion elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, AwaitableInfo? awaitOpt, BoundStatement body, bool @checked, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false) : base(BoundKind.ForEachStatement, syntax, breakLabel, continueLabel, hasErrors || iterationVariableType.HasErrors() || iterationErrorExpressionOpt.HasErrors() || expression.HasErrors() || deconstructionOpt.HasErrors() || body.HasErrors()) { - Debug.Assert((object)iterationVariableType != null, "Field 'iterationVariableType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(iterationVariableType is object, "Field 'iterationVariableType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!iterationVariables.IsDefault, "Field 'iterationVariables' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)continueLabel != null, "Field 'continueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(breakLabel is object, "Field 'breakLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(continueLabel is object, "Field 'continueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.EnumeratorInfoOpt = enumeratorInfoOpt; this.ElementConversion = elementConversion; @@ -3490,7 +3571,7 @@ public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo enumerator } - public ForEachEnumeratorInfo EnumeratorInfoOpt { get; } + public ForEachEnumeratorInfo? EnumeratorInfoOpt { get; } public Conversion ElementConversion { get; } @@ -3498,21 +3579,21 @@ public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo enumerator public ImmutableArray IterationVariables { get; } - public BoundExpression IterationErrorExpressionOpt { get; } + public BoundExpression? IterationErrorExpressionOpt { get; } public BoundExpression Expression { get; } - public BoundForEachDeconstructStep DeconstructionOpt { get; } + public BoundForEachDeconstructStep? DeconstructionOpt { get; } - public AwaitableInfo AwaitOpt { get; } + public AwaitableInfo? AwaitOpt { get; } public BoundStatement Body { get; } public bool Checked { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitForEachStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitForEachStatement(this); - public BoundForEachStatement Update(ForEachEnumeratorInfo enumeratorInfoOpt, Conversion elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray iterationVariables, BoundExpression iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep deconstructionOpt, AwaitableInfo awaitOpt, BoundStatement body, bool @checked, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) + public BoundForEachStatement Update(ForEachEnumeratorInfo? enumeratorInfoOpt, Conversion elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, AwaitableInfo? awaitOpt, BoundStatement body, bool @checked, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel) { if (enumeratorInfoOpt != this.EnumeratorInfoOpt || elementConversion != this.ElementConversion || iterationVariableType != this.IterationVariableType || iterationVariables != this.IterationVariables || iterationErrorExpressionOpt != this.IterationErrorExpressionOpt || expression != this.Expression || deconstructionOpt != this.DeconstructionOpt || awaitOpt != this.AwaitOpt || body != this.Body || @checked != this.Checked || breakLabel != this.BreakLabel || continueLabel != this.ContinueLabel) { @@ -3530,8 +3611,8 @@ public BoundForEachDeconstructStep(SyntaxNode syntax, BoundDeconstructionAssignm : base(BoundKind.ForEachDeconstructStep, syntax, hasErrors || deconstructionAssignment.HasErrors() || targetPlaceholder.HasErrors()) { - Debug.Assert((object)deconstructionAssignment != null, "Field 'deconstructionAssignment' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)targetPlaceholder != null, "Field 'targetPlaceholder' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(deconstructionAssignment is object, "Field 'deconstructionAssignment' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(targetPlaceholder is object, "Field 'targetPlaceholder' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.DeconstructionAssignment = deconstructionAssignment; this.TargetPlaceholder = targetPlaceholder; @@ -3542,7 +3623,7 @@ public BoundForEachDeconstructStep(SyntaxNode syntax, BoundDeconstructionAssignm public BoundDeconstructValuePlaceholder TargetPlaceholder { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitForEachDeconstructStep(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitForEachDeconstructStep(this); public BoundForEachDeconstructStep Update(BoundDeconstructionAssignmentOperator deconstructionAssignment, BoundDeconstructValuePlaceholder targetPlaceholder) { @@ -3558,12 +3639,12 @@ public BoundForEachDeconstructStep Update(BoundDeconstructionAssignmentOperator internal sealed partial class BoundUsingStatement : BoundStatement { - public BoundUsingStatement(SyntaxNode syntax, ImmutableArray locals, BoundMultipleLocalDeclarations declarationsOpt, BoundExpression expressionOpt, Conversion iDisposableConversion, BoundStatement body, AwaitableInfo awaitOpt, MethodSymbol disposeMethodOpt, bool hasErrors = false) + public BoundUsingStatement(SyntaxNode syntax, ImmutableArray locals, BoundMultipleLocalDeclarations? declarationsOpt, BoundExpression? expressionOpt, Conversion iDisposableConversion, BoundStatement body, AwaitableInfo? awaitOpt, MethodSymbol? disposeMethodOpt, bool hasErrors = false) : base(BoundKind.UsingStatement, syntax, hasErrors || declarationsOpt.HasErrors() || expressionOpt.HasErrors() || body.HasErrors()) { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.DeclarationsOpt = declarationsOpt; @@ -3577,21 +3658,21 @@ public BoundUsingStatement(SyntaxNode syntax, ImmutableArray locals public ImmutableArray Locals { get; } - public BoundMultipleLocalDeclarations DeclarationsOpt { get; } + public BoundMultipleLocalDeclarations? DeclarationsOpt { get; } - public BoundExpression ExpressionOpt { get; } + public BoundExpression? ExpressionOpt { get; } public Conversion IDisposableConversion { get; } public BoundStatement Body { get; } - public AwaitableInfo AwaitOpt { get; } + public AwaitableInfo? AwaitOpt { get; } - public MethodSymbol DisposeMethodOpt { get; } + public MethodSymbol? DisposeMethodOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitUsingStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitUsingStatement(this); - public BoundUsingStatement Update(ImmutableArray locals, BoundMultipleLocalDeclarations declarationsOpt, BoundExpression expressionOpt, Conversion iDisposableConversion, BoundStatement body, AwaitableInfo awaitOpt, MethodSymbol disposeMethodOpt) + public BoundUsingStatement Update(ImmutableArray locals, BoundMultipleLocalDeclarations? declarationsOpt, BoundExpression? expressionOpt, Conversion iDisposableConversion, BoundStatement body, AwaitableInfo? awaitOpt, MethodSymbol? disposeMethodOpt) { if (locals != this.Locals || declarationsOpt != this.DeclarationsOpt || expressionOpt != this.ExpressionOpt || iDisposableConversion != this.IDisposableConversion || body != this.Body || awaitOpt != this.AwaitOpt || disposeMethodOpt != this.DisposeMethodOpt) { @@ -3610,8 +3691,8 @@ public BoundFixedStatement(SyntaxNode syntax, ImmutableArray locals { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)declarations != null, "Field 'declarations' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(declarations is object, "Field 'declarations' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.Declarations = declarations; @@ -3625,7 +3706,7 @@ public BoundFixedStatement(SyntaxNode syntax, ImmutableArray locals public BoundStatement Body { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitFixedStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFixedStatement(this); public BoundFixedStatement Update(ImmutableArray locals, BoundMultipleLocalDeclarations declarations, BoundStatement body) { @@ -3645,8 +3726,8 @@ public BoundLockStatement(SyntaxNode syntax, BoundExpression argument, BoundStat : base(BoundKind.LockStatement, syntax, hasErrors || argument.HasErrors() || body.HasErrors()) { - Debug.Assert((object)argument != null, "Field 'argument' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(argument is object, "Field 'argument' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Argument = argument; this.Body = body; @@ -3657,7 +3738,7 @@ public BoundLockStatement(SyntaxNode syntax, BoundExpression argument, BoundStat public BoundStatement Body { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLockStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLockStatement(this); public BoundLockStatement Update(BoundExpression argument, BoundStatement body) { @@ -3673,11 +3754,11 @@ public BoundLockStatement Update(BoundExpression argument, BoundStatement body) internal sealed partial class BoundTryStatement : BoundStatement { - public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray catchBlocks, BoundBlock finallyBlockOpt, LabelSymbol finallyLabelOpt, bool preferFaultHandler, bool hasErrors = false) + public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler, bool hasErrors = false) : base(BoundKind.TryStatement, syntax, hasErrors || tryBlock.HasErrors() || catchBlocks.HasErrors() || finallyBlockOpt.HasErrors()) { - Debug.Assert((object)tryBlock != null, "Field 'tryBlock' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(tryBlock is object, "Field 'tryBlock' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!catchBlocks.IsDefault, "Field 'catchBlocks' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); this.TryBlock = tryBlock; @@ -3692,15 +3773,15 @@ public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray< public ImmutableArray CatchBlocks { get; } - public BoundBlock FinallyBlockOpt { get; } + public BoundBlock? FinallyBlockOpt { get; } - public LabelSymbol FinallyLabelOpt { get; } + public LabelSymbol? FinallyLabelOpt { get; } public bool PreferFaultHandler { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTryStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTryStatement(this); - public BoundTryStatement Update(BoundBlock tryBlock, ImmutableArray catchBlocks, BoundBlock finallyBlockOpt, LabelSymbol finallyLabelOpt, bool preferFaultHandler) + public BoundTryStatement Update(BoundBlock tryBlock, ImmutableArray catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler) { if (tryBlock != this.TryBlock || catchBlocks != this.CatchBlocks || finallyBlockOpt != this.FinallyBlockOpt || finallyLabelOpt != this.FinallyLabelOpt || preferFaultHandler != this.PreferFaultHandler) { @@ -3714,12 +3795,12 @@ public BoundTryStatement Update(BoundBlock tryBlock, ImmutableArray locals, BoundExpression exceptionSourceOpt, TypeSymbol exceptionTypeOpt, BoundExpression exceptionFilterOpt, BoundBlock body, bool isSynthesizedAsyncCatchAll, bool hasErrors = false) + public BoundCatchBlock(SyntaxNode syntax, ImmutableArray locals, BoundExpression? exceptionSourceOpt, TypeSymbol? exceptionTypeOpt, BoundExpression? exceptionFilterOpt, BoundBlock body, bool isSynthesizedAsyncCatchAll, bool hasErrors = false) : base(BoundKind.CatchBlock, syntax, hasErrors || exceptionSourceOpt.HasErrors() || exceptionFilterOpt.HasErrors() || body.HasErrors()) { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.ExceptionSourceOpt = exceptionSourceOpt; @@ -3732,19 +3813,19 @@ public BoundCatchBlock(SyntaxNode syntax, ImmutableArray locals, Bo public ImmutableArray Locals { get; } - public BoundExpression ExceptionSourceOpt { get; } + public BoundExpression? ExceptionSourceOpt { get; } - public TypeSymbol ExceptionTypeOpt { get; } + public TypeSymbol? ExceptionTypeOpt { get; } - public BoundExpression ExceptionFilterOpt { get; } + public BoundExpression? ExceptionFilterOpt { get; } public BoundBlock Body { get; } public bool IsSynthesizedAsyncCatchAll { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitCatchBlock(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitCatchBlock(this); - public BoundCatchBlock Update(ImmutableArray locals, BoundExpression exceptionSourceOpt, TypeSymbol exceptionTypeOpt, BoundExpression exceptionFilterOpt, BoundBlock body, bool isSynthesizedAsyncCatchAll) + public BoundCatchBlock Update(ImmutableArray locals, BoundExpression? exceptionSourceOpt, TypeSymbol? exceptionTypeOpt, BoundExpression? exceptionFilterOpt, BoundBlock body, bool isSynthesizedAsyncCatchAll) { if (locals != this.Locals || exceptionSourceOpt != this.ExceptionSourceOpt || !TypeSymbol.Equals(exceptionTypeOpt, this.ExceptionTypeOpt, TypeCompareKind.ConsiderEverything) || exceptionFilterOpt != this.ExceptionFilterOpt || body != this.Body || isSynthesizedAsyncCatchAll != this.IsSynthesizedAsyncCatchAll) { @@ -3758,24 +3839,24 @@ public BoundCatchBlock Update(ImmutableArray locals, BoundExpressio internal sealed partial class BoundLiteral : BoundExpression { - public BoundLiteral(SyntaxNode syntax, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors) + public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors) : base(BoundKind.Literal, syntax, type, hasErrors) { this.ConstantValueOpt = constantValueOpt; } - public BoundLiteral(SyntaxNode syntax, ConstantValue constantValueOpt, TypeSymbol type) + public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type) : base(BoundKind.Literal, syntax, type) { this.ConstantValueOpt = constantValueOpt; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLiteral(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLiteral(this); - public BoundLiteral Update(ConstantValue constantValueOpt, TypeSymbol type) + public BoundLiteral Update(ConstantValue? constantValueOpt, TypeSymbol? type) { if (constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -3800,7 +3881,7 @@ public BoundThisReference(SyntaxNode syntax, TypeSymbol type, bool hasErrors) : base(BoundKind.ThisReference, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -3808,12 +3889,14 @@ public BoundThisReference(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.ThisReference, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitThisReference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitThisReference(this); public BoundThisReference Update(TypeSymbol type) { @@ -3840,7 +3923,7 @@ public BoundPreviousSubmissionReference(SyntaxNode syntax, TypeSymbol type, bool : base(BoundKind.PreviousSubmissionReference, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -3848,12 +3931,14 @@ public BoundPreviousSubmissionReference(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.PreviousSubmissionReference, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPreviousSubmissionReference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPreviousSubmissionReference(this); public BoundPreviousSubmissionReference Update(TypeSymbol type) { @@ -3880,7 +3965,7 @@ public BoundHostObjectMemberReference(SyntaxNode syntax, TypeSymbol type, bool h : base(BoundKind.HostObjectMemberReference, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -3888,12 +3973,14 @@ public BoundHostObjectMemberReference(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.HostObjectMemberReference, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitHostObjectMemberReference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitHostObjectMemberReference(this); public BoundHostObjectMemberReference Update(TypeSymbol type) { @@ -3916,20 +4003,22 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundBaseReference : BoundExpression { - public BoundBaseReference(SyntaxNode syntax, TypeSymbol type, bool hasErrors) + public BoundBaseReference(SyntaxNode syntax, TypeSymbol? type, bool hasErrors) : base(BoundKind.BaseReference, syntax, type, hasErrors) { } - public BoundBaseReference(SyntaxNode syntax, TypeSymbol type) + public BoundBaseReference(SyntaxNode syntax, TypeSymbol? type) : base(BoundKind.BaseReference, syntax, type) { } + + public new TypeSymbol? Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitBaseReference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitBaseReference(this); - public BoundBaseReference Update(TypeSymbol type) + public BoundBaseReference Update(TypeSymbol? type) { if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -3950,12 +4039,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundLocal : BoundExpression { - public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors) + public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors) : base(BoundKind.Local, syntax, type, hasErrors) { - Debug.Assert((object)localSymbol != null, "Field 'localSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(localSymbol is object, "Field 'localSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LocalSymbol = localSymbol; this.DeclarationKind = declarationKind; @@ -3963,12 +4052,12 @@ public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarat this.IsNullableUnknown = isNullableUnknown; } - public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue constantValueOpt, bool isNullableUnknown, TypeSymbol type) + public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type) : base(BoundKind.Local, syntax, type) { - Debug.Assert((object)localSymbol != null, "Field 'localSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(localSymbol is object, "Field 'localSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LocalSymbol = localSymbol; this.DeclarationKind = declarationKind; @@ -3977,17 +4066,19 @@ public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarat } + public new TypeSymbol Type => base.Type!; + public LocalSymbol LocalSymbol { get; } public BoundLocalDeclarationKind DeclarationKind { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } public bool IsNullableUnknown { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLocal(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLocal(this); - public BoundLocal Update(LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue constantValueOpt, bool isNullableUnknown, TypeSymbol type) + public BoundLocal Update(LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type) { if (localSymbol != this.LocalSymbol || declarationKind != this.DeclarationKind || constantValueOpt != this.ConstantValueOpt || isNullableUnknown != this.IsNullableUnknown || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -4012,9 +4103,9 @@ public BoundPseudoVariable(SyntaxNode syntax, LocalSymbol localSymbol, PseudoVar : base(BoundKind.PseudoVariable, syntax, type, hasErrors) { - Debug.Assert((object)localSymbol != null, "Field 'localSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)emitExpressions != null, "Field 'emitExpressions' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(localSymbol is object, "Field 'localSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(emitExpressions is object, "Field 'emitExpressions' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LocalSymbol = localSymbol; this.EmitExpressions = emitExpressions; @@ -4024,20 +4115,22 @@ public BoundPseudoVariable(SyntaxNode syntax, LocalSymbol localSymbol, PseudoVar : base(BoundKind.PseudoVariable, syntax, type) { - Debug.Assert((object)localSymbol != null, "Field 'localSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)emitExpressions != null, "Field 'emitExpressions' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(localSymbol is object, "Field 'localSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(emitExpressions is object, "Field 'emitExpressions' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.LocalSymbol = localSymbol; this.EmitExpressions = emitExpressions; } + public new TypeSymbol Type => base.Type!; + public LocalSymbol LocalSymbol { get; } public PseudoVariableExpressions EmitExpressions { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPseudoVariable(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPseudoVariable(this); public BoundPseudoVariable Update(LocalSymbol localSymbol, PseudoVariableExpressions emitExpressions, TypeSymbol type) { @@ -4064,20 +4157,22 @@ public BoundRangeVariable(SyntaxNode syntax, RangeVariableSymbol rangeVariableSy : base(BoundKind.RangeVariable, syntax, type, hasErrors || value.HasErrors()) { - Debug.Assert((object)rangeVariableSymbol != null, "Field 'rangeVariableSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(rangeVariableSymbol is object, "Field 'rangeVariableSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.RangeVariableSymbol = rangeVariableSymbol; this.Value = value; } + public new TypeSymbol Type => base.Type!; + public RangeVariableSymbol RangeVariableSymbol { get; } public BoundExpression Value { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitRangeVariable(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitRangeVariable(this); public BoundRangeVariable Update(RangeVariableSymbol rangeVariableSymbol, BoundExpression value, TypeSymbol type) { @@ -4104,8 +4199,8 @@ public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, TypeSy : base(BoundKind.Parameter, syntax, type, hasErrors) { - Debug.Assert((object)parameterSymbol != null, "Field 'parameterSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(parameterSymbol is object, "Field 'parameterSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ParameterSymbol = parameterSymbol; } @@ -4114,16 +4209,18 @@ public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, TypeSy : base(BoundKind.Parameter, syntax, type) { - Debug.Assert((object)parameterSymbol != null, "Field 'parameterSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(parameterSymbol is object, "Field 'parameterSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ParameterSymbol = parameterSymbol; } + public new TypeSymbol Type => base.Type!; + public ParameterSymbol ParameterSymbol { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitParameter(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitParameter(this); public BoundParameter Update(ParameterSymbol parameterSymbol, TypeSymbol type) { @@ -4150,7 +4247,7 @@ public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors) : base(BoundKind.LabelStatement, syntax, hasErrors) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -4159,7 +4256,7 @@ public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label) : base(BoundKind.LabelStatement, syntax) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -4167,7 +4264,7 @@ public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label) public LabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLabelStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLabelStatement(this); public BoundLabelStatement Update(LabelSymbol label) { @@ -4183,11 +4280,11 @@ public BoundLabelStatement Update(LabelSymbol label) internal sealed partial class BoundGotoStatement : BoundStatement { - public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression caseExpressionOpt, BoundLabel labelExpressionOpt, bool hasErrors = false) + public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt, bool hasErrors = false) : base(BoundKind.GotoStatement, syntax, hasErrors || caseExpressionOpt.HasErrors() || labelExpressionOpt.HasErrors()) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; this.CaseExpressionOpt = caseExpressionOpt; @@ -4197,13 +4294,13 @@ public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression public LabelSymbol Label { get; } - public BoundExpression CaseExpressionOpt { get; } + public BoundExpression? CaseExpressionOpt { get; } - public BoundLabel LabelExpressionOpt { get; } + public BoundLabel? LabelExpressionOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitGotoStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitGotoStatement(this); - public BoundGotoStatement Update(LabelSymbol label, BoundExpression caseExpressionOpt, BoundLabel labelExpressionOpt) + public BoundGotoStatement Update(LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt) { if (label != this.Label || caseExpressionOpt != this.CaseExpressionOpt || labelExpressionOpt != this.LabelExpressionOpt) { @@ -4221,8 +4318,8 @@ public BoundLabeledStatement(SyntaxNode syntax, LabelSymbol label, BoundStatemen : base(BoundKind.LabeledStatement, syntax, hasErrors || body.HasErrors()) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; this.Body = body; @@ -4233,7 +4330,7 @@ public BoundLabeledStatement(SyntaxNode syntax, LabelSymbol label, BoundStatemen public BoundStatement Body { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLabeledStatement(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLabeledStatement(this); public BoundLabeledStatement Update(LabelSymbol label, BoundStatement body) { @@ -4249,20 +4346,20 @@ public BoundLabeledStatement Update(LabelSymbol label, BoundStatement body) internal sealed partial class BoundLabel : BoundExpression { - public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol type, bool hasErrors) + public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type, bool hasErrors) : base(BoundKind.Label, syntax, type, hasErrors) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } - public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol type) + public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type) : base(BoundKind.Label, syntax, type) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -4270,9 +4367,9 @@ public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol type) public LabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLabel(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLabel(this); - public BoundLabel Update(LabelSymbol label, TypeSymbol type) + public BoundLabel Update(LabelSymbol label, TypeSymbol? type) { if (label != this.Label || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -4314,7 +4411,7 @@ public BoundStatementList(SyntaxNode syntax, ImmutableArray stat public ImmutableArray Statements { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitStatementList(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitStatementList(this); public BoundStatementList Update(ImmutableArray statements) { @@ -4334,8 +4431,8 @@ public BoundConditionalGoto(SyntaxNode syntax, BoundExpression condition, bool j : base(BoundKind.ConditionalGoto, syntax, hasErrors || condition.HasErrors()) { - Debug.Assert((object)condition != null, "Field 'condition' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(condition is object, "Field 'condition' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Condition = condition; this.JumpIfTrue = jumpIfTrue; @@ -4349,7 +4446,7 @@ public BoundConditionalGoto(SyntaxNode syntax, BoundExpression condition, bool j public LabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalGoto(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalGoto(this); public BoundConditionalGoto Update(BoundExpression condition, bool jumpIfTrue, LabelSymbol label) { @@ -4365,13 +4462,13 @@ public BoundConditionalGoto Update(BoundExpression condition, bool jumpIfTrue, L internal sealed partial class BoundSwitchExpression : BoundExpression { - public BoundSwitchExpression(SyntaxNode syntax, BoundExpression expression, ImmutableArray switchArms, BoundDecisionDag decisionDag, LabelSymbol defaultLabel, bool reportedNotExhaustive, TypeSymbol type, bool hasErrors = false) + public BoundSwitchExpression(SyntaxNode syntax, BoundExpression expression, ImmutableArray switchArms, BoundDecisionDag decisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.SwitchExpression, syntax, type, hasErrors || expression.HasErrors() || switchArms.HasErrors() || decisionDag.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!switchArms.IsDefault, "Field 'switchArms' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)decisionDag != null, "Field 'decisionDag' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(decisionDag is object, "Field 'decisionDag' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.SwitchArms = switchArms; @@ -4387,13 +4484,13 @@ public BoundSwitchExpression(SyntaxNode syntax, BoundExpression expression, Immu public BoundDecisionDag DecisionDag { get; } - public LabelSymbol DefaultLabel { get; } + public LabelSymbol? DefaultLabel { get; } public bool ReportedNotExhaustive { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchExpression(this); - public BoundSwitchExpression Update(BoundExpression expression, ImmutableArray switchArms, BoundDecisionDag decisionDag, LabelSymbol defaultLabel, bool reportedNotExhaustive, TypeSymbol type) + public BoundSwitchExpression Update(BoundExpression expression, ImmutableArray switchArms, BoundDecisionDag decisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type) { if (expression != this.Expression || switchArms != this.SwitchArms || decisionDag != this.DecisionDag || defaultLabel != this.DefaultLabel || reportedNotExhaustive != this.ReportedNotExhaustive || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -4414,14 +4511,14 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundSwitchExpressionArm : BoundNode { - public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray locals, BoundPattern pattern, BoundExpression whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false) + public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false) : base(BoundKind.SwitchExpressionArm, syntax, hasErrors || pattern.HasErrors() || whenClause.HasErrors() || value.HasErrors()) { Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)pattern != null, "Field 'pattern' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(pattern is object, "Field 'pattern' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.Pattern = pattern; @@ -4435,15 +4532,15 @@ public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray l public BoundPattern Pattern { get; } - public BoundExpression WhenClause { get; } + public BoundExpression? WhenClause { get; } public BoundExpression Value { get; } public LabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchExpressionArm(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchExpressionArm(this); - public BoundSwitchExpressionArm Update(ImmutableArray locals, BoundPattern pattern, BoundExpression whenClause, BoundExpression value, LabelSymbol label) + public BoundSwitchExpressionArm Update(ImmutableArray locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label) { if (locals != this.Locals || pattern != this.Pattern || whenClause != this.WhenClause || value != this.Value || label != this.Label) { @@ -4461,7 +4558,7 @@ public BoundDecisionDag(SyntaxNode syntax, BoundDecisionDagNode rootNode, bool h : base(BoundKind.DecisionDag, syntax, hasErrors) { - Debug.Assert((object)rootNode != null, "Field 'rootNode' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(rootNode is object, "Field 'rootNode' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.RootNode = rootNode; } @@ -4470,7 +4567,7 @@ public BoundDecisionDag(SyntaxNode syntax, BoundDecisionDagNode rootNode) : base(BoundKind.DecisionDag, syntax) { - Debug.Assert((object)rootNode != null, "Field 'rootNode' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(rootNode is object, "Field 'rootNode' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.RootNode = rootNode; } @@ -4478,7 +4575,7 @@ public BoundDecisionDag(SyntaxNode syntax, BoundDecisionDagNode rootNode) public BoundDecisionDagNode RootNode { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDecisionDag(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDecisionDag(this); public BoundDecisionDag Update(BoundDecisionDagNode rootNode) { @@ -4512,8 +4609,8 @@ public BoundEvaluationDecisionDagNode(SyntaxNode syntax, BoundDagEvaluation eval : base(BoundKind.EvaluationDecisionDagNode, syntax, hasErrors || evaluation.HasErrors() || next.HasErrors()) { - Debug.Assert((object)evaluation != null, "Field 'evaluation' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)next != null, "Field 'next' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(evaluation is object, "Field 'evaluation' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(next is object, "Field 'next' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Evaluation = evaluation; this.Next = next; @@ -4524,7 +4621,7 @@ public BoundEvaluationDecisionDagNode(SyntaxNode syntax, BoundDagEvaluation eval public BoundDecisionDagNode Next { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitEvaluationDecisionDagNode(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitEvaluationDecisionDagNode(this); public BoundEvaluationDecisionDagNode Update(BoundDagEvaluation evaluation, BoundDecisionDagNode next) { @@ -4544,9 +4641,9 @@ public BoundTestDecisionDagNode(SyntaxNode syntax, BoundDagTest test, BoundDecis : base(BoundKind.TestDecisionDagNode, syntax, hasErrors || test.HasErrors() || whenTrue.HasErrors() || whenFalse.HasErrors()) { - Debug.Assert((object)test != null, "Field 'test' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenTrue != null, "Field 'whenTrue' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenFalse != null, "Field 'whenFalse' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(test is object, "Field 'test' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(whenTrue is object, "Field 'whenTrue' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(whenFalse is object, "Field 'whenFalse' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Test = test; this.WhenTrue = whenTrue; @@ -4560,7 +4657,7 @@ public BoundTestDecisionDagNode(SyntaxNode syntax, BoundDagTest test, BoundDecis public BoundDecisionDagNode WhenFalse { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTestDecisionDagNode(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTestDecisionDagNode(this); public BoundTestDecisionDagNode Update(BoundDagTest test, BoundDecisionDagNode whenTrue, BoundDecisionDagNode whenFalse) { @@ -4576,12 +4673,12 @@ public BoundTestDecisionDagNode Update(BoundDagTest test, BoundDecisionDagNode internal sealed partial class BoundWhenDecisionDagNode : BoundDecisionDagNode { - public BoundWhenDecisionDagNode(SyntaxNode syntax, ImmutableArray bindings, BoundExpression whenExpression, BoundDecisionDagNode whenTrue, BoundDecisionDagNode whenFalse, bool hasErrors = false) + public BoundWhenDecisionDagNode(SyntaxNode syntax, ImmutableArray bindings, BoundExpression? whenExpression, BoundDecisionDagNode whenTrue, BoundDecisionDagNode ? whenFalse, bool hasErrors = false) : base(BoundKind.WhenDecisionDagNode, syntax, hasErrors || whenExpression.HasErrors() || whenTrue.HasErrors() || whenFalse.HasErrors()) { Debug.Assert(!bindings.IsDefault, "Field 'bindings' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenTrue != null, "Field 'whenTrue' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(whenTrue is object, "Field 'whenTrue' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Bindings = bindings; this.WhenExpression = whenExpression; @@ -4592,15 +4689,15 @@ public BoundWhenDecisionDagNode(SyntaxNode syntax, ImmutableArray Bindings { get; } - public BoundExpression WhenExpression { get; } + public BoundExpression? WhenExpression { get; } public BoundDecisionDagNode WhenTrue { get; } - public BoundDecisionDagNode WhenFalse { get; } + public BoundDecisionDagNode ? WhenFalse { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitWhenDecisionDagNode(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitWhenDecisionDagNode(this); - public BoundWhenDecisionDagNode Update(ImmutableArray bindings, BoundExpression whenExpression, BoundDecisionDagNode whenTrue, BoundDecisionDagNode whenFalse) + public BoundWhenDecisionDagNode Update(ImmutableArray bindings, BoundExpression? whenExpression, BoundDecisionDagNode whenTrue, BoundDecisionDagNode ? whenFalse) { if (bindings != this.Bindings || whenExpression != this.WhenExpression || whenTrue != this.WhenTrue || whenFalse != this.WhenFalse) { @@ -4618,7 +4715,7 @@ public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label, bool hasEr : base(BoundKind.LeafDecisionDagNode, syntax, hasErrors) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -4627,7 +4724,7 @@ public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label) : base(BoundKind.LeafDecisionDagNode, syntax) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; } @@ -4635,7 +4732,7 @@ public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label) public LabelSymbol Label { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLeafDecisionDagNode(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLeafDecisionDagNode(this); public BoundLeafDecisionDagNode Update(LabelSymbol label) { @@ -4655,7 +4752,7 @@ protected BoundDagTest(BoundKind kind, SyntaxNode syntax, BoundDagTemp input, bo : base(kind, syntax, hasErrors) { - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Input = input; } @@ -4666,11 +4763,11 @@ protected BoundDagTest(BoundKind kind, SyntaxNode syntax, BoundDagTemp input, bo internal sealed partial class BoundDagTemp : BoundNode { - public BoundDagTemp(SyntaxNode syntax, TypeSymbol type, BoundDagEvaluation source, int index, bool hasErrors = false) + public BoundDagTemp(SyntaxNode syntax, TypeSymbol type, BoundDagEvaluation? source, int index, bool hasErrors = false) : base(BoundKind.DagTemp, syntax, hasErrors || source.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Type = type; this.Source = source; @@ -4680,13 +4777,13 @@ public BoundDagTemp(SyntaxNode syntax, TypeSymbol type, BoundDagEvaluation sourc public TypeSymbol Type { get; } - public BoundDagEvaluation Source { get; } + public BoundDagEvaluation? Source { get; } public int Index { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagTemp(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagTemp(this); - public BoundDagTemp Update(TypeSymbol type, BoundDagEvaluation source, int index) + public BoundDagTemp Update(TypeSymbol type, BoundDagEvaluation? source, int index) { if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything) || source != this.Source || index != this.Index) { @@ -4704,8 +4801,8 @@ public BoundDagTypeTest(SyntaxNode syntax, TypeSymbol type, BoundDagTemp input, : base(BoundKind.DagTypeTest, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Type = type; } @@ -4713,7 +4810,7 @@ public BoundDagTypeTest(SyntaxNode syntax, TypeSymbol type, BoundDagTemp input, public TypeSymbol Type { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagTypeTest(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagTypeTest(this); public BoundDagTypeTest Update(TypeSymbol type, BoundDagTemp input) { @@ -4733,12 +4830,12 @@ public BoundDagNonNullTest(SyntaxNode syntax, BoundDagTemp input, bool hasErrors : base(BoundKind.DagNonNullTest, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagNonNullTest(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagNonNullTest(this); public BoundDagNonNullTest Update(BoundDagTemp input) { @@ -4758,12 +4855,12 @@ public BoundDagExplicitNullTest(SyntaxNode syntax, BoundDagTemp input, bool hasE : base(BoundKind.DagExplicitNullTest, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagExplicitNullTest(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagExplicitNullTest(this); public BoundDagExplicitNullTest Update(BoundDagTemp input) { @@ -4783,8 +4880,8 @@ public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp in : base(BoundKind.DagValueTest, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Value = value; } @@ -4792,7 +4889,7 @@ public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp in public ConstantValue Value { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagValueTest(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagValueTest(this); public BoundDagValueTest Update(ConstantValue value, BoundDagTemp input) { @@ -4812,7 +4909,7 @@ protected BoundDagEvaluation(BoundKind kind, SyntaxNode syntax, BoundDagTemp inp : base(kind, syntax, input, hasErrors) { - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -4824,8 +4921,8 @@ public BoundDagDeconstructEvaluation(SyntaxNode syntax, MethodSymbol deconstruct : base(BoundKind.DagDeconstructEvaluation, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)deconstructMethod != null, "Field 'deconstructMethod' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(deconstructMethod is object, "Field 'deconstructMethod' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.DeconstructMethod = deconstructMethod; } @@ -4833,7 +4930,7 @@ public BoundDagDeconstructEvaluation(SyntaxNode syntax, MethodSymbol deconstruct public MethodSymbol DeconstructMethod { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagDeconstructEvaluation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagDeconstructEvaluation(this); public BoundDagDeconstructEvaluation Update(MethodSymbol deconstructMethod, BoundDagTemp input) { @@ -4853,8 +4950,8 @@ public BoundDagTypeEvaluation(SyntaxNode syntax, TypeSymbol type, BoundDagTemp i : base(BoundKind.DagTypeEvaluation, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Type = type; } @@ -4862,7 +4959,7 @@ public BoundDagTypeEvaluation(SyntaxNode syntax, TypeSymbol type, BoundDagTemp i public TypeSymbol Type { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagTypeEvaluation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagTypeEvaluation(this); public BoundDagTypeEvaluation Update(TypeSymbol type, BoundDagTemp input) { @@ -4882,8 +4979,8 @@ public BoundDagFieldEvaluation(SyntaxNode syntax, FieldSymbol field, BoundDagTem : base(BoundKind.DagFieldEvaluation, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)field != null, "Field 'field' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(field is object, "Field 'field' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Field = field; } @@ -4891,7 +4988,7 @@ public BoundDagFieldEvaluation(SyntaxNode syntax, FieldSymbol field, BoundDagTem public FieldSymbol Field { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagFieldEvaluation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagFieldEvaluation(this); public BoundDagFieldEvaluation Update(FieldSymbol field, BoundDagTemp input) { @@ -4911,8 +5008,8 @@ public BoundDagPropertyEvaluation(SyntaxNode syntax, PropertySymbol property, Bo : base(BoundKind.DagPropertyEvaluation, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)property != null, "Field 'property' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(property is object, "Field 'property' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Property = property; } @@ -4920,7 +5017,7 @@ public BoundDagPropertyEvaluation(SyntaxNode syntax, PropertySymbol property, Bo public PropertySymbol Property { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagPropertyEvaluation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagPropertyEvaluation(this); public BoundDagPropertyEvaluation Update(PropertySymbol property, BoundDagTemp input) { @@ -4940,8 +5037,8 @@ public BoundDagIndexEvaluation(SyntaxNode syntax, PropertySymbol property, int i : base(BoundKind.DagIndexEvaluation, syntax, input, hasErrors || input.HasErrors()) { - Debug.Assert((object)property != null, "Field 'property' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)input != null, "Field 'input' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(property is object, "Field 'property' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(input is object, "Field 'input' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Property = property; this.Index = index; @@ -4952,7 +5049,7 @@ public BoundDagIndexEvaluation(SyntaxNode syntax, PropertySymbol property, int i public int Index { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDagIndexEvaluation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDagIndexEvaluation(this); public BoundDagIndexEvaluation Update(PropertySymbol property, int index, BoundDagTemp input) { @@ -4985,7 +5082,7 @@ public BoundSwitchSection(SyntaxNode syntax, ImmutableArray locals, public ImmutableArray SwitchLabels { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchSection(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchSection(this); public BoundSwitchSection Update(ImmutableArray locals, ImmutableArray switchLabels, ImmutableArray statements) { @@ -5001,12 +5098,12 @@ public BoundSwitchSection Update(ImmutableArray locals, ImmutableAr internal sealed partial class BoundSwitchLabel : BoundNode { - public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, BoundExpression whenClause, bool hasErrors = false) + public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause, bool hasErrors = false) : base(BoundKind.SwitchLabel, syntax, hasErrors || pattern.HasErrors() || whenClause.HasErrors()) { - Debug.Assert((object)label != null, "Field 'label' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)pattern != null, "Field 'pattern' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(label is object, "Field 'label' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(pattern is object, "Field 'pattern' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Label = label; this.Pattern = pattern; @@ -5018,11 +5115,11 @@ public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern patte public BoundPattern Pattern { get; } - public BoundExpression WhenClause { get; } + public BoundExpression? WhenClause { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchLabel(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSwitchLabel(this); - public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, BoundExpression whenClause) + public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause) { if (label != this.Label || pattern != this.Pattern || whenClause != this.WhenClause) { @@ -5036,7 +5133,7 @@ public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, BoundExp internal abstract partial class BoundMethodOrPropertyGroup : BoundExpression { - protected BoundMethodOrPropertyGroup(BoundKind kind, SyntaxNode syntax, BoundExpression receiverOpt, LookupResultKind resultKind, bool hasErrors = false) + protected BoundMethodOrPropertyGroup(BoundKind kind, SyntaxNode syntax, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false) : base(kind, syntax, null, hasErrors) { this.ReceiverOpt = receiverOpt; @@ -5044,7 +5141,9 @@ protected BoundMethodOrPropertyGroup(BoundKind kind, SyntaxNode syntax, BoundExp } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } @@ -5052,11 +5151,11 @@ protected BoundMethodOrPropertyGroup(BoundKind kind, SyntaxNode syntax, BoundExp internal sealed partial class BoundSequencePointExpression : BoundExpression { - public BoundSequencePointExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol type, bool hasErrors = false) + public BoundSequencePointExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.SequencePointExpression, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } @@ -5064,9 +5163,9 @@ public BoundSequencePointExpression(SyntaxNode syntax, BoundExpression expressio public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePointExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSequencePointExpression(this); - public BoundSequencePointExpression Update(BoundExpression expression, TypeSymbol type) + public BoundSequencePointExpression Update(BoundExpression expression, TypeSymbol? type) { if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5093,8 +5192,8 @@ public BoundSequence(SyntaxNode syntax, ImmutableArray locals, Immu Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!sideEffects.IsDefault, "Field 'sideEffects' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.SideEffects = sideEffects; @@ -5102,13 +5201,15 @@ public BoundSequence(SyntaxNode syntax, ImmutableArray locals, Immu } + public new TypeSymbol Type => base.Type!; + public ImmutableArray Locals { get; } public ImmutableArray SideEffects { get; } public BoundExpression Value { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSequence(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSequence(this); public BoundSequence Update(ImmutableArray locals, ImmutableArray sideEffects, BoundExpression value, TypeSymbol type) { @@ -5137,8 +5238,8 @@ public BoundSpillSequence(SyntaxNode syntax, ImmutableArray locals, Debug.Assert(!locals.IsDefault, "Field 'locals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!sideEffects.IsDefault, "Field 'sideEffects' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Locals = locals; this.SideEffects = sideEffects; @@ -5146,13 +5247,15 @@ public BoundSpillSequence(SyntaxNode syntax, ImmutableArray locals, } + public new TypeSymbol Type => base.Type!; + public ImmutableArray Locals { get; } public ImmutableArray SideEffects { get; } public BoundExpression Value { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSpillSequence(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSpillSequence(this); public BoundSpillSequence Update(ImmutableArray locals, ImmutableArray sideEffects, BoundExpression value, TypeSymbol type) { @@ -5179,9 +5282,9 @@ public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, Imm : base(BoundKind.DynamicMemberAccess, syntax, type, hasErrors || receiver.HasErrors()) { - Debug.Assert((object)receiver != null, "Field 'receiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)name != null, "Field 'name' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(receiver is object, "Field 'receiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(name is object, "Field 'name' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Receiver = receiver; this.TypeArgumentsOpt = typeArgumentsOpt; @@ -5191,6 +5294,8 @@ public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, Imm } + public new TypeSymbol Type => base.Type!; + public BoundExpression Receiver { get; } public ImmutableArray TypeArgumentsOpt { get; } @@ -5201,7 +5306,7 @@ public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, Imm public bool Indexed { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicMemberAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicMemberAccess(this); public BoundDynamicMemberAccess Update(BoundExpression receiver, ImmutableArray typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type) { @@ -5224,11 +5329,11 @@ protected override BoundExpression ShallowClone() internal abstract partial class BoundDynamicInvocableBase : BoundExpression { - protected BoundDynamicInvocableBase(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray arguments, TypeSymbol type, bool hasErrors = false) + protected BoundDynamicInvocableBase(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray arguments, TypeSymbol? type, bool hasErrors = false) : base(kind, syntax, type, hasErrors) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); this.Expression = expression; @@ -5248,9 +5353,9 @@ public BoundDynamicInvocation(SyntaxNode syntax, ImmutableArray argument { Debug.Assert(!applicableMethods.IsDefault, "Field 'applicableMethods' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ArgumentNamesOpt = argumentNamesOpt; this.ArgumentRefKindsOpt = argumentRefKindsOpt; @@ -5258,13 +5363,15 @@ public BoundDynamicInvocation(SyntaxNode syntax, ImmutableArray argument } + public new TypeSymbol Type => base.Type!; + public ImmutableArray ArgumentNamesOpt { get; } public ImmutableArray ArgumentRefKindsOpt { get; } public ImmutableArray ApplicableMethods { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicInvocation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicInvocation(this); public BoundDynamicInvocation Update(ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, ImmutableArray applicableMethods, BoundExpression expression, ImmutableArray arguments, TypeSymbol type) { @@ -5291,20 +5398,22 @@ public BoundConditionalAccess(SyntaxNode syntax, BoundExpression receiver, Bound : base(BoundKind.ConditionalAccess, syntax, type, hasErrors || receiver.HasErrors() || accessExpression.HasErrors()) { - Debug.Assert((object)receiver != null, "Field 'receiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)accessExpression != null, "Field 'accessExpression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(receiver is object, "Field 'receiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(accessExpression is object, "Field 'accessExpression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Receiver = receiver; this.AccessExpression = accessExpression; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Receiver { get; } public BoundExpression AccessExpression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalAccess(this); public BoundConditionalAccess Update(BoundExpression receiver, BoundExpression accessExpression, TypeSymbol type) { @@ -5327,13 +5436,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundLoweredConditionalAccess : BoundExpression { - public BoundLoweredConditionalAccess(SyntaxNode syntax, BoundExpression receiver, MethodSymbol hasValueMethodOpt, BoundExpression whenNotNull, BoundExpression whenNullOpt, int id, TypeSymbol type, bool hasErrors = false) + public BoundLoweredConditionalAccess(SyntaxNode syntax, BoundExpression receiver, MethodSymbol? hasValueMethodOpt, BoundExpression whenNotNull, BoundExpression? whenNullOpt, int id, TypeSymbol type, bool hasErrors = false) : base(BoundKind.LoweredConditionalAccess, syntax, type, hasErrors || receiver.HasErrors() || whenNotNull.HasErrors() || whenNullOpt.HasErrors()) { - Debug.Assert((object)receiver != null, "Field 'receiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenNotNull != null, "Field 'whenNotNull' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(receiver is object, "Field 'receiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(whenNotNull is object, "Field 'whenNotNull' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Receiver = receiver; this.HasValueMethodOpt = hasValueMethodOpt; @@ -5343,19 +5452,21 @@ public BoundLoweredConditionalAccess(SyntaxNode syntax, BoundExpression receiver } + public new TypeSymbol Type => base.Type!; + public BoundExpression Receiver { get; } - public MethodSymbol HasValueMethodOpt { get; } + public MethodSymbol? HasValueMethodOpt { get; } public BoundExpression WhenNotNull { get; } - public BoundExpression WhenNullOpt { get; } + public BoundExpression? WhenNullOpt { get; } public int Id { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLoweredConditionalAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLoweredConditionalAccess(this); - public BoundLoweredConditionalAccess Update(BoundExpression receiver, MethodSymbol hasValueMethodOpt, BoundExpression whenNotNull, BoundExpression whenNullOpt, int id, TypeSymbol type) + public BoundLoweredConditionalAccess Update(BoundExpression receiver, MethodSymbol? hasValueMethodOpt, BoundExpression whenNotNull, BoundExpression? whenNullOpt, int id, TypeSymbol type) { if (receiver != this.Receiver || hasValueMethodOpt != this.HasValueMethodOpt || whenNotNull != this.WhenNotNull || whenNullOpt != this.WhenNullOpt || id != this.Id || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5380,7 +5491,7 @@ public BoundConditionalReceiver(SyntaxNode syntax, int id, TypeSymbol type, bool : base(BoundKind.ConditionalReceiver, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Id = id; } @@ -5389,15 +5500,17 @@ public BoundConditionalReceiver(SyntaxNode syntax, int id, TypeSymbol type) : base(BoundKind.ConditionalReceiver, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Id = id; } + public new TypeSymbol Type => base.Type!; + public int Id { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalReceiver(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConditionalReceiver(this); public BoundConditionalReceiver Update(int id, TypeSymbol type) { @@ -5424,20 +5537,22 @@ public BoundComplexConditionalReceiver(SyntaxNode syntax, BoundExpression valueT : base(BoundKind.ComplexConditionalReceiver, syntax, type, hasErrors || valueTypeReceiver.HasErrors() || referenceTypeReceiver.HasErrors()) { - Debug.Assert((object)valueTypeReceiver != null, "Field 'valueTypeReceiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)referenceTypeReceiver != null, "Field 'referenceTypeReceiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(valueTypeReceiver is object, "Field 'valueTypeReceiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(referenceTypeReceiver is object, "Field 'referenceTypeReceiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ValueTypeReceiver = valueTypeReceiver; this.ReferenceTypeReceiver = referenceTypeReceiver; } + public new TypeSymbol Type => base.Type!; + public BoundExpression ValueTypeReceiver { get; } public BoundExpression ReferenceTypeReceiver { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitComplexConditionalReceiver(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitComplexConditionalReceiver(this); public BoundComplexConditionalReceiver Update(BoundExpression valueTypeReceiver, BoundExpression referenceTypeReceiver, TypeSymbol type) { @@ -5460,11 +5575,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundMethodGroup : BoundMethodOrPropertyGroup { - public BoundMethodGroup(SyntaxNode syntax, ImmutableArray typeArgumentsOpt, string name, ImmutableArray methods, Symbol lookupSymbolOpt, DiagnosticInfo lookupError, BoundMethodGroupFlags flags, BoundExpression receiverOpt, LookupResultKind resultKind, bool hasErrors = false) + public BoundMethodGroup(SyntaxNode syntax, ImmutableArray typeArgumentsOpt, string name, ImmutableArray methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false) : base(BoundKind.MethodGroup, syntax, receiverOpt, resultKind, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)name != null, "Field 'name' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(name is object, "Field 'name' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!methods.IsDefault, "Field 'methods' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); this.TypeArgumentsOpt = typeArgumentsOpt; @@ -5482,15 +5597,15 @@ public BoundMethodGroup(SyntaxNode syntax, ImmutableArray t public ImmutableArray Methods { get; } - public Symbol LookupSymbolOpt { get; } + public Symbol? LookupSymbolOpt { get; } - public DiagnosticInfo LookupError { get; } + public DiagnosticInfo? LookupError { get; } - public BoundMethodGroupFlags Flags { get; } + public BoundMethodGroupFlags? Flags { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitMethodGroup(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitMethodGroup(this); - public BoundMethodGroup Update(ImmutableArray typeArgumentsOpt, string name, ImmutableArray methods, Symbol lookupSymbolOpt, DiagnosticInfo lookupError, BoundMethodGroupFlags flags, BoundExpression receiverOpt, LookupResultKind resultKind) + public BoundMethodGroup Update(ImmutableArray typeArgumentsOpt, string name, ImmutableArray methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, BoundExpression? receiverOpt, LookupResultKind resultKind) { if (typeArgumentsOpt != this.TypeArgumentsOpt || name != this.Name || methods != this.Methods || lookupSymbolOpt != this.LookupSymbolOpt || lookupError != this.LookupError || flags != this.Flags || receiverOpt != this.ReceiverOpt || resultKind != this.ResultKind) { @@ -5511,7 +5626,7 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundPropertyGroup : BoundMethodOrPropertyGroup { - public BoundPropertyGroup(SyntaxNode syntax, ImmutableArray properties, BoundExpression receiverOpt, LookupResultKind resultKind, bool hasErrors = false) + public BoundPropertyGroup(SyntaxNode syntax, ImmutableArray properties, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false) : base(BoundKind.PropertyGroup, syntax, receiverOpt, resultKind, hasErrors || receiverOpt.HasErrors()) { @@ -5523,9 +5638,9 @@ public BoundPropertyGroup(SyntaxNode syntax, ImmutableArray prop public ImmutableArray Properties { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyGroup(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyGroup(this); - public BoundPropertyGroup Update(ImmutableArray properties, BoundExpression receiverOpt, LookupResultKind resultKind) + public BoundPropertyGroup Update(ImmutableArray properties, BoundExpression? receiverOpt, LookupResultKind resultKind) { if (properties != this.Properties || receiverOpt != this.ReceiverOpt || resultKind != this.ResultKind) { @@ -5546,13 +5661,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundCall : BoundExpression { - public BoundCall(SyntaxNode syntax, BoundExpression receiverOpt, MethodSymbol method, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, Binder binderOpt, TypeSymbol type, bool hasErrors = false) + public BoundCall(SyntaxNode syntax, BoundExpression? receiverOpt, MethodSymbol method, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, Binder? binderOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.Call, syntax, type, hasErrors || receiverOpt.HasErrors() || arguments.HasErrors()) { - Debug.Assert((object)method != null, "Field 'method' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(method is object, "Field 'method' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.Method = method; @@ -5568,7 +5683,9 @@ public BoundCall(SyntaxNode syntax, BoundExpression receiverOpt, MethodSymbol me } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public MethodSymbol Method { get; } @@ -5589,11 +5706,11 @@ public BoundCall(SyntaxNode syntax, BoundExpression receiverOpt, MethodSymbol me private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } - public Binder BinderOpt { get; } + public Binder? BinderOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitCall(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitCall(this); - public BoundCall Update(BoundExpression receiverOpt, MethodSymbol method, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, Binder binderOpt, TypeSymbol type) + public BoundCall Update(BoundExpression? receiverOpt, MethodSymbol method, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, Binder? binderOpt, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || method != this.Method || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || isDelegateCall != this.IsDelegateCall || expanded != this.Expanded || invokedAsExtensionMethod != this.InvokedAsExtensionMethod || argsToParamsOpt != this.ArgsToParamsOpt || resultKind != this.ResultKind || binderOpt != this.BinderOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5614,13 +5731,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundEventAssignmentOperator : BoundExpression { - public BoundEventAssignmentOperator(SyntaxNode syntax, EventSymbol @event, bool isAddition, bool isDynamic, BoundExpression receiverOpt, BoundExpression argument, TypeSymbol type, bool hasErrors = false) + public BoundEventAssignmentOperator(SyntaxNode syntax, EventSymbol @event, bool isAddition, bool isDynamic, BoundExpression? receiverOpt, BoundExpression argument, TypeSymbol type, bool hasErrors = false) : base(BoundKind.EventAssignmentOperator, syntax, type, hasErrors || receiverOpt.HasErrors() || argument.HasErrors()) { - Debug.Assert((object)@event != null, "Field '@event' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)argument != null, "Field 'argument' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(@event is object, "Field '@event' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(argument is object, "Field 'argument' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Event = @event; this.IsAddition = isAddition; @@ -5630,19 +5747,21 @@ public BoundEventAssignmentOperator(SyntaxNode syntax, EventSymbol @event, bool } + public new TypeSymbol Type => base.Type!; + public EventSymbol Event { get; } public bool IsAddition { get; } public bool IsDynamic { get; } - public BoundExpression ReceiverOpt { get; } + public BoundExpression? ReceiverOpt { get; } public BoundExpression Argument { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitEventAssignmentOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitEventAssignmentOperator(this); - public BoundEventAssignmentOperator Update(EventSymbol @event, bool isAddition, bool isDynamic, BoundExpression receiverOpt, BoundExpression argument, TypeSymbol type) + public BoundEventAssignmentOperator Update(EventSymbol @event, bool isAddition, bool isDynamic, BoundExpression? receiverOpt, BoundExpression argument, TypeSymbol type) { if (@event != this.Event || isAddition != this.IsAddition || isDynamic != this.IsDynamic || receiverOpt != this.ReceiverOpt || argument != this.Argument || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5663,13 +5782,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundAttribute : BoundExpression { - public BoundAttribute(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray constructorArguments, ImmutableArray constructorArgumentNamesOpt, ImmutableArray constructorArgumentsToParamsOpt, bool constructorExpanded, ImmutableArray namedArguments, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) + public BoundAttribute(SyntaxNode syntax, MethodSymbol? constructor, ImmutableArray constructorArguments, ImmutableArray constructorArgumentNamesOpt, ImmutableArray constructorArgumentsToParamsOpt, bool constructorExpanded, ImmutableArray namedArguments, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.Attribute, syntax, type, hasErrors || constructorArguments.HasErrors() || namedArguments.HasErrors()) { Debug.Assert(!constructorArguments.IsDefault, "Field 'constructorArguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!namedArguments.IsDefault, "Field 'namedArguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Constructor = constructor; this.ConstructorArguments = constructorArguments; @@ -5681,7 +5800,9 @@ public BoundAttribute(SyntaxNode syntax, MethodSymbol constructor, ImmutableArra } - public MethodSymbol Constructor { get; } + public new TypeSymbol Type => base.Type!; + + public MethodSymbol? Constructor { get; } public ImmutableArray ConstructorArguments { get; } @@ -5696,9 +5817,9 @@ public BoundAttribute(SyntaxNode syntax, MethodSymbol constructor, ImmutableArra private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAttribute(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAttribute(this); - public BoundAttribute Update(MethodSymbol constructor, ImmutableArray constructorArguments, ImmutableArray constructorArgumentNamesOpt, ImmutableArray constructorArgumentsToParamsOpt, bool constructorExpanded, ImmutableArray namedArguments, LookupResultKind resultKind, TypeSymbol type) + public BoundAttribute Update(MethodSymbol? constructor, ImmutableArray constructorArguments, ImmutableArray constructorArgumentNamesOpt, ImmutableArray constructorArgumentsToParamsOpt, bool constructorExpanded, ImmutableArray namedArguments, LookupResultKind resultKind, TypeSymbol type) { if (constructor != this.Constructor || constructorArguments != this.ConstructorArguments || constructorArgumentNamesOpt != this.ConstructorArgumentNamesOpt || constructorArgumentsToParamsOpt != this.ConstructorArgumentsToParamsOpt || constructorExpanded != this.ConstructorExpanded || namedArguments != this.NamedArguments || resultKind != this.ResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5719,14 +5840,14 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundObjectCreationExpression : BoundExpression { - public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray constructorsGroup, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, ConstantValue constantValueOpt, BoundObjectInitializerExpressionBase initializerExpressionOpt, Binder binderOpt, TypeSymbol type, bool hasErrors = false) + public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray constructorsGroup, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, Binder? binderOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.ObjectCreationExpression, syntax, type, hasErrors || arguments.HasErrors() || initializerExpressionOpt.HasErrors()) { - Debug.Assert((object)constructor != null, "Field 'constructor' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(constructor is object, "Field 'constructor' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!constructorsGroup.IsDefault, "Field 'constructorsGroup' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Constructor = constructor; this.ConstructorsGroup = constructorsGroup; @@ -5741,6 +5862,8 @@ public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor } + public new TypeSymbol Type => base.Type!; + public MethodSymbol Constructor { get; } public ImmutableArray ConstructorsGroup { get; } @@ -5755,15 +5878,15 @@ public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor public ImmutableArray ArgsToParamsOpt { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } - public BoundObjectInitializerExpressionBase InitializerExpressionOpt { get; } + public BoundObjectInitializerExpressionBase? InitializerExpressionOpt { get; } - public Binder BinderOpt { get; } + public Binder? BinderOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitObjectCreationExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitObjectCreationExpression(this); - public BoundObjectCreationExpression Update(MethodSymbol constructor, ImmutableArray constructorsGroup, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, ConstantValue constantValueOpt, BoundObjectInitializerExpressionBase initializerExpressionOpt, Binder binderOpt, TypeSymbol type) + public BoundObjectCreationExpression Update(MethodSymbol constructor, ImmutableArray constructorsGroup, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, Binder? binderOpt, TypeSymbol type) { if (constructor != this.Constructor || constructorsGroup != this.ConstructorsGroup || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || expanded != this.Expanded || argsToParamsOpt != this.ArgsToParamsOpt || constantValueOpt != this.ConstantValueOpt || initializerExpressionOpt != this.InitializerExpressionOpt || binderOpt != this.BinderOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5784,7 +5907,7 @@ protected override BoundExpression ShallowClone() internal abstract partial class BoundTupleExpression : BoundExpression { - protected BoundTupleExpression(BoundKind kind, SyntaxNode syntax, ImmutableArray arguments, TypeSymbol type, bool hasErrors = false) + protected BoundTupleExpression(BoundKind kind, SyntaxNode syntax, ImmutableArray arguments, TypeSymbol? type, bool hasErrors = false) : base(kind, syntax, type, hasErrors) { @@ -5799,7 +5922,7 @@ protected BoundTupleExpression(BoundKind kind, SyntaxNode syntax, ImmutableArray internal sealed partial class BoundTupleLiteral : BoundTupleExpression { - public BoundTupleLiteral(SyntaxNode syntax, ImmutableArray argumentNamesOpt, ImmutableArray inferredNamesOpt, ImmutableArray arguments, TypeSymbol type, bool hasErrors = false) + public BoundTupleLiteral(SyntaxNode syntax, ImmutableArray argumentNamesOpt, ImmutableArray inferredNamesOpt, ImmutableArray arguments, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.TupleLiteral, syntax, arguments, type, hasErrors || arguments.HasErrors()) { @@ -5810,13 +5933,15 @@ public BoundTupleLiteral(SyntaxNode syntax, ImmutableArray argumentNames } + public new TypeSymbol? Type => base.Type!; + public ImmutableArray ArgumentNamesOpt { get; } public ImmutableArray InferredNamesOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitTupleLiteral(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTupleLiteral(this); - public BoundTupleLiteral Update(ImmutableArray argumentNamesOpt, ImmutableArray inferredNamesOpt, ImmutableArray arguments, TypeSymbol type) + public BoundTupleLiteral Update(ImmutableArray argumentNamesOpt, ImmutableArray inferredNamesOpt, ImmutableArray arguments, TypeSymbol? type) { if (argumentNamesOpt != this.ArgumentNamesOpt || inferredNamesOpt != this.InferredNamesOpt || arguments != this.Arguments || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5841,17 +5966,19 @@ public BoundConvertedTupleLiteral(SyntaxNode syntax, BoundTupleLiteral sourceTup : base(BoundKind.ConvertedTupleLiteral, syntax, arguments, type, hasErrors || sourceTuple.HasErrors() || arguments.HasErrors()) { - Debug.Assert((object)sourceTuple != null, "Field 'sourceTuple' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(sourceTuple is object, "Field 'sourceTuple' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.SourceTuple = sourceTuple; } + public new TypeSymbol Type => base.Type!; + public BoundTupleLiteral SourceTuple { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConvertedTupleLiteral(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConvertedTupleLiteral(this); public BoundConvertedTupleLiteral Update(BoundTupleLiteral sourceTuple, ImmutableArray arguments, TypeSymbol type) { @@ -5874,14 +6001,14 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundDynamicObjectCreationExpression : BoundExpression { - public BoundDynamicObjectCreationExpression(SyntaxNode syntax, string name, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, BoundObjectInitializerExpressionBase initializerExpressionOpt, ImmutableArray applicableMethods, TypeSymbol type, bool hasErrors = false) + public BoundDynamicObjectCreationExpression(SyntaxNode syntax, string name, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, ImmutableArray applicableMethods, TypeSymbol type, bool hasErrors = false) : base(BoundKind.DynamicObjectCreationExpression, syntax, type, hasErrors || arguments.HasErrors() || initializerExpressionOpt.HasErrors()) { - Debug.Assert((object)name != null, "Field 'name' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(name is object, "Field 'name' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!applicableMethods.IsDefault, "Field 'applicableMethods' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Name = name; this.Arguments = arguments; @@ -5892,6 +6019,8 @@ public BoundDynamicObjectCreationExpression(SyntaxNode syntax, string name, Immu } + public new TypeSymbol Type => base.Type!; + public string Name { get; } public ImmutableArray Arguments { get; } @@ -5900,13 +6029,13 @@ public BoundDynamicObjectCreationExpression(SyntaxNode syntax, string name, Immu public ImmutableArray ArgumentRefKindsOpt { get; } - public BoundObjectInitializerExpressionBase InitializerExpressionOpt { get; } + public BoundObjectInitializerExpressionBase? InitializerExpressionOpt { get; } public ImmutableArray ApplicableMethods { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicObjectCreationExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicObjectCreationExpression(this); - public BoundDynamicObjectCreationExpression Update(string name, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, BoundObjectInitializerExpressionBase initializerExpressionOpt, ImmutableArray applicableMethods, TypeSymbol type) + public BoundDynamicObjectCreationExpression Update(string name, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, ImmutableArray applicableMethods, TypeSymbol type) { if (name != this.Name || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || initializerExpressionOpt != this.InitializerExpressionOpt || applicableMethods != this.ApplicableMethods || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5927,24 +6056,26 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundNoPiaObjectCreationExpression : BoundExpression { - public BoundNoPiaObjectCreationExpression(SyntaxNode syntax, string guidString, BoundObjectInitializerExpressionBase initializerExpressionOpt, TypeSymbol type, bool hasErrors = false) + public BoundNoPiaObjectCreationExpression(SyntaxNode syntax, string? guidString, BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.NoPiaObjectCreationExpression, syntax, type, hasErrors || initializerExpressionOpt.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.GuidString = guidString; this.InitializerExpressionOpt = initializerExpressionOpt; } - public string GuidString { get; } + public new TypeSymbol Type => base.Type!; - public BoundObjectInitializerExpressionBase InitializerExpressionOpt { get; } + public string? GuidString { get; } + + public BoundObjectInitializerExpressionBase? InitializerExpressionOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNoPiaObjectCreationExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNoPiaObjectCreationExpression(this); - public BoundNoPiaObjectCreationExpression Update(string guidString, BoundObjectInitializerExpressionBase initializerExpressionOpt, TypeSymbol type) + public BoundNoPiaObjectCreationExpression Update(string? guidString, BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type) { if (guidString != this.GuidString || initializerExpressionOpt != this.InitializerExpressionOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -5970,12 +6101,14 @@ protected BoundObjectInitializerExpressionBase(BoundKind kind, SyntaxNode syntax { Debug.Assert(!initializers.IsDefault, "Field 'initializers' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Initializers = initializers; } + public new TypeSymbol Type => base.Type!; + public ImmutableArray Initializers { get; } } @@ -5986,12 +6119,12 @@ public BoundObjectInitializerExpression(SyntaxNode syntax, ImmutableArray visitor.VisitObjectInitializerExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitObjectInitializerExpression(this); public BoundObjectInitializerExpression Update(ImmutableArray initializers, TypeSymbol type) { @@ -6014,13 +6147,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundObjectInitializerMember : BoundExpression { - public BoundObjectInitializerMember(SyntaxNode syntax, Symbol memberSymbol, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, TypeSymbol receiverType, Binder binderOpt, TypeSymbol type, bool hasErrors = false) + public BoundObjectInitializerMember(SyntaxNode syntax, Symbol? memberSymbol, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, TypeSymbol receiverType, Binder? binderOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.ObjectInitializerMember, syntax, type, hasErrors || arguments.HasErrors()) { Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)receiverType != null, "Field 'receiverType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(receiverType is object, "Field 'receiverType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.MemberSymbol = memberSymbol; this.Arguments = arguments; @@ -6034,7 +6167,9 @@ public BoundObjectInitializerMember(SyntaxNode syntax, Symbol memberSymbol, Immu } - public Symbol MemberSymbol { get; } + public new TypeSymbol Type => base.Type!; + + public Symbol? MemberSymbol { get; } public ImmutableArray Arguments { get; } @@ -6051,11 +6186,11 @@ public BoundObjectInitializerMember(SyntaxNode syntax, Symbol memberSymbol, Immu public TypeSymbol ReceiverType { get; } - public Binder BinderOpt { get; } + public Binder? BinderOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitObjectInitializerMember(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitObjectInitializerMember(this); - public BoundObjectInitializerMember Update(Symbol memberSymbol, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, TypeSymbol receiverType, Binder binderOpt, TypeSymbol type) + public BoundObjectInitializerMember Update(Symbol? memberSymbol, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, LookupResultKind resultKind, TypeSymbol receiverType, Binder? binderOpt, TypeSymbol type) { if (memberSymbol != this.MemberSymbol || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || expanded != this.Expanded || argsToParamsOpt != this.ArgsToParamsOpt || resultKind != this.ResultKind || !TypeSymbol.Equals(receiverType, this.ReceiverType, TypeCompareKind.ConsiderEverything) || binderOpt != this.BinderOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6080,9 +6215,9 @@ public BoundDynamicObjectInitializerMember(SyntaxNode syntax, string memberName, : base(BoundKind.DynamicObjectInitializerMember, syntax, type, hasErrors) { - Debug.Assert((object)memberName != null, "Field 'memberName' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)receiverType != null, "Field 'receiverType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(memberName is object, "Field 'memberName' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(receiverType is object, "Field 'receiverType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.MemberName = memberName; this.ReceiverType = receiverType; @@ -6092,20 +6227,22 @@ public BoundDynamicObjectInitializerMember(SyntaxNode syntax, string memberName, : base(BoundKind.DynamicObjectInitializerMember, syntax, type) { - Debug.Assert((object)memberName != null, "Field 'memberName' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)receiverType != null, "Field 'receiverType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(memberName is object, "Field 'memberName' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(receiverType is object, "Field 'receiverType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.MemberName = memberName; this.ReceiverType = receiverType; } + public new TypeSymbol Type => base.Type!; + public string MemberName { get; } public TypeSymbol ReceiverType { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicObjectInitializerMember(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicObjectInitializerMember(this); public BoundDynamicObjectInitializerMember Update(string memberName, TypeSymbol receiverType, TypeSymbol type) { @@ -6133,12 +6270,12 @@ public BoundCollectionInitializerExpression(SyntaxNode syntax, ImmutableArray visitor.VisitCollectionInitializerExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitCollectionInitializerExpression(this); public BoundCollectionInitializerExpression Update(ImmutableArray initializers, TypeSymbol type) { @@ -6161,13 +6298,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundCollectionElementInitializer : BoundExpression { - public BoundCollectionElementInitializer(SyntaxNode syntax, MethodSymbol addMethod, ImmutableArray arguments, BoundExpression implicitReceiverOpt, bool expanded, ImmutableArray argsToParamsOpt, bool invokedAsExtensionMethod, LookupResultKind resultKind, Binder binderOpt, TypeSymbol type, bool hasErrors = false) + public BoundCollectionElementInitializer(SyntaxNode syntax, MethodSymbol addMethod, ImmutableArray arguments, BoundExpression? implicitReceiverOpt, bool expanded, ImmutableArray argsToParamsOpt, bool invokedAsExtensionMethod, LookupResultKind resultKind, Binder? binderOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.CollectionElementInitializer, syntax, type, hasErrors || arguments.HasErrors() || implicitReceiverOpt.HasErrors()) { - Debug.Assert((object)addMethod != null, "Field 'addMethod' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(addMethod is object, "Field 'addMethod' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.AddMethod = addMethod; this.Arguments = arguments; @@ -6180,11 +6317,13 @@ public BoundCollectionElementInitializer(SyntaxNode syntax, MethodSymbol addMeth } + public new TypeSymbol Type => base.Type!; + public MethodSymbol AddMethod { get; } public ImmutableArray Arguments { get; } - public BoundExpression ImplicitReceiverOpt { get; } + public BoundExpression? ImplicitReceiverOpt { get; } public bool Expanded { get; } @@ -6195,11 +6334,11 @@ public BoundCollectionElementInitializer(SyntaxNode syntax, MethodSymbol addMeth private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } - public Binder BinderOpt { get; } + public Binder? BinderOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitCollectionElementInitializer(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitCollectionElementInitializer(this); - public BoundCollectionElementInitializer Update(MethodSymbol addMethod, ImmutableArray arguments, BoundExpression implicitReceiverOpt, bool expanded, ImmutableArray argsToParamsOpt, bool invokedAsExtensionMethod, LookupResultKind resultKind, Binder binderOpt, TypeSymbol type) + public BoundCollectionElementInitializer Update(MethodSymbol addMethod, ImmutableArray arguments, BoundExpression? implicitReceiverOpt, bool expanded, ImmutableArray argsToParamsOpt, bool invokedAsExtensionMethod, LookupResultKind resultKind, Binder? binderOpt, TypeSymbol type) { if (addMethod != this.AddMethod || arguments != this.Arguments || implicitReceiverOpt != this.ImplicitReceiverOpt || expanded != this.Expanded || argsToParamsOpt != this.ArgsToParamsOpt || invokedAsExtensionMethod != this.InvokedAsExtensionMethod || resultKind != this.ResultKind || binderOpt != this.BinderOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6225,17 +6364,19 @@ public BoundDynamicCollectionElementInitializer(SyntaxNode syntax, ImmutableArra { Debug.Assert(!applicableMethods.IsDefault, "Field 'applicableMethods' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ApplicableMethods = applicableMethods; } + public new TypeSymbol Type => base.Type!; + public ImmutableArray ApplicableMethods { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicCollectionElementInitializer(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicCollectionElementInitializer(this); public BoundDynamicCollectionElementInitializer Update(ImmutableArray applicableMethods, BoundExpression expression, ImmutableArray arguments, TypeSymbol type) { @@ -6262,7 +6403,7 @@ public BoundImplicitReceiver(SyntaxNode syntax, TypeSymbol type, bool hasErrors) : base(BoundKind.ImplicitReceiver, syntax, type, hasErrors) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -6270,12 +6411,14 @@ public BoundImplicitReceiver(SyntaxNode syntax, TypeSymbol type) : base(BoundKind.ImplicitReceiver, syntax, type) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitImplicitReceiver(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitImplicitReceiver(this); public BoundImplicitReceiver Update(TypeSymbol type) { @@ -6302,10 +6445,10 @@ public BoundAnonymousObjectCreationExpression(SyntaxNode syntax, MethodSymbol co : base(BoundKind.AnonymousObjectCreationExpression, syntax, type, hasErrors || arguments.HasErrors() || declarations.HasErrors()) { - Debug.Assert((object)constructor != null, "Field 'constructor' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(constructor is object, "Field 'constructor' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!declarations.IsDefault, "Field 'declarations' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Constructor = constructor; this.Arguments = arguments; @@ -6313,13 +6456,15 @@ public BoundAnonymousObjectCreationExpression(SyntaxNode syntax, MethodSymbol co } + public new TypeSymbol Type => base.Type!; + public MethodSymbol Constructor { get; } public ImmutableArray Arguments { get; } public ImmutableArray Declarations { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAnonymousObjectCreationExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAnonymousObjectCreationExpression(this); public BoundAnonymousObjectCreationExpression Update(MethodSymbol constructor, ImmutableArray arguments, ImmutableArray declarations, TypeSymbol type) { @@ -6346,8 +6491,8 @@ public BoundAnonymousPropertyDeclaration(SyntaxNode syntax, PropertySymbol prope : base(BoundKind.AnonymousPropertyDeclaration, syntax, type, hasErrors) { - Debug.Assert((object)property != null, "Field 'property' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(property is object, "Field 'property' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Property = property; } @@ -6356,16 +6501,18 @@ public BoundAnonymousPropertyDeclaration(SyntaxNode syntax, PropertySymbol prope : base(BoundKind.AnonymousPropertyDeclaration, syntax, type) { - Debug.Assert((object)property != null, "Field 'property' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(property is object, "Field 'property' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Property = property; } + public new TypeSymbol Type => base.Type!; + public PropertySymbol Property { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitAnonymousPropertyDeclaration(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitAnonymousPropertyDeclaration(this); public BoundAnonymousPropertyDeclaration Update(PropertySymbol property, TypeSymbol type) { @@ -6388,21 +6535,23 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundNewT : BoundExpression { - public BoundNewT(SyntaxNode syntax, BoundObjectInitializerExpressionBase initializerExpressionOpt, TypeSymbol type, bool hasErrors = false) + public BoundNewT(SyntaxNode syntax, BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.NewT, syntax, type, hasErrors || initializerExpressionOpt.HasErrors()) { - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.InitializerExpressionOpt = initializerExpressionOpt; } - public BoundObjectInitializerExpressionBase InitializerExpressionOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundObjectInitializerExpressionBase? InitializerExpressionOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNewT(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNewT(this); - public BoundNewT Update(BoundObjectInitializerExpressionBase initializerExpressionOpt, TypeSymbol type) + public BoundNewT Update(BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type) { if (initializerExpressionOpt != this.InitializerExpressionOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6423,12 +6572,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundDelegateCreationExpression : BoundExpression { - public BoundDelegateCreationExpression(SyntaxNode syntax, BoundExpression argument, MethodSymbol methodOpt, bool isExtensionMethod, TypeSymbol type, bool hasErrors = false) + public BoundDelegateCreationExpression(SyntaxNode syntax, BoundExpression argument, MethodSymbol? methodOpt, bool isExtensionMethod, TypeSymbol type, bool hasErrors = false) : base(BoundKind.DelegateCreationExpression, syntax, type, hasErrors || argument.HasErrors()) { - Debug.Assert((object)argument != null, "Field 'argument' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(argument is object, "Field 'argument' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Argument = argument; this.MethodOpt = methodOpt; @@ -6436,15 +6585,17 @@ public BoundDelegateCreationExpression(SyntaxNode syntax, BoundExpression argume } + public new TypeSymbol Type => base.Type!; + public BoundExpression Argument { get; } - public MethodSymbol MethodOpt { get; } + public MethodSymbol? MethodOpt { get; } public bool IsExtensionMethod { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDelegateCreationExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDelegateCreationExpression(this); - public BoundDelegateCreationExpression Update(BoundExpression argument, MethodSymbol methodOpt, bool isExtensionMethod, TypeSymbol type) + public BoundDelegateCreationExpression Update(BoundExpression argument, MethodSymbol? methodOpt, bool isExtensionMethod, TypeSymbol type) { if (argument != this.Argument || methodOpt != this.MethodOpt || isExtensionMethod != this.IsExtensionMethod || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6465,25 +6616,27 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundArrayCreation : BoundExpression { - public BoundArrayCreation(SyntaxNode syntax, ImmutableArray bounds, BoundArrayInitialization initializerOpt, TypeSymbol type, bool hasErrors = false) + public BoundArrayCreation(SyntaxNode syntax, ImmutableArray bounds, BoundArrayInitialization? initializerOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.ArrayCreation, syntax, type, hasErrors || bounds.HasErrors() || initializerOpt.HasErrors()) { Debug.Assert(!bounds.IsDefault, "Field 'bounds' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Bounds = bounds; this.InitializerOpt = initializerOpt; } + public new TypeSymbol Type => base.Type!; + public ImmutableArray Bounds { get; } - public BoundArrayInitialization InitializerOpt { get; } + public BoundArrayInitialization? InitializerOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArrayCreation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArrayCreation(this); - public BoundArrayCreation Update(ImmutableArray bounds, BoundArrayInitialization initializerOpt, TypeSymbol type) + public BoundArrayCreation Update(ImmutableArray bounds, BoundArrayInitialization? initializerOpt, TypeSymbol type) { if (bounds != this.Bounds || initializerOpt != this.InitializerOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6514,9 +6667,11 @@ public BoundArrayInitialization(SyntaxNode syntax, ImmutableArray base.Type!; + public ImmutableArray Initializers { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitArrayInitialization(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitArrayInitialization(this); public BoundArrayInitialization Update(ImmutableArray initializers) { @@ -6539,24 +6694,24 @@ protected override BoundExpression ShallowClone() internal partial class BoundStackAllocArrayCreation : BoundExpression { - protected BoundStackAllocArrayCreation(BoundKind kind, SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization initializerOpt, TypeSymbol type, bool hasErrors = false) + protected BoundStackAllocArrayCreation(BoundKind kind, SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol? type, bool hasErrors = false) : base(kind, syntax, type, hasErrors) { - Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)count != null, "Field 'count' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(elementType is object, "Field 'elementType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(count is object, "Field 'count' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ElementType = elementType; this.Count = count; this.InitializerOpt = initializerOpt; } - public BoundStackAllocArrayCreation(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization initializerOpt, TypeSymbol type, bool hasErrors = false) + public BoundStackAllocArrayCreation(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.StackAllocArrayCreation, syntax, type, hasErrors || count.HasErrors() || initializerOpt.HasErrors()) { - Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)count != null, "Field 'count' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(elementType is object, "Field 'elementType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(count is object, "Field 'count' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ElementType = elementType; this.Count = count; @@ -6568,11 +6723,11 @@ public BoundStackAllocArrayCreation(SyntaxNode syntax, TypeSymbol elementType, B public BoundExpression Count { get; } - public BoundArrayInitialization InitializerOpt { get; } + public BoundArrayInitialization? InitializerOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitStackAllocArrayCreation(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitStackAllocArrayCreation(this); - public BoundStackAllocArrayCreation Update(TypeSymbol elementType, BoundExpression count, BoundArrayInitialization initializerOpt, TypeSymbol type) + public BoundStackAllocArrayCreation Update(TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol? type) { if (!TypeSymbol.Equals(elementType, this.ElementType, TypeCompareKind.ConsiderEverything) || count != this.Count || initializerOpt != this.InitializerOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6593,20 +6748,22 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundConvertedStackAllocExpression : BoundStackAllocArrayCreation { - public BoundConvertedStackAllocExpression(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization initializerOpt, TypeSymbol type, bool hasErrors = false) + public BoundConvertedStackAllocExpression(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol type, bool hasErrors = false) : base(BoundKind.ConvertedStackAllocExpression, syntax, elementType, count, initializerOpt, type, hasErrors || count.HasErrors() || initializerOpt.HasErrors()) { - Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)count != null, "Field 'count' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(elementType is object, "Field 'elementType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(count is object, "Field 'count' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConvertedStackAllocExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConvertedStackAllocExpression(this); - public new BoundConvertedStackAllocExpression Update(TypeSymbol elementType, BoundExpression count, BoundArrayInitialization initializerOpt, TypeSymbol type) + public new BoundConvertedStackAllocExpression Update(TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol type) { if (!TypeSymbol.Equals(elementType, this.ElementType, TypeCompareKind.ConsiderEverything) || count != this.Count || initializerOpt != this.InitializerOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6627,12 +6784,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundFieldAccess : BoundExpression { - public BoundFieldAccess(SyntaxNode syntax, BoundExpression receiverOpt, FieldSymbol fieldSymbol, ConstantValue constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false) + public BoundFieldAccess(SyntaxNode syntax, BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false) : base(BoundKind.FieldAccess, syntax, type, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)fieldSymbol != null, "Field 'fieldSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(fieldSymbol is object, "Field 'fieldSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.FieldSymbol = fieldSymbol; @@ -6643,11 +6800,13 @@ public BoundFieldAccess(SyntaxNode syntax, BoundExpression receiverOpt, FieldSym } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public FieldSymbol FieldSymbol { get; } - public ConstantValue ConstantValueOpt { get; } + public ConstantValue? ConstantValueOpt { get; } private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } @@ -6656,9 +6815,9 @@ public BoundFieldAccess(SyntaxNode syntax, BoundExpression receiverOpt, FieldSym public bool IsDeclaration { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitFieldAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitFieldAccess(this); - public BoundFieldAccess Update(BoundExpression receiverOpt, FieldSymbol fieldSymbol, ConstantValue constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type) + public BoundFieldAccess Update(BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || fieldSymbol != this.FieldSymbol || constantValueOpt != this.ConstantValueOpt || resultKind != this.ResultKind || isByValue != this.IsByValue || isDeclaration != this.IsDeclaration || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6683,8 +6842,8 @@ public BoundHoistedFieldAccess(SyntaxNode syntax, FieldSymbol fieldSymbol, TypeS : base(BoundKind.HoistedFieldAccess, syntax, type, hasErrors) { - Debug.Assert((object)fieldSymbol != null, "Field 'fieldSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(fieldSymbol is object, "Field 'fieldSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.FieldSymbol = fieldSymbol; } @@ -6693,16 +6852,18 @@ public BoundHoistedFieldAccess(SyntaxNode syntax, FieldSymbol fieldSymbol, TypeS : base(BoundKind.HoistedFieldAccess, syntax, type) { - Debug.Assert((object)fieldSymbol != null, "Field 'fieldSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(fieldSymbol is object, "Field 'fieldSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.FieldSymbol = fieldSymbol; } + public new TypeSymbol Type => base.Type!; + public FieldSymbol FieldSymbol { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitHoistedFieldAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitHoistedFieldAccess(this); public BoundHoistedFieldAccess Update(FieldSymbol fieldSymbol, TypeSymbol type) { @@ -6725,12 +6886,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundPropertyAccess : BoundExpression { - public BoundPropertyAccess(SyntaxNode syntax, BoundExpression receiverOpt, PropertySymbol propertySymbol, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) + public BoundPropertyAccess(SyntaxNode syntax, BoundExpression? receiverOpt, PropertySymbol propertySymbol, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.PropertyAccess, syntax, type, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)propertySymbol != null, "Field 'propertySymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(propertySymbol is object, "Field 'propertySymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.PropertySymbol = propertySymbol; @@ -6738,16 +6899,18 @@ public BoundPropertyAccess(SyntaxNode syntax, BoundExpression receiverOpt, Prope } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public PropertySymbol PropertySymbol { get; } private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitPropertyAccess(this); - public BoundPropertyAccess Update(BoundExpression receiverOpt, PropertySymbol propertySymbol, LookupResultKind resultKind, TypeSymbol type) + public BoundPropertyAccess Update(BoundExpression? receiverOpt, PropertySymbol propertySymbol, LookupResultKind resultKind, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || propertySymbol != this.PropertySymbol || resultKind != this.ResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6768,12 +6931,12 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundEventAccess : BoundExpression { - public BoundEventAccess(SyntaxNode syntax, BoundExpression receiverOpt, EventSymbol eventSymbol, bool isUsableAsField, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) + public BoundEventAccess(SyntaxNode syntax, BoundExpression? receiverOpt, EventSymbol eventSymbol, bool isUsableAsField, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.EventAccess, syntax, type, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)eventSymbol != null, "Field 'eventSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(eventSymbol is object, "Field 'eventSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.EventSymbol = eventSymbol; @@ -6782,7 +6945,9 @@ public BoundEventAccess(SyntaxNode syntax, BoundExpression receiverOpt, EventSym } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public EventSymbol EventSymbol { get; } @@ -6791,9 +6956,9 @@ public BoundEventAccess(SyntaxNode syntax, BoundExpression receiverOpt, EventSym private readonly LookupResultKind _ResultKind; public override LookupResultKind ResultKind { get { return _ResultKind;} } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitEventAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitEventAccess(this); - public BoundEventAccess Update(BoundExpression receiverOpt, EventSymbol eventSymbol, bool isUsableAsField, LookupResultKind resultKind, TypeSymbol type) + public BoundEventAccess Update(BoundExpression? receiverOpt, EventSymbol eventSymbol, bool isUsableAsField, LookupResultKind resultKind, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || eventSymbol != this.EventSymbol || isUsableAsField != this.IsUsableAsField || resultKind != this.ResultKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6814,13 +6979,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundIndexerAccess : BoundExpression { - public BoundIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, PropertySymbol indexer, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, Binder binderOpt, bool useSetterForDefaultArgumentGeneration, TypeSymbol type, bool hasErrors = false) + public BoundIndexerAccess(SyntaxNode syntax, BoundExpression? receiverOpt, PropertySymbol indexer, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, Binder? binderOpt, bool useSetterForDefaultArgumentGeneration, TypeSymbol type, bool hasErrors = false) : base(BoundKind.IndexerAccess, syntax, type, hasErrors || receiverOpt.HasErrors() || arguments.HasErrors()) { - Debug.Assert((object)indexer != null, "Field 'indexer' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(indexer is object, "Field 'indexer' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.Indexer = indexer; @@ -6834,7 +6999,9 @@ public BoundIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, Proper } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public PropertySymbol Indexer { get; } @@ -6848,13 +7015,13 @@ public BoundIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, Proper public ImmutableArray ArgsToParamsOpt { get; } - public Binder BinderOpt { get; } + public Binder? BinderOpt { get; } public bool UseSetterForDefaultArgumentGeneration { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIndexerAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIndexerAccess(this); - public BoundIndexerAccess Update(BoundExpression receiverOpt, PropertySymbol indexer, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, Binder binderOpt, bool useSetterForDefaultArgumentGeneration, TypeSymbol type) + public BoundIndexerAccess Update(BoundExpression? receiverOpt, PropertySymbol indexer, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, bool expanded, ImmutableArray argsToParamsOpt, Binder? binderOpt, bool useSetterForDefaultArgumentGeneration, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || indexer != this.Indexer || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || expanded != this.Expanded || argsToParamsOpt != this.ArgsToParamsOpt || binderOpt != this.BinderOpt || useSetterForDefaultArgumentGeneration != this.UseSetterForDefaultArgumentGeneration || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6879,11 +7046,11 @@ public BoundIndexOrRangePatternIndexerAccess(SyntaxNode syntax, BoundExpression : base(BoundKind.IndexOrRangePatternIndexerAccess, syntax, type, hasErrors || receiver.HasErrors() || argument.HasErrors()) { - Debug.Assert((object)receiver != null, "Field 'receiver' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)lengthOrCountProperty != null, "Field 'lengthOrCountProperty' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)patternSymbol != null, "Field 'patternSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)argument != null, "Field 'argument' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(receiver is object, "Field 'receiver' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(lengthOrCountProperty is object, "Field 'lengthOrCountProperty' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(patternSymbol is object, "Field 'patternSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(argument is object, "Field 'argument' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Receiver = receiver; this.LengthOrCountProperty = lengthOrCountProperty; @@ -6892,6 +7059,8 @@ public BoundIndexOrRangePatternIndexerAccess(SyntaxNode syntax, BoundExpression } + public new TypeSymbol Type => base.Type!; + public BoundExpression Receiver { get; } public PropertySymbol LengthOrCountProperty { get; } @@ -6900,7 +7069,7 @@ public BoundIndexOrRangePatternIndexerAccess(SyntaxNode syntax, BoundExpression public BoundExpression Argument { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIndexOrRangePatternIndexerAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIndexOrRangePatternIndexerAccess(this); public BoundIndexOrRangePatternIndexerAccess Update(BoundExpression receiver, PropertySymbol lengthOrCountProperty, Symbol patternSymbol, BoundExpression argument, TypeSymbol type) { @@ -6923,13 +7092,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundDynamicIndexerAccess : BoundExpression { - public BoundDynamicIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, ImmutableArray applicableIndexers, TypeSymbol type, bool hasErrors = false) + public BoundDynamicIndexerAccess(SyntaxNode syntax, BoundExpression? receiverOpt, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, ImmutableArray applicableIndexers, TypeSymbol type, bool hasErrors = false) : base(BoundKind.DynamicIndexerAccess, syntax, type, hasErrors || receiverOpt.HasErrors() || arguments.HasErrors()) { Debug.Assert(!arguments.IsDefault, "Field 'arguments' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); Debug.Assert(!applicableIndexers.IsDefault, "Field 'applicableIndexers' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.ReceiverOpt = receiverOpt; this.Arguments = arguments; @@ -6939,7 +7108,9 @@ public BoundDynamicIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, } - public BoundExpression ReceiverOpt { get; } + public new TypeSymbol Type => base.Type!; + + public BoundExpression? ReceiverOpt { get; } public ImmutableArray Arguments { get; } @@ -6949,9 +7120,9 @@ public BoundDynamicIndexerAccess(SyntaxNode syntax, BoundExpression receiverOpt, public ImmutableArray ApplicableIndexers { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicIndexerAccess(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDynamicIndexerAccess(this); - public BoundDynamicIndexerAccess Update(BoundExpression receiverOpt, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, ImmutableArray applicableIndexers, TypeSymbol type) + public BoundDynamicIndexerAccess Update(BoundExpression? receiverOpt, ImmutableArray arguments, ImmutableArray argumentNamesOpt, ImmutableArray argumentRefKindsOpt, ImmutableArray applicableIndexers, TypeSymbol type) { if (receiverOpt != this.ReceiverOpt || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || argumentRefKindsOpt != this.ArgumentRefKindsOpt || applicableIndexers != this.ApplicableIndexers || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -6972,15 +7143,15 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundLambda : BoundExpression { - public BoundLambda(SyntaxNode syntax, UnboundLambda unboundLambda, LambdaSymbol symbol, BoundBlock body, ImmutableArray diagnostics, Binder binder, TypeSymbol type, bool hasErrors = false) + public BoundLambda(SyntaxNode syntax, UnboundLambda unboundLambda, LambdaSymbol symbol, BoundBlock body, ImmutableArray diagnostics, Binder binder, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.Lambda, syntax, type, hasErrors || unboundLambda.HasErrors() || body.HasErrors()) { - Debug.Assert((object)unboundLambda != null, "Field 'unboundLambda' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)symbol != null, "Field 'symbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)body != null, "Field 'body' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(unboundLambda is object, "Field 'unboundLambda' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(symbol is object, "Field 'symbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(body is object, "Field 'body' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!diagnostics.IsDefault, "Field 'diagnostics' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)binder != null, "Field 'binder' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(binder is object, "Field 'binder' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.UnboundLambda = unboundLambda; this.Symbol = symbol; @@ -6994,15 +7165,17 @@ public BoundLambda(SyntaxNode syntax, UnboundLambda unboundLambda, LambdaSymbol public LambdaSymbol Symbol { get; } + public new TypeSymbol? Type => base.Type!; + public BoundBlock Body { get; } public ImmutableArray Diagnostics { get; } public Binder Binder { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitLambda(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitLambda(this); - public BoundLambda Update(UnboundLambda unboundLambda, LambdaSymbol symbol, BoundBlock body, ImmutableArray diagnostics, Binder binder, TypeSymbol type) + public BoundLambda Update(UnboundLambda unboundLambda, LambdaSymbol symbol, BoundBlock body, ImmutableArray diagnostics, Binder binder, TypeSymbol? type) { if (unboundLambda != this.UnboundLambda || symbol != this.Symbol || body != this.Body || diagnostics != this.Diagnostics || binder != this.Binder || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7020,7 +7193,7 @@ public UnboundLambda(SyntaxNode syntax, UnboundLambdaState data, bool hasErrors) : base(BoundKind.UnboundLambda, syntax, null, hasErrors) { - Debug.Assert((object)data != null, "Field 'data' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(data is object, "Field 'data' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Data = data; } @@ -7029,15 +7202,17 @@ public UnboundLambda(SyntaxNode syntax, UnboundLambdaState data) : base(BoundKind.UnboundLambda, syntax, null) { - Debug.Assert((object)data != null, "Field 'data' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(data is object, "Field 'data' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Data = data; } + public new TypeSymbol Type => base.Type!; + public UnboundLambdaState Data { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitUnboundLambda(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitUnboundLambda(this); public UnboundLambda Update(UnboundLambdaState data) { @@ -7060,13 +7235,13 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundQueryClause : BoundExpression { - public BoundQueryClause(SyntaxNode syntax, BoundExpression value, RangeVariableSymbol definedSymbol, Binder binder, TypeSymbol type, bool hasErrors = false) + public BoundQueryClause(SyntaxNode syntax, BoundExpression value, RangeVariableSymbol? definedSymbol, Binder binder, TypeSymbol type, bool hasErrors = false) : base(BoundKind.QueryClause, syntax, type, hasErrors || value.HasErrors()) { - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)binder != null, "Field 'binder' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(binder is object, "Field 'binder' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Value = value; this.DefinedSymbol = definedSymbol; @@ -7074,15 +7249,17 @@ public BoundQueryClause(SyntaxNode syntax, BoundExpression value, RangeVariableS } + public new TypeSymbol Type => base.Type!; + public BoundExpression Value { get; } - public RangeVariableSymbol DefinedSymbol { get; } + public RangeVariableSymbol? DefinedSymbol { get; } public Binder Binder { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitQueryClause(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitQueryClause(this); - public BoundQueryClause Update(BoundExpression value, RangeVariableSymbol definedSymbol, Binder binder, TypeSymbol type) + public BoundQueryClause Update(BoundExpression value, RangeVariableSymbol? definedSymbol, Binder binder, TypeSymbol type) { if (value != this.Value || definedSymbol != this.DefinedSymbol || binder != this.Binder || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7105,7 +7282,7 @@ public BoundTypeOrInstanceInitializers(SyntaxNode syntax, ImmutableArray visitor.VisitTypeOrInstanceInitializers(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitTypeOrInstanceInitializers(this); public new BoundTypeOrInstanceInitializers Update(ImmutableArray statements) { @@ -7125,20 +7302,22 @@ public BoundNameOfOperator(SyntaxNode syntax, BoundExpression argument, Constant : base(BoundKind.NameOfOperator, syntax, type, hasErrors || argument.HasErrors()) { - Debug.Assert((object)argument != null, "Field 'argument' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)constantValueOpt != null, "Field 'constantValueOpt' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)type != null, "Field 'type' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(argument is object, "Field 'argument' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(constantValueOpt is object, "Field 'constantValueOpt' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(type is object, "Field 'type' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Argument = argument; this.ConstantValueOpt = constantValueOpt; } + public new TypeSymbol Type => base.Type!; + public BoundExpression Argument { get; } public ConstantValue ConstantValueOpt { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNameOfOperator(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNameOfOperator(this); public BoundNameOfOperator Update(BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type) { @@ -7161,7 +7340,7 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundInterpolatedString : BoundExpression { - public BoundInterpolatedString(SyntaxNode syntax, ImmutableArray parts, TypeSymbol type, bool hasErrors = false) + public BoundInterpolatedString(SyntaxNode syntax, ImmutableArray parts, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.InterpolatedString, syntax, type, hasErrors || parts.HasErrors()) { @@ -7173,9 +7352,9 @@ public BoundInterpolatedString(SyntaxNode syntax, ImmutableArray Parts { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitInterpolatedString(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitInterpolatedString(this); - public BoundInterpolatedString Update(ImmutableArray parts, TypeSymbol type) + public BoundInterpolatedString Update(ImmutableArray parts, TypeSymbol? type) { if (parts != this.Parts || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7196,11 +7375,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundStringInsert : BoundExpression { - public BoundStringInsert(SyntaxNode syntax, BoundExpression value, BoundExpression alignment, BoundLiteral format, TypeSymbol type, bool hasErrors = false) + public BoundStringInsert(SyntaxNode syntax, BoundExpression value, BoundExpression? alignment, BoundLiteral? format, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.StringInsert, syntax, type, hasErrors || value.HasErrors() || alignment.HasErrors() || format.HasErrors()) { - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Value = value; this.Alignment = alignment; @@ -7210,13 +7389,13 @@ public BoundStringInsert(SyntaxNode syntax, BoundExpression value, BoundExpressi public BoundExpression Value { get; } - public BoundExpression Alignment { get; } + public BoundExpression? Alignment { get; } - public BoundLiteral Format { get; } + public BoundLiteral? Format { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitStringInsert(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitStringInsert(this); - public BoundStringInsert Update(BoundExpression value, BoundExpression alignment, BoundLiteral format, TypeSymbol type) + public BoundStringInsert Update(BoundExpression value, BoundExpression? alignment, BoundLiteral? format, TypeSymbol? type) { if (value != this.Value || alignment != this.Alignment || format != this.Format || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7237,15 +7416,15 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundIsPatternExpression : BoundExpression { - public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, BoundPattern pattern, BoundDecisionDag decisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol type, bool hasErrors = false) + public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, BoundPattern pattern, BoundDecisionDag decisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.IsPatternExpression, syntax, type, hasErrors || expression.HasErrors() || pattern.HasErrors() || decisionDag.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)pattern != null, "Field 'pattern' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)decisionDag != null, "Field 'decisionDag' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenTrueLabel != null, "Field 'whenTrueLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)whenFalseLabel != null, "Field 'whenFalseLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(pattern is object, "Field 'pattern' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(decisionDag is object, "Field 'decisionDag' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(whenTrueLabel is object, "Field 'whenTrueLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(whenFalseLabel is object, "Field 'whenFalseLabel' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.Pattern = pattern; @@ -7265,9 +7444,9 @@ public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, B public LabelSymbol WhenFalseLabel { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitIsPatternExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitIsPatternExpression(this); - public BoundIsPatternExpression Update(BoundExpression expression, BoundPattern pattern, BoundDecisionDag decisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol type) + public BoundIsPatternExpression Update(BoundExpression expression, BoundPattern pattern, BoundDecisionDag decisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type) { if (expression != this.Expression || pattern != this.Pattern || decisionDag != this.DecisionDag || whenTrueLabel != this.WhenTrueLabel || whenFalseLabel != this.WhenFalseLabel || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7292,7 +7471,7 @@ protected BoundPattern(BoundKind kind, SyntaxNode syntax, TypeSymbol inputType, : base(kind, syntax, hasErrors) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.InputType = inputType; } @@ -7301,7 +7480,7 @@ protected BoundPattern(BoundKind kind, SyntaxNode syntax, TypeSymbol inputType) : base(kind, syntax) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.InputType = inputType; } @@ -7316,9 +7495,9 @@ public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantVa : base(BoundKind.ConstantPattern, syntax, inputType, hasErrors || value.HasErrors()) { - Debug.Assert((object)value != null, "Field 'value' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)constantValue != null, "Field 'constantValue' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(value is object, "Field 'value' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(constantValue is object, "Field 'constantValue' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Value = value; this.ConstantValue = constantValue; @@ -7329,7 +7508,7 @@ public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantVa public ConstantValue ConstantValue { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConstantPattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConstantPattern(this); public BoundConstantPattern Update(BoundExpression value, ConstantValue constantValue, TypeSymbol inputType) { @@ -7349,7 +7528,7 @@ public BoundDiscardPattern(SyntaxNode syntax, TypeSymbol inputType, bool hasErro : base(BoundKind.DiscardPattern, syntax, inputType, hasErrors) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } @@ -7357,12 +7536,12 @@ public BoundDiscardPattern(SyntaxNode syntax, TypeSymbol inputType) : base(BoundKind.DiscardPattern, syntax, inputType) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDiscardPattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDiscardPattern(this); public BoundDiscardPattern Update(TypeSymbol inputType) { @@ -7378,11 +7557,11 @@ public BoundDiscardPattern Update(TypeSymbol inputType) internal sealed partial class BoundDeclarationPattern : BoundPattern { - public BoundDeclarationPattern(SyntaxNode syntax, Symbol variable, BoundExpression variableAccess, BoundTypeExpression declaredType, bool isVar, TypeSymbol inputType, bool hasErrors = false) + public BoundDeclarationPattern(SyntaxNode syntax, Symbol? variable, BoundExpression? variableAccess, BoundTypeExpression? declaredType, bool isVar, TypeSymbol inputType, bool hasErrors = false) : base(BoundKind.DeclarationPattern, syntax, inputType, hasErrors || variableAccess.HasErrors() || declaredType.HasErrors()) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Variable = variable; this.VariableAccess = variableAccess; @@ -7391,17 +7570,17 @@ public BoundDeclarationPattern(SyntaxNode syntax, Symbol variable, BoundExpressi } - public Symbol Variable { get; } + public Symbol? Variable { get; } - public BoundExpression VariableAccess { get; } + public BoundExpression? VariableAccess { get; } - public BoundTypeExpression DeclaredType { get; } + public BoundTypeExpression? DeclaredType { get; } public bool IsVar { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDeclarationPattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDeclarationPattern(this); - public BoundDeclarationPattern Update(Symbol variable, BoundExpression variableAccess, BoundTypeExpression declaredType, bool isVar, TypeSymbol inputType) + public BoundDeclarationPattern Update(Symbol? variable, BoundExpression? variableAccess, BoundTypeExpression? declaredType, bool isVar, TypeSymbol inputType) { if (variable != this.Variable || variableAccess != this.VariableAccess || declaredType != this.DeclaredType || isVar != this.IsVar || !TypeSymbol.Equals(inputType, this.InputType, TypeCompareKind.ConsiderEverything)) { @@ -7415,11 +7594,11 @@ public BoundDeclarationPattern Update(Symbol variable, BoundExpression variableA internal sealed partial class BoundRecursivePattern : BoundPattern { - public BoundRecursivePattern(SyntaxNode syntax, BoundTypeExpression declaredType, MethodSymbol deconstructMethod, ImmutableArray deconstruction, ImmutableArray properties, Symbol variable, BoundExpression variableAccess, TypeSymbol inputType, bool hasErrors = false) + public BoundRecursivePattern(SyntaxNode syntax, BoundTypeExpression? declaredType, MethodSymbol? deconstructMethod, ImmutableArray deconstruction, ImmutableArray properties, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, bool hasErrors = false) : base(BoundKind.RecursivePattern, syntax, inputType, hasErrors || declaredType.HasErrors() || deconstruction.HasErrors() || properties.HasErrors() || variableAccess.HasErrors()) { - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.DeclaredType = declaredType; this.DeconstructMethod = deconstructMethod; @@ -7430,21 +7609,21 @@ public BoundRecursivePattern(SyntaxNode syntax, BoundTypeExpression declaredType } - public BoundTypeExpression DeclaredType { get; } + public BoundTypeExpression? DeclaredType { get; } - public MethodSymbol DeconstructMethod { get; } + public MethodSymbol? DeconstructMethod { get; } public ImmutableArray Deconstruction { get; } public ImmutableArray Properties { get; } - public Symbol Variable { get; } + public Symbol? Variable { get; } - public BoundExpression VariableAccess { get; } + public BoundExpression? VariableAccess { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitRecursivePattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitRecursivePattern(this); - public BoundRecursivePattern Update(BoundTypeExpression declaredType, MethodSymbol deconstructMethod, ImmutableArray deconstruction, ImmutableArray properties, Symbol variable, BoundExpression variableAccess, TypeSymbol inputType) + public BoundRecursivePattern Update(BoundTypeExpression? declaredType, MethodSymbol? deconstructMethod, ImmutableArray deconstruction, ImmutableArray properties, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType) { if (declaredType != this.DeclaredType || deconstructMethod != this.DeconstructMethod || deconstruction != this.Deconstruction || properties != this.Properties || variable != this.Variable || variableAccess != this.VariableAccess || !TypeSymbol.Equals(inputType, this.InputType, TypeCompareKind.ConsiderEverything)) { @@ -7462,10 +7641,10 @@ public BoundITuplePattern(SyntaxNode syntax, MethodSymbol getLengthMethod, Metho : base(BoundKind.ITuplePattern, syntax, inputType, hasErrors || subpatterns.HasErrors()) { - Debug.Assert((object)getLengthMethod != null, "Field 'getLengthMethod' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)getItemMethod != null, "Field 'getItemMethod' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(getLengthMethod is object, "Field 'getLengthMethod' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); + Debug.Assert(getItemMethod is object, "Field 'getItemMethod' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); Debug.Assert(!subpatterns.IsDefault, "Field 'subpatterns' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); - Debug.Assert((object)inputType != null, "Field 'inputType' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(inputType is object, "Field 'inputType' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.GetLengthMethod = getLengthMethod; this.GetItemMethod = getItemMethod; @@ -7479,7 +7658,7 @@ public BoundITuplePattern(SyntaxNode syntax, MethodSymbol getLengthMethod, Metho public ImmutableArray Subpatterns { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitITuplePattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitITuplePattern(this); public BoundITuplePattern Update(MethodSymbol getLengthMethod, MethodSymbol getItemMethod, ImmutableArray subpatterns, TypeSymbol inputType) { @@ -7495,24 +7674,24 @@ public BoundITuplePattern Update(MethodSymbol getLengthMethod, MethodSymbol getI internal sealed partial class BoundSubpattern : BoundNode { - public BoundSubpattern(SyntaxNode syntax, Symbol symbol, BoundPattern pattern, bool hasErrors = false) + public BoundSubpattern(SyntaxNode syntax, Symbol? symbol, BoundPattern pattern, bool hasErrors = false) : base(BoundKind.Subpattern, syntax, hasErrors || pattern.HasErrors()) { - Debug.Assert((object)pattern != null, "Field 'pattern' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(pattern is object, "Field 'pattern' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Symbol = symbol; this.Pattern = pattern; } - public Symbol Symbol { get; } + public Symbol? Symbol { get; } public BoundPattern Pattern { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitSubpattern(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitSubpattern(this); - public BoundSubpattern Update(Symbol symbol, BoundPattern pattern) + public BoundSubpattern Update(Symbol? symbol, BoundPattern pattern) { if (symbol != this.Symbol || pattern != this.Pattern) { @@ -7526,20 +7705,22 @@ public BoundSubpattern Update(Symbol symbol, BoundPattern pattern) internal sealed partial class BoundDiscardExpression : BoundExpression { - public BoundDiscardExpression(SyntaxNode syntax, TypeSymbol type, bool hasErrors) + public BoundDiscardExpression(SyntaxNode syntax, TypeSymbol? type, bool hasErrors) : base(BoundKind.DiscardExpression, syntax, type, hasErrors) { } - public BoundDiscardExpression(SyntaxNode syntax, TypeSymbol type) + public BoundDiscardExpression(SyntaxNode syntax, TypeSymbol? type) : base(BoundKind.DiscardExpression, syntax, type) { } + + public new TypeSymbol? Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDiscardExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDiscardExpression(this); - public BoundDiscardExpression Update(TypeSymbol type) + public BoundDiscardExpression Update(TypeSymbol? type) { if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7560,11 +7741,11 @@ protected override BoundExpression ShallowClone() internal sealed partial class BoundThrowExpression : BoundExpression { - public BoundThrowExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol type, bool hasErrors = false) + public BoundThrowExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.ThrowExpression, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; } @@ -7572,9 +7753,9 @@ public BoundThrowExpression(SyntaxNode syntax, BoundExpression expression, TypeS public BoundExpression Expression { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitThrowExpression(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitThrowExpression(this); - public BoundThrowExpression Update(BoundExpression expression, TypeSymbol type) + public BoundThrowExpression Update(BoundExpression expression, TypeSymbol? type) { if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7595,36 +7776,38 @@ protected override BoundExpression ShallowClone() internal abstract partial class VariablePendingInference : BoundExpression { - protected VariablePendingInference(BoundKind kind, SyntaxNode syntax, Symbol variableSymbol, BoundExpression receiverOpt, bool hasErrors = false) + protected VariablePendingInference(BoundKind kind, SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false) : base(kind, syntax, null, hasErrors) { - Debug.Assert((object)variableSymbol != null, "Field 'variableSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(variableSymbol is object, "Field 'variableSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.VariableSymbol = variableSymbol; this.ReceiverOpt = receiverOpt; } + public new TypeSymbol Type => base.Type!; + public Symbol VariableSymbol { get; } - public BoundExpression ReceiverOpt { get; } + public BoundExpression? ReceiverOpt { get; } } internal sealed partial class OutVariablePendingInference : VariablePendingInference { - public OutVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression receiverOpt, bool hasErrors = false) + public OutVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false) : base(BoundKind.OutVariablePendingInference, syntax, variableSymbol, receiverOpt, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)variableSymbol != null, "Field 'variableSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(variableSymbol is object, "Field 'variableSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitOutVariablePendingInference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitOutVariablePendingInference(this); - public OutVariablePendingInference Update(Symbol variableSymbol, BoundExpression receiverOpt) + public OutVariablePendingInference Update(Symbol variableSymbol, BoundExpression? receiverOpt) { if (variableSymbol != this.VariableSymbol || receiverOpt != this.ReceiverOpt) { @@ -7645,18 +7828,18 @@ protected override BoundExpression ShallowClone() internal sealed partial class DeconstructionVariablePendingInference : VariablePendingInference { - public DeconstructionVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression receiverOpt, bool hasErrors = false) + public DeconstructionVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false) : base(BoundKind.DeconstructionVariablePendingInference, syntax, variableSymbol, receiverOpt, hasErrors || receiverOpt.HasErrors()) { - Debug.Assert((object)variableSymbol != null, "Field 'variableSymbol' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(variableSymbol is object, "Field 'variableSymbol' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructionVariablePendingInference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitDeconstructionVariablePendingInference(this); - public DeconstructionVariablePendingInference Update(Symbol variableSymbol, BoundExpression receiverOpt) + public DeconstructionVariablePendingInference Update(Symbol variableSymbol, BoundExpression? receiverOpt) { if (variableSymbol != this.VariableSymbol || receiverOpt != this.ReceiverOpt) { @@ -7687,8 +7870,10 @@ public OutDeconstructVarPendingInference(SyntaxNode syntax) { } + + public new TypeSymbol Type => base.Type!; [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitOutDeconstructVarPendingInference(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitOutDeconstructVarPendingInference(this); public OutDeconstructVarPendingInference Update() { @@ -7698,7 +7883,7 @@ public OutDeconstructVarPendingInference Update() internal abstract partial class BoundMethodBodyBase : BoundNode { - protected BoundMethodBodyBase(BoundKind kind, SyntaxNode syntax, BoundBlock blockBody, BoundBlock expressionBody, bool hasErrors = false) + protected BoundMethodBodyBase(BoundKind kind, SyntaxNode syntax, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false) : base(kind, syntax, hasErrors) { this.BlockBody = blockBody; @@ -7706,22 +7891,22 @@ protected BoundMethodBodyBase(BoundKind kind, SyntaxNode syntax, BoundBlock bloc } - public BoundBlock BlockBody { get; } + public BoundBlock? BlockBody { get; } - public BoundBlock ExpressionBody { get; } + public BoundBlock? ExpressionBody { get; } } internal sealed partial class BoundNonConstructorMethodBody : BoundMethodBodyBase { - public BoundNonConstructorMethodBody(SyntaxNode syntax, BoundBlock blockBody, BoundBlock expressionBody, bool hasErrors = false) + public BoundNonConstructorMethodBody(SyntaxNode syntax, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false) : base(BoundKind.NonConstructorMethodBody, syntax, blockBody, expressionBody, hasErrors || blockBody.HasErrors() || expressionBody.HasErrors()) { } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitNonConstructorMethodBody(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitNonConstructorMethodBody(this); - public BoundNonConstructorMethodBody Update(BoundBlock blockBody, BoundBlock expressionBody) + public BoundNonConstructorMethodBody Update(BoundBlock? blockBody, BoundBlock? expressionBody) { if (blockBody != this.BlockBody || expressionBody != this.ExpressionBody) { @@ -7735,7 +7920,7 @@ public BoundNonConstructorMethodBody Update(BoundBlock blockBody, BoundBlock exp internal sealed partial class BoundConstructorMethodBody : BoundMethodBodyBase { - public BoundConstructorMethodBody(SyntaxNode syntax, ImmutableArray locals, BoundExpressionStatement initializer, BoundBlock blockBody, BoundBlock expressionBody, bool hasErrors = false) + public BoundConstructorMethodBody(SyntaxNode syntax, ImmutableArray locals, BoundExpressionStatement? initializer, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false) : base(BoundKind.ConstructorMethodBody, syntax, blockBody, expressionBody, hasErrors || initializer.HasErrors() || blockBody.HasErrors() || expressionBody.HasErrors()) { @@ -7748,11 +7933,11 @@ public BoundConstructorMethodBody(SyntaxNode syntax, ImmutableArray public ImmutableArray Locals { get; } - public BoundExpressionStatement Initializer { get; } + public BoundExpressionStatement? Initializer { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitConstructorMethodBody(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitConstructorMethodBody(this); - public BoundConstructorMethodBody Update(ImmutableArray locals, BoundExpressionStatement initializer, BoundBlock blockBody, BoundBlock expressionBody) + public BoundConstructorMethodBody Update(ImmutableArray locals, BoundExpressionStatement? initializer, BoundBlock? blockBody, BoundBlock? expressionBody) { if (locals != this.Locals || initializer != this.Initializer || blockBody != this.BlockBody || expressionBody != this.ExpressionBody) { @@ -7766,11 +7951,11 @@ public BoundConstructorMethodBody Update(ImmutableArray locals, Bou internal sealed partial class BoundExpressionWithNullability : BoundExpression { - public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol type, bool hasErrors = false) + public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type, bool hasErrors = false) : base(BoundKind.ExpressionWithNullability, syntax, type, hasErrors || expression.HasErrors()) { - Debug.Assert((object)expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)"); + Debug.Assert(expression is object, "Field 'expression' cannot be null (make the type nullable in BoundNodes.xml to remove this check)"); this.Expression = expression; this.NullableAnnotation = nullableAnnotation; @@ -7779,11 +7964,13 @@ public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression express public BoundExpression Expression { get; } + public new TypeSymbol? Type => base.Type!; + public NullableAnnotation NullableAnnotation { get; } [DebuggerStepThrough] - public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.VisitExpressionWithNullability(this); + public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.VisitExpressionWithNullability(this); - public BoundExpressionWithNullability Update(BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol type) + public BoundExpressionWithNullability Update(BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type) { if (expression != this.Expression || nullableAnnotation != this.NullableAnnotation || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) { @@ -7811,374 +7998,374 @@ internal R VisitInternal(BoundNode node, A arg) switch (node.Kind) { case BoundKind.FieldEqualsValue: - return VisitFieldEqualsValue(node as BoundFieldEqualsValue, arg); + return VisitFieldEqualsValue((BoundFieldEqualsValue)node, arg); case BoundKind.PropertyEqualsValue: - return VisitPropertyEqualsValue(node as BoundPropertyEqualsValue, arg); + return VisitPropertyEqualsValue((BoundPropertyEqualsValue)node, arg); case BoundKind.ParameterEqualsValue: - return VisitParameterEqualsValue(node as BoundParameterEqualsValue, arg); + return VisitParameterEqualsValue((BoundParameterEqualsValue)node, arg); case BoundKind.GlobalStatementInitializer: - return VisitGlobalStatementInitializer(node as BoundGlobalStatementInitializer, arg); + return VisitGlobalStatementInitializer((BoundGlobalStatementInitializer)node, arg); case BoundKind.DeconstructValuePlaceholder: - return VisitDeconstructValuePlaceholder(node as BoundDeconstructValuePlaceholder, arg); + return VisitDeconstructValuePlaceholder((BoundDeconstructValuePlaceholder)node, arg); case BoundKind.TupleOperandPlaceholder: - return VisitTupleOperandPlaceholder(node as BoundTupleOperandPlaceholder, arg); + return VisitTupleOperandPlaceholder((BoundTupleOperandPlaceholder)node, arg); case BoundKind.AwaitableValuePlaceholder: - return VisitAwaitableValuePlaceholder(node as BoundAwaitableValuePlaceholder, arg); + return VisitAwaitableValuePlaceholder((BoundAwaitableValuePlaceholder)node, arg); case BoundKind.DisposableValuePlaceholder: - return VisitDisposableValuePlaceholder(node as BoundDisposableValuePlaceholder, arg); + return VisitDisposableValuePlaceholder((BoundDisposableValuePlaceholder)node, arg); case BoundKind.Dup: - return VisitDup(node as BoundDup, arg); + return VisitDup((BoundDup)node, arg); case BoundKind.PassByCopy: - return VisitPassByCopy(node as BoundPassByCopy, arg); + return VisitPassByCopy((BoundPassByCopy)node, arg); case BoundKind.BadExpression: - return VisitBadExpression(node as BoundBadExpression, arg); + return VisitBadExpression((BoundBadExpression)node, arg); case BoundKind.BadStatement: - return VisitBadStatement(node as BoundBadStatement, arg); + return VisitBadStatement((BoundBadStatement)node, arg); case BoundKind.ExtractedFinallyBlock: - return VisitExtractedFinallyBlock(node as BoundExtractedFinallyBlock, arg); + return VisitExtractedFinallyBlock((BoundExtractedFinallyBlock)node, arg); case BoundKind.TypeExpression: - return VisitTypeExpression(node as BoundTypeExpression, arg); + return VisitTypeExpression((BoundTypeExpression)node, arg); case BoundKind.TypeOrValueExpression: - return VisitTypeOrValueExpression(node as BoundTypeOrValueExpression, arg); + return VisitTypeOrValueExpression((BoundTypeOrValueExpression)node, arg); case BoundKind.NamespaceExpression: - return VisitNamespaceExpression(node as BoundNamespaceExpression, arg); + return VisitNamespaceExpression((BoundNamespaceExpression)node, arg); case BoundKind.UnaryOperator: - return VisitUnaryOperator(node as BoundUnaryOperator, arg); + return VisitUnaryOperator((BoundUnaryOperator)node, arg); case BoundKind.IncrementOperator: - return VisitIncrementOperator(node as BoundIncrementOperator, arg); + return VisitIncrementOperator((BoundIncrementOperator)node, arg); case BoundKind.AddressOfOperator: - return VisitAddressOfOperator(node as BoundAddressOfOperator, arg); + return VisitAddressOfOperator((BoundAddressOfOperator)node, arg); case BoundKind.PointerIndirectionOperator: - return VisitPointerIndirectionOperator(node as BoundPointerIndirectionOperator, arg); + return VisitPointerIndirectionOperator((BoundPointerIndirectionOperator)node, arg); case BoundKind.PointerElementAccess: - return VisitPointerElementAccess(node as BoundPointerElementAccess, arg); + return VisitPointerElementAccess((BoundPointerElementAccess)node, arg); case BoundKind.RefTypeOperator: - return VisitRefTypeOperator(node as BoundRefTypeOperator, arg); + return VisitRefTypeOperator((BoundRefTypeOperator)node, arg); case BoundKind.MakeRefOperator: - return VisitMakeRefOperator(node as BoundMakeRefOperator, arg); + return VisitMakeRefOperator((BoundMakeRefOperator)node, arg); case BoundKind.RefValueOperator: - return VisitRefValueOperator(node as BoundRefValueOperator, arg); + return VisitRefValueOperator((BoundRefValueOperator)node, arg); case BoundKind.FromEndIndexExpression: - return VisitFromEndIndexExpression(node as BoundFromEndIndexExpression, arg); + return VisitFromEndIndexExpression((BoundFromEndIndexExpression)node, arg); case BoundKind.RangeExpression: - return VisitRangeExpression(node as BoundRangeExpression, arg); + return VisitRangeExpression((BoundRangeExpression)node, arg); case BoundKind.BinaryOperator: - return VisitBinaryOperator(node as BoundBinaryOperator, arg); + return VisitBinaryOperator((BoundBinaryOperator)node, arg); case BoundKind.TupleBinaryOperator: - return VisitTupleBinaryOperator(node as BoundTupleBinaryOperator, arg); + return VisitTupleBinaryOperator((BoundTupleBinaryOperator)node, arg); case BoundKind.UserDefinedConditionalLogicalOperator: - return VisitUserDefinedConditionalLogicalOperator(node as BoundUserDefinedConditionalLogicalOperator, arg); + return VisitUserDefinedConditionalLogicalOperator((BoundUserDefinedConditionalLogicalOperator)node, arg); case BoundKind.CompoundAssignmentOperator: - return VisitCompoundAssignmentOperator(node as BoundCompoundAssignmentOperator, arg); + return VisitCompoundAssignmentOperator((BoundCompoundAssignmentOperator)node, arg); case BoundKind.AssignmentOperator: - return VisitAssignmentOperator(node as BoundAssignmentOperator, arg); + return VisitAssignmentOperator((BoundAssignmentOperator)node, arg); case BoundKind.DeconstructionAssignmentOperator: - return VisitDeconstructionAssignmentOperator(node as BoundDeconstructionAssignmentOperator, arg); + return VisitDeconstructionAssignmentOperator((BoundDeconstructionAssignmentOperator)node, arg); case BoundKind.NullCoalescingOperator: - return VisitNullCoalescingOperator(node as BoundNullCoalescingOperator, arg); + return VisitNullCoalescingOperator((BoundNullCoalescingOperator)node, arg); case BoundKind.NullCoalescingAssignmentOperator: - return VisitNullCoalescingAssignmentOperator(node as BoundNullCoalescingAssignmentOperator, arg); + return VisitNullCoalescingAssignmentOperator((BoundNullCoalescingAssignmentOperator)node, arg); case BoundKind.ConditionalOperator: - return VisitConditionalOperator(node as BoundConditionalOperator, arg); + return VisitConditionalOperator((BoundConditionalOperator)node, arg); case BoundKind.ArrayAccess: - return VisitArrayAccess(node as BoundArrayAccess, arg); + return VisitArrayAccess((BoundArrayAccess)node, arg); case BoundKind.ArrayLength: - return VisitArrayLength(node as BoundArrayLength, arg); + return VisitArrayLength((BoundArrayLength)node, arg); case BoundKind.AwaitExpression: - return VisitAwaitExpression(node as BoundAwaitExpression, arg); + return VisitAwaitExpression((BoundAwaitExpression)node, arg); case BoundKind.TypeOfOperator: - return VisitTypeOfOperator(node as BoundTypeOfOperator, arg); + return VisitTypeOfOperator((BoundTypeOfOperator)node, arg); case BoundKind.MethodDefIndex: - return VisitMethodDefIndex(node as BoundMethodDefIndex, arg); + return VisitMethodDefIndex((BoundMethodDefIndex)node, arg); case BoundKind.MaximumMethodDefIndex: - return VisitMaximumMethodDefIndex(node as BoundMaximumMethodDefIndex, arg); + return VisitMaximumMethodDefIndex((BoundMaximumMethodDefIndex)node, arg); case BoundKind.InstrumentationPayloadRoot: - return VisitInstrumentationPayloadRoot(node as BoundInstrumentationPayloadRoot, arg); + return VisitInstrumentationPayloadRoot((BoundInstrumentationPayloadRoot)node, arg); case BoundKind.ModuleVersionId: - return VisitModuleVersionId(node as BoundModuleVersionId, arg); + return VisitModuleVersionId((BoundModuleVersionId)node, arg); case BoundKind.ModuleVersionIdString: - return VisitModuleVersionIdString(node as BoundModuleVersionIdString, arg); + return VisitModuleVersionIdString((BoundModuleVersionIdString)node, arg); case BoundKind.SourceDocumentIndex: - return VisitSourceDocumentIndex(node as BoundSourceDocumentIndex, arg); + return VisitSourceDocumentIndex((BoundSourceDocumentIndex)node, arg); case BoundKind.MethodInfo: - return VisitMethodInfo(node as BoundMethodInfo, arg); + return VisitMethodInfo((BoundMethodInfo)node, arg); case BoundKind.FieldInfo: - return VisitFieldInfo(node as BoundFieldInfo, arg); + return VisitFieldInfo((BoundFieldInfo)node, arg); case BoundKind.DefaultExpression: - return VisitDefaultExpression(node as BoundDefaultExpression, arg); + return VisitDefaultExpression((BoundDefaultExpression)node, arg); case BoundKind.IsOperator: - return VisitIsOperator(node as BoundIsOperator, arg); + return VisitIsOperator((BoundIsOperator)node, arg); case BoundKind.AsOperator: - return VisitAsOperator(node as BoundAsOperator, arg); + return VisitAsOperator((BoundAsOperator)node, arg); case BoundKind.SizeOfOperator: - return VisitSizeOfOperator(node as BoundSizeOfOperator, arg); + return VisitSizeOfOperator((BoundSizeOfOperator)node, arg); case BoundKind.Conversion: - return VisitConversion(node as BoundConversion, arg); + return VisitConversion((BoundConversion)node, arg); case BoundKind.ReadOnlySpanFromArray: - return VisitReadOnlySpanFromArray(node as BoundReadOnlySpanFromArray, arg); + return VisitReadOnlySpanFromArray((BoundReadOnlySpanFromArray)node, arg); case BoundKind.ArgList: - return VisitArgList(node as BoundArgList, arg); + return VisitArgList((BoundArgList)node, arg); case BoundKind.ArgListOperator: - return VisitArgListOperator(node as BoundArgListOperator, arg); + return VisitArgListOperator((BoundArgListOperator)node, arg); case BoundKind.FixedLocalCollectionInitializer: - return VisitFixedLocalCollectionInitializer(node as BoundFixedLocalCollectionInitializer, arg); + return VisitFixedLocalCollectionInitializer((BoundFixedLocalCollectionInitializer)node, arg); case BoundKind.SequencePoint: - return VisitSequencePoint(node as BoundSequencePoint, arg); + return VisitSequencePoint((BoundSequencePoint)node, arg); case BoundKind.SequencePointWithSpan: - return VisitSequencePointWithSpan(node as BoundSequencePointWithSpan, arg); + return VisitSequencePointWithSpan((BoundSequencePointWithSpan)node, arg); case BoundKind.Block: - return VisitBlock(node as BoundBlock, arg); + return VisitBlock((BoundBlock)node, arg); case BoundKind.Scope: - return VisitScope(node as BoundScope, arg); + return VisitScope((BoundScope)node, arg); case BoundKind.StateMachineScope: - return VisitStateMachineScope(node as BoundStateMachineScope, arg); + return VisitStateMachineScope((BoundStateMachineScope)node, arg); case BoundKind.LocalDeclaration: - return VisitLocalDeclaration(node as BoundLocalDeclaration, arg); + return VisitLocalDeclaration((BoundLocalDeclaration)node, arg); case BoundKind.MultipleLocalDeclarations: - return VisitMultipleLocalDeclarations(node as BoundMultipleLocalDeclarations, arg); + return VisitMultipleLocalDeclarations((BoundMultipleLocalDeclarations)node, arg); case BoundKind.UsingLocalDeclarations: - return VisitUsingLocalDeclarations(node as BoundUsingLocalDeclarations, arg); + return VisitUsingLocalDeclarations((BoundUsingLocalDeclarations)node, arg); case BoundKind.LocalFunctionStatement: - return VisitLocalFunctionStatement(node as BoundLocalFunctionStatement, arg); + return VisitLocalFunctionStatement((BoundLocalFunctionStatement)node, arg); case BoundKind.NoOpStatement: - return VisitNoOpStatement(node as BoundNoOpStatement, arg); + return VisitNoOpStatement((BoundNoOpStatement)node, arg); case BoundKind.ReturnStatement: - return VisitReturnStatement(node as BoundReturnStatement, arg); + return VisitReturnStatement((BoundReturnStatement)node, arg); case BoundKind.YieldReturnStatement: - return VisitYieldReturnStatement(node as BoundYieldReturnStatement, arg); + return VisitYieldReturnStatement((BoundYieldReturnStatement)node, arg); case BoundKind.YieldBreakStatement: - return VisitYieldBreakStatement(node as BoundYieldBreakStatement, arg); + return VisitYieldBreakStatement((BoundYieldBreakStatement)node, arg); case BoundKind.ThrowStatement: - return VisitThrowStatement(node as BoundThrowStatement, arg); + return VisitThrowStatement((BoundThrowStatement)node, arg); case BoundKind.ExpressionStatement: - return VisitExpressionStatement(node as BoundExpressionStatement, arg); + return VisitExpressionStatement((BoundExpressionStatement)node, arg); case BoundKind.BreakStatement: - return VisitBreakStatement(node as BoundBreakStatement, arg); + return VisitBreakStatement((BoundBreakStatement)node, arg); case BoundKind.ContinueStatement: - return VisitContinueStatement(node as BoundContinueStatement, arg); + return VisitContinueStatement((BoundContinueStatement)node, arg); case BoundKind.SwitchStatement: - return VisitSwitchStatement(node as BoundSwitchStatement, arg); + return VisitSwitchStatement((BoundSwitchStatement)node, arg); case BoundKind.SwitchDispatch: - return VisitSwitchDispatch(node as BoundSwitchDispatch, arg); + return VisitSwitchDispatch((BoundSwitchDispatch)node, arg); case BoundKind.IfStatement: - return VisitIfStatement(node as BoundIfStatement, arg); + return VisitIfStatement((BoundIfStatement)node, arg); case BoundKind.DoStatement: - return VisitDoStatement(node as BoundDoStatement, arg); + return VisitDoStatement((BoundDoStatement)node, arg); case BoundKind.WhileStatement: - return VisitWhileStatement(node as BoundWhileStatement, arg); + return VisitWhileStatement((BoundWhileStatement)node, arg); case BoundKind.ForStatement: - return VisitForStatement(node as BoundForStatement, arg); + return VisitForStatement((BoundForStatement)node, arg); case BoundKind.ForEachStatement: - return VisitForEachStatement(node as BoundForEachStatement, arg); + return VisitForEachStatement((BoundForEachStatement)node, arg); case BoundKind.ForEachDeconstructStep: - return VisitForEachDeconstructStep(node as BoundForEachDeconstructStep, arg); + return VisitForEachDeconstructStep((BoundForEachDeconstructStep)node, arg); case BoundKind.UsingStatement: - return VisitUsingStatement(node as BoundUsingStatement, arg); + return VisitUsingStatement((BoundUsingStatement)node, arg); case BoundKind.FixedStatement: - return VisitFixedStatement(node as BoundFixedStatement, arg); + return VisitFixedStatement((BoundFixedStatement)node, arg); case BoundKind.LockStatement: - return VisitLockStatement(node as BoundLockStatement, arg); + return VisitLockStatement((BoundLockStatement)node, arg); case BoundKind.TryStatement: - return VisitTryStatement(node as BoundTryStatement, arg); + return VisitTryStatement((BoundTryStatement)node, arg); case BoundKind.CatchBlock: - return VisitCatchBlock(node as BoundCatchBlock, arg); + return VisitCatchBlock((BoundCatchBlock)node, arg); case BoundKind.Literal: - return VisitLiteral(node as BoundLiteral, arg); + return VisitLiteral((BoundLiteral)node, arg); case BoundKind.ThisReference: - return VisitThisReference(node as BoundThisReference, arg); + return VisitThisReference((BoundThisReference)node, arg); case BoundKind.PreviousSubmissionReference: - return VisitPreviousSubmissionReference(node as BoundPreviousSubmissionReference, arg); + return VisitPreviousSubmissionReference((BoundPreviousSubmissionReference)node, arg); case BoundKind.HostObjectMemberReference: - return VisitHostObjectMemberReference(node as BoundHostObjectMemberReference, arg); + return VisitHostObjectMemberReference((BoundHostObjectMemberReference)node, arg); case BoundKind.BaseReference: - return VisitBaseReference(node as BoundBaseReference, arg); + return VisitBaseReference((BoundBaseReference)node, arg); case BoundKind.Local: - return VisitLocal(node as BoundLocal, arg); + return VisitLocal((BoundLocal)node, arg); case BoundKind.PseudoVariable: - return VisitPseudoVariable(node as BoundPseudoVariable, arg); + return VisitPseudoVariable((BoundPseudoVariable)node, arg); case BoundKind.RangeVariable: - return VisitRangeVariable(node as BoundRangeVariable, arg); + return VisitRangeVariable((BoundRangeVariable)node, arg); case BoundKind.Parameter: - return VisitParameter(node as BoundParameter, arg); + return VisitParameter((BoundParameter)node, arg); case BoundKind.LabelStatement: - return VisitLabelStatement(node as BoundLabelStatement, arg); + return VisitLabelStatement((BoundLabelStatement)node, arg); case BoundKind.GotoStatement: - return VisitGotoStatement(node as BoundGotoStatement, arg); + return VisitGotoStatement((BoundGotoStatement)node, arg); case BoundKind.LabeledStatement: - return VisitLabeledStatement(node as BoundLabeledStatement, arg); + return VisitLabeledStatement((BoundLabeledStatement)node, arg); case BoundKind.Label: - return VisitLabel(node as BoundLabel, arg); + return VisitLabel((BoundLabel)node, arg); case BoundKind.StatementList: - return VisitStatementList(node as BoundStatementList, arg); + return VisitStatementList((BoundStatementList)node, arg); case BoundKind.ConditionalGoto: - return VisitConditionalGoto(node as BoundConditionalGoto, arg); + return VisitConditionalGoto((BoundConditionalGoto)node, arg); case BoundKind.SwitchExpression: - return VisitSwitchExpression(node as BoundSwitchExpression, arg); + return VisitSwitchExpression((BoundSwitchExpression)node, arg); case BoundKind.SwitchExpressionArm: - return VisitSwitchExpressionArm(node as BoundSwitchExpressionArm, arg); + return VisitSwitchExpressionArm((BoundSwitchExpressionArm)node, arg); case BoundKind.DecisionDag: - return VisitDecisionDag(node as BoundDecisionDag, arg); + return VisitDecisionDag((BoundDecisionDag)node, arg); case BoundKind.EvaluationDecisionDagNode: - return VisitEvaluationDecisionDagNode(node as BoundEvaluationDecisionDagNode, arg); + return VisitEvaluationDecisionDagNode((BoundEvaluationDecisionDagNode)node, arg); case BoundKind.TestDecisionDagNode: - return VisitTestDecisionDagNode(node as BoundTestDecisionDagNode, arg); + return VisitTestDecisionDagNode((BoundTestDecisionDagNode)node, arg); case BoundKind.WhenDecisionDagNode: - return VisitWhenDecisionDagNode(node as BoundWhenDecisionDagNode, arg); + return VisitWhenDecisionDagNode((BoundWhenDecisionDagNode)node, arg); case BoundKind.LeafDecisionDagNode: - return VisitLeafDecisionDagNode(node as BoundLeafDecisionDagNode, arg); + return VisitLeafDecisionDagNode((BoundLeafDecisionDagNode)node, arg); case BoundKind.DagTemp: - return VisitDagTemp(node as BoundDagTemp, arg); + return VisitDagTemp((BoundDagTemp)node, arg); case BoundKind.DagTypeTest: - return VisitDagTypeTest(node as BoundDagTypeTest, arg); + return VisitDagTypeTest((BoundDagTypeTest)node, arg); case BoundKind.DagNonNullTest: - return VisitDagNonNullTest(node as BoundDagNonNullTest, arg); + return VisitDagNonNullTest((BoundDagNonNullTest)node, arg); case BoundKind.DagExplicitNullTest: - return VisitDagExplicitNullTest(node as BoundDagExplicitNullTest, arg); + return VisitDagExplicitNullTest((BoundDagExplicitNullTest)node, arg); case BoundKind.DagValueTest: - return VisitDagValueTest(node as BoundDagValueTest, arg); + return VisitDagValueTest((BoundDagValueTest)node, arg); case BoundKind.DagDeconstructEvaluation: - return VisitDagDeconstructEvaluation(node as BoundDagDeconstructEvaluation, arg); + return VisitDagDeconstructEvaluation((BoundDagDeconstructEvaluation)node, arg); case BoundKind.DagTypeEvaluation: - return VisitDagTypeEvaluation(node as BoundDagTypeEvaluation, arg); + return VisitDagTypeEvaluation((BoundDagTypeEvaluation)node, arg); case BoundKind.DagFieldEvaluation: - return VisitDagFieldEvaluation(node as BoundDagFieldEvaluation, arg); + return VisitDagFieldEvaluation((BoundDagFieldEvaluation)node, arg); case BoundKind.DagPropertyEvaluation: - return VisitDagPropertyEvaluation(node as BoundDagPropertyEvaluation, arg); + return VisitDagPropertyEvaluation((BoundDagPropertyEvaluation)node, arg); case BoundKind.DagIndexEvaluation: - return VisitDagIndexEvaluation(node as BoundDagIndexEvaluation, arg); + return VisitDagIndexEvaluation((BoundDagIndexEvaluation)node, arg); case BoundKind.SwitchSection: - return VisitSwitchSection(node as BoundSwitchSection, arg); + return VisitSwitchSection((BoundSwitchSection)node, arg); case BoundKind.SwitchLabel: - return VisitSwitchLabel(node as BoundSwitchLabel, arg); + return VisitSwitchLabel((BoundSwitchLabel)node, arg); case BoundKind.SequencePointExpression: - return VisitSequencePointExpression(node as BoundSequencePointExpression, arg); + return VisitSequencePointExpression((BoundSequencePointExpression)node, arg); case BoundKind.Sequence: - return VisitSequence(node as BoundSequence, arg); + return VisitSequence((BoundSequence)node, arg); case BoundKind.SpillSequence: - return VisitSpillSequence(node as BoundSpillSequence, arg); + return VisitSpillSequence((BoundSpillSequence)node, arg); case BoundKind.DynamicMemberAccess: - return VisitDynamicMemberAccess(node as BoundDynamicMemberAccess, arg); + return VisitDynamicMemberAccess((BoundDynamicMemberAccess)node, arg); case BoundKind.DynamicInvocation: - return VisitDynamicInvocation(node as BoundDynamicInvocation, arg); + return VisitDynamicInvocation((BoundDynamicInvocation)node, arg); case BoundKind.ConditionalAccess: - return VisitConditionalAccess(node as BoundConditionalAccess, arg); + return VisitConditionalAccess((BoundConditionalAccess)node, arg); case BoundKind.LoweredConditionalAccess: - return VisitLoweredConditionalAccess(node as BoundLoweredConditionalAccess, arg); + return VisitLoweredConditionalAccess((BoundLoweredConditionalAccess)node, arg); case BoundKind.ConditionalReceiver: - return VisitConditionalReceiver(node as BoundConditionalReceiver, arg); + return VisitConditionalReceiver((BoundConditionalReceiver)node, arg); case BoundKind.ComplexConditionalReceiver: - return VisitComplexConditionalReceiver(node as BoundComplexConditionalReceiver, arg); + return VisitComplexConditionalReceiver((BoundComplexConditionalReceiver)node, arg); case BoundKind.MethodGroup: - return VisitMethodGroup(node as BoundMethodGroup, arg); + return VisitMethodGroup((BoundMethodGroup)node, arg); case BoundKind.PropertyGroup: - return VisitPropertyGroup(node as BoundPropertyGroup, arg); + return VisitPropertyGroup((BoundPropertyGroup)node, arg); case BoundKind.Call: - return VisitCall(node as BoundCall, arg); + return VisitCall((BoundCall)node, arg); case BoundKind.EventAssignmentOperator: - return VisitEventAssignmentOperator(node as BoundEventAssignmentOperator, arg); + return VisitEventAssignmentOperator((BoundEventAssignmentOperator)node, arg); case BoundKind.Attribute: - return VisitAttribute(node as BoundAttribute, arg); + return VisitAttribute((BoundAttribute)node, arg); case BoundKind.ObjectCreationExpression: - return VisitObjectCreationExpression(node as BoundObjectCreationExpression, arg); + return VisitObjectCreationExpression((BoundObjectCreationExpression)node, arg); case BoundKind.TupleLiteral: - return VisitTupleLiteral(node as BoundTupleLiteral, arg); + return VisitTupleLiteral((BoundTupleLiteral)node, arg); case BoundKind.ConvertedTupleLiteral: - return VisitConvertedTupleLiteral(node as BoundConvertedTupleLiteral, arg); + return VisitConvertedTupleLiteral((BoundConvertedTupleLiteral)node, arg); case BoundKind.DynamicObjectCreationExpression: - return VisitDynamicObjectCreationExpression(node as BoundDynamicObjectCreationExpression, arg); + return VisitDynamicObjectCreationExpression((BoundDynamicObjectCreationExpression)node, arg); case BoundKind.NoPiaObjectCreationExpression: - return VisitNoPiaObjectCreationExpression(node as BoundNoPiaObjectCreationExpression, arg); + return VisitNoPiaObjectCreationExpression((BoundNoPiaObjectCreationExpression)node, arg); case BoundKind.ObjectInitializerExpression: - return VisitObjectInitializerExpression(node as BoundObjectInitializerExpression, arg); + return VisitObjectInitializerExpression((BoundObjectInitializerExpression)node, arg); case BoundKind.ObjectInitializerMember: - return VisitObjectInitializerMember(node as BoundObjectInitializerMember, arg); + return VisitObjectInitializerMember((BoundObjectInitializerMember)node, arg); case BoundKind.DynamicObjectInitializerMember: - return VisitDynamicObjectInitializerMember(node as BoundDynamicObjectInitializerMember, arg); + return VisitDynamicObjectInitializerMember((BoundDynamicObjectInitializerMember)node, arg); case BoundKind.CollectionInitializerExpression: - return VisitCollectionInitializerExpression(node as BoundCollectionInitializerExpression, arg); + return VisitCollectionInitializerExpression((BoundCollectionInitializerExpression)node, arg); case BoundKind.CollectionElementInitializer: - return VisitCollectionElementInitializer(node as BoundCollectionElementInitializer, arg); + return VisitCollectionElementInitializer((BoundCollectionElementInitializer)node, arg); case BoundKind.DynamicCollectionElementInitializer: - return VisitDynamicCollectionElementInitializer(node as BoundDynamicCollectionElementInitializer, arg); + return VisitDynamicCollectionElementInitializer((BoundDynamicCollectionElementInitializer)node, arg); case BoundKind.ImplicitReceiver: - return VisitImplicitReceiver(node as BoundImplicitReceiver, arg); + return VisitImplicitReceiver((BoundImplicitReceiver)node, arg); case BoundKind.AnonymousObjectCreationExpression: - return VisitAnonymousObjectCreationExpression(node as BoundAnonymousObjectCreationExpression, arg); + return VisitAnonymousObjectCreationExpression((BoundAnonymousObjectCreationExpression)node, arg); case BoundKind.AnonymousPropertyDeclaration: - return VisitAnonymousPropertyDeclaration(node as BoundAnonymousPropertyDeclaration, arg); + return VisitAnonymousPropertyDeclaration((BoundAnonymousPropertyDeclaration)node, arg); case BoundKind.NewT: - return VisitNewT(node as BoundNewT, arg); + return VisitNewT((BoundNewT)node, arg); case BoundKind.DelegateCreationExpression: - return VisitDelegateCreationExpression(node as BoundDelegateCreationExpression, arg); + return VisitDelegateCreationExpression((BoundDelegateCreationExpression)node, arg); case BoundKind.ArrayCreation: - return VisitArrayCreation(node as BoundArrayCreation, arg); + return VisitArrayCreation((BoundArrayCreation)node, arg); case BoundKind.ArrayInitialization: - return VisitArrayInitialization(node as BoundArrayInitialization, arg); + return VisitArrayInitialization((BoundArrayInitialization)node, arg); case BoundKind.StackAllocArrayCreation: - return VisitStackAllocArrayCreation(node as BoundStackAllocArrayCreation, arg); + return VisitStackAllocArrayCreation((BoundStackAllocArrayCreation)node, arg); case BoundKind.ConvertedStackAllocExpression: - return VisitConvertedStackAllocExpression(node as BoundConvertedStackAllocExpression, arg); + return VisitConvertedStackAllocExpression((BoundConvertedStackAllocExpression)node, arg); case BoundKind.FieldAccess: - return VisitFieldAccess(node as BoundFieldAccess, arg); + return VisitFieldAccess((BoundFieldAccess)node, arg); case BoundKind.HoistedFieldAccess: - return VisitHoistedFieldAccess(node as BoundHoistedFieldAccess, arg); + return VisitHoistedFieldAccess((BoundHoistedFieldAccess)node, arg); case BoundKind.PropertyAccess: - return VisitPropertyAccess(node as BoundPropertyAccess, arg); + return VisitPropertyAccess((BoundPropertyAccess)node, arg); case BoundKind.EventAccess: - return VisitEventAccess(node as BoundEventAccess, arg); + return VisitEventAccess((BoundEventAccess)node, arg); case BoundKind.IndexerAccess: - return VisitIndexerAccess(node as BoundIndexerAccess, arg); + return VisitIndexerAccess((BoundIndexerAccess)node, arg); case BoundKind.IndexOrRangePatternIndexerAccess: - return VisitIndexOrRangePatternIndexerAccess(node as BoundIndexOrRangePatternIndexerAccess, arg); + return VisitIndexOrRangePatternIndexerAccess((BoundIndexOrRangePatternIndexerAccess)node, arg); case BoundKind.DynamicIndexerAccess: - return VisitDynamicIndexerAccess(node as BoundDynamicIndexerAccess, arg); + return VisitDynamicIndexerAccess((BoundDynamicIndexerAccess)node, arg); case BoundKind.Lambda: - return VisitLambda(node as BoundLambda, arg); + return VisitLambda((BoundLambda)node, arg); case BoundKind.UnboundLambda: - return VisitUnboundLambda(node as UnboundLambda, arg); + return VisitUnboundLambda((UnboundLambda)node, arg); case BoundKind.QueryClause: - return VisitQueryClause(node as BoundQueryClause, arg); + return VisitQueryClause((BoundQueryClause)node, arg); case BoundKind.TypeOrInstanceInitializers: - return VisitTypeOrInstanceInitializers(node as BoundTypeOrInstanceInitializers, arg); + return VisitTypeOrInstanceInitializers((BoundTypeOrInstanceInitializers)node, arg); case BoundKind.NameOfOperator: - return VisitNameOfOperator(node as BoundNameOfOperator, arg); + return VisitNameOfOperator((BoundNameOfOperator)node, arg); case BoundKind.InterpolatedString: - return VisitInterpolatedString(node as BoundInterpolatedString, arg); + return VisitInterpolatedString((BoundInterpolatedString)node, arg); case BoundKind.StringInsert: - return VisitStringInsert(node as BoundStringInsert, arg); + return VisitStringInsert((BoundStringInsert)node, arg); case BoundKind.IsPatternExpression: - return VisitIsPatternExpression(node as BoundIsPatternExpression, arg); + return VisitIsPatternExpression((BoundIsPatternExpression)node, arg); case BoundKind.ConstantPattern: - return VisitConstantPattern(node as BoundConstantPattern, arg); + return VisitConstantPattern((BoundConstantPattern)node, arg); case BoundKind.DiscardPattern: - return VisitDiscardPattern(node as BoundDiscardPattern, arg); + return VisitDiscardPattern((BoundDiscardPattern)node, arg); case BoundKind.DeclarationPattern: - return VisitDeclarationPattern(node as BoundDeclarationPattern, arg); + return VisitDeclarationPattern((BoundDeclarationPattern)node, arg); case BoundKind.RecursivePattern: - return VisitRecursivePattern(node as BoundRecursivePattern, arg); + return VisitRecursivePattern((BoundRecursivePattern)node, arg); case BoundKind.ITuplePattern: - return VisitITuplePattern(node as BoundITuplePattern, arg); + return VisitITuplePattern((BoundITuplePattern)node, arg); case BoundKind.Subpattern: - return VisitSubpattern(node as BoundSubpattern, arg); + return VisitSubpattern((BoundSubpattern)node, arg); case BoundKind.DiscardExpression: - return VisitDiscardExpression(node as BoundDiscardExpression, arg); + return VisitDiscardExpression((BoundDiscardExpression)node, arg); case BoundKind.ThrowExpression: - return VisitThrowExpression(node as BoundThrowExpression, arg); + return VisitThrowExpression((BoundThrowExpression)node, arg); case BoundKind.OutVariablePendingInference: - return VisitOutVariablePendingInference(node as OutVariablePendingInference, arg); + return VisitOutVariablePendingInference((OutVariablePendingInference)node, arg); case BoundKind.DeconstructionVariablePendingInference: - return VisitDeconstructionVariablePendingInference(node as DeconstructionVariablePendingInference, arg); + return VisitDeconstructionVariablePendingInference((DeconstructionVariablePendingInference)node, arg); case BoundKind.OutDeconstructVarPendingInference: - return VisitOutDeconstructVarPendingInference(node as OutDeconstructVarPendingInference, arg); + return VisitOutDeconstructVarPendingInference((OutDeconstructVarPendingInference)node, arg); case BoundKind.NonConstructorMethodBody: - return VisitNonConstructorMethodBody(node as BoundNonConstructorMethodBody, arg); + return VisitNonConstructorMethodBody((BoundNonConstructorMethodBody)node, arg); case BoundKind.ConstructorMethodBody: - return VisitConstructorMethodBody(node as BoundConstructorMethodBody, arg); + return VisitConstructorMethodBody((BoundConstructorMethodBody)node, arg); case BoundKind.ExpressionWithNullability: - return VisitExpressionWithNullability(node as BoundExpressionWithNullability, arg); + return VisitExpressionWithNullability((BoundExpressionWithNullability)node, arg); } - return default(R); + return default(R)!; } } @@ -8371,525 +8558,525 @@ internal abstract partial class BoundTreeVisitor internal abstract partial class BoundTreeVisitor { - public virtual BoundNode VisitFieldEqualsValue(BoundFieldEqualsValue node) => this.DefaultVisit(node); - public virtual BoundNode VisitPropertyEqualsValue(BoundPropertyEqualsValue node) => this.DefaultVisit(node); - public virtual BoundNode VisitParameterEqualsValue(BoundParameterEqualsValue node) => this.DefaultVisit(node); - public virtual BoundNode VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) => this.DefaultVisit(node); - public virtual BoundNode VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) => this.DefaultVisit(node); - public virtual BoundNode VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) => this.DefaultVisit(node); - public virtual BoundNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) => this.DefaultVisit(node); - public virtual BoundNode VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) => this.DefaultVisit(node); - public virtual BoundNode VisitDup(BoundDup node) => this.DefaultVisit(node); - public virtual BoundNode VisitPassByCopy(BoundPassByCopy node) => this.DefaultVisit(node); - public virtual BoundNode VisitBadExpression(BoundBadExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitBadStatement(BoundBadStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) => this.DefaultVisit(node); - public virtual BoundNode VisitTypeExpression(BoundTypeExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitNamespaceExpression(BoundNamespaceExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitUnaryOperator(BoundUnaryOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitIncrementOperator(BoundIncrementOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitAddressOfOperator(BoundAddressOfOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitPointerElementAccess(BoundPointerElementAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitRefTypeOperator(BoundRefTypeOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitMakeRefOperator(BoundMakeRefOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitRefValueOperator(BoundRefValueOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitRangeExpression(BoundRangeExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitBinaryOperator(BoundBinaryOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitAssignmentOperator(BoundAssignmentOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitConditionalOperator(BoundConditionalOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitArrayAccess(BoundArrayAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitArrayLength(BoundArrayLength node) => this.DefaultVisit(node); - public virtual BoundNode VisitAwaitExpression(BoundAwaitExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitTypeOfOperator(BoundTypeOfOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitMethodDefIndex(BoundMethodDefIndex node) => this.DefaultVisit(node); - public virtual BoundNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) => this.DefaultVisit(node); - public virtual BoundNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) => this.DefaultVisit(node); - public virtual BoundNode VisitModuleVersionId(BoundModuleVersionId node) => this.DefaultVisit(node); - public virtual BoundNode VisitModuleVersionIdString(BoundModuleVersionIdString node) => this.DefaultVisit(node); - public virtual BoundNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node) => this.DefaultVisit(node); - public virtual BoundNode VisitMethodInfo(BoundMethodInfo node) => this.DefaultVisit(node); - public virtual BoundNode VisitFieldInfo(BoundFieldInfo node) => this.DefaultVisit(node); - public virtual BoundNode VisitDefaultExpression(BoundDefaultExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitIsOperator(BoundIsOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitAsOperator(BoundAsOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitSizeOfOperator(BoundSizeOfOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitConversion(BoundConversion node) => this.DefaultVisit(node); - public virtual BoundNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) => this.DefaultVisit(node); - public virtual BoundNode VisitArgList(BoundArgList node) => this.DefaultVisit(node); - public virtual BoundNode VisitArgListOperator(BoundArgListOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) => this.DefaultVisit(node); - public virtual BoundNode VisitSequencePoint(BoundSequencePoint node) => this.DefaultVisit(node); - public virtual BoundNode VisitSequencePointWithSpan(BoundSequencePointWithSpan node) => this.DefaultVisit(node); - public virtual BoundNode VisitBlock(BoundBlock node) => this.DefaultVisit(node); - public virtual BoundNode VisitScope(BoundScope node) => this.DefaultVisit(node); - public virtual BoundNode VisitStateMachineScope(BoundStateMachineScope node) => this.DefaultVisit(node); - public virtual BoundNode VisitLocalDeclaration(BoundLocalDeclaration node) => this.DefaultVisit(node); - public virtual BoundNode VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) => this.DefaultVisit(node); - public virtual BoundNode VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) => this.DefaultVisit(node); - public virtual BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitNoOpStatement(BoundNoOpStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitReturnStatement(BoundReturnStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitYieldBreakStatement(BoundYieldBreakStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitThrowStatement(BoundThrowStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitExpressionStatement(BoundExpressionStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitBreakStatement(BoundBreakStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitContinueStatement(BoundContinueStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchStatement(BoundSwitchStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchDispatch(BoundSwitchDispatch node) => this.DefaultVisit(node); - public virtual BoundNode VisitIfStatement(BoundIfStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitDoStatement(BoundDoStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitWhileStatement(BoundWhileStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitForStatement(BoundForStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitForEachStatement(BoundForEachStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitForEachDeconstructStep(BoundForEachDeconstructStep node) => this.DefaultVisit(node); - public virtual BoundNode VisitUsingStatement(BoundUsingStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitFixedStatement(BoundFixedStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitLockStatement(BoundLockStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitTryStatement(BoundTryStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitCatchBlock(BoundCatchBlock node) => this.DefaultVisit(node); - public virtual BoundNode VisitLiteral(BoundLiteral node) => this.DefaultVisit(node); - public virtual BoundNode VisitThisReference(BoundThisReference node) => this.DefaultVisit(node); - public virtual BoundNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) => this.DefaultVisit(node); - public virtual BoundNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node) => this.DefaultVisit(node); - public virtual BoundNode VisitBaseReference(BoundBaseReference node) => this.DefaultVisit(node); - public virtual BoundNode VisitLocal(BoundLocal node) => this.DefaultVisit(node); - public virtual BoundNode VisitPseudoVariable(BoundPseudoVariable node) => this.DefaultVisit(node); - public virtual BoundNode VisitRangeVariable(BoundRangeVariable node) => this.DefaultVisit(node); - public virtual BoundNode VisitParameter(BoundParameter node) => this.DefaultVisit(node); - public virtual BoundNode VisitLabelStatement(BoundLabelStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitGotoStatement(BoundGotoStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitLabeledStatement(BoundLabeledStatement node) => this.DefaultVisit(node); - public virtual BoundNode VisitLabel(BoundLabel node) => this.DefaultVisit(node); - public virtual BoundNode VisitStatementList(BoundStatementList node) => this.DefaultVisit(node); - public virtual BoundNode VisitConditionalGoto(BoundConditionalGoto node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchExpression(BoundSwitchExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchExpressionArm(BoundSwitchExpressionArm node) => this.DefaultVisit(node); - public virtual BoundNode VisitDecisionDag(BoundDecisionDag node) => this.DefaultVisit(node); - public virtual BoundNode VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) => this.DefaultVisit(node); - public virtual BoundNode VisitTestDecisionDagNode(BoundTestDecisionDagNode node) => this.DefaultVisit(node); - public virtual BoundNode VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) => this.DefaultVisit(node); - public virtual BoundNode VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagTemp(BoundDagTemp node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagTypeTest(BoundDagTypeTest node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagNonNullTest(BoundDagNonNullTest node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagExplicitNullTest(BoundDagExplicitNullTest node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagValueTest(BoundDagValueTest node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagTypeEvaluation(BoundDagTypeEvaluation node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagFieldEvaluation(BoundDagFieldEvaluation node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) => this.DefaultVisit(node); - public virtual BoundNode VisitDagIndexEvaluation(BoundDagIndexEvaluation node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchSection(BoundSwitchSection node) => this.DefaultVisit(node); - public virtual BoundNode VisitSwitchLabel(BoundSwitchLabel node) => this.DefaultVisit(node); - public virtual BoundNode VisitSequencePointExpression(BoundSequencePointExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitSequence(BoundSequence node) => this.DefaultVisit(node); - public virtual BoundNode VisitSpillSequence(BoundSpillSequence node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) => this.DefaultVisit(node); - public virtual BoundNode VisitConditionalAccess(BoundConditionalAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitConditionalReceiver(BoundConditionalReceiver node) => this.DefaultVisit(node); - public virtual BoundNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) => this.DefaultVisit(node); - public virtual BoundNode VisitMethodGroup(BoundMethodGroup node) => this.DefaultVisit(node); - public virtual BoundNode VisitPropertyGroup(BoundPropertyGroup node) => this.DefaultVisit(node); - public virtual BoundNode VisitCall(BoundCall node) => this.DefaultVisit(node); - public virtual BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitAttribute(BoundAttribute node) => this.DefaultVisit(node); - public virtual BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitTupleLiteral(BoundTupleLiteral node) => this.DefaultVisit(node); - public virtual BoundNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitObjectInitializerMember(BoundObjectInitializerMember node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) => this.DefaultVisit(node); - public virtual BoundNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) => this.DefaultVisit(node); - public virtual BoundNode VisitImplicitReceiver(BoundImplicitReceiver node) => this.DefaultVisit(node); - public virtual BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) => this.DefaultVisit(node); - public virtual BoundNode VisitNewT(BoundNewT node) => this.DefaultVisit(node); - public virtual BoundNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitArrayCreation(BoundArrayCreation node) => this.DefaultVisit(node); - public virtual BoundNode VisitArrayInitialization(BoundArrayInitialization node) => this.DefaultVisit(node); - public virtual BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) => this.DefaultVisit(node); - public virtual BoundNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitFieldAccess(BoundFieldAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitPropertyAccess(BoundPropertyAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitEventAccess(BoundEventAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitIndexerAccess(BoundIndexerAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) => this.DefaultVisit(node); - public virtual BoundNode VisitLambda(BoundLambda node) => this.DefaultVisit(node); - public virtual BoundNode VisitUnboundLambda(UnboundLambda node) => this.DefaultVisit(node); - public virtual BoundNode VisitQueryClause(BoundQueryClause node) => this.DefaultVisit(node); - public virtual BoundNode VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) => this.DefaultVisit(node); - public virtual BoundNode VisitNameOfOperator(BoundNameOfOperator node) => this.DefaultVisit(node); - public virtual BoundNode VisitInterpolatedString(BoundInterpolatedString node) => this.DefaultVisit(node); - public virtual BoundNode VisitStringInsert(BoundStringInsert node) => this.DefaultVisit(node); - public virtual BoundNode VisitIsPatternExpression(BoundIsPatternExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitConstantPattern(BoundConstantPattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitDiscardPattern(BoundDiscardPattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitDeclarationPattern(BoundDeclarationPattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitRecursivePattern(BoundRecursivePattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitITuplePattern(BoundITuplePattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitSubpattern(BoundSubpattern node) => this.DefaultVisit(node); - public virtual BoundNode VisitDiscardExpression(BoundDiscardExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitThrowExpression(BoundThrowExpression node) => this.DefaultVisit(node); - public virtual BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node) => this.DefaultVisit(node); - public virtual BoundNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) => this.DefaultVisit(node); - public virtual BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) => this.DefaultVisit(node); - public virtual BoundNode VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) => this.DefaultVisit(node); - public virtual BoundNode VisitConstructorMethodBody(BoundConstructorMethodBody node) => this.DefaultVisit(node); - public virtual BoundNode VisitExpressionWithNullability(BoundExpressionWithNullability node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFieldEqualsValue(BoundFieldEqualsValue node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPropertyEqualsValue(BoundPropertyEqualsValue node) => this.DefaultVisit(node); + public virtual BoundNode? VisitParameterEqualsValue(BoundParameterEqualsValue node) => this.DefaultVisit(node); + public virtual BoundNode? VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDup(BoundDup node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPassByCopy(BoundPassByCopy node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBadExpression(BoundBadExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBadStatement(BoundBadStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTypeExpression(BoundTypeExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTypeOrValueExpression(BoundTypeOrValueExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNamespaceExpression(BoundNamespaceExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitUnaryOperator(BoundUnaryOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIncrementOperator(BoundIncrementOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAddressOfOperator(BoundAddressOfOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPointerElementAccess(BoundPointerElementAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitRefTypeOperator(BoundRefTypeOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMakeRefOperator(BoundMakeRefOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitRefValueOperator(BoundRefValueOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFromEndIndexExpression(BoundFromEndIndexExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitRangeExpression(BoundRangeExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBinaryOperator(BoundBinaryOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTupleBinaryOperator(BoundTupleBinaryOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAssignmentOperator(BoundAssignmentOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNullCoalescingOperator(BoundNullCoalescingOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConditionalOperator(BoundConditionalOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArrayAccess(BoundArrayAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArrayLength(BoundArrayLength node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAwaitExpression(BoundAwaitExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTypeOfOperator(BoundTypeOfOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMethodDefIndex(BoundMethodDefIndex node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) => this.DefaultVisit(node); + public virtual BoundNode? VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) => this.DefaultVisit(node); + public virtual BoundNode? VisitModuleVersionId(BoundModuleVersionId node) => this.DefaultVisit(node); + public virtual BoundNode? VisitModuleVersionIdString(BoundModuleVersionIdString node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSourceDocumentIndex(BoundSourceDocumentIndex node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMethodInfo(BoundMethodInfo node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFieldInfo(BoundFieldInfo node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDefaultExpression(BoundDefaultExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIsOperator(BoundIsOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAsOperator(BoundAsOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSizeOfOperator(BoundSizeOfOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConversion(BoundConversion node) => this.DefaultVisit(node); + public virtual BoundNode? VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArgList(BoundArgList node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArgListOperator(BoundArgListOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSequencePoint(BoundSequencePoint node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSequencePointWithSpan(BoundSequencePointWithSpan node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBlock(BoundBlock node) => this.DefaultVisit(node); + public virtual BoundNode? VisitScope(BoundScope node) => this.DefaultVisit(node); + public virtual BoundNode? VisitStateMachineScope(BoundStateMachineScope node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLocalDeclaration(BoundLocalDeclaration node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) => this.DefaultVisit(node); + public virtual BoundNode? VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNoOpStatement(BoundNoOpStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitReturnStatement(BoundReturnStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitYieldReturnStatement(BoundYieldReturnStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitYieldBreakStatement(BoundYieldBreakStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitThrowStatement(BoundThrowStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitExpressionStatement(BoundExpressionStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBreakStatement(BoundBreakStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitContinueStatement(BoundContinueStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchStatement(BoundSwitchStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchDispatch(BoundSwitchDispatch node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIfStatement(BoundIfStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDoStatement(BoundDoStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitWhileStatement(BoundWhileStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitForStatement(BoundForStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitForEachStatement(BoundForEachStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitForEachDeconstructStep(BoundForEachDeconstructStep node) => this.DefaultVisit(node); + public virtual BoundNode? VisitUsingStatement(BoundUsingStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFixedStatement(BoundFixedStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLockStatement(BoundLockStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTryStatement(BoundTryStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitCatchBlock(BoundCatchBlock node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLiteral(BoundLiteral node) => this.DefaultVisit(node); + public virtual BoundNode? VisitThisReference(BoundThisReference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitHostObjectMemberReference(BoundHostObjectMemberReference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitBaseReference(BoundBaseReference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLocal(BoundLocal node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPseudoVariable(BoundPseudoVariable node) => this.DefaultVisit(node); + public virtual BoundNode? VisitRangeVariable(BoundRangeVariable node) => this.DefaultVisit(node); + public virtual BoundNode? VisitParameter(BoundParameter node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLabelStatement(BoundLabelStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitGotoStatement(BoundGotoStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLabeledStatement(BoundLabeledStatement node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLabel(BoundLabel node) => this.DefaultVisit(node); + public virtual BoundNode? VisitStatementList(BoundStatementList node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConditionalGoto(BoundConditionalGoto node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchExpression(BoundSwitchExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchExpressionArm(BoundSwitchExpressionArm node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDecisionDag(BoundDecisionDag node) => this.DefaultVisit(node); + public virtual BoundNode? VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTestDecisionDagNode(BoundTestDecisionDagNode node) => this.DefaultVisit(node); + public virtual BoundNode? VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagTemp(BoundDagTemp node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagTypeTest(BoundDagTypeTest node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagNonNullTest(BoundDagNonNullTest node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagExplicitNullTest(BoundDagExplicitNullTest node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagValueTest(BoundDagValueTest node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagTypeEvaluation(BoundDagTypeEvaluation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagFieldEvaluation(BoundDagFieldEvaluation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDagIndexEvaluation(BoundDagIndexEvaluation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchSection(BoundSwitchSection node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSwitchLabel(BoundSwitchLabel node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSequencePointExpression(BoundSequencePointExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSequence(BoundSequence node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSpillSequence(BoundSpillSequence node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicMemberAccess(BoundDynamicMemberAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicInvocation(BoundDynamicInvocation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConditionalAccess(BoundConditionalAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConditionalReceiver(BoundConditionalReceiver node) => this.DefaultVisit(node); + public virtual BoundNode? VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) => this.DefaultVisit(node); + public virtual BoundNode? VisitMethodGroup(BoundMethodGroup node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPropertyGroup(BoundPropertyGroup node) => this.DefaultVisit(node); + public virtual BoundNode? VisitCall(BoundCall node) => this.DefaultVisit(node); + public virtual BoundNode? VisitEventAssignmentOperator(BoundEventAssignmentOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAttribute(BoundAttribute node) => this.DefaultVisit(node); + public virtual BoundNode? VisitObjectCreationExpression(BoundObjectCreationExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTupleLiteral(BoundTupleLiteral node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitObjectInitializerExpression(BoundObjectInitializerExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitObjectInitializerMember(BoundObjectInitializerMember node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) => this.DefaultVisit(node); + public virtual BoundNode? VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitCollectionElementInitializer(BoundCollectionElementInitializer node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) => this.DefaultVisit(node); + public virtual BoundNode? VisitImplicitReceiver(BoundImplicitReceiver node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNewT(BoundNewT node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDelegateCreationExpression(BoundDelegateCreationExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArrayCreation(BoundArrayCreation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitArrayInitialization(BoundArrayInitialization node) => this.DefaultVisit(node); + public virtual BoundNode? VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitFieldAccess(BoundFieldAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitHoistedFieldAccess(BoundHoistedFieldAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitPropertyAccess(BoundPropertyAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitEventAccess(BoundEventAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIndexerAccess(BoundIndexerAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) => this.DefaultVisit(node); + public virtual BoundNode? VisitLambda(BoundLambda node) => this.DefaultVisit(node); + public virtual BoundNode? VisitUnboundLambda(UnboundLambda node) => this.DefaultVisit(node); + public virtual BoundNode? VisitQueryClause(BoundQueryClause node) => this.DefaultVisit(node); + public virtual BoundNode? VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNameOfOperator(BoundNameOfOperator node) => this.DefaultVisit(node); + public virtual BoundNode? VisitInterpolatedString(BoundInterpolatedString node) => this.DefaultVisit(node); + public virtual BoundNode? VisitStringInsert(BoundStringInsert node) => this.DefaultVisit(node); + public virtual BoundNode? VisitIsPatternExpression(BoundIsPatternExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConstantPattern(BoundConstantPattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDiscardPattern(BoundDiscardPattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDeclarationPattern(BoundDeclarationPattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitRecursivePattern(BoundRecursivePattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitITuplePattern(BoundITuplePattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitSubpattern(BoundSubpattern node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDiscardExpression(BoundDiscardExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitThrowExpression(BoundThrowExpression node) => this.DefaultVisit(node); + public virtual BoundNode? VisitOutVariablePendingInference(OutVariablePendingInference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) => this.DefaultVisit(node); + public virtual BoundNode? VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) => this.DefaultVisit(node); + public virtual BoundNode? VisitConstructorMethodBody(BoundConstructorMethodBody node) => this.DefaultVisit(node); + public virtual BoundNode? VisitExpressionWithNullability(BoundExpressionWithNullability node) => this.DefaultVisit(node); } internal abstract partial class BoundTreeWalker: BoundTreeVisitor { - public override BoundNode VisitFieldEqualsValue(BoundFieldEqualsValue node) + public override BoundNode? VisitFieldEqualsValue(BoundFieldEqualsValue node) { this.Visit(node.Value); return null; } - public override BoundNode VisitPropertyEqualsValue(BoundPropertyEqualsValue node) + public override BoundNode? VisitPropertyEqualsValue(BoundPropertyEqualsValue node) { this.Visit(node.Value); return null; } - public override BoundNode VisitParameterEqualsValue(BoundParameterEqualsValue node) + public override BoundNode? VisitParameterEqualsValue(BoundParameterEqualsValue node) { this.Visit(node.Value); return null; } - public override BoundNode VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) + public override BoundNode? VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) { this.Visit(node.Statement); return null; } - public override BoundNode VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) => null; - public override BoundNode VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) => null; - public override BoundNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) => null; - public override BoundNode VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) => null; - public override BoundNode VisitDup(BoundDup node) => null; - public override BoundNode VisitPassByCopy(BoundPassByCopy node) + public override BoundNode? VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) => null; + public override BoundNode? VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) => null; + public override BoundNode? VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) => null; + public override BoundNode? VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) => null; + public override BoundNode? VisitDup(BoundDup node) => null; + public override BoundNode? VisitPassByCopy(BoundPassByCopy node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitBadExpression(BoundBadExpression node) + public override BoundNode? VisitBadExpression(BoundBadExpression node) { this.VisitList(node.ChildBoundNodes); return null; } - public override BoundNode VisitBadStatement(BoundBadStatement node) + public override BoundNode? VisitBadStatement(BoundBadStatement node) { this.VisitList(node.ChildBoundNodes); return null; } - public override BoundNode VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) + public override BoundNode? VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) { this.Visit(node.FinallyBlock); return null; } - public override BoundNode VisitTypeExpression(BoundTypeExpression node) + public override BoundNode? VisitTypeExpression(BoundTypeExpression node) { this.Visit(node.BoundContainingTypeOpt); this.VisitList(node.BoundDimensionsOpt); return null; } - public override BoundNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node) => null; - public override BoundNode VisitNamespaceExpression(BoundNamespaceExpression node) => null; - public override BoundNode VisitUnaryOperator(BoundUnaryOperator node) + public override BoundNode? VisitTypeOrValueExpression(BoundTypeOrValueExpression node) => null; + public override BoundNode? VisitNamespaceExpression(BoundNamespaceExpression node) => null; + public override BoundNode? VisitUnaryOperator(BoundUnaryOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitIncrementOperator(BoundIncrementOperator node) + public override BoundNode? VisitIncrementOperator(BoundIncrementOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitAddressOfOperator(BoundAddressOfOperator node) + public override BoundNode? VisitAddressOfOperator(BoundAddressOfOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) + public override BoundNode? VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node) + public override BoundNode? VisitPointerElementAccess(BoundPointerElementAccess node) { this.Visit(node.Expression); this.Visit(node.Index); return null; } - public override BoundNode VisitRefTypeOperator(BoundRefTypeOperator node) + public override BoundNode? VisitRefTypeOperator(BoundRefTypeOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitMakeRefOperator(BoundMakeRefOperator node) + public override BoundNode? VisitMakeRefOperator(BoundMakeRefOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitRefValueOperator(BoundRefValueOperator node) + public override BoundNode? VisitRefValueOperator(BoundRefValueOperator node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node) + public override BoundNode? VisitFromEndIndexExpression(BoundFromEndIndexExpression node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitRangeExpression(BoundRangeExpression node) + public override BoundNode? VisitRangeExpression(BoundRangeExpression node) { this.Visit(node.LeftOperandOpt); this.Visit(node.RightOperandOpt); return null; } - public override BoundNode VisitBinaryOperator(BoundBinaryOperator node) + public override BoundNode? VisitBinaryOperator(BoundBinaryOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node) + public override BoundNode? VisitTupleBinaryOperator(BoundTupleBinaryOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) + public override BoundNode? VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) + public override BoundNode? VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node) + public override BoundNode? VisitAssignmentOperator(BoundAssignmentOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) + public override BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) { this.Visit(node.Left); this.Visit(node.Right); return null; } - public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node) + public override BoundNode? VisitNullCoalescingOperator(BoundNullCoalescingOperator node) { this.Visit(node.LeftOperand); this.Visit(node.RightOperand); return null; } - public override BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) + public override BoundNode? VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) { this.Visit(node.LeftOperand); this.Visit(node.RightOperand); return null; } - public override BoundNode VisitConditionalOperator(BoundConditionalOperator node) + public override BoundNode? VisitConditionalOperator(BoundConditionalOperator node) { this.Visit(node.Condition); this.Visit(node.Consequence); this.Visit(node.Alternative); return null; } - public override BoundNode VisitArrayAccess(BoundArrayAccess node) + public override BoundNode? VisitArrayAccess(BoundArrayAccess node) { this.Visit(node.Expression); this.VisitList(node.Indices); return null; } - public override BoundNode VisitArrayLength(BoundArrayLength node) + public override BoundNode? VisitArrayLength(BoundArrayLength node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitAwaitExpression(BoundAwaitExpression node) + public override BoundNode? VisitAwaitExpression(BoundAwaitExpression node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitTypeOfOperator(BoundTypeOfOperator node) + public override BoundNode? VisitTypeOfOperator(BoundTypeOfOperator node) { this.Visit(node.SourceType); return null; } - public override BoundNode VisitMethodDefIndex(BoundMethodDefIndex node) => null; - public override BoundNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) => null; - public override BoundNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) => null; - public override BoundNode VisitModuleVersionId(BoundModuleVersionId node) => null; - public override BoundNode VisitModuleVersionIdString(BoundModuleVersionIdString node) => null; - public override BoundNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node) => null; - public override BoundNode VisitMethodInfo(BoundMethodInfo node) => null; - public override BoundNode VisitFieldInfo(BoundFieldInfo node) => null; - public override BoundNode VisitDefaultExpression(BoundDefaultExpression node) => null; - public override BoundNode VisitIsOperator(BoundIsOperator node) + public override BoundNode? VisitMethodDefIndex(BoundMethodDefIndex node) => null; + public override BoundNode? VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) => null; + public override BoundNode? VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) => null; + public override BoundNode? VisitModuleVersionId(BoundModuleVersionId node) => null; + public override BoundNode? VisitModuleVersionIdString(BoundModuleVersionIdString node) => null; + public override BoundNode? VisitSourceDocumentIndex(BoundSourceDocumentIndex node) => null; + public override BoundNode? VisitMethodInfo(BoundMethodInfo node) => null; + public override BoundNode? VisitFieldInfo(BoundFieldInfo node) => null; + public override BoundNode? VisitDefaultExpression(BoundDefaultExpression node) => null; + public override BoundNode? VisitIsOperator(BoundIsOperator node) { this.Visit(node.Operand); this.Visit(node.TargetType); return null; } - public override BoundNode VisitAsOperator(BoundAsOperator node) + public override BoundNode? VisitAsOperator(BoundAsOperator node) { this.Visit(node.Operand); this.Visit(node.TargetType); return null; } - public override BoundNode VisitSizeOfOperator(BoundSizeOfOperator node) + public override BoundNode? VisitSizeOfOperator(BoundSizeOfOperator node) { this.Visit(node.SourceType); return null; } - public override BoundNode VisitConversion(BoundConversion node) + public override BoundNode? VisitConversion(BoundConversion node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) + public override BoundNode? VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) { this.Visit(node.Operand); return null; } - public override BoundNode VisitArgList(BoundArgList node) => null; - public override BoundNode VisitArgListOperator(BoundArgListOperator node) + public override BoundNode? VisitArgList(BoundArgList node) => null; + public override BoundNode? VisitArgListOperator(BoundArgListOperator node) { this.VisitList(node.Arguments); return null; } - public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) + public override BoundNode? VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitSequencePoint(BoundSequencePoint node) + public override BoundNode? VisitSequencePoint(BoundSequencePoint node) { this.Visit(node.StatementOpt); return null; } - public override BoundNode VisitSequencePointWithSpan(BoundSequencePointWithSpan node) + public override BoundNode? VisitSequencePointWithSpan(BoundSequencePointWithSpan node) { this.Visit(node.StatementOpt); return null; } - public override BoundNode VisitBlock(BoundBlock node) + public override BoundNode? VisitBlock(BoundBlock node) { this.VisitList(node.Statements); return null; } - public override BoundNode VisitScope(BoundScope node) + public override BoundNode? VisitScope(BoundScope node) { this.VisitList(node.Statements); return null; } - public override BoundNode VisitStateMachineScope(BoundStateMachineScope node) + public override BoundNode? VisitStateMachineScope(BoundStateMachineScope node) { this.Visit(node.Statement); return null; } - public override BoundNode VisitLocalDeclaration(BoundLocalDeclaration node) + public override BoundNode? VisitLocalDeclaration(BoundLocalDeclaration node) { this.Visit(node.DeclaredTypeOpt); this.Visit(node.InitializerOpt); this.VisitList(node.ArgumentsOpt); return null; } - public override BoundNode VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) + public override BoundNode? VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) { this.VisitList(node.LocalDeclarations); return null; } - public override BoundNode VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) + public override BoundNode? VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) { this.VisitList(node.LocalDeclarations); return null; } - public override BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node) + public override BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement node) { this.Visit(node.BlockBody); this.Visit(node.ExpressionBody); return null; } - public override BoundNode VisitNoOpStatement(BoundNoOpStatement node) => null; - public override BoundNode VisitReturnStatement(BoundReturnStatement node) + public override BoundNode? VisitNoOpStatement(BoundNoOpStatement node) => null; + public override BoundNode? VisitReturnStatement(BoundReturnStatement node) { this.Visit(node.ExpressionOpt); return null; } - public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node) + public override BoundNode? VisitYieldReturnStatement(BoundYieldReturnStatement node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitYieldBreakStatement(BoundYieldBreakStatement node) => null; - public override BoundNode VisitThrowStatement(BoundThrowStatement node) + public override BoundNode? VisitYieldBreakStatement(BoundYieldBreakStatement node) => null; + public override BoundNode? VisitThrowStatement(BoundThrowStatement node) { this.Visit(node.ExpressionOpt); return null; } - public override BoundNode VisitExpressionStatement(BoundExpressionStatement node) + public override BoundNode? VisitExpressionStatement(BoundExpressionStatement node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitBreakStatement(BoundBreakStatement node) => null; - public override BoundNode VisitContinueStatement(BoundContinueStatement node) => null; - public override BoundNode VisitSwitchStatement(BoundSwitchStatement node) + public override BoundNode? VisitBreakStatement(BoundBreakStatement node) => null; + public override BoundNode? VisitContinueStatement(BoundContinueStatement node) => null; + public override BoundNode? VisitSwitchStatement(BoundSwitchStatement node) { this.Visit(node.Expression); this.VisitList(node.SwitchSections); this.Visit(node.DefaultLabel); return null; } - public override BoundNode VisitSwitchDispatch(BoundSwitchDispatch node) + public override BoundNode? VisitSwitchDispatch(BoundSwitchDispatch node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitIfStatement(BoundIfStatement node) + public override BoundNode? VisitIfStatement(BoundIfStatement node) { this.Visit(node.Condition); this.Visit(node.Consequence); this.Visit(node.AlternativeOpt); return null; } - public override BoundNode VisitDoStatement(BoundDoStatement node) + public override BoundNode? VisitDoStatement(BoundDoStatement node) { this.Visit(node.Condition); this.Visit(node.Body); return null; } - public override BoundNode VisitWhileStatement(BoundWhileStatement node) + public override BoundNode? VisitWhileStatement(BoundWhileStatement node) { this.Visit(node.Condition); this.Visit(node.Body); return null; } - public override BoundNode VisitForStatement(BoundForStatement node) + public override BoundNode? VisitForStatement(BoundForStatement node) { this.Visit(node.Initializer); this.Visit(node.Condition); @@ -8897,7 +9084,7 @@ public override BoundNode VisitForStatement(BoundForStatement node) this.Visit(node.Body); return null; } - public override BoundNode VisitForEachStatement(BoundForEachStatement node) + public override BoundNode? VisitForEachStatement(BoundForEachStatement node) { this.Visit(node.IterationVariableType); this.Visit(node.IterationErrorExpressionOpt); @@ -8906,436 +9093,436 @@ public override BoundNode VisitForEachStatement(BoundForEachStatement node) this.Visit(node.Body); return null; } - public override BoundNode VisitForEachDeconstructStep(BoundForEachDeconstructStep node) + public override BoundNode? VisitForEachDeconstructStep(BoundForEachDeconstructStep node) { this.Visit(node.DeconstructionAssignment); this.Visit(node.TargetPlaceholder); return null; } - public override BoundNode VisitUsingStatement(BoundUsingStatement node) + public override BoundNode? VisitUsingStatement(BoundUsingStatement node) { this.Visit(node.DeclarationsOpt); this.Visit(node.ExpressionOpt); this.Visit(node.Body); return null; } - public override BoundNode VisitFixedStatement(BoundFixedStatement node) + public override BoundNode? VisitFixedStatement(BoundFixedStatement node) { this.Visit(node.Declarations); this.Visit(node.Body); return null; } - public override BoundNode VisitLockStatement(BoundLockStatement node) + public override BoundNode? VisitLockStatement(BoundLockStatement node) { this.Visit(node.Argument); this.Visit(node.Body); return null; } - public override BoundNode VisitTryStatement(BoundTryStatement node) + public override BoundNode? VisitTryStatement(BoundTryStatement node) { this.Visit(node.TryBlock); this.VisitList(node.CatchBlocks); this.Visit(node.FinallyBlockOpt); return null; } - public override BoundNode VisitCatchBlock(BoundCatchBlock node) + public override BoundNode? VisitCatchBlock(BoundCatchBlock node) { this.Visit(node.ExceptionSourceOpt); this.Visit(node.ExceptionFilterOpt); this.Visit(node.Body); return null; } - public override BoundNode VisitLiteral(BoundLiteral node) => null; - public override BoundNode VisitThisReference(BoundThisReference node) => null; - public override BoundNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) => null; - public override BoundNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node) => null; - public override BoundNode VisitBaseReference(BoundBaseReference node) => null; - public override BoundNode VisitLocal(BoundLocal node) => null; - public override BoundNode VisitPseudoVariable(BoundPseudoVariable node) => null; - public override BoundNode VisitRangeVariable(BoundRangeVariable node) + public override BoundNode? VisitLiteral(BoundLiteral node) => null; + public override BoundNode? VisitThisReference(BoundThisReference node) => null; + public override BoundNode? VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) => null; + public override BoundNode? VisitHostObjectMemberReference(BoundHostObjectMemberReference node) => null; + public override BoundNode? VisitBaseReference(BoundBaseReference node) => null; + public override BoundNode? VisitLocal(BoundLocal node) => null; + public override BoundNode? VisitPseudoVariable(BoundPseudoVariable node) => null; + public override BoundNode? VisitRangeVariable(BoundRangeVariable node) { this.Visit(node.Value); return null; } - public override BoundNode VisitParameter(BoundParameter node) => null; - public override BoundNode VisitLabelStatement(BoundLabelStatement node) => null; - public override BoundNode VisitGotoStatement(BoundGotoStatement node) + public override BoundNode? VisitParameter(BoundParameter node) => null; + public override BoundNode? VisitLabelStatement(BoundLabelStatement node) => null; + public override BoundNode? VisitGotoStatement(BoundGotoStatement node) { this.Visit(node.CaseExpressionOpt); this.Visit(node.LabelExpressionOpt); return null; } - public override BoundNode VisitLabeledStatement(BoundLabeledStatement node) + public override BoundNode? VisitLabeledStatement(BoundLabeledStatement node) { this.Visit(node.Body); return null; } - public override BoundNode VisitLabel(BoundLabel node) => null; - public override BoundNode VisitStatementList(BoundStatementList node) + public override BoundNode? VisitLabel(BoundLabel node) => null; + public override BoundNode? VisitStatementList(BoundStatementList node) { this.VisitList(node.Statements); return null; } - public override BoundNode VisitConditionalGoto(BoundConditionalGoto node) + public override BoundNode? VisitConditionalGoto(BoundConditionalGoto node) { this.Visit(node.Condition); return null; } - public override BoundNode VisitSwitchExpression(BoundSwitchExpression node) + public override BoundNode? VisitSwitchExpression(BoundSwitchExpression node) { this.Visit(node.Expression); this.VisitList(node.SwitchArms); return null; } - public override BoundNode VisitSwitchExpressionArm(BoundSwitchExpressionArm node) + public override BoundNode? VisitSwitchExpressionArm(BoundSwitchExpressionArm node) { this.Visit(node.Pattern); this.Visit(node.WhenClause); this.Visit(node.Value); return null; } - public override BoundNode VisitDecisionDag(BoundDecisionDag node) => null; - public override BoundNode VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) + public override BoundNode? VisitDecisionDag(BoundDecisionDag node) => null; + public override BoundNode? VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) { this.Visit(node.Evaluation); this.Visit(node.Next); return null; } - public override BoundNode VisitTestDecisionDagNode(BoundTestDecisionDagNode node) + public override BoundNode? VisitTestDecisionDagNode(BoundTestDecisionDagNode node) { this.Visit(node.Test); this.Visit(node.WhenTrue); this.Visit(node.WhenFalse); return null; } - public override BoundNode VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) + public override BoundNode? VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) { this.Visit(node.WhenExpression); this.Visit(node.WhenTrue); this.Visit(node.WhenFalse); return null; } - public override BoundNode VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => null; - public override BoundNode VisitDagTemp(BoundDagTemp node) + public override BoundNode? VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => null; + public override BoundNode? VisitDagTemp(BoundDagTemp node) { this.Visit(node.Source); return null; } - public override BoundNode VisitDagTypeTest(BoundDagTypeTest node) + public override BoundNode? VisitDagTypeTest(BoundDagTypeTest node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagNonNullTest(BoundDagNonNullTest node) + public override BoundNode? VisitDagNonNullTest(BoundDagNonNullTest node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagExplicitNullTest(BoundDagExplicitNullTest node) + public override BoundNode? VisitDagExplicitNullTest(BoundDagExplicitNullTest node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagValueTest(BoundDagValueTest node) + public override BoundNode? VisitDagValueTest(BoundDagValueTest node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) + public override BoundNode? VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagTypeEvaluation(BoundDagTypeEvaluation node) + public override BoundNode? VisitDagTypeEvaluation(BoundDagTypeEvaluation node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagFieldEvaluation(BoundDagFieldEvaluation node) + public override BoundNode? VisitDagFieldEvaluation(BoundDagFieldEvaluation node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) + public override BoundNode? VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) { this.Visit(node.Input); return null; } - public override BoundNode VisitDagIndexEvaluation(BoundDagIndexEvaluation node) + public override BoundNode? VisitDagIndexEvaluation(BoundDagIndexEvaluation node) { this.Visit(node.Input); return null; } - public override BoundNode VisitSwitchSection(BoundSwitchSection node) + public override BoundNode? VisitSwitchSection(BoundSwitchSection node) { this.VisitList(node.SwitchLabels); this.VisitList(node.Statements); return null; } - public override BoundNode VisitSwitchLabel(BoundSwitchLabel node) + public override BoundNode? VisitSwitchLabel(BoundSwitchLabel node) { this.Visit(node.Pattern); this.Visit(node.WhenClause); return null; } - public override BoundNode VisitSequencePointExpression(BoundSequencePointExpression node) + public override BoundNode? VisitSequencePointExpression(BoundSequencePointExpression node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitSequence(BoundSequence node) + public override BoundNode? VisitSequence(BoundSequence node) { this.VisitList(node.SideEffects); this.Visit(node.Value); return null; } - public override BoundNode VisitSpillSequence(BoundSpillSequence node) + public override BoundNode? VisitSpillSequence(BoundSpillSequence node) { this.VisitList(node.SideEffects); this.Visit(node.Value); return null; } - public override BoundNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node) + public override BoundNode? VisitDynamicMemberAccess(BoundDynamicMemberAccess node) { this.Visit(node.Receiver); return null; } - public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) + public override BoundNode? VisitDynamicInvocation(BoundDynamicInvocation node) { this.Visit(node.Expression); this.VisitList(node.Arguments); return null; } - public override BoundNode VisitConditionalAccess(BoundConditionalAccess node) + public override BoundNode? VisitConditionalAccess(BoundConditionalAccess node) { this.Visit(node.Receiver); this.Visit(node.AccessExpression); return null; } - public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) + public override BoundNode? VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) { this.Visit(node.Receiver); this.Visit(node.WhenNotNull); this.Visit(node.WhenNullOpt); return null; } - public override BoundNode VisitConditionalReceiver(BoundConditionalReceiver node) => null; - public override BoundNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) + public override BoundNode? VisitConditionalReceiver(BoundConditionalReceiver node) => null; + public override BoundNode? VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) { this.Visit(node.ValueTypeReceiver); this.Visit(node.ReferenceTypeReceiver); return null; } - public override BoundNode VisitMethodGroup(BoundMethodGroup node) + public override BoundNode? VisitMethodGroup(BoundMethodGroup node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitPropertyGroup(BoundPropertyGroup node) + public override BoundNode? VisitPropertyGroup(BoundPropertyGroup node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitCall(BoundCall node) + public override BoundNode? VisitCall(BoundCall node) { this.Visit(node.ReceiverOpt); this.VisitList(node.Arguments); return null; } - public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node) + public override BoundNode? VisitEventAssignmentOperator(BoundEventAssignmentOperator node) { this.Visit(node.ReceiverOpt); this.Visit(node.Argument); return null; } - public override BoundNode VisitAttribute(BoundAttribute node) + public override BoundNode? VisitAttribute(BoundAttribute node) { this.VisitList(node.ConstructorArguments); this.VisitList(node.NamedArguments); return null; } - public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node) + public override BoundNode? VisitObjectCreationExpression(BoundObjectCreationExpression node) { this.VisitList(node.Arguments); this.Visit(node.InitializerExpressionOpt); return null; } - public override BoundNode VisitTupleLiteral(BoundTupleLiteral node) + public override BoundNode? VisitTupleLiteral(BoundTupleLiteral node) { this.VisitList(node.Arguments); return null; } - public override BoundNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) + public override BoundNode? VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) { this.VisitList(node.Arguments); return null; } - public override BoundNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) + public override BoundNode? VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) { this.VisitList(node.Arguments); this.Visit(node.InitializerExpressionOpt); return null; } - public override BoundNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) + public override BoundNode? VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) { this.Visit(node.InitializerExpressionOpt); return null; } - public override BoundNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node) + public override BoundNode? VisitObjectInitializerExpression(BoundObjectInitializerExpression node) { this.VisitList(node.Initializers); return null; } - public override BoundNode VisitObjectInitializerMember(BoundObjectInitializerMember node) + public override BoundNode? VisitObjectInitializerMember(BoundObjectInitializerMember node) { this.VisitList(node.Arguments); return null; } - public override BoundNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) => null; - public override BoundNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) + public override BoundNode? VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) => null; + public override BoundNode? VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) { this.VisitList(node.Initializers); return null; } - public override BoundNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node) + public override BoundNode? VisitCollectionElementInitializer(BoundCollectionElementInitializer node) { this.VisitList(node.Arguments); this.Visit(node.ImplicitReceiverOpt); return null; } - public override BoundNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) + public override BoundNode? VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) { this.Visit(node.Expression); this.VisitList(node.Arguments); return null; } - public override BoundNode VisitImplicitReceiver(BoundImplicitReceiver node) => null; - public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) + public override BoundNode? VisitImplicitReceiver(BoundImplicitReceiver node) => null; + public override BoundNode? VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) { this.VisitList(node.Arguments); this.VisitList(node.Declarations); return null; } - public override BoundNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) => null; - public override BoundNode VisitNewT(BoundNewT node) + public override BoundNode? VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) => null; + public override BoundNode? VisitNewT(BoundNewT node) { this.Visit(node.InitializerExpressionOpt); return null; } - public override BoundNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node) + public override BoundNode? VisitDelegateCreationExpression(BoundDelegateCreationExpression node) { this.Visit(node.Argument); return null; } - public override BoundNode VisitArrayCreation(BoundArrayCreation node) + public override BoundNode? VisitArrayCreation(BoundArrayCreation node) { this.VisitList(node.Bounds); this.Visit(node.InitializerOpt); return null; } - public override BoundNode VisitArrayInitialization(BoundArrayInitialization node) + public override BoundNode? VisitArrayInitialization(BoundArrayInitialization node) { this.VisitList(node.Initializers); return null; } - public override BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) + public override BoundNode? VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) { this.Visit(node.Count); this.Visit(node.InitializerOpt); return null; } - public override BoundNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) + public override BoundNode? VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) { this.Visit(node.Count); this.Visit(node.InitializerOpt); return null; } - public override BoundNode VisitFieldAccess(BoundFieldAccess node) + public override BoundNode? VisitFieldAccess(BoundFieldAccess node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node) => null; - public override BoundNode VisitPropertyAccess(BoundPropertyAccess node) + public override BoundNode? VisitHoistedFieldAccess(BoundHoistedFieldAccess node) => null; + public override BoundNode? VisitPropertyAccess(BoundPropertyAccess node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitEventAccess(BoundEventAccess node) + public override BoundNode? VisitEventAccess(BoundEventAccess node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitIndexerAccess(BoundIndexerAccess node) + public override BoundNode? VisitIndexerAccess(BoundIndexerAccess node) { this.Visit(node.ReceiverOpt); this.VisitList(node.Arguments); return null; } - public override BoundNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) + public override BoundNode? VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) { this.Visit(node.Receiver); this.Visit(node.Argument); return null; } - public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) + public override BoundNode? VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) { this.Visit(node.ReceiverOpt); this.VisitList(node.Arguments); return null; } - public override BoundNode VisitLambda(BoundLambda node) + public override BoundNode? VisitLambda(BoundLambda node) { this.Visit(node.Body); return null; } - public override BoundNode VisitUnboundLambda(UnboundLambda node) => null; - public override BoundNode VisitQueryClause(BoundQueryClause node) + public override BoundNode? VisitUnboundLambda(UnboundLambda node) => null; + public override BoundNode? VisitQueryClause(BoundQueryClause node) { this.Visit(node.Value); return null; } - public override BoundNode VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) + public override BoundNode? VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) { this.VisitList(node.Statements); return null; } - public override BoundNode VisitNameOfOperator(BoundNameOfOperator node) + public override BoundNode? VisitNameOfOperator(BoundNameOfOperator node) { this.Visit(node.Argument); return null; } - public override BoundNode VisitInterpolatedString(BoundInterpolatedString node) + public override BoundNode? VisitInterpolatedString(BoundInterpolatedString node) { this.VisitList(node.Parts); return null; } - public override BoundNode VisitStringInsert(BoundStringInsert node) + public override BoundNode? VisitStringInsert(BoundStringInsert node) { this.Visit(node.Value); this.Visit(node.Alignment); this.Visit(node.Format); return null; } - public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node) + public override BoundNode? VisitIsPatternExpression(BoundIsPatternExpression node) { this.Visit(node.Expression); this.Visit(node.Pattern); return null; } - public override BoundNode VisitConstantPattern(BoundConstantPattern node) + public override BoundNode? VisitConstantPattern(BoundConstantPattern node) { this.Visit(node.Value); return null; } - public override BoundNode VisitDiscardPattern(BoundDiscardPattern node) => null; - public override BoundNode VisitDeclarationPattern(BoundDeclarationPattern node) + public override BoundNode? VisitDiscardPattern(BoundDiscardPattern node) => null; + public override BoundNode? VisitDeclarationPattern(BoundDeclarationPattern node) { this.Visit(node.VariableAccess); this.Visit(node.DeclaredType); return null; } - public override BoundNode VisitRecursivePattern(BoundRecursivePattern node) + public override BoundNode? VisitRecursivePattern(BoundRecursivePattern node) { this.Visit(node.DeclaredType); this.VisitList(node.Deconstruction); @@ -9343,47 +9530,47 @@ public override BoundNode VisitRecursivePattern(BoundRecursivePattern node) this.Visit(node.VariableAccess); return null; } - public override BoundNode VisitITuplePattern(BoundITuplePattern node) + public override BoundNode? VisitITuplePattern(BoundITuplePattern node) { this.VisitList(node.Subpatterns); return null; } - public override BoundNode VisitSubpattern(BoundSubpattern node) + public override BoundNode? VisitSubpattern(BoundSubpattern node) { this.Visit(node.Pattern); return null; } - public override BoundNode VisitDiscardExpression(BoundDiscardExpression node) => null; - public override BoundNode VisitThrowExpression(BoundThrowExpression node) + public override BoundNode? VisitDiscardExpression(BoundDiscardExpression node) => null; + public override BoundNode? VisitThrowExpression(BoundThrowExpression node) { this.Visit(node.Expression); return null; } - public override BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node) + public override BoundNode? VisitOutVariablePendingInference(OutVariablePendingInference node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) + public override BoundNode? VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) { this.Visit(node.ReceiverOpt); return null; } - public override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) => null; - public override BoundNode VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) + public override BoundNode? VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) => null; + public override BoundNode? VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) { this.Visit(node.BlockBody); this.Visit(node.ExpressionBody); return null; } - public override BoundNode VisitConstructorMethodBody(BoundConstructorMethodBody node) + public override BoundNode? VisitConstructorMethodBody(BoundConstructorMethodBody node) { this.Visit(node.Initializer); this.Visit(node.BlockBody); this.Visit(node.ExpressionBody); return null; } - public override BoundNode VisitExpressionWithNullability(BoundExpressionWithNullability node) + public override BoundNode? VisitExpressionWithNullability(BoundExpressionWithNullability node) { this.Visit(node.Expression); return null; @@ -9392,160 +9579,160 @@ public override BoundNode VisitExpressionWithNullability(BoundExpressionWithNull internal abstract partial class BoundTreeRewriter : BoundTreeVisitor { - public override BoundNode VisitFieldEqualsValue(BoundFieldEqualsValue node) + public override BoundNode? VisitFieldEqualsValue(BoundFieldEqualsValue node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); return node.Update(node.Field, node.Locals, value); } - public override BoundNode VisitPropertyEqualsValue(BoundPropertyEqualsValue node) + public override BoundNode? VisitPropertyEqualsValue(BoundPropertyEqualsValue node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); return node.Update(node.Property, node.Locals, value); } - public override BoundNode VisitParameterEqualsValue(BoundParameterEqualsValue node) + public override BoundNode? VisitParameterEqualsValue(BoundParameterEqualsValue node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); return node.Update(node.Parameter, node.Locals, value); } - public override BoundNode VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) + public override BoundNode? VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node) { BoundStatement statement = (BoundStatement)this.Visit(node.Statement); return node.Update(statement); } - public override BoundNode VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) + public override BoundNode? VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ValEscape, type); } - public override BoundNode VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) + public override BoundNode? VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) + public override BoundNode? VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) + public override BoundNode? VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitDup(BoundDup node) + public override BoundNode? VisitDup(BoundDup node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.RefKind, type); } - public override BoundNode VisitPassByCopy(BoundPassByCopy node) + public override BoundNode? VisitPassByCopy(BoundPassByCopy node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, type); } - public override BoundNode VisitBadExpression(BoundBadExpression node) + public override BoundNode? VisitBadExpression(BoundBadExpression node) { ImmutableArray childBoundNodes = this.VisitList(node.ChildBoundNodes); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ResultKind, node.Symbols, childBoundNodes, type); } - public override BoundNode VisitBadStatement(BoundBadStatement node) + public override BoundNode? VisitBadStatement(BoundBadStatement node) { ImmutableArray childBoundNodes = this.VisitList(node.ChildBoundNodes); return node.Update(childBoundNodes); } - public override BoundNode VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) + public override BoundNode? VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node) { BoundBlock finallyBlock = (BoundBlock)this.Visit(node.FinallyBlock); return node.Update(finallyBlock); } - public override BoundNode VisitTypeExpression(BoundTypeExpression node) + public override BoundNode? VisitTypeExpression(BoundTypeExpression node) { - BoundTypeExpression boundContainingTypeOpt = (BoundTypeExpression)this.Visit(node.BoundContainingTypeOpt); + BoundTypeExpression? boundContainingTypeOpt = (BoundTypeExpression?)this.Visit(node.BoundContainingTypeOpt); ImmutableArray boundDimensionsOpt = this.VisitList(node.BoundDimensionsOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.AliasOpt, boundContainingTypeOpt, boundDimensionsOpt, node.TypeWithAnnotations, type); } - public override BoundNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node) + public override BoundNode? VisitTypeOrValueExpression(BoundTypeOrValueExpression node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Data, type); } - public override BoundNode VisitNamespaceExpression(BoundNamespaceExpression node) + public override BoundNode? VisitNamespaceExpression(BoundNamespaceExpression node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.NamespaceSymbol, node.AliasOpt); } - public override BoundNode VisitUnaryOperator(BoundUnaryOperator node) + public override BoundNode? VisitUnaryOperator(BoundUnaryOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.OperatorKind, operand, node.ConstantValueOpt, node.MethodOpt, node.ResultKind, type); } - public override BoundNode VisitIncrementOperator(BoundIncrementOperator node) + public override BoundNode? VisitIncrementOperator(BoundIncrementOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.OperatorKind, operand, node.MethodOpt, node.OperandConversion, node.ResultConversion, node.ResultKind, type); } - public override BoundNode VisitAddressOfOperator(BoundAddressOfOperator node) + public override BoundNode? VisitAddressOfOperator(BoundAddressOfOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, node.IsManaged, type); } - public override BoundNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) + public override BoundNode? VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, type); } - public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node) + public override BoundNode? VisitPointerElementAccess(BoundPointerElementAccess node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundExpression index = (BoundExpression)this.Visit(node.Index); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, index, node.Checked, type); } - public override BoundNode VisitRefTypeOperator(BoundRefTypeOperator node) + public override BoundNode? VisitRefTypeOperator(BoundRefTypeOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, node.GetTypeFromHandle, type); } - public override BoundNode VisitMakeRefOperator(BoundMakeRefOperator node) + public override BoundNode? VisitMakeRefOperator(BoundMakeRefOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, type); } - public override BoundNode VisitRefValueOperator(BoundRefValueOperator node) + public override BoundNode? VisitRefValueOperator(BoundRefValueOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.NullableAnnotation, operand, type); } - public override BoundNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node) + public override BoundNode? VisitFromEndIndexExpression(BoundFromEndIndexExpression node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, node.MethodOpt, type); } - public override BoundNode VisitRangeExpression(BoundRangeExpression node) + public override BoundNode? VisitRangeExpression(BoundRangeExpression node) { - BoundExpression leftOperandOpt = (BoundExpression)this.Visit(node.LeftOperandOpt); - BoundExpression rightOperandOpt = (BoundExpression)this.Visit(node.RightOperandOpt); + BoundExpression? leftOperandOpt = (BoundExpression?)this.Visit(node.LeftOperandOpt); + BoundExpression? rightOperandOpt = (BoundExpression?)this.Visit(node.RightOperandOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(leftOperandOpt, rightOperandOpt, node.MethodOpt, type); } - public override BoundNode VisitBinaryOperator(BoundBinaryOperator node) + public override BoundNode? VisitBinaryOperator(BoundBinaryOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.OperatorKind, node.ConstantValueOpt, node.MethodOpt, node.ResultKind, left, right, type); } - public override BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node) + public override BoundNode? VisitTupleBinaryOperator(BoundTupleBinaryOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); @@ -9554,49 +9741,49 @@ public override BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node TypeSymbol type = this.VisitType(node.Type); return node.Update(left, right, convertedLeft, convertedRight, node.OperatorKind, node.Operators, type); } - public override BoundNode VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) + public override BoundNode? VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.OperatorKind, node.LogicalOperator, node.TrueOperator, node.FalseOperator, node.ResultKind, left, right, type); } - public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) + public override BoundNode? VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Operator, left, right, node.LeftConversion, node.FinalConversion, node.ResultKind, type); } - public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node) + public override BoundNode? VisitAssignmentOperator(BoundAssignmentOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); TypeSymbol type = this.VisitType(node.Type); return node.Update(left, right, node.IsRef, type); } - public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) + public override BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) { BoundTupleExpression left = (BoundTupleExpression)this.Visit(node.Left); BoundConversion right = (BoundConversion)this.Visit(node.Right); TypeSymbol type = this.VisitType(node.Type); return node.Update(left, right, node.IsUsed, type); } - public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node) + public override BoundNode? VisitNullCoalescingOperator(BoundNullCoalescingOperator node) { BoundExpression leftOperand = (BoundExpression)this.Visit(node.LeftOperand); BoundExpression rightOperand = (BoundExpression)this.Visit(node.RightOperand); TypeSymbol type = this.VisitType(node.Type); return node.Update(leftOperand, rightOperand, node.LeftConversion, node.OperatorResultKind, type); } - public override BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) + public override BoundNode? VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) { BoundExpression leftOperand = (BoundExpression)this.Visit(node.LeftOperand); BoundExpression rightOperand = (BoundExpression)this.Visit(node.RightOperand); TypeSymbol type = this.VisitType(node.Type); return node.Update(leftOperand, rightOperand, type); } - public override BoundNode VisitConditionalOperator(BoundConditionalOperator node) + public override BoundNode? VisitConditionalOperator(BoundConditionalOperator node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); BoundExpression consequence = (BoundExpression)this.Visit(node.Consequence); @@ -9604,362 +9791,362 @@ public override BoundNode VisitConditionalOperator(BoundConditionalOperator node TypeSymbol type = this.VisitType(node.Type); return node.Update(node.IsRef, condition, consequence, alternative, node.ConstantValueOpt, type); } - public override BoundNode VisitArrayAccess(BoundArrayAccess node) + public override BoundNode? VisitArrayAccess(BoundArrayAccess node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray indices = this.VisitList(node.Indices); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, indices, type); } - public override BoundNode VisitArrayLength(BoundArrayLength node) + public override BoundNode? VisitArrayLength(BoundArrayLength node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, type); } - public override BoundNode VisitAwaitExpression(BoundAwaitExpression node) + public override BoundNode? VisitAwaitExpression(BoundAwaitExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, node.AwaitableInfo, type); } - public override BoundNode VisitTypeOfOperator(BoundTypeOfOperator node) + public override BoundNode? VisitTypeOfOperator(BoundTypeOfOperator node) { BoundTypeExpression sourceType = (BoundTypeExpression)this.Visit(node.SourceType); TypeSymbol type = this.VisitType(node.Type); return node.Update(sourceType, node.GetTypeFromHandle, type); } - public override BoundNode VisitMethodDefIndex(BoundMethodDefIndex node) + public override BoundNode? VisitMethodDefIndex(BoundMethodDefIndex node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Method, type); } - public override BoundNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) + public override BoundNode? VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) + public override BoundNode? VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.AnalysisKind, type); } - public override BoundNode VisitModuleVersionId(BoundModuleVersionId node) + public override BoundNode? VisitModuleVersionId(BoundModuleVersionId node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitModuleVersionIdString(BoundModuleVersionIdString node) + public override BoundNode? VisitModuleVersionIdString(BoundModuleVersionIdString node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node) + public override BoundNode? VisitSourceDocumentIndex(BoundSourceDocumentIndex node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Document, type); } - public override BoundNode VisitMethodInfo(BoundMethodInfo node) + public override BoundNode? VisitMethodInfo(BoundMethodInfo node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Method, node.GetMethodFromHandle, type); } - public override BoundNode VisitFieldInfo(BoundFieldInfo node) + public override BoundNode? VisitFieldInfo(BoundFieldInfo node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Field, node.GetFieldFromHandle, type); } - public override BoundNode VisitDefaultExpression(BoundDefaultExpression node) + public override BoundNode? VisitDefaultExpression(BoundDefaultExpression node) { - BoundTypeExpression targetType = node.TargetType; + BoundTypeExpression? targetType = node.TargetType; TypeSymbol type = this.VisitType(node.Type); return node.Update(targetType, node.ConstantValueOpt, type); } - public override BoundNode VisitIsOperator(BoundIsOperator node) + public override BoundNode? VisitIsOperator(BoundIsOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundTypeExpression targetType = (BoundTypeExpression)this.Visit(node.TargetType); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, targetType, node.Conversion, type); } - public override BoundNode VisitAsOperator(BoundAsOperator node) + public override BoundNode? VisitAsOperator(BoundAsOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundTypeExpression targetType = (BoundTypeExpression)this.Visit(node.TargetType); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, targetType, node.Conversion, type); } - public override BoundNode VisitSizeOfOperator(BoundSizeOfOperator node) + public override BoundNode? VisitSizeOfOperator(BoundSizeOfOperator node) { BoundTypeExpression sourceType = (BoundTypeExpression)this.Visit(node.SourceType); TypeSymbol type = this.VisitType(node.Type); return node.Update(sourceType, node.ConstantValueOpt, type); } - public override BoundNode VisitConversion(BoundConversion node) + public override BoundNode? VisitConversion(BoundConversion node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, node.Conversion, node.IsBaseConversion, node.Checked, node.ExplicitCastInCode, node.ConstantValueOpt, node.ConversionGroupOpt, type); } - public override BoundNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) + public override BoundNode? VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); TypeSymbol type = this.VisitType(node.Type); return node.Update(operand, node.ConversionMethod, type); } - public override BoundNode VisitArgList(BoundArgList node) + public override BoundNode? VisitArgList(BoundArgList node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitArgListOperator(BoundArgListOperator node) + public override BoundNode? VisitArgListOperator(BoundArgListOperator node) { ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(arguments, node.ArgumentRefKindsOpt, type); } - public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) + public override BoundNode? VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol elementPointerType = this.VisitType(node.ElementPointerType); TypeSymbol type = this.VisitType(node.Type); return node.Update(elementPointerType, node.ElementPointerTypeConversion, expression, node.GetPinnableOpt, type); } - public override BoundNode VisitSequencePoint(BoundSequencePoint node) + public override BoundNode? VisitSequencePoint(BoundSequencePoint node) { - BoundStatement statementOpt = (BoundStatement)this.Visit(node.StatementOpt); + BoundStatement? statementOpt = (BoundStatement?)this.Visit(node.StatementOpt); return node.Update(statementOpt); } - public override BoundNode VisitSequencePointWithSpan(BoundSequencePointWithSpan node) + public override BoundNode? VisitSequencePointWithSpan(BoundSequencePointWithSpan node) { - BoundStatement statementOpt = (BoundStatement)this.Visit(node.StatementOpt); + BoundStatement? statementOpt = (BoundStatement?)this.Visit(node.StatementOpt); return node.Update(statementOpt, node.Span); } - public override BoundNode VisitBlock(BoundBlock node) + public override BoundNode? VisitBlock(BoundBlock node) { ImmutableArray statements = this.VisitList(node.Statements); return node.Update(node.Locals, node.LocalFunctions, statements); } - public override BoundNode VisitScope(BoundScope node) + public override BoundNode? VisitScope(BoundScope node) { ImmutableArray statements = this.VisitList(node.Statements); return node.Update(node.Locals, statements); } - public override BoundNode VisitStateMachineScope(BoundStateMachineScope node) + public override BoundNode? VisitStateMachineScope(BoundStateMachineScope node) { BoundStatement statement = (BoundStatement)this.Visit(node.Statement); return node.Update(node.Fields, statement); } - public override BoundNode VisitLocalDeclaration(BoundLocalDeclaration node) + public override BoundNode? VisitLocalDeclaration(BoundLocalDeclaration node) { - BoundTypeExpression declaredTypeOpt = (BoundTypeExpression)this.Visit(node.DeclaredTypeOpt); - BoundExpression initializerOpt = (BoundExpression)this.Visit(node.InitializerOpt); + BoundTypeExpression? declaredTypeOpt = (BoundTypeExpression?)this.Visit(node.DeclaredTypeOpt); + BoundExpression? initializerOpt = (BoundExpression?)this.Visit(node.InitializerOpt); ImmutableArray argumentsOpt = this.VisitList(node.ArgumentsOpt); return node.Update(node.LocalSymbol, declaredTypeOpt, initializerOpt, argumentsOpt, node.InferredType); } - public override BoundNode VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) + public override BoundNode? VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node) { ImmutableArray localDeclarations = this.VisitList(node.LocalDeclarations); return node.Update(localDeclarations); } - public override BoundNode VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) + public override BoundNode? VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node) { ImmutableArray localDeclarations = this.VisitList(node.LocalDeclarations); return node.Update(node.DisposeMethodOpt, node.IDisposableConversion, node.AwaitOpt, localDeclarations); } - public override BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node) + public override BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement node) { - BoundBlock blockBody = (BoundBlock)this.Visit(node.BlockBody); - BoundBlock expressionBody = (BoundBlock)this.Visit(node.ExpressionBody); + BoundBlock? blockBody = (BoundBlock?)this.Visit(node.BlockBody); + BoundBlock? expressionBody = (BoundBlock?)this.Visit(node.ExpressionBody); return node.Update(node.Symbol, blockBody, expressionBody); } - public override BoundNode VisitNoOpStatement(BoundNoOpStatement node) => node; - public override BoundNode VisitReturnStatement(BoundReturnStatement node) + public override BoundNode? VisitNoOpStatement(BoundNoOpStatement node) => node; + public override BoundNode? VisitReturnStatement(BoundReturnStatement node) { - BoundExpression expressionOpt = (BoundExpression)this.Visit(node.ExpressionOpt); + BoundExpression? expressionOpt = (BoundExpression?)this.Visit(node.ExpressionOpt); return node.Update(node.RefKind, expressionOpt); } - public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node) + public override BoundNode? VisitYieldReturnStatement(BoundYieldReturnStatement node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); return node.Update(expression); } - public override BoundNode VisitYieldBreakStatement(BoundYieldBreakStatement node) => node; - public override BoundNode VisitThrowStatement(BoundThrowStatement node) + public override BoundNode? VisitYieldBreakStatement(BoundYieldBreakStatement node) => node; + public override BoundNode? VisitThrowStatement(BoundThrowStatement node) { - BoundExpression expressionOpt = (BoundExpression)this.Visit(node.ExpressionOpt); + BoundExpression? expressionOpt = (BoundExpression?)this.Visit(node.ExpressionOpt); return node.Update(expressionOpt); } - public override BoundNode VisitExpressionStatement(BoundExpressionStatement node) + public override BoundNode? VisitExpressionStatement(BoundExpressionStatement node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); return node.Update(expression); } - public override BoundNode VisitBreakStatement(BoundBreakStatement node) => node; - public override BoundNode VisitContinueStatement(BoundContinueStatement node) => node; - public override BoundNode VisitSwitchStatement(BoundSwitchStatement node) + public override BoundNode? VisitBreakStatement(BoundBreakStatement node) => node; + public override BoundNode? VisitContinueStatement(BoundContinueStatement node) => node; + public override BoundNode? VisitSwitchStatement(BoundSwitchStatement node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray switchSections = this.VisitList(node.SwitchSections); BoundDecisionDag decisionDag = node.DecisionDag; - BoundSwitchLabel defaultLabel = (BoundSwitchLabel)this.Visit(node.DefaultLabel); + BoundSwitchLabel? defaultLabel = (BoundSwitchLabel?)this.Visit(node.DefaultLabel); return node.Update(expression, node.InnerLocals, node.InnerLocalFunctions, switchSections, decisionDag, defaultLabel, node.BreakLabel); } - public override BoundNode VisitSwitchDispatch(BoundSwitchDispatch node) + public override BoundNode? VisitSwitchDispatch(BoundSwitchDispatch node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); return node.Update(expression, node.Cases, node.DefaultLabel, node.EqualityMethod); } - public override BoundNode VisitIfStatement(BoundIfStatement node) + public override BoundNode? VisitIfStatement(BoundIfStatement node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); BoundStatement consequence = (BoundStatement)this.Visit(node.Consequence); - BoundStatement alternativeOpt = (BoundStatement)this.Visit(node.AlternativeOpt); + BoundStatement? alternativeOpt = (BoundStatement?)this.Visit(node.AlternativeOpt); return node.Update(condition, consequence, alternativeOpt); } - public override BoundNode VisitDoStatement(BoundDoStatement node) + public override BoundNode? VisitDoStatement(BoundDoStatement node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.Locals, condition, body, node.BreakLabel, node.ContinueLabel); } - public override BoundNode VisitWhileStatement(BoundWhileStatement node) + public override BoundNode? VisitWhileStatement(BoundWhileStatement node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.Locals, condition, body, node.BreakLabel, node.ContinueLabel); } - public override BoundNode VisitForStatement(BoundForStatement node) + public override BoundNode? VisitForStatement(BoundForStatement node) { - BoundStatement initializer = (BoundStatement)this.Visit(node.Initializer); - BoundExpression condition = (BoundExpression)this.Visit(node.Condition); - BoundStatement increment = (BoundStatement)this.Visit(node.Increment); + BoundStatement? initializer = (BoundStatement?)this.Visit(node.Initializer); + BoundExpression? condition = (BoundExpression?)this.Visit(node.Condition); + BoundStatement? increment = (BoundStatement?)this.Visit(node.Increment); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.OuterLocals, initializer, node.InnerLocals, condition, increment, body, node.BreakLabel, node.ContinueLabel); } - public override BoundNode VisitForEachStatement(BoundForEachStatement node) + public override BoundNode? VisitForEachStatement(BoundForEachStatement node) { BoundTypeExpression iterationVariableType = (BoundTypeExpression)this.Visit(node.IterationVariableType); - BoundExpression iterationErrorExpressionOpt = (BoundExpression)this.Visit(node.IterationErrorExpressionOpt); + BoundExpression? iterationErrorExpressionOpt = (BoundExpression?)this.Visit(node.IterationErrorExpressionOpt); BoundExpression expression = (BoundExpression)this.Visit(node.Expression); - BoundForEachDeconstructStep deconstructionOpt = (BoundForEachDeconstructStep)this.Visit(node.DeconstructionOpt); + BoundForEachDeconstructStep? deconstructionOpt = (BoundForEachDeconstructStep?)this.Visit(node.DeconstructionOpt); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.EnumeratorInfoOpt, node.ElementConversion, iterationVariableType, node.IterationVariables, iterationErrorExpressionOpt, expression, deconstructionOpt, node.AwaitOpt, body, node.Checked, node.BreakLabel, node.ContinueLabel); } - public override BoundNode VisitForEachDeconstructStep(BoundForEachDeconstructStep node) + public override BoundNode? VisitForEachDeconstructStep(BoundForEachDeconstructStep node) { BoundDeconstructionAssignmentOperator deconstructionAssignment = (BoundDeconstructionAssignmentOperator)this.Visit(node.DeconstructionAssignment); BoundDeconstructValuePlaceholder targetPlaceholder = (BoundDeconstructValuePlaceholder)this.Visit(node.TargetPlaceholder); return node.Update(deconstructionAssignment, targetPlaceholder); } - public override BoundNode VisitUsingStatement(BoundUsingStatement node) + public override BoundNode? VisitUsingStatement(BoundUsingStatement node) { - BoundMultipleLocalDeclarations declarationsOpt = (BoundMultipleLocalDeclarations)this.Visit(node.DeclarationsOpt); - BoundExpression expressionOpt = (BoundExpression)this.Visit(node.ExpressionOpt); + BoundMultipleLocalDeclarations? declarationsOpt = (BoundMultipleLocalDeclarations?)this.Visit(node.DeclarationsOpt); + BoundExpression? expressionOpt = (BoundExpression?)this.Visit(node.ExpressionOpt); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.Locals, declarationsOpt, expressionOpt, node.IDisposableConversion, body, node.AwaitOpt, node.DisposeMethodOpt); } - public override BoundNode VisitFixedStatement(BoundFixedStatement node) + public override BoundNode? VisitFixedStatement(BoundFixedStatement node) { BoundMultipleLocalDeclarations declarations = (BoundMultipleLocalDeclarations)this.Visit(node.Declarations); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.Locals, declarations, body); } - public override BoundNode VisitLockStatement(BoundLockStatement node) + public override BoundNode? VisitLockStatement(BoundLockStatement node) { BoundExpression argument = (BoundExpression)this.Visit(node.Argument); BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(argument, body); } - public override BoundNode VisitTryStatement(BoundTryStatement node) + public override BoundNode? VisitTryStatement(BoundTryStatement node) { BoundBlock tryBlock = (BoundBlock)this.Visit(node.TryBlock); ImmutableArray catchBlocks = this.VisitList(node.CatchBlocks); - BoundBlock finallyBlockOpt = (BoundBlock)this.Visit(node.FinallyBlockOpt); + BoundBlock? finallyBlockOpt = (BoundBlock?)this.Visit(node.FinallyBlockOpt); return node.Update(tryBlock, catchBlocks, finallyBlockOpt, node.FinallyLabelOpt, node.PreferFaultHandler); } - public override BoundNode VisitCatchBlock(BoundCatchBlock node) + public override BoundNode? VisitCatchBlock(BoundCatchBlock node) { - BoundExpression exceptionSourceOpt = (BoundExpression)this.Visit(node.ExceptionSourceOpt); - BoundExpression exceptionFilterOpt = (BoundExpression)this.Visit(node.ExceptionFilterOpt); + BoundExpression? exceptionSourceOpt = (BoundExpression?)this.Visit(node.ExceptionSourceOpt); + BoundExpression? exceptionFilterOpt = (BoundExpression?)this.Visit(node.ExceptionFilterOpt); BoundBlock body = (BoundBlock)this.Visit(node.Body); TypeSymbol exceptionTypeOpt = this.VisitType(node.ExceptionTypeOpt); return node.Update(node.Locals, exceptionSourceOpt, exceptionTypeOpt, exceptionFilterOpt, body, node.IsSynthesizedAsyncCatchAll); } - public override BoundNode VisitLiteral(BoundLiteral node) + public override BoundNode? VisitLiteral(BoundLiteral node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ConstantValueOpt, type); } - public override BoundNode VisitThisReference(BoundThisReference node) + public override BoundNode? VisitThisReference(BoundThisReference node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) + public override BoundNode? VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node) + public override BoundNode? VisitHostObjectMemberReference(BoundHostObjectMemberReference node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitBaseReference(BoundBaseReference node) + public override BoundNode? VisitBaseReference(BoundBaseReference node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitLocal(BoundLocal node) + public override BoundNode? VisitLocal(BoundLocal node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.LocalSymbol, node.DeclarationKind, node.ConstantValueOpt, node.IsNullableUnknown, type); } - public override BoundNode VisitPseudoVariable(BoundPseudoVariable node) + public override BoundNode? VisitPseudoVariable(BoundPseudoVariable node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.LocalSymbol, node.EmitExpressions, type); } - public override BoundNode VisitRangeVariable(BoundRangeVariable node) + public override BoundNode? VisitRangeVariable(BoundRangeVariable node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.RangeVariableSymbol, value, type); } - public override BoundNode VisitParameter(BoundParameter node) + public override BoundNode? VisitParameter(BoundParameter node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ParameterSymbol, type); } - public override BoundNode VisitLabelStatement(BoundLabelStatement node) => node; - public override BoundNode VisitGotoStatement(BoundGotoStatement node) + public override BoundNode? VisitLabelStatement(BoundLabelStatement node) => node; + public override BoundNode? VisitGotoStatement(BoundGotoStatement node) { - BoundExpression caseExpressionOpt = (BoundExpression)this.Visit(node.CaseExpressionOpt); - BoundLabel labelExpressionOpt = (BoundLabel)this.Visit(node.LabelExpressionOpt); + BoundExpression? caseExpressionOpt = (BoundExpression?)this.Visit(node.CaseExpressionOpt); + BoundLabel? labelExpressionOpt = (BoundLabel?)this.Visit(node.LabelExpressionOpt); return node.Update(node.Label, caseExpressionOpt, labelExpressionOpt); } - public override BoundNode VisitLabeledStatement(BoundLabeledStatement node) + public override BoundNode? VisitLabeledStatement(BoundLabeledStatement node) { BoundStatement body = (BoundStatement)this.Visit(node.Body); return node.Update(node.Label, body); } - public override BoundNode VisitLabel(BoundLabel node) + public override BoundNode? VisitLabel(BoundLabel node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Label, type); } - public override BoundNode VisitStatementList(BoundStatementList node) + public override BoundNode? VisitStatementList(BoundStatementList node) { ImmutableArray statements = this.VisitList(node.Statements); return node.Update(statements); } - public override BoundNode VisitConditionalGoto(BoundConditionalGoto node) + public override BoundNode? VisitConditionalGoto(BoundConditionalGoto node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); return node.Update(condition, node.JumpIfTrue, node.Label); } - public override BoundNode VisitSwitchExpression(BoundSwitchExpression node) + public override BoundNode? VisitSwitchExpression(BoundSwitchExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray switchArms = this.VisitList(node.SwitchArms); @@ -9967,411 +10154,411 @@ public override BoundNode VisitSwitchExpression(BoundSwitchExpression node) TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, switchArms, decisionDag, node.DefaultLabel, node.ReportedNotExhaustive, type); } - public override BoundNode VisitSwitchExpressionArm(BoundSwitchExpressionArm node) + public override BoundNode? VisitSwitchExpressionArm(BoundSwitchExpressionArm node) { BoundPattern pattern = (BoundPattern)this.Visit(node.Pattern); - BoundExpression whenClause = (BoundExpression)this.Visit(node.WhenClause); + BoundExpression? whenClause = (BoundExpression?)this.Visit(node.WhenClause); BoundExpression value = (BoundExpression)this.Visit(node.Value); return node.Update(node.Locals, pattern, whenClause, value, node.Label); } - public override BoundNode VisitDecisionDag(BoundDecisionDag node) => node; - public override BoundNode VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) + public override BoundNode? VisitDecisionDag(BoundDecisionDag node) => node; + public override BoundNode? VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node) { BoundDagEvaluation evaluation = (BoundDagEvaluation)this.Visit(node.Evaluation); BoundDecisionDagNode next = (BoundDecisionDagNode )this.Visit(node.Next); return node.Update(evaluation, next); } - public override BoundNode VisitTestDecisionDagNode(BoundTestDecisionDagNode node) + public override BoundNode? VisitTestDecisionDagNode(BoundTestDecisionDagNode node) { BoundDagTest test = (BoundDagTest)this.Visit(node.Test); BoundDecisionDagNode whenTrue = (BoundDecisionDagNode )this.Visit(node.WhenTrue); BoundDecisionDagNode whenFalse = (BoundDecisionDagNode )this.Visit(node.WhenFalse); return node.Update(test, whenTrue, whenFalse); } - public override BoundNode VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) + public override BoundNode? VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node) { - BoundExpression whenExpression = (BoundExpression)this.Visit(node.WhenExpression); + BoundExpression? whenExpression = (BoundExpression?)this.Visit(node.WhenExpression); BoundDecisionDagNode whenTrue = (BoundDecisionDagNode )this.Visit(node.WhenTrue); - BoundDecisionDagNode whenFalse = (BoundDecisionDagNode )this.Visit(node.WhenFalse); + BoundDecisionDagNode ? whenFalse = (BoundDecisionDagNode ?)this.Visit(node.WhenFalse); return node.Update(node.Bindings, whenExpression, whenTrue, whenFalse); } - public override BoundNode VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => node; - public override BoundNode VisitDagTemp(BoundDagTemp node) + public override BoundNode? VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node) => node; + public override BoundNode? VisitDagTemp(BoundDagTemp node) { - BoundDagEvaluation source = (BoundDagEvaluation)this.Visit(node.Source); + BoundDagEvaluation? source = (BoundDagEvaluation?)this.Visit(node.Source); TypeSymbol type = this.VisitType(node.Type); return node.Update(type, source, node.Index); } - public override BoundNode VisitDagTypeTest(BoundDagTypeTest node) + public override BoundNode? VisitDagTypeTest(BoundDagTypeTest node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); TypeSymbol type = this.VisitType(node.Type); return node.Update(type, input); } - public override BoundNode VisitDagNonNullTest(BoundDagNonNullTest node) + public override BoundNode? VisitDagNonNullTest(BoundDagNonNullTest node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(input); } - public override BoundNode VisitDagExplicitNullTest(BoundDagExplicitNullTest node) + public override BoundNode? VisitDagExplicitNullTest(BoundDagExplicitNullTest node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(input); } - public override BoundNode VisitDagValueTest(BoundDagValueTest node) + public override BoundNode? VisitDagValueTest(BoundDagValueTest node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(node.Value, input); } - public override BoundNode VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) + public override BoundNode? VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(node.DeconstructMethod, input); } - public override BoundNode VisitDagTypeEvaluation(BoundDagTypeEvaluation node) + public override BoundNode? VisitDagTypeEvaluation(BoundDagTypeEvaluation node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); TypeSymbol type = this.VisitType(node.Type); return node.Update(type, input); } - public override BoundNode VisitDagFieldEvaluation(BoundDagFieldEvaluation node) + public override BoundNode? VisitDagFieldEvaluation(BoundDagFieldEvaluation node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(node.Field, input); } - public override BoundNode VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) + public override BoundNode? VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(node.Property, input); } - public override BoundNode VisitDagIndexEvaluation(BoundDagIndexEvaluation node) + public override BoundNode? VisitDagIndexEvaluation(BoundDagIndexEvaluation node) { BoundDagTemp input = (BoundDagTemp)this.Visit(node.Input); return node.Update(node.Property, node.Index, input); } - public override BoundNode VisitSwitchSection(BoundSwitchSection node) + public override BoundNode? VisitSwitchSection(BoundSwitchSection node) { ImmutableArray switchLabels = this.VisitList(node.SwitchLabels); ImmutableArray statements = this.VisitList(node.Statements); return node.Update(node.Locals, switchLabels, statements); } - public override BoundNode VisitSwitchLabel(BoundSwitchLabel node) + public override BoundNode? VisitSwitchLabel(BoundSwitchLabel node) { BoundPattern pattern = (BoundPattern)this.Visit(node.Pattern); - BoundExpression whenClause = (BoundExpression)this.Visit(node.WhenClause); + BoundExpression? whenClause = (BoundExpression?)this.Visit(node.WhenClause); return node.Update(node.Label, pattern, whenClause); } - public override BoundNode VisitSequencePointExpression(BoundSequencePointExpression node) + public override BoundNode? VisitSequencePointExpression(BoundSequencePointExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, type); } - public override BoundNode VisitSequence(BoundSequence node) + public override BoundNode? VisitSequence(BoundSequence node) { ImmutableArray sideEffects = this.VisitList(node.SideEffects); BoundExpression value = (BoundExpression)this.Visit(node.Value); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Locals, sideEffects, value, type); } - public override BoundNode VisitSpillSequence(BoundSpillSequence node) + public override BoundNode? VisitSpillSequence(BoundSpillSequence node) { ImmutableArray sideEffects = this.VisitList(node.SideEffects); BoundExpression value = (BoundExpression)this.Visit(node.Value); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Locals, sideEffects, value, type); } - public override BoundNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node) + public override BoundNode? VisitDynamicMemberAccess(BoundDynamicMemberAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiver, node.TypeArgumentsOpt, node.Name, node.Invoked, node.Indexed, type); } - public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) + public override BoundNode? VisitDynamicInvocation(BoundDynamicInvocation node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.ApplicableMethods, expression, arguments, type); } - public override BoundNode VisitConditionalAccess(BoundConditionalAccess node) + public override BoundNode? VisitConditionalAccess(BoundConditionalAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression accessExpression = (BoundExpression)this.Visit(node.AccessExpression); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiver, accessExpression, type); } - public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) + public override BoundNode? VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression whenNotNull = (BoundExpression)this.Visit(node.WhenNotNull); - BoundExpression whenNullOpt = (BoundExpression)this.Visit(node.WhenNullOpt); + BoundExpression? whenNullOpt = (BoundExpression?)this.Visit(node.WhenNullOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiver, node.HasValueMethodOpt, whenNotNull, whenNullOpt, node.Id, type); } - public override BoundNode VisitConditionalReceiver(BoundConditionalReceiver node) + public override BoundNode? VisitConditionalReceiver(BoundConditionalReceiver node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Id, type); } - public override BoundNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) + public override BoundNode? VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) { BoundExpression valueTypeReceiver = (BoundExpression)this.Visit(node.ValueTypeReceiver); BoundExpression referenceTypeReceiver = (BoundExpression)this.Visit(node.ReferenceTypeReceiver); TypeSymbol type = this.VisitType(node.Type); return node.Update(valueTypeReceiver, referenceTypeReceiver, type); } - public override BoundNode VisitMethodGroup(BoundMethodGroup node) + public override BoundNode? VisitMethodGroup(BoundMethodGroup node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.TypeArgumentsOpt, node.Name, node.Methods, node.LookupSymbolOpt, node.LookupError, node.Flags, receiverOpt, node.ResultKind); } - public override BoundNode VisitPropertyGroup(BoundPropertyGroup node) + public override BoundNode? VisitPropertyGroup(BoundPropertyGroup node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Properties, receiverOpt, node.ResultKind); } - public override BoundNode VisitCall(BoundCall node) + public override BoundNode? VisitCall(BoundCall node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, node.Method, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.IsDelegateCall, node.Expanded, node.InvokedAsExtensionMethod, node.ArgsToParamsOpt, node.ResultKind, node.BinderOpt, type); } - public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node) + public override BoundNode? VisitEventAssignmentOperator(BoundEventAssignmentOperator node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundExpression argument = (BoundExpression)this.Visit(node.Argument); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Event, node.IsAddition, node.IsDynamic, receiverOpt, argument, type); } - public override BoundNode VisitAttribute(BoundAttribute node) + public override BoundNode? VisitAttribute(BoundAttribute node) { ImmutableArray constructorArguments = this.VisitList(node.ConstructorArguments); ImmutableArray namedArguments = this.VisitList(node.NamedArguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Constructor, constructorArguments, node.ConstructorArgumentNamesOpt, node.ConstructorArgumentsToParamsOpt, node.ConstructorExpanded, namedArguments, node.ResultKind, type); } - public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node) + public override BoundNode? VisitObjectCreationExpression(BoundObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Constructor, node.ConstructorsGroup, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.Expanded, node.ArgsToParamsOpt, node.ConstantValueOpt, initializerExpressionOpt, node.BinderOpt, type); } - public override BoundNode VisitTupleLiteral(BoundTupleLiteral node) + public override BoundNode? VisitTupleLiteral(BoundTupleLiteral node) { ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ArgumentNamesOpt, node.InferredNamesOpt, arguments, type); } - public override BoundNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) + public override BoundNode? VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) { BoundTupleLiteral sourceTuple = node.SourceTuple; ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(sourceTuple, arguments, type); } - public override BoundNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) + public override BoundNode? VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Name, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, initializerExpressionOpt, node.ApplicableMethods, type); } - public override BoundNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) + public override BoundNode? VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) { - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.GuidString, initializerExpressionOpt, type); } - public override BoundNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node) + public override BoundNode? VisitObjectInitializerExpression(BoundObjectInitializerExpression node) { ImmutableArray initializers = this.VisitList(node.Initializers); TypeSymbol type = this.VisitType(node.Type); return node.Update(initializers, type); } - public override BoundNode VisitObjectInitializerMember(BoundObjectInitializerMember node) + public override BoundNode? VisitObjectInitializerMember(BoundObjectInitializerMember node) { ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol receiverType = this.VisitType(node.ReceiverType); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.MemberSymbol, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.Expanded, node.ArgsToParamsOpt, node.ResultKind, receiverType, node.BinderOpt, type); } - public override BoundNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) + public override BoundNode? VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) { TypeSymbol receiverType = this.VisitType(node.ReceiverType); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.MemberName, receiverType, type); } - public override BoundNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) + public override BoundNode? VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) { ImmutableArray initializers = this.VisitList(node.Initializers); TypeSymbol type = this.VisitType(node.Type); return node.Update(initializers, type); } - public override BoundNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node) + public override BoundNode? VisitCollectionElementInitializer(BoundCollectionElementInitializer node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundExpression implicitReceiverOpt = (BoundExpression)this.Visit(node.ImplicitReceiverOpt); + BoundExpression? implicitReceiverOpt = (BoundExpression?)this.Visit(node.ImplicitReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.AddMethod, arguments, implicitReceiverOpt, node.Expanded, node.ArgsToParamsOpt, node.InvokedAsExtensionMethod, node.ResultKind, node.BinderOpt, type); } - public override BoundNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) + public override BoundNode? VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.ApplicableMethods, expression, arguments, type); } - public override BoundNode VisitImplicitReceiver(BoundImplicitReceiver node) + public override BoundNode? VisitImplicitReceiver(BoundImplicitReceiver node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) + public override BoundNode? VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); ImmutableArray declarations = this.VisitList(node.Declarations); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Constructor, arguments, declarations, type); } - public override BoundNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) + public override BoundNode? VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Property, type); } - public override BoundNode VisitNewT(BoundNewT node) + public override BoundNode? VisitNewT(BoundNewT node) { - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(initializerExpressionOpt, type); } - public override BoundNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node) + public override BoundNode? VisitDelegateCreationExpression(BoundDelegateCreationExpression node) { BoundExpression argument = (BoundExpression)this.Visit(node.Argument); TypeSymbol type = this.VisitType(node.Type); return node.Update(argument, node.MethodOpt, node.IsExtensionMethod, type); } - public override BoundNode VisitArrayCreation(BoundArrayCreation node) + public override BoundNode? VisitArrayCreation(BoundArrayCreation node) { ImmutableArray bounds = this.VisitList(node.Bounds); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(bounds, initializerOpt, type); } - public override BoundNode VisitArrayInitialization(BoundArrayInitialization node) + public override BoundNode? VisitArrayInitialization(BoundArrayInitialization node) { ImmutableArray initializers = this.VisitList(node.Initializers); TypeSymbol type = this.VisitType(node.Type); return node.Update(initializers); } - public override BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) + public override BoundNode? VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) { BoundExpression count = (BoundExpression)this.Visit(node.Count); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); TypeSymbol elementType = this.VisitType(node.ElementType); TypeSymbol type = this.VisitType(node.Type); return node.Update(elementType, count, initializerOpt, type); } - public override BoundNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) + public override BoundNode? VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) { BoundExpression count = (BoundExpression)this.Visit(node.Count); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); TypeSymbol elementType = this.VisitType(node.ElementType); TypeSymbol type = this.VisitType(node.Type); return node.Update(elementType, count, initializerOpt, type); } - public override BoundNode VisitFieldAccess(BoundFieldAccess node) + public override BoundNode? VisitFieldAccess(BoundFieldAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, node.FieldSymbol, node.ConstantValueOpt, node.ResultKind, node.IsByValue, node.IsDeclaration, type); } - public override BoundNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node) + public override BoundNode? VisitHoistedFieldAccess(BoundHoistedFieldAccess node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.FieldSymbol, type); } - public override BoundNode VisitPropertyAccess(BoundPropertyAccess node) + public override BoundNode? VisitPropertyAccess(BoundPropertyAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, node.PropertySymbol, node.ResultKind, type); } - public override BoundNode VisitEventAccess(BoundEventAccess node) + public override BoundNode? VisitEventAccess(BoundEventAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, node.EventSymbol, node.IsUsableAsField, node.ResultKind, type); } - public override BoundNode VisitIndexerAccess(BoundIndexerAccess node) + public override BoundNode? VisitIndexerAccess(BoundIndexerAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, node.Indexer, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.Expanded, node.ArgsToParamsOpt, node.BinderOpt, node.UseSetterForDefaultArgumentGeneration, type); } - public override BoundNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) + public override BoundNode? VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression argument = (BoundExpression)this.Visit(node.Argument); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiver, node.LengthOrCountProperty, node.PatternSymbol, argument, type); } - public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) + public override BoundNode? VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); TypeSymbol type = this.VisitType(node.Type); return node.Update(receiverOpt, arguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.ApplicableIndexers, type); } - public override BoundNode VisitLambda(BoundLambda node) + public override BoundNode? VisitLambda(BoundLambda node) { UnboundLambda unboundLambda = node.UnboundLambda; BoundBlock body = (BoundBlock)this.Visit(node.Body); TypeSymbol type = this.VisitType(node.Type); return node.Update(unboundLambda, node.Symbol, body, node.Diagnostics, node.Binder, type); } - public override BoundNode VisitUnboundLambda(UnboundLambda node) + public override BoundNode? VisitUnboundLambda(UnboundLambda node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(node.Data); } - public override BoundNode VisitQueryClause(BoundQueryClause node) + public override BoundNode? VisitQueryClause(BoundQueryClause node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); TypeSymbol type = this.VisitType(node.Type); return node.Update(value, node.DefinedSymbol, node.Binder, type); } - public override BoundNode VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) + public override BoundNode? VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node) { ImmutableArray statements = this.VisitList(node.Statements); return node.Update(statements); } - public override BoundNode VisitNameOfOperator(BoundNameOfOperator node) + public override BoundNode? VisitNameOfOperator(BoundNameOfOperator node) { BoundExpression argument = (BoundExpression)this.Visit(node.Argument); TypeSymbol type = this.VisitType(node.Type); return node.Update(argument, node.ConstantValueOpt, type); } - public override BoundNode VisitInterpolatedString(BoundInterpolatedString node) + public override BoundNode? VisitInterpolatedString(BoundInterpolatedString node) { ImmutableArray parts = this.VisitList(node.Parts); TypeSymbol type = this.VisitType(node.Type); return node.Update(parts, type); } - public override BoundNode VisitStringInsert(BoundStringInsert node) + public override BoundNode? VisitStringInsert(BoundStringInsert node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); - BoundExpression alignment = (BoundExpression)this.Visit(node.Alignment); - BoundLiteral format = (BoundLiteral)this.Visit(node.Format); + BoundExpression? alignment = (BoundExpression?)this.Visit(node.Alignment); + BoundLiteral? format = (BoundLiteral?)this.Visit(node.Format); TypeSymbol type = this.VisitType(node.Type); return node.Update(value, alignment, format, type); } - public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node) + public override BoundNode? VisitIsPatternExpression(BoundIsPatternExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundPattern pattern = (BoundPattern)this.Visit(node.Pattern); @@ -10379,86 +10566,86 @@ public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, pattern, decisionDag, node.WhenTrueLabel, node.WhenFalseLabel, type); } - public override BoundNode VisitConstantPattern(BoundConstantPattern node) + public override BoundNode? VisitConstantPattern(BoundConstantPattern node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); TypeSymbol inputType = this.VisitType(node.InputType); return node.Update(value, node.ConstantValue, inputType); } - public override BoundNode VisitDiscardPattern(BoundDiscardPattern node) + public override BoundNode? VisitDiscardPattern(BoundDiscardPattern node) { TypeSymbol inputType = this.VisitType(node.InputType); return node.Update(inputType); } - public override BoundNode VisitDeclarationPattern(BoundDeclarationPattern node) + public override BoundNode? VisitDeclarationPattern(BoundDeclarationPattern node) { - BoundExpression variableAccess = (BoundExpression)this.Visit(node.VariableAccess); - BoundTypeExpression declaredType = (BoundTypeExpression)this.Visit(node.DeclaredType); + BoundExpression? variableAccess = (BoundExpression?)this.Visit(node.VariableAccess); + BoundTypeExpression? declaredType = (BoundTypeExpression?)this.Visit(node.DeclaredType); TypeSymbol inputType = this.VisitType(node.InputType); return node.Update(node.Variable, variableAccess, declaredType, node.IsVar, inputType); } - public override BoundNode VisitRecursivePattern(BoundRecursivePattern node) + public override BoundNode? VisitRecursivePattern(BoundRecursivePattern node) { - BoundTypeExpression declaredType = (BoundTypeExpression)this.Visit(node.DeclaredType); + BoundTypeExpression? declaredType = (BoundTypeExpression?)this.Visit(node.DeclaredType); ImmutableArray deconstruction = this.VisitList(node.Deconstruction); ImmutableArray properties = this.VisitList(node.Properties); - BoundExpression variableAccess = (BoundExpression)this.Visit(node.VariableAccess); + BoundExpression? variableAccess = (BoundExpression?)this.Visit(node.VariableAccess); TypeSymbol inputType = this.VisitType(node.InputType); return node.Update(declaredType, node.DeconstructMethod, deconstruction, properties, node.Variable, variableAccess, inputType); } - public override BoundNode VisitITuplePattern(BoundITuplePattern node) + public override BoundNode? VisitITuplePattern(BoundITuplePattern node) { ImmutableArray subpatterns = this.VisitList(node.Subpatterns); TypeSymbol inputType = this.VisitType(node.InputType); return node.Update(node.GetLengthMethod, node.GetItemMethod, subpatterns, inputType); } - public override BoundNode VisitSubpattern(BoundSubpattern node) + public override BoundNode? VisitSubpattern(BoundSubpattern node) { BoundPattern pattern = (BoundPattern)this.Visit(node.Pattern); return node.Update(node.Symbol, pattern); } - public override BoundNode VisitDiscardExpression(BoundDiscardExpression node) + public override BoundNode? VisitDiscardExpression(BoundDiscardExpression node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(type); } - public override BoundNode VisitThrowExpression(BoundThrowExpression node) + public override BoundNode? VisitThrowExpression(BoundThrowExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); return node.Update(expression, type); } - public override BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node) + public override BoundNode? VisitOutVariablePendingInference(OutVariablePendingInference node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.VariableSymbol, receiverOpt); } - public override BoundNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) + public override BoundNode? VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); TypeSymbol type = this.VisitType(node.Type); return node.Update(node.VariableSymbol, receiverOpt); } - public override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) + public override BoundNode? VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) { TypeSymbol type = this.VisitType(node.Type); return node.Update(); } - public override BoundNode VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) + public override BoundNode? VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node) { - BoundBlock blockBody = (BoundBlock)this.Visit(node.BlockBody); - BoundBlock expressionBody = (BoundBlock)this.Visit(node.ExpressionBody); + BoundBlock? blockBody = (BoundBlock?)this.Visit(node.BlockBody); + BoundBlock? expressionBody = (BoundBlock?)this.Visit(node.ExpressionBody); return node.Update(blockBody, expressionBody); } - public override BoundNode VisitConstructorMethodBody(BoundConstructorMethodBody node) + public override BoundNode? VisitConstructorMethodBody(BoundConstructorMethodBody node) { - BoundExpressionStatement initializer = (BoundExpressionStatement)this.Visit(node.Initializer); - BoundBlock blockBody = (BoundBlock)this.Visit(node.BlockBody); - BoundBlock expressionBody = (BoundBlock)this.Visit(node.ExpressionBody); + BoundExpressionStatement? initializer = (BoundExpressionStatement?)this.Visit(node.Initializer); + BoundBlock? blockBody = (BoundBlock?)this.Visit(node.BlockBody); + BoundBlock? expressionBody = (BoundBlock?)this.Visit(node.ExpressionBody); return node.Update(node.Locals, initializer, blockBody, expressionBody); } - public override BoundNode VisitExpressionWithNullability(BoundExpressionWithNullability node) + public override BoundNode? VisitExpressionWithNullability(BoundExpressionWithNullability node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); TypeSymbol type = this.VisitType(node.Type); @@ -10475,7 +10662,7 @@ public NullabilityRewriter(ImmutableDictionary childBoundNodes = this.VisitList(node.ChildBoundNodes); BoundBadExpression updatedNode; @@ -10569,9 +10756,9 @@ public override BoundNode VisitBadExpression(BoundBadExpression node) return updatedNode; } - public override BoundNode VisitTypeExpression(BoundTypeExpression node) + public override BoundNode? VisitTypeExpression(BoundTypeExpression node) { - BoundTypeExpression boundContainingTypeOpt = (BoundTypeExpression)this.Visit(node.BoundContainingTypeOpt); + BoundTypeExpression? boundContainingTypeOpt = (BoundTypeExpression?)this.Visit(node.BoundContainingTypeOpt); ImmutableArray boundDimensionsOpt = this.VisitList(node.BoundDimensionsOpt); BoundTypeExpression updatedNode; @@ -10587,7 +10774,7 @@ public override BoundNode VisitTypeExpression(BoundTypeExpression node) return updatedNode; } - public override BoundNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node) + public override BoundNode? VisitTypeOrValueExpression(BoundTypeOrValueExpression node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -10599,7 +10786,7 @@ public override BoundNode VisitTypeOrValueExpression(BoundTypeOrValueExpression return updatedNode; } - public override BoundNode VisitNamespaceExpression(BoundNamespaceExpression node) + public override BoundNode? VisitNamespaceExpression(BoundNamespaceExpression node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -10611,7 +10798,7 @@ public override BoundNode VisitNamespaceExpression(BoundNamespaceExpression node return updatedNode; } - public override BoundNode VisitUnaryOperator(BoundUnaryOperator node) + public override BoundNode? VisitUnaryOperator(BoundUnaryOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundUnaryOperator updatedNode; @@ -10628,7 +10815,7 @@ public override BoundNode VisitUnaryOperator(BoundUnaryOperator node) return updatedNode; } - public override BoundNode VisitIncrementOperator(BoundIncrementOperator node) + public override BoundNode? VisitIncrementOperator(BoundIncrementOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundIncrementOperator updatedNode; @@ -10645,7 +10832,7 @@ public override BoundNode VisitIncrementOperator(BoundIncrementOperator node) return updatedNode; } - public override BoundNode VisitAddressOfOperator(BoundAddressOfOperator node) + public override BoundNode? VisitAddressOfOperator(BoundAddressOfOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundAddressOfOperator updatedNode; @@ -10662,7 +10849,7 @@ public override BoundNode VisitAddressOfOperator(BoundAddressOfOperator node) return updatedNode; } - public override BoundNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) + public override BoundNode? VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundPointerIndirectionOperator updatedNode; @@ -10679,7 +10866,7 @@ public override BoundNode VisitPointerIndirectionOperator(BoundPointerIndirectio return updatedNode; } - public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node) + public override BoundNode? VisitPointerElementAccess(BoundPointerElementAccess node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundExpression index = (BoundExpression)this.Visit(node.Index); @@ -10697,7 +10884,7 @@ public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess no return updatedNode; } - public override BoundNode VisitRefTypeOperator(BoundRefTypeOperator node) + public override BoundNode? VisitRefTypeOperator(BoundRefTypeOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundRefTypeOperator updatedNode; @@ -10714,7 +10901,7 @@ public override BoundNode VisitRefTypeOperator(BoundRefTypeOperator node) return updatedNode; } - public override BoundNode VisitMakeRefOperator(BoundMakeRefOperator node) + public override BoundNode? VisitMakeRefOperator(BoundMakeRefOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundMakeRefOperator updatedNode; @@ -10731,7 +10918,7 @@ public override BoundNode VisitMakeRefOperator(BoundMakeRefOperator node) return updatedNode; } - public override BoundNode VisitRefValueOperator(BoundRefValueOperator node) + public override BoundNode? VisitRefValueOperator(BoundRefValueOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundRefValueOperator updatedNode; @@ -10748,7 +10935,7 @@ public override BoundNode VisitRefValueOperator(BoundRefValueOperator node) return updatedNode; } - public override BoundNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node) + public override BoundNode? VisitFromEndIndexExpression(BoundFromEndIndexExpression node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundFromEndIndexExpression updatedNode; @@ -10765,10 +10952,10 @@ public override BoundNode VisitFromEndIndexExpression(BoundFromEndIndexExpressio return updatedNode; } - public override BoundNode VisitRangeExpression(BoundRangeExpression node) + public override BoundNode? VisitRangeExpression(BoundRangeExpression node) { - BoundExpression leftOperandOpt = (BoundExpression)this.Visit(node.LeftOperandOpt); - BoundExpression rightOperandOpt = (BoundExpression)this.Visit(node.RightOperandOpt); + BoundExpression? leftOperandOpt = (BoundExpression?)this.Visit(node.LeftOperandOpt); + BoundExpression? rightOperandOpt = (BoundExpression?)this.Visit(node.RightOperandOpt); BoundRangeExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -10783,7 +10970,7 @@ public override BoundNode VisitRangeExpression(BoundRangeExpression node) return updatedNode; } - public override BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node) + public override BoundNode? VisitTupleBinaryOperator(BoundTupleBinaryOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); @@ -10803,7 +10990,7 @@ public override BoundNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node return updatedNode; } - public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) + public override BoundNode? VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); @@ -10821,7 +11008,7 @@ public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmen return updatedNode; } - public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node) + public override BoundNode? VisitAssignmentOperator(BoundAssignmentOperator node) { BoundExpression left = (BoundExpression)this.Visit(node.Left); BoundExpression right = (BoundExpression)this.Visit(node.Right); @@ -10839,7 +11026,7 @@ public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node) return updatedNode; } - public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) + public override BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) { BoundTupleExpression left = (BoundTupleExpression)this.Visit(node.Left); BoundConversion right = (BoundConversion)this.Visit(node.Right); @@ -10857,7 +11044,7 @@ public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstruct return updatedNode; } - public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node) + public override BoundNode? VisitNullCoalescingOperator(BoundNullCoalescingOperator node) { BoundExpression leftOperand = (BoundExpression)this.Visit(node.LeftOperand); BoundExpression rightOperand = (BoundExpression)this.Visit(node.RightOperand); @@ -10875,7 +11062,7 @@ public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperato return updatedNode; } - public override BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) + public override BoundNode? VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node) { BoundExpression leftOperand = (BoundExpression)this.Visit(node.LeftOperand); BoundExpression rightOperand = (BoundExpression)this.Visit(node.RightOperand); @@ -10893,7 +11080,7 @@ public override BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalesc return updatedNode; } - public override BoundNode VisitConditionalOperator(BoundConditionalOperator node) + public override BoundNode? VisitConditionalOperator(BoundConditionalOperator node) { BoundExpression condition = (BoundExpression)this.Visit(node.Condition); BoundExpression consequence = (BoundExpression)this.Visit(node.Consequence); @@ -10912,7 +11099,7 @@ public override BoundNode VisitConditionalOperator(BoundConditionalOperator node return updatedNode; } - public override BoundNode VisitArrayAccess(BoundArrayAccess node) + public override BoundNode? VisitArrayAccess(BoundArrayAccess node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray indices = this.VisitList(node.Indices); @@ -10930,7 +11117,7 @@ public override BoundNode VisitArrayAccess(BoundArrayAccess node) return updatedNode; } - public override BoundNode VisitArrayLength(BoundArrayLength node) + public override BoundNode? VisitArrayLength(BoundArrayLength node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundArrayLength updatedNode; @@ -10947,7 +11134,7 @@ public override BoundNode VisitArrayLength(BoundArrayLength node) return updatedNode; } - public override BoundNode VisitAwaitExpression(BoundAwaitExpression node) + public override BoundNode? VisitAwaitExpression(BoundAwaitExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundAwaitExpression updatedNode; @@ -10964,7 +11151,7 @@ public override BoundNode VisitAwaitExpression(BoundAwaitExpression node) return updatedNode; } - public override BoundNode VisitTypeOfOperator(BoundTypeOfOperator node) + public override BoundNode? VisitTypeOfOperator(BoundTypeOfOperator node) { BoundTypeExpression sourceType = (BoundTypeExpression)this.Visit(node.SourceType); BoundTypeOfOperator updatedNode; @@ -10981,7 +11168,7 @@ public override BoundNode VisitTypeOfOperator(BoundTypeOfOperator node) return updatedNode; } - public override BoundNode VisitMethodDefIndex(BoundMethodDefIndex node) + public override BoundNode? VisitMethodDefIndex(BoundMethodDefIndex node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -10993,7 +11180,7 @@ public override BoundNode VisitMethodDefIndex(BoundMethodDefIndex node) return updatedNode; } - public override BoundNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) + public override BoundNode? VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11005,7 +11192,7 @@ public override BoundNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex return updatedNode; } - public override BoundNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) + public override BoundNode? VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11017,7 +11204,7 @@ public override BoundNode VisitInstrumentationPayloadRoot(BoundInstrumentationPa return updatedNode; } - public override BoundNode VisitModuleVersionId(BoundModuleVersionId node) + public override BoundNode? VisitModuleVersionId(BoundModuleVersionId node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11029,7 +11216,7 @@ public override BoundNode VisitModuleVersionId(BoundModuleVersionId node) return updatedNode; } - public override BoundNode VisitModuleVersionIdString(BoundModuleVersionIdString node) + public override BoundNode? VisitModuleVersionIdString(BoundModuleVersionIdString node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11041,7 +11228,7 @@ public override BoundNode VisitModuleVersionIdString(BoundModuleVersionIdString return updatedNode; } - public override BoundNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node) + public override BoundNode? VisitSourceDocumentIndex(BoundSourceDocumentIndex node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11053,7 +11240,7 @@ public override BoundNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node return updatedNode; } - public override BoundNode VisitMethodInfo(BoundMethodInfo node) + public override BoundNode? VisitMethodInfo(BoundMethodInfo node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11065,7 +11252,7 @@ public override BoundNode VisitMethodInfo(BoundMethodInfo node) return updatedNode; } - public override BoundNode VisitFieldInfo(BoundFieldInfo node) + public override BoundNode? VisitFieldInfo(BoundFieldInfo node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11077,9 +11264,9 @@ public override BoundNode VisitFieldInfo(BoundFieldInfo node) return updatedNode; } - public override BoundNode VisitDefaultExpression(BoundDefaultExpression node) + public override BoundNode? VisitDefaultExpression(BoundDefaultExpression node) { - BoundTypeExpression targetType = node.TargetType; + BoundTypeExpression? targetType = node.TargetType; BoundDefaultExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11094,7 +11281,7 @@ public override BoundNode VisitDefaultExpression(BoundDefaultExpression node) return updatedNode; } - public override BoundNode VisitIsOperator(BoundIsOperator node) + public override BoundNode? VisitIsOperator(BoundIsOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundTypeExpression targetType = (BoundTypeExpression)this.Visit(node.TargetType); @@ -11112,7 +11299,7 @@ public override BoundNode VisitIsOperator(BoundIsOperator node) return updatedNode; } - public override BoundNode VisitAsOperator(BoundAsOperator node) + public override BoundNode? VisitAsOperator(BoundAsOperator node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundTypeExpression targetType = (BoundTypeExpression)this.Visit(node.TargetType); @@ -11130,7 +11317,7 @@ public override BoundNode VisitAsOperator(BoundAsOperator node) return updatedNode; } - public override BoundNode VisitSizeOfOperator(BoundSizeOfOperator node) + public override BoundNode? VisitSizeOfOperator(BoundSizeOfOperator node) { BoundTypeExpression sourceType = (BoundTypeExpression)this.Visit(node.SourceType); BoundSizeOfOperator updatedNode; @@ -11147,7 +11334,7 @@ public override BoundNode VisitSizeOfOperator(BoundSizeOfOperator node) return updatedNode; } - public override BoundNode VisitConversion(BoundConversion node) + public override BoundNode? VisitConversion(BoundConversion node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundConversion updatedNode; @@ -11164,7 +11351,7 @@ public override BoundNode VisitConversion(BoundConversion node) return updatedNode; } - public override BoundNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) + public override BoundNode? VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node) { BoundExpression operand = (BoundExpression)this.Visit(node.Operand); BoundReadOnlySpanFromArray updatedNode; @@ -11181,7 +11368,7 @@ public override BoundNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray return updatedNode; } - public override BoundNode VisitArgList(BoundArgList node) + public override BoundNode? VisitArgList(BoundArgList node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11193,7 +11380,7 @@ public override BoundNode VisitArgList(BoundArgList node) return updatedNode; } - public override BoundNode VisitArgListOperator(BoundArgListOperator node) + public override BoundNode? VisitArgListOperator(BoundArgListOperator node) { ImmutableArray arguments = this.VisitList(node.Arguments); BoundArgListOperator updatedNode; @@ -11210,7 +11397,7 @@ public override BoundNode VisitArgListOperator(BoundArgListOperator node) return updatedNode; } - public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) + public override BoundNode? VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundFixedLocalCollectionInitializer updatedNode; @@ -11227,7 +11414,7 @@ public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCo return updatedNode; } - public override BoundNode VisitLiteral(BoundLiteral node) + public override BoundNode? VisitLiteral(BoundLiteral node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11239,7 +11426,7 @@ public override BoundNode VisitLiteral(BoundLiteral node) return updatedNode; } - public override BoundNode VisitThisReference(BoundThisReference node) + public override BoundNode? VisitThisReference(BoundThisReference node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11251,7 +11438,7 @@ public override BoundNode VisitThisReference(BoundThisReference node) return updatedNode; } - public override BoundNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) + public override BoundNode? VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11263,7 +11450,7 @@ public override BoundNode VisitPreviousSubmissionReference(BoundPreviousSubmissi return updatedNode; } - public override BoundNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node) + public override BoundNode? VisitHostObjectMemberReference(BoundHostObjectMemberReference node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11275,7 +11462,7 @@ public override BoundNode VisitHostObjectMemberReference(BoundHostObjectMemberRe return updatedNode; } - public override BoundNode VisitBaseReference(BoundBaseReference node) + public override BoundNode? VisitBaseReference(BoundBaseReference node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11287,7 +11474,7 @@ public override BoundNode VisitBaseReference(BoundBaseReference node) return updatedNode; } - public override BoundNode VisitLocal(BoundLocal node) + public override BoundNode? VisitLocal(BoundLocal node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11299,7 +11486,7 @@ public override BoundNode VisitLocal(BoundLocal node) return updatedNode; } - public override BoundNode VisitPseudoVariable(BoundPseudoVariable node) + public override BoundNode? VisitPseudoVariable(BoundPseudoVariable node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11311,7 +11498,7 @@ public override BoundNode VisitPseudoVariable(BoundPseudoVariable node) return updatedNode; } - public override BoundNode VisitRangeVariable(BoundRangeVariable node) + public override BoundNode? VisitRangeVariable(BoundRangeVariable node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); BoundRangeVariable updatedNode; @@ -11328,7 +11515,7 @@ public override BoundNode VisitRangeVariable(BoundRangeVariable node) return updatedNode; } - public override BoundNode VisitParameter(BoundParameter node) + public override BoundNode? VisitParameter(BoundParameter node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11340,7 +11527,7 @@ public override BoundNode VisitParameter(BoundParameter node) return updatedNode; } - public override BoundNode VisitLabel(BoundLabel node) + public override BoundNode? VisitLabel(BoundLabel node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11352,7 +11539,7 @@ public override BoundNode VisitLabel(BoundLabel node) return updatedNode; } - public override BoundNode VisitSwitchExpression(BoundSwitchExpression node) + public override BoundNode? VisitSwitchExpression(BoundSwitchExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray switchArms = this.VisitList(node.SwitchArms); @@ -11371,7 +11558,7 @@ public override BoundNode VisitSwitchExpression(BoundSwitchExpression node) return updatedNode; } - public override BoundNode VisitSequencePointExpression(BoundSequencePointExpression node) + public override BoundNode? VisitSequencePointExpression(BoundSequencePointExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundSequencePointExpression updatedNode; @@ -11388,7 +11575,7 @@ public override BoundNode VisitSequencePointExpression(BoundSequencePointExpress return updatedNode; } - public override BoundNode VisitSequence(BoundSequence node) + public override BoundNode? VisitSequence(BoundSequence node) { ImmutableArray sideEffects = this.VisitList(node.SideEffects); BoundExpression value = (BoundExpression)this.Visit(node.Value); @@ -11406,7 +11593,7 @@ public override BoundNode VisitSequence(BoundSequence node) return updatedNode; } - public override BoundNode VisitSpillSequence(BoundSpillSequence node) + public override BoundNode? VisitSpillSequence(BoundSpillSequence node) { ImmutableArray sideEffects = this.VisitList(node.SideEffects); BoundExpression value = (BoundExpression)this.Visit(node.Value); @@ -11424,7 +11611,7 @@ public override BoundNode VisitSpillSequence(BoundSpillSequence node) return updatedNode; } - public override BoundNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node) + public override BoundNode? VisitDynamicMemberAccess(BoundDynamicMemberAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundDynamicMemberAccess updatedNode; @@ -11441,7 +11628,7 @@ public override BoundNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node return updatedNode; } - public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) + public override BoundNode? VisitDynamicInvocation(BoundDynamicInvocation node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray arguments = this.VisitList(node.Arguments); @@ -11459,7 +11646,7 @@ public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) return updatedNode; } - public override BoundNode VisitConditionalAccess(BoundConditionalAccess node) + public override BoundNode? VisitConditionalAccess(BoundConditionalAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression accessExpression = (BoundExpression)this.Visit(node.AccessExpression); @@ -11477,11 +11664,11 @@ public override BoundNode VisitConditionalAccess(BoundConditionalAccess node) return updatedNode; } - public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) + public override BoundNode? VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression whenNotNull = (BoundExpression)this.Visit(node.WhenNotNull); - BoundExpression whenNullOpt = (BoundExpression)this.Visit(node.WhenNullOpt); + BoundExpression? whenNullOpt = (BoundExpression?)this.Visit(node.WhenNullOpt); BoundLoweredConditionalAccess updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11496,7 +11683,7 @@ public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalA return updatedNode; } - public override BoundNode VisitConditionalReceiver(BoundConditionalReceiver node) + public override BoundNode? VisitConditionalReceiver(BoundConditionalReceiver node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11508,7 +11695,7 @@ public override BoundNode VisitConditionalReceiver(BoundConditionalReceiver node return updatedNode; } - public override BoundNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) + public override BoundNode? VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node) { BoundExpression valueTypeReceiver = (BoundExpression)this.Visit(node.ValueTypeReceiver); BoundExpression referenceTypeReceiver = (BoundExpression)this.Visit(node.ReferenceTypeReceiver); @@ -11526,9 +11713,9 @@ public override BoundNode VisitComplexConditionalReceiver(BoundComplexConditiona return updatedNode; } - public override BoundNode VisitMethodGroup(BoundMethodGroup node) + public override BoundNode? VisitMethodGroup(BoundMethodGroup node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundMethodGroup updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11543,9 +11730,9 @@ public override BoundNode VisitMethodGroup(BoundMethodGroup node) return updatedNode; } - public override BoundNode VisitPropertyGroup(BoundPropertyGroup node) + public override BoundNode? VisitPropertyGroup(BoundPropertyGroup node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundPropertyGroup updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11560,9 +11747,9 @@ public override BoundNode VisitPropertyGroup(BoundPropertyGroup node) return updatedNode; } - public override BoundNode VisitCall(BoundCall node) + public override BoundNode? VisitCall(BoundCall node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); BoundCall updatedNode; @@ -11578,9 +11765,9 @@ public override BoundNode VisitCall(BoundCall node) return updatedNode; } - public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node) + public override BoundNode? VisitEventAssignmentOperator(BoundEventAssignmentOperator node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundExpression argument = (BoundExpression)this.Visit(node.Argument); BoundEventAssignmentOperator updatedNode; @@ -11596,7 +11783,7 @@ public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOpera return updatedNode; } - public override BoundNode VisitAttribute(BoundAttribute node) + public override BoundNode? VisitAttribute(BoundAttribute node) { ImmutableArray constructorArguments = this.VisitList(node.ConstructorArguments); ImmutableArray namedArguments = this.VisitList(node.NamedArguments); @@ -11614,10 +11801,10 @@ public override BoundNode VisitAttribute(BoundAttribute node) return updatedNode; } - public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node) + public override BoundNode? VisitObjectCreationExpression(BoundObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); BoundObjectCreationExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11632,7 +11819,7 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre return updatedNode; } - public override BoundNode VisitTupleLiteral(BoundTupleLiteral node) + public override BoundNode? VisitTupleLiteral(BoundTupleLiteral node) { ImmutableArray arguments = this.VisitList(node.Arguments); BoundTupleLiteral updatedNode; @@ -11649,7 +11836,7 @@ public override BoundNode VisitTupleLiteral(BoundTupleLiteral node) return updatedNode; } - public override BoundNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) + public override BoundNode? VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node) { BoundTupleLiteral sourceTuple = (BoundTupleLiteral)this.Visit(node.SourceTuple); ImmutableArray arguments = this.VisitList(node.Arguments); @@ -11667,10 +11854,10 @@ public override BoundNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral return updatedNode; } - public override BoundNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) + public override BoundNode? VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); BoundDynamicObjectCreationExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11685,9 +11872,9 @@ public override BoundNode VisitDynamicObjectCreationExpression(BoundDynamicObjec return updatedNode; } - public override BoundNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) + public override BoundNode? VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node) { - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); BoundNoPiaObjectCreationExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11702,7 +11889,7 @@ public override BoundNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCre return updatedNode; } - public override BoundNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node) + public override BoundNode? VisitObjectInitializerExpression(BoundObjectInitializerExpression node) { ImmutableArray initializers = this.VisitList(node.Initializers); BoundObjectInitializerExpression updatedNode; @@ -11719,7 +11906,7 @@ public override BoundNode VisitObjectInitializerExpression(BoundObjectInitialize return updatedNode; } - public override BoundNode VisitObjectInitializerMember(BoundObjectInitializerMember node) + public override BoundNode? VisitObjectInitializerMember(BoundObjectInitializerMember node) { ImmutableArray arguments = this.VisitList(node.Arguments); BoundObjectInitializerMember updatedNode; @@ -11736,7 +11923,7 @@ public override BoundNode VisitObjectInitializerMember(BoundObjectInitializerMem return updatedNode; } - public override BoundNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) + public override BoundNode? VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11748,7 +11935,7 @@ public override BoundNode VisitDynamicObjectInitializerMember(BoundDynamicObject return updatedNode; } - public override BoundNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) + public override BoundNode? VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node) { ImmutableArray initializers = this.VisitList(node.Initializers); BoundCollectionInitializerExpression updatedNode; @@ -11765,10 +11952,10 @@ public override BoundNode VisitCollectionInitializerExpression(BoundCollectionIn return updatedNode; } - public override BoundNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node) + public override BoundNode? VisitCollectionElementInitializer(BoundCollectionElementInitializer node) { ImmutableArray arguments = this.VisitList(node.Arguments); - BoundExpression implicitReceiverOpt = (BoundExpression)this.Visit(node.ImplicitReceiverOpt); + BoundExpression? implicitReceiverOpt = (BoundExpression?)this.Visit(node.ImplicitReceiverOpt); BoundCollectionElementInitializer updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11783,7 +11970,7 @@ public override BoundNode VisitCollectionElementInitializer(BoundCollectionEleme return updatedNode; } - public override BoundNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) + public override BoundNode? VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); ImmutableArray arguments = this.VisitList(node.Arguments); @@ -11801,7 +11988,7 @@ public override BoundNode VisitDynamicCollectionElementInitializer(BoundDynamicC return updatedNode; } - public override BoundNode VisitImplicitReceiver(BoundImplicitReceiver node) + public override BoundNode? VisitImplicitReceiver(BoundImplicitReceiver node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11813,7 +12000,7 @@ public override BoundNode VisitImplicitReceiver(BoundImplicitReceiver node) return updatedNode; } - public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) + public override BoundNode? VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node) { ImmutableArray arguments = this.VisitList(node.Arguments); ImmutableArray declarations = this.VisitList(node.Declarations); @@ -11831,7 +12018,7 @@ public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousO return updatedNode; } - public override BoundNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) + public override BoundNode? VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11843,9 +12030,9 @@ public override BoundNode VisitAnonymousPropertyDeclaration(BoundAnonymousProper return updatedNode; } - public override BoundNode VisitNewT(BoundNewT node) + public override BoundNode? VisitNewT(BoundNewT node) { - BoundObjectInitializerExpressionBase initializerExpressionOpt = (BoundObjectInitializerExpressionBase)this.Visit(node.InitializerExpressionOpt); + BoundObjectInitializerExpressionBase? initializerExpressionOpt = (BoundObjectInitializerExpressionBase?)this.Visit(node.InitializerExpressionOpt); BoundNewT updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11860,7 +12047,7 @@ public override BoundNode VisitNewT(BoundNewT node) return updatedNode; } - public override BoundNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node) + public override BoundNode? VisitDelegateCreationExpression(BoundDelegateCreationExpression node) { BoundExpression argument = (BoundExpression)this.Visit(node.Argument); BoundDelegateCreationExpression updatedNode; @@ -11877,10 +12064,10 @@ public override BoundNode VisitDelegateCreationExpression(BoundDelegateCreationE return updatedNode; } - public override BoundNode VisitArrayCreation(BoundArrayCreation node) + public override BoundNode? VisitArrayCreation(BoundArrayCreation node) { ImmutableArray bounds = this.VisitList(node.Bounds); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); BoundArrayCreation updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11895,7 +12082,7 @@ public override BoundNode VisitArrayCreation(BoundArrayCreation node) return updatedNode; } - public override BoundNode VisitArrayInitialization(BoundArrayInitialization node) + public override BoundNode? VisitArrayInitialization(BoundArrayInitialization node) { ImmutableArray initializers = this.VisitList(node.Initializers); BoundArrayInitialization updatedNode; @@ -11912,10 +12099,10 @@ public override BoundNode VisitArrayInitialization(BoundArrayInitialization node return updatedNode; } - public override BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) + public override BoundNode? VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node) { BoundExpression count = (BoundExpression)this.Visit(node.Count); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); BoundStackAllocArrayCreation updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11930,10 +12117,10 @@ public override BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreat return updatedNode; } - public override BoundNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) + public override BoundNode? VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node) { BoundExpression count = (BoundExpression)this.Visit(node.Count); - BoundArrayInitialization initializerOpt = (BoundArrayInitialization)this.Visit(node.InitializerOpt); + BoundArrayInitialization? initializerOpt = (BoundArrayInitialization?)this.Visit(node.InitializerOpt); BoundConvertedStackAllocExpression updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11948,9 +12135,9 @@ public override BoundNode VisitConvertedStackAllocExpression(BoundConvertedStack return updatedNode; } - public override BoundNode VisitFieldAccess(BoundFieldAccess node) + public override BoundNode? VisitFieldAccess(BoundFieldAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundFieldAccess updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11965,7 +12152,7 @@ public override BoundNode VisitFieldAccess(BoundFieldAccess node) return updatedNode; } - public override BoundNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node) + public override BoundNode? VisitHoistedFieldAccess(BoundHoistedFieldAccess node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -11977,9 +12164,9 @@ public override BoundNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node) return updatedNode; } - public override BoundNode VisitPropertyAccess(BoundPropertyAccess node) + public override BoundNode? VisitPropertyAccess(BoundPropertyAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundPropertyAccess updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -11994,9 +12181,9 @@ public override BoundNode VisitPropertyAccess(BoundPropertyAccess node) return updatedNode; } - public override BoundNode VisitEventAccess(BoundEventAccess node) + public override BoundNode? VisitEventAccess(BoundEventAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); BoundEventAccess updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -12011,9 +12198,9 @@ public override BoundNode VisitEventAccess(BoundEventAccess node) return updatedNode; } - public override BoundNode VisitIndexerAccess(BoundIndexerAccess node) + public override BoundNode? VisitIndexerAccess(BoundIndexerAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); BoundIndexerAccess updatedNode; @@ -12029,7 +12216,7 @@ public override BoundNode VisitIndexerAccess(BoundIndexerAccess node) return updatedNode; } - public override BoundNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) + public override BoundNode? VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node) { BoundExpression receiver = (BoundExpression)this.Visit(node.Receiver); BoundExpression argument = (BoundExpression)this.Visit(node.Argument); @@ -12047,9 +12234,9 @@ public override BoundNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRang return updatedNode; } - public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) + public override BoundNode? VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); ImmutableArray arguments = this.VisitList(node.Arguments); BoundDynamicIndexerAccess updatedNode; @@ -12065,7 +12252,7 @@ public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess no return updatedNode; } - public override BoundNode VisitLambda(BoundLambda node) + public override BoundNode? VisitLambda(BoundLambda node) { UnboundLambda unboundLambda = node.UnboundLambda; BoundBlock body = (BoundBlock)this.Visit(node.Body); @@ -12083,7 +12270,7 @@ public override BoundNode VisitLambda(BoundLambda node) return updatedNode; } - public override BoundNode VisitUnboundLambda(UnboundLambda node) + public override BoundNode? VisitUnboundLambda(UnboundLambda node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -12095,7 +12282,7 @@ public override BoundNode VisitUnboundLambda(UnboundLambda node) return updatedNode; } - public override BoundNode VisitQueryClause(BoundQueryClause node) + public override BoundNode? VisitQueryClause(BoundQueryClause node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); BoundQueryClause updatedNode; @@ -12112,7 +12299,7 @@ public override BoundNode VisitQueryClause(BoundQueryClause node) return updatedNode; } - public override BoundNode VisitNameOfOperator(BoundNameOfOperator node) + public override BoundNode? VisitNameOfOperator(BoundNameOfOperator node) { BoundExpression argument = (BoundExpression)this.Visit(node.Argument); BoundNameOfOperator updatedNode; @@ -12129,7 +12316,7 @@ public override BoundNode VisitNameOfOperator(BoundNameOfOperator node) return updatedNode; } - public override BoundNode VisitInterpolatedString(BoundInterpolatedString node) + public override BoundNode? VisitInterpolatedString(BoundInterpolatedString node) { ImmutableArray parts = this.VisitList(node.Parts); BoundInterpolatedString updatedNode; @@ -12146,11 +12333,11 @@ public override BoundNode VisitInterpolatedString(BoundInterpolatedString node) return updatedNode; } - public override BoundNode VisitStringInsert(BoundStringInsert node) + public override BoundNode? VisitStringInsert(BoundStringInsert node) { BoundExpression value = (BoundExpression)this.Visit(node.Value); - BoundExpression alignment = (BoundExpression)this.Visit(node.Alignment); - BoundLiteral format = (BoundLiteral)this.Visit(node.Format); + BoundExpression? alignment = (BoundExpression?)this.Visit(node.Alignment); + BoundLiteral? format = (BoundLiteral?)this.Visit(node.Format); BoundStringInsert updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -12165,7 +12352,7 @@ public override BoundNode VisitStringInsert(BoundStringInsert node) return updatedNode; } - public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node) + public override BoundNode? VisitIsPatternExpression(BoundIsPatternExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundPattern pattern = (BoundPattern)this.Visit(node.Pattern); @@ -12184,7 +12371,7 @@ public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node return updatedNode; } - public override BoundNode VisitDiscardExpression(BoundDiscardExpression node) + public override BoundNode? VisitDiscardExpression(BoundDiscardExpression node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -12196,7 +12383,7 @@ public override BoundNode VisitDiscardExpression(BoundDiscardExpression node) return updatedNode; } - public override BoundNode VisitThrowExpression(BoundThrowExpression node) + public override BoundNode? VisitThrowExpression(BoundThrowExpression node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundThrowExpression updatedNode; @@ -12213,9 +12400,9 @@ public override BoundNode VisitThrowExpression(BoundThrowExpression node) return updatedNode; } - public override BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node) + public override BoundNode? VisitOutVariablePendingInference(OutVariablePendingInference node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); OutVariablePendingInference updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -12230,9 +12417,9 @@ public override BoundNode VisitOutVariablePendingInference(OutVariablePendingInf return updatedNode; } - public override BoundNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) + public override BoundNode? VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node) { - BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt); + BoundExpression? receiverOpt = (BoundExpression?)this.Visit(node.ReceiverOpt); DeconstructionVariablePendingInference updatedNode; if (_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) @@ -12247,7 +12434,7 @@ public override BoundNode VisitDeconstructionVariablePendingInference(Deconstruc return updatedNode; } - public override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) + public override BoundNode? VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node) { if (!_updatedNullabilities.TryGetValue(node, out (NullabilityInfo Info, TypeSymbol Type) infoAndType)) { @@ -12259,7 +12446,7 @@ public override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructV return updatedNode; } - public override BoundNode VisitExpressionWithNullability(BoundExpressionWithNullability node) + public override BoundNode? VisitExpressionWithNullability(BoundExpressionWithNullability node) { BoundExpression expression = (BoundExpression)this.Visit(node.Expression); BoundExpressionWithNullability updatedNode; @@ -12277,78 +12464,78 @@ public override BoundNode VisitExpressionWithNullability(BoundExpressionWithNull } } - internal sealed class BoundTreeDumperNodeProducer : BoundTreeVisitor + internal sealed class BoundTreeDumperNodeProducer : BoundTreeVisitor { private BoundTreeDumperNodeProducer() { } public static TreeDumperNode MakeTree(BoundNode node) => (new BoundTreeDumperNodeProducer()).Visit(node, null); - public override TreeDumperNode VisitFieldEqualsValue(BoundFieldEqualsValue node, object arg) => new TreeDumperNode("fieldEqualsValue", null, new TreeDumperNode[] + public override TreeDumperNode VisitFieldEqualsValue(BoundFieldEqualsValue node, object? arg) => new TreeDumperNode("fieldEqualsValue", null, new TreeDumperNode[] { new TreeDumperNode("field", node.Field, null), new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }) } ); - public override TreeDumperNode VisitPropertyEqualsValue(BoundPropertyEqualsValue node, object arg) => new TreeDumperNode("propertyEqualsValue", null, new TreeDumperNode[] + public override TreeDumperNode VisitPropertyEqualsValue(BoundPropertyEqualsValue node, object? arg) => new TreeDumperNode("propertyEqualsValue", null, new TreeDumperNode[] { new TreeDumperNode("property", node.Property, null), new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }) } ); - public override TreeDumperNode VisitParameterEqualsValue(BoundParameterEqualsValue node, object arg) => new TreeDumperNode("parameterEqualsValue", null, new TreeDumperNode[] + public override TreeDumperNode VisitParameterEqualsValue(BoundParameterEqualsValue node, object? arg) => new TreeDumperNode("parameterEqualsValue", null, new TreeDumperNode[] { new TreeDumperNode("parameter", node.Parameter, null), new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }) } ); - public override TreeDumperNode VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node, object arg) => new TreeDumperNode("globalStatementInitializer", null, new TreeDumperNode[] + public override TreeDumperNode VisitGlobalStatementInitializer(BoundGlobalStatementInitializer node, object? arg) => new TreeDumperNode("globalStatementInitializer", null, new TreeDumperNode[] { new TreeDumperNode("statement", null, new TreeDumperNode[] { Visit(node.Statement, null) }) } ); - public override TreeDumperNode VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node, object arg) => new TreeDumperNode("deconstructValuePlaceholder", null, new TreeDumperNode[] + public override TreeDumperNode VisitDeconstructValuePlaceholder(BoundDeconstructValuePlaceholder node, object? arg) => new TreeDumperNode("deconstructValuePlaceholder", null, new TreeDumperNode[] { new TreeDumperNode("valEscape", node.ValEscape, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node, object arg) => new TreeDumperNode("tupleOperandPlaceholder", null, new TreeDumperNode[] + public override TreeDumperNode VisitTupleOperandPlaceholder(BoundTupleOperandPlaceholder node, object? arg) => new TreeDumperNode("tupleOperandPlaceholder", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node, object arg) => new TreeDumperNode("awaitableValuePlaceholder", null, new TreeDumperNode[] + public override TreeDumperNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlaceholder node, object? arg) => new TreeDumperNode("awaitableValuePlaceholder", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node, object arg) => new TreeDumperNode("disposableValuePlaceholder", null, new TreeDumperNode[] + public override TreeDumperNode VisitDisposableValuePlaceholder(BoundDisposableValuePlaceholder node, object? arg) => new TreeDumperNode("disposableValuePlaceholder", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDup(BoundDup node, object arg) => new TreeDumperNode("dup", null, new TreeDumperNode[] + public override TreeDumperNode VisitDup(BoundDup node, object? arg) => new TreeDumperNode("dup", null, new TreeDumperNode[] { new TreeDumperNode("refKind", node.RefKind, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPassByCopy(BoundPassByCopy node, object arg) => new TreeDumperNode("passByCopy", null, new TreeDumperNode[] + public override TreeDumperNode VisitPassByCopy(BoundPassByCopy node, object? arg) => new TreeDumperNode("passByCopy", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitBadExpression(BoundBadExpression node, object arg) => new TreeDumperNode("badExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitBadExpression(BoundBadExpression node, object? arg) => new TreeDumperNode("badExpression", null, new TreeDumperNode[] { new TreeDumperNode("resultKind", node.ResultKind, null), new TreeDumperNode("symbols", node.Symbols, null), @@ -12357,17 +12544,17 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitBadStatement(BoundBadStatement node, object arg) => new TreeDumperNode("badStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitBadStatement(BoundBadStatement node, object? arg) => new TreeDumperNode("badStatement", null, new TreeDumperNode[] { new TreeDumperNode("childBoundNodes", null, from x in node.ChildBoundNodes select Visit(x, null)) } ); - public override TreeDumperNode VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node, object arg) => new TreeDumperNode("extractedFinallyBlock", null, new TreeDumperNode[] + public override TreeDumperNode VisitExtractedFinallyBlock(BoundExtractedFinallyBlock node, object? arg) => new TreeDumperNode("extractedFinallyBlock", null, new TreeDumperNode[] { new TreeDumperNode("finallyBlock", null, new TreeDumperNode[] { Visit(node.FinallyBlock, null) }) } ); - public override TreeDumperNode VisitTypeExpression(BoundTypeExpression node, object arg) => new TreeDumperNode("typeExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitTypeExpression(BoundTypeExpression node, object? arg) => new TreeDumperNode("typeExpression", null, new TreeDumperNode[] { new TreeDumperNode("aliasOpt", node.AliasOpt, null), new TreeDumperNode("boundContainingTypeOpt", null, new TreeDumperNode[] { Visit(node.BoundContainingTypeOpt, null) }), @@ -12377,14 +12564,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node, object arg) => new TreeDumperNode("typeOrValueExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitTypeOrValueExpression(BoundTypeOrValueExpression node, object? arg) => new TreeDumperNode("typeOrValueExpression", null, new TreeDumperNode[] { new TreeDumperNode("data", node.Data, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNamespaceExpression(BoundNamespaceExpression node, object arg) => new TreeDumperNode("namespaceExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitNamespaceExpression(BoundNamespaceExpression node, object? arg) => new TreeDumperNode("namespaceExpression", null, new TreeDumperNode[] { new TreeDumperNode("namespaceSymbol", node.NamespaceSymbol, null), new TreeDumperNode("aliasOpt", node.AliasOpt, null), @@ -12392,7 +12579,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitUnaryOperator(BoundUnaryOperator node, object arg) => new TreeDumperNode("unaryOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitUnaryOperator(BoundUnaryOperator node, object? arg) => new TreeDumperNode("unaryOperator", null, new TreeDumperNode[] { new TreeDumperNode("operatorKind", node.OperatorKind, null), new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), @@ -12403,7 +12590,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitIncrementOperator(BoundIncrementOperator node, object arg) => new TreeDumperNode("incrementOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitIncrementOperator(BoundIncrementOperator node, object? arg) => new TreeDumperNode("incrementOperator", null, new TreeDumperNode[] { new TreeDumperNode("operatorKind", node.OperatorKind, null), new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), @@ -12415,7 +12602,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAddressOfOperator(BoundAddressOfOperator node, object arg) => new TreeDumperNode("addressOfOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitAddressOfOperator(BoundAddressOfOperator node, object? arg) => new TreeDumperNode("addressOfOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("isManaged", node.IsManaged, null), @@ -12423,14 +12610,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node, object arg) => new TreeDumperNode("pointerIndirectionOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitPointerIndirectionOperator(BoundPointerIndirectionOperator node, object? arg) => new TreeDumperNode("pointerIndirectionOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPointerElementAccess(BoundPointerElementAccess node, object arg) => new TreeDumperNode("pointerElementAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitPointerElementAccess(BoundPointerElementAccess node, object? arg) => new TreeDumperNode("pointerElementAccess", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("index", null, new TreeDumperNode[] { Visit(node.Index, null) }), @@ -12439,7 +12626,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitRefTypeOperator(BoundRefTypeOperator node, object arg) => new TreeDumperNode("refTypeOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitRefTypeOperator(BoundRefTypeOperator node, object? arg) => new TreeDumperNode("refTypeOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("getTypeFromHandle", node.GetTypeFromHandle, null), @@ -12447,14 +12634,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitMakeRefOperator(BoundMakeRefOperator node, object arg) => new TreeDumperNode("makeRefOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitMakeRefOperator(BoundMakeRefOperator node, object? arg) => new TreeDumperNode("makeRefOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitRefValueOperator(BoundRefValueOperator node, object arg) => new TreeDumperNode("refValueOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitRefValueOperator(BoundRefValueOperator node, object? arg) => new TreeDumperNode("refValueOperator", null, new TreeDumperNode[] { new TreeDumperNode("nullableAnnotation", node.NullableAnnotation, null), new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), @@ -12462,7 +12649,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node, object arg) => new TreeDumperNode("fromEndIndexExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitFromEndIndexExpression(BoundFromEndIndexExpression node, object? arg) => new TreeDumperNode("fromEndIndexExpression", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("methodOpt", node.MethodOpt, null), @@ -12470,7 +12657,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitRangeExpression(BoundRangeExpression node, object arg) => new TreeDumperNode("rangeExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitRangeExpression(BoundRangeExpression node, object? arg) => new TreeDumperNode("rangeExpression", null, new TreeDumperNode[] { new TreeDumperNode("leftOperandOpt", null, new TreeDumperNode[] { Visit(node.LeftOperandOpt, null) }), new TreeDumperNode("rightOperandOpt", null, new TreeDumperNode[] { Visit(node.RightOperandOpt, null) }), @@ -12479,7 +12666,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitBinaryOperator(BoundBinaryOperator node, object arg) => new TreeDumperNode("binaryOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitBinaryOperator(BoundBinaryOperator node, object? arg) => new TreeDumperNode("binaryOperator", null, new TreeDumperNode[] { new TreeDumperNode("operatorKind", node.OperatorKind, null), new TreeDumperNode("constantValueOpt", node.ConstantValueOpt, null), @@ -12491,7 +12678,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node, object arg) => new TreeDumperNode("tupleBinaryOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitTupleBinaryOperator(BoundTupleBinaryOperator node, object? arg) => new TreeDumperNode("tupleBinaryOperator", null, new TreeDumperNode[] { new TreeDumperNode("left", null, new TreeDumperNode[] { Visit(node.Left, null) }), new TreeDumperNode("right", null, new TreeDumperNode[] { Visit(node.Right, null) }), @@ -12503,7 +12690,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node, object arg) => new TreeDumperNode("userDefinedConditionalLogicalOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitUserDefinedConditionalLogicalOperator(BoundUserDefinedConditionalLogicalOperator node, object? arg) => new TreeDumperNode("userDefinedConditionalLogicalOperator", null, new TreeDumperNode[] { new TreeDumperNode("operatorKind", node.OperatorKind, null), new TreeDumperNode("logicalOperator", node.LogicalOperator, null), @@ -12516,7 +12703,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node, object arg) => new TreeDumperNode("compoundAssignmentOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitCompoundAssignmentOperator(BoundCompoundAssignmentOperator node, object? arg) => new TreeDumperNode("compoundAssignmentOperator", null, new TreeDumperNode[] { new TreeDumperNode("@operator", node.Operator, null), new TreeDumperNode("left", null, new TreeDumperNode[] { Visit(node.Left, null) }), @@ -12528,7 +12715,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAssignmentOperator(BoundAssignmentOperator node, object arg) => new TreeDumperNode("assignmentOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitAssignmentOperator(BoundAssignmentOperator node, object? arg) => new TreeDumperNode("assignmentOperator", null, new TreeDumperNode[] { new TreeDumperNode("left", null, new TreeDumperNode[] { Visit(node.Left, null) }), new TreeDumperNode("right", null, new TreeDumperNode[] { Visit(node.Right, null) }), @@ -12537,7 +12724,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node, object arg) => new TreeDumperNode("deconstructionAssignmentOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node, object? arg) => new TreeDumperNode("deconstructionAssignmentOperator", null, new TreeDumperNode[] { new TreeDumperNode("left", null, new TreeDumperNode[] { Visit(node.Left, null) }), new TreeDumperNode("right", null, new TreeDumperNode[] { Visit(node.Right, null) }), @@ -12546,7 +12733,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node, object arg) => new TreeDumperNode("nullCoalescingOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node, object? arg) => new TreeDumperNode("nullCoalescingOperator", null, new TreeDumperNode[] { new TreeDumperNode("leftOperand", null, new TreeDumperNode[] { Visit(node.LeftOperand, null) }), new TreeDumperNode("rightOperand", null, new TreeDumperNode[] { Visit(node.RightOperand, null) }), @@ -12556,7 +12743,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node, object arg) => new TreeDumperNode("nullCoalescingAssignmentOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node, object? arg) => new TreeDumperNode("nullCoalescingAssignmentOperator", null, new TreeDumperNode[] { new TreeDumperNode("leftOperand", null, new TreeDumperNode[] { Visit(node.LeftOperand, null) }), new TreeDumperNode("rightOperand", null, new TreeDumperNode[] { Visit(node.RightOperand, null) }), @@ -12564,7 +12751,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConditionalOperator(BoundConditionalOperator node, object arg) => new TreeDumperNode("conditionalOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitConditionalOperator(BoundConditionalOperator node, object? arg) => new TreeDumperNode("conditionalOperator", null, new TreeDumperNode[] { new TreeDumperNode("isRef", node.IsRef, null), new TreeDumperNode("condition", null, new TreeDumperNode[] { Visit(node.Condition, null) }), @@ -12575,7 +12762,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArrayAccess(BoundArrayAccess node, object arg) => new TreeDumperNode("arrayAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitArrayAccess(BoundArrayAccess node, object? arg) => new TreeDumperNode("arrayAccess", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("indices", null, from x in node.Indices select Visit(x, null)), @@ -12583,14 +12770,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArrayLength(BoundArrayLength node, object arg) => new TreeDumperNode("arrayLength", null, new TreeDumperNode[] + public override TreeDumperNode VisitArrayLength(BoundArrayLength node, object? arg) => new TreeDumperNode("arrayLength", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAwaitExpression(BoundAwaitExpression node, object arg) => new TreeDumperNode("awaitExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitAwaitExpression(BoundAwaitExpression node, object? arg) => new TreeDumperNode("awaitExpression", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("awaitableInfo", node.AwaitableInfo, null), @@ -12598,7 +12785,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTypeOfOperator(BoundTypeOfOperator node, object arg) => new TreeDumperNode("typeOfOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitTypeOfOperator(BoundTypeOfOperator node, object? arg) => new TreeDumperNode("typeOfOperator", null, new TreeDumperNode[] { new TreeDumperNode("sourceType", null, new TreeDumperNode[] { Visit(node.SourceType, null) }), new TreeDumperNode("getTypeFromHandle", node.GetTypeFromHandle, null), @@ -12606,46 +12793,46 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitMethodDefIndex(BoundMethodDefIndex node, object arg) => new TreeDumperNode("methodDefIndex", null, new TreeDumperNode[] + public override TreeDumperNode VisitMethodDefIndex(BoundMethodDefIndex node, object? arg) => new TreeDumperNode("methodDefIndex", null, new TreeDumperNode[] { new TreeDumperNode("method", node.Method, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node, object arg) => new TreeDumperNode("maximumMethodDefIndex", null, new TreeDumperNode[] + public override TreeDumperNode VisitMaximumMethodDefIndex(BoundMaximumMethodDefIndex node, object? arg) => new TreeDumperNode("maximumMethodDefIndex", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node, object arg) => new TreeDumperNode("instrumentationPayloadRoot", null, new TreeDumperNode[] + public override TreeDumperNode VisitInstrumentationPayloadRoot(BoundInstrumentationPayloadRoot node, object? arg) => new TreeDumperNode("instrumentationPayloadRoot", null, new TreeDumperNode[] { new TreeDumperNode("analysisKind", node.AnalysisKind, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitModuleVersionId(BoundModuleVersionId node, object arg) => new TreeDumperNode("moduleVersionId", null, new TreeDumperNode[] + public override TreeDumperNode VisitModuleVersionId(BoundModuleVersionId node, object? arg) => new TreeDumperNode("moduleVersionId", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitModuleVersionIdString(BoundModuleVersionIdString node, object arg) => new TreeDumperNode("moduleVersionIdString", null, new TreeDumperNode[] + public override TreeDumperNode VisitModuleVersionIdString(BoundModuleVersionIdString node, object? arg) => new TreeDumperNode("moduleVersionIdString", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node, object arg) => new TreeDumperNode("sourceDocumentIndex", null, new TreeDumperNode[] + public override TreeDumperNode VisitSourceDocumentIndex(BoundSourceDocumentIndex node, object? arg) => new TreeDumperNode("sourceDocumentIndex", null, new TreeDumperNode[] { new TreeDumperNode("document", node.Document, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitMethodInfo(BoundMethodInfo node, object arg) => new TreeDumperNode("methodInfo", null, new TreeDumperNode[] + public override TreeDumperNode VisitMethodInfo(BoundMethodInfo node, object? arg) => new TreeDumperNode("methodInfo", null, new TreeDumperNode[] { new TreeDumperNode("method", node.Method, null), new TreeDumperNode("getMethodFromHandle", node.GetMethodFromHandle, null), @@ -12653,7 +12840,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitFieldInfo(BoundFieldInfo node, object arg) => new TreeDumperNode("fieldInfo", null, new TreeDumperNode[] + public override TreeDumperNode VisitFieldInfo(BoundFieldInfo node, object? arg) => new TreeDumperNode("fieldInfo", null, new TreeDumperNode[] { new TreeDumperNode("field", node.Field, null), new TreeDumperNode("getFieldFromHandle", node.GetFieldFromHandle, null), @@ -12661,7 +12848,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDefaultExpression(BoundDefaultExpression node, object arg) => new TreeDumperNode("defaultExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitDefaultExpression(BoundDefaultExpression node, object? arg) => new TreeDumperNode("defaultExpression", null, new TreeDumperNode[] { new TreeDumperNode("targetType", null, new TreeDumperNode[] { Visit(node.TargetType, null) }), new TreeDumperNode("constantValueOpt", node.ConstantValueOpt, null), @@ -12669,7 +12856,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitIsOperator(BoundIsOperator node, object arg) => new TreeDumperNode("isOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitIsOperator(BoundIsOperator node, object? arg) => new TreeDumperNode("isOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("targetType", null, new TreeDumperNode[] { Visit(node.TargetType, null) }), @@ -12678,7 +12865,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAsOperator(BoundAsOperator node, object arg) => new TreeDumperNode("asOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitAsOperator(BoundAsOperator node, object? arg) => new TreeDumperNode("asOperator", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("targetType", null, new TreeDumperNode[] { Visit(node.TargetType, null) }), @@ -12687,7 +12874,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSizeOfOperator(BoundSizeOfOperator node, object arg) => new TreeDumperNode("sizeOfOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitSizeOfOperator(BoundSizeOfOperator node, object? arg) => new TreeDumperNode("sizeOfOperator", null, new TreeDumperNode[] { new TreeDumperNode("sourceType", null, new TreeDumperNode[] { Visit(node.SourceType, null) }), new TreeDumperNode("constantValueOpt", node.ConstantValueOpt, null), @@ -12695,7 +12882,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConversion(BoundConversion node, object arg) => new TreeDumperNode("conversion", null, new TreeDumperNode[] + public override TreeDumperNode VisitConversion(BoundConversion node, object? arg) => new TreeDumperNode("conversion", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("conversion", node.Conversion, null), @@ -12708,7 +12895,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node, object arg) => new TreeDumperNode("readOnlySpanFromArray", null, new TreeDumperNode[] + public override TreeDumperNode VisitReadOnlySpanFromArray(BoundReadOnlySpanFromArray node, object? arg) => new TreeDumperNode("readOnlySpanFromArray", null, new TreeDumperNode[] { new TreeDumperNode("operand", null, new TreeDumperNode[] { Visit(node.Operand, null) }), new TreeDumperNode("conversionMethod", node.ConversionMethod, null), @@ -12716,13 +12903,13 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArgList(BoundArgList node, object arg) => new TreeDumperNode("argList", null, new TreeDumperNode[] + public override TreeDumperNode VisitArgList(BoundArgList node, object? arg) => new TreeDumperNode("argList", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArgListOperator(BoundArgListOperator node, object arg) => new TreeDumperNode("argListOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitArgListOperator(BoundArgListOperator node, object? arg) => new TreeDumperNode("argListOperator", null, new TreeDumperNode[] { new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), new TreeDumperNode("argumentRefKindsOpt", node.ArgumentRefKindsOpt, null), @@ -12730,7 +12917,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node, object arg) => new TreeDumperNode("fixedLocalCollectionInitializer", null, new TreeDumperNode[] + public override TreeDumperNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCollectionInitializer node, object? arg) => new TreeDumperNode("fixedLocalCollectionInitializer", null, new TreeDumperNode[] { new TreeDumperNode("elementPointerType", node.ElementPointerType, null), new TreeDumperNode("elementPointerTypeConversion", node.ElementPointerTypeConversion, null), @@ -12740,37 +12927,37 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSequencePoint(BoundSequencePoint node, object arg) => new TreeDumperNode("sequencePoint", null, new TreeDumperNode[] + public override TreeDumperNode VisitSequencePoint(BoundSequencePoint node, object? arg) => new TreeDumperNode("sequencePoint", null, new TreeDumperNode[] { new TreeDumperNode("statementOpt", null, new TreeDumperNode[] { Visit(node.StatementOpt, null) }) } ); - public override TreeDumperNode VisitSequencePointWithSpan(BoundSequencePointWithSpan node, object arg) => new TreeDumperNode("sequencePointWithSpan", null, new TreeDumperNode[] + public override TreeDumperNode VisitSequencePointWithSpan(BoundSequencePointWithSpan node, object? arg) => new TreeDumperNode("sequencePointWithSpan", null, new TreeDumperNode[] { new TreeDumperNode("statementOpt", null, new TreeDumperNode[] { Visit(node.StatementOpt, null) }), new TreeDumperNode("span", node.Span, null) } ); - public override TreeDumperNode VisitBlock(BoundBlock node, object arg) => new TreeDumperNode("block", null, new TreeDumperNode[] + public override TreeDumperNode VisitBlock(BoundBlock node, object? arg) => new TreeDumperNode("block", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("localFunctions", node.LocalFunctions, null), new TreeDumperNode("statements", null, from x in node.Statements select Visit(x, null)) } ); - public override TreeDumperNode VisitScope(BoundScope node, object arg) => new TreeDumperNode("scope", null, new TreeDumperNode[] + public override TreeDumperNode VisitScope(BoundScope node, object? arg) => new TreeDumperNode("scope", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("statements", null, from x in node.Statements select Visit(x, null)) } ); - public override TreeDumperNode VisitStateMachineScope(BoundStateMachineScope node, object arg) => new TreeDumperNode("stateMachineScope", null, new TreeDumperNode[] + public override TreeDumperNode VisitStateMachineScope(BoundStateMachineScope node, object? arg) => new TreeDumperNode("stateMachineScope", null, new TreeDumperNode[] { new TreeDumperNode("fields", node.Fields, null), new TreeDumperNode("statement", null, new TreeDumperNode[] { Visit(node.Statement, null) }) } ); - public override TreeDumperNode VisitLocalDeclaration(BoundLocalDeclaration node, object arg) => new TreeDumperNode("localDeclaration", null, new TreeDumperNode[] + public override TreeDumperNode VisitLocalDeclaration(BoundLocalDeclaration node, object? arg) => new TreeDumperNode("localDeclaration", null, new TreeDumperNode[] { new TreeDumperNode("localSymbol", node.LocalSymbol, null), new TreeDumperNode("declaredTypeOpt", null, new TreeDumperNode[] { Visit(node.DeclaredTypeOpt, null) }), @@ -12779,12 +12966,12 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("inferredType", node.InferredType, null) } ); - public override TreeDumperNode VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node, object arg) => new TreeDumperNode("multipleLocalDeclarations", null, new TreeDumperNode[] + public override TreeDumperNode VisitMultipleLocalDeclarations(BoundMultipleLocalDeclarations node, object? arg) => new TreeDumperNode("multipleLocalDeclarations", null, new TreeDumperNode[] { new TreeDumperNode("localDeclarations", null, from x in node.LocalDeclarations select Visit(x, null)) } ); - public override TreeDumperNode VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node, object arg) => new TreeDumperNode("usingLocalDeclarations", null, new TreeDumperNode[] + public override TreeDumperNode VisitUsingLocalDeclarations(BoundUsingLocalDeclarations node, object? arg) => new TreeDumperNode("usingLocalDeclarations", null, new TreeDumperNode[] { new TreeDumperNode("disposeMethodOpt", node.DisposeMethodOpt, null), new TreeDumperNode("iDisposableConversion", node.IDisposableConversion, null), @@ -12792,52 +12979,52 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("localDeclarations", null, from x in node.LocalDeclarations select Visit(x, null)) } ); - public override TreeDumperNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node, object arg) => new TreeDumperNode("localFunctionStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node, object? arg) => new TreeDumperNode("localFunctionStatement", null, new TreeDumperNode[] { new TreeDumperNode("symbol", node.Symbol, null), new TreeDumperNode("blockBody", null, new TreeDumperNode[] { Visit(node.BlockBody, null) }), new TreeDumperNode("expressionBody", null, new TreeDumperNode[] { Visit(node.ExpressionBody, null) }) } ); - public override TreeDumperNode VisitNoOpStatement(BoundNoOpStatement node, object arg) => new TreeDumperNode("noOpStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitNoOpStatement(BoundNoOpStatement node, object? arg) => new TreeDumperNode("noOpStatement", null, new TreeDumperNode[] { new TreeDumperNode("flavor", node.Flavor, null) } ); - public override TreeDumperNode VisitReturnStatement(BoundReturnStatement node, object arg) => new TreeDumperNode("returnStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitReturnStatement(BoundReturnStatement node, object? arg) => new TreeDumperNode("returnStatement", null, new TreeDumperNode[] { new TreeDumperNode("refKind", node.RefKind, null), new TreeDumperNode("expressionOpt", null, new TreeDumperNode[] { Visit(node.ExpressionOpt, null) }) } ); - public override TreeDumperNode VisitYieldReturnStatement(BoundYieldReturnStatement node, object arg) => new TreeDumperNode("yieldReturnStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitYieldReturnStatement(BoundYieldReturnStatement node, object? arg) => new TreeDumperNode("yieldReturnStatement", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }) } ); - public override TreeDumperNode VisitYieldBreakStatement(BoundYieldBreakStatement node, object arg) => new TreeDumperNode("yieldBreakStatement", null, Array.Empty() + public override TreeDumperNode VisitYieldBreakStatement(BoundYieldBreakStatement node, object? arg) => new TreeDumperNode("yieldBreakStatement", null, Array.Empty() ); - public override TreeDumperNode VisitThrowStatement(BoundThrowStatement node, object arg) => new TreeDumperNode("throwStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitThrowStatement(BoundThrowStatement node, object? arg) => new TreeDumperNode("throwStatement", null, new TreeDumperNode[] { new TreeDumperNode("expressionOpt", null, new TreeDumperNode[] { Visit(node.ExpressionOpt, null) }) } ); - public override TreeDumperNode VisitExpressionStatement(BoundExpressionStatement node, object arg) => new TreeDumperNode("expressionStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitExpressionStatement(BoundExpressionStatement node, object? arg) => new TreeDumperNode("expressionStatement", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }) } ); - public override TreeDumperNode VisitBreakStatement(BoundBreakStatement node, object arg) => new TreeDumperNode("breakStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitBreakStatement(BoundBreakStatement node, object? arg) => new TreeDumperNode("breakStatement", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitContinueStatement(BoundContinueStatement node, object arg) => new TreeDumperNode("continueStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitContinueStatement(BoundContinueStatement node, object? arg) => new TreeDumperNode("continueStatement", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitSwitchStatement(BoundSwitchStatement node, object arg) => new TreeDumperNode("switchStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchStatement(BoundSwitchStatement node, object? arg) => new TreeDumperNode("switchStatement", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("innerLocals", node.InnerLocals, null), @@ -12848,7 +13035,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("breakLabel", node.BreakLabel, null) } ); - public override TreeDumperNode VisitSwitchDispatch(BoundSwitchDispatch node, object arg) => new TreeDumperNode("switchDispatch", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchDispatch(BoundSwitchDispatch node, object? arg) => new TreeDumperNode("switchDispatch", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("cases", node.Cases, null), @@ -12856,14 +13043,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("equalityMethod", node.EqualityMethod, null) } ); - public override TreeDumperNode VisitIfStatement(BoundIfStatement node, object arg) => new TreeDumperNode("ifStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitIfStatement(BoundIfStatement node, object? arg) => new TreeDumperNode("ifStatement", null, new TreeDumperNode[] { new TreeDumperNode("condition", null, new TreeDumperNode[] { Visit(node.Condition, null) }), new TreeDumperNode("consequence", null, new TreeDumperNode[] { Visit(node.Consequence, null) }), new TreeDumperNode("alternativeOpt", null, new TreeDumperNode[] { Visit(node.AlternativeOpt, null) }) } ); - public override TreeDumperNode VisitDoStatement(BoundDoStatement node, object arg) => new TreeDumperNode("doStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitDoStatement(BoundDoStatement node, object? arg) => new TreeDumperNode("doStatement", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("condition", null, new TreeDumperNode[] { Visit(node.Condition, null) }), @@ -12872,7 +13059,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("continueLabel", node.ContinueLabel, null) } ); - public override TreeDumperNode VisitWhileStatement(BoundWhileStatement node, object arg) => new TreeDumperNode("whileStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitWhileStatement(BoundWhileStatement node, object? arg) => new TreeDumperNode("whileStatement", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("condition", null, new TreeDumperNode[] { Visit(node.Condition, null) }), @@ -12881,7 +13068,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("continueLabel", node.ContinueLabel, null) } ); - public override TreeDumperNode VisitForStatement(BoundForStatement node, object arg) => new TreeDumperNode("forStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitForStatement(BoundForStatement node, object? arg) => new TreeDumperNode("forStatement", null, new TreeDumperNode[] { new TreeDumperNode("outerLocals", node.OuterLocals, null), new TreeDumperNode("initializer", null, new TreeDumperNode[] { Visit(node.Initializer, null) }), @@ -12893,7 +13080,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("continueLabel", node.ContinueLabel, null) } ); - public override TreeDumperNode VisitForEachStatement(BoundForEachStatement node, object arg) => new TreeDumperNode("forEachStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitForEachStatement(BoundForEachStatement node, object? arg) => new TreeDumperNode("forEachStatement", null, new TreeDumperNode[] { new TreeDumperNode("enumeratorInfoOpt", node.EnumeratorInfoOpt, null), new TreeDumperNode("elementConversion", node.ElementConversion, null), @@ -12909,13 +13096,13 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("continueLabel", node.ContinueLabel, null) } ); - public override TreeDumperNode VisitForEachDeconstructStep(BoundForEachDeconstructStep node, object arg) => new TreeDumperNode("forEachDeconstructStep", null, new TreeDumperNode[] + public override TreeDumperNode VisitForEachDeconstructStep(BoundForEachDeconstructStep node, object? arg) => new TreeDumperNode("forEachDeconstructStep", null, new TreeDumperNode[] { new TreeDumperNode("deconstructionAssignment", null, new TreeDumperNode[] { Visit(node.DeconstructionAssignment, null) }), new TreeDumperNode("targetPlaceholder", null, new TreeDumperNode[] { Visit(node.TargetPlaceholder, null) }) } ); - public override TreeDumperNode VisitUsingStatement(BoundUsingStatement node, object arg) => new TreeDumperNode("usingStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitUsingStatement(BoundUsingStatement node, object? arg) => new TreeDumperNode("usingStatement", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("declarationsOpt", null, new TreeDumperNode[] { Visit(node.DeclarationsOpt, null) }), @@ -12926,20 +13113,20 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("disposeMethodOpt", node.DisposeMethodOpt, null) } ); - public override TreeDumperNode VisitFixedStatement(BoundFixedStatement node, object arg) => new TreeDumperNode("fixedStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitFixedStatement(BoundFixedStatement node, object? arg) => new TreeDumperNode("fixedStatement", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("declarations", null, new TreeDumperNode[] { Visit(node.Declarations, null) }), new TreeDumperNode("body", null, new TreeDumperNode[] { Visit(node.Body, null) }) } ); - public override TreeDumperNode VisitLockStatement(BoundLockStatement node, object arg) => new TreeDumperNode("lockStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitLockStatement(BoundLockStatement node, object? arg) => new TreeDumperNode("lockStatement", null, new TreeDumperNode[] { new TreeDumperNode("argument", null, new TreeDumperNode[] { Visit(node.Argument, null) }), new TreeDumperNode("body", null, new TreeDumperNode[] { Visit(node.Body, null) }) } ); - public override TreeDumperNode VisitTryStatement(BoundTryStatement node, object arg) => new TreeDumperNode("tryStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitTryStatement(BoundTryStatement node, object? arg) => new TreeDumperNode("tryStatement", null, new TreeDumperNode[] { new TreeDumperNode("tryBlock", null, new TreeDumperNode[] { Visit(node.TryBlock, null) }), new TreeDumperNode("catchBlocks", null, from x in node.CatchBlocks select Visit(x, null)), @@ -12948,7 +13135,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("preferFaultHandler", node.PreferFaultHandler, null) } ); - public override TreeDumperNode VisitCatchBlock(BoundCatchBlock node, object arg) => new TreeDumperNode("catchBlock", null, new TreeDumperNode[] + public override TreeDumperNode VisitCatchBlock(BoundCatchBlock node, object? arg) => new TreeDumperNode("catchBlock", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("exceptionSourceOpt", null, new TreeDumperNode[] { Visit(node.ExceptionSourceOpt, null) }), @@ -12958,38 +13145,38 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSynthesizedAsyncCatchAll", node.IsSynthesizedAsyncCatchAll, null) } ); - public override TreeDumperNode VisitLiteral(BoundLiteral node, object arg) => new TreeDumperNode("literal", null, new TreeDumperNode[] + public override TreeDumperNode VisitLiteral(BoundLiteral node, object? arg) => new TreeDumperNode("literal", null, new TreeDumperNode[] { new TreeDumperNode("constantValueOpt", node.ConstantValueOpt, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitThisReference(BoundThisReference node, object arg) => new TreeDumperNode("thisReference", null, new TreeDumperNode[] + public override TreeDumperNode VisitThisReference(BoundThisReference node, object? arg) => new TreeDumperNode("thisReference", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node, object arg) => new TreeDumperNode("previousSubmissionReference", null, new TreeDumperNode[] + public override TreeDumperNode VisitPreviousSubmissionReference(BoundPreviousSubmissionReference node, object? arg) => new TreeDumperNode("previousSubmissionReference", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node, object arg) => new TreeDumperNode("hostObjectMemberReference", null, new TreeDumperNode[] + public override TreeDumperNode VisitHostObjectMemberReference(BoundHostObjectMemberReference node, object? arg) => new TreeDumperNode("hostObjectMemberReference", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitBaseReference(BoundBaseReference node, object arg) => new TreeDumperNode("baseReference", null, new TreeDumperNode[] + public override TreeDumperNode VisitBaseReference(BoundBaseReference node, object? arg) => new TreeDumperNode("baseReference", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitLocal(BoundLocal node, object arg) => new TreeDumperNode("local", null, new TreeDumperNode[] + public override TreeDumperNode VisitLocal(BoundLocal node, object? arg) => new TreeDumperNode("local", null, new TreeDumperNode[] { new TreeDumperNode("localSymbol", node.LocalSymbol, null), new TreeDumperNode("declarationKind", node.DeclarationKind, null), @@ -12999,7 +13186,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPseudoVariable(BoundPseudoVariable node, object arg) => new TreeDumperNode("pseudoVariable", null, new TreeDumperNode[] + public override TreeDumperNode VisitPseudoVariable(BoundPseudoVariable node, object? arg) => new TreeDumperNode("pseudoVariable", null, new TreeDumperNode[] { new TreeDumperNode("localSymbol", node.LocalSymbol, null), new TreeDumperNode("emitExpressions", node.EmitExpressions, null), @@ -13007,7 +13194,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitRangeVariable(BoundRangeVariable node, object arg) => new TreeDumperNode("rangeVariable", null, new TreeDumperNode[] + public override TreeDumperNode VisitRangeVariable(BoundRangeVariable node, object? arg) => new TreeDumperNode("rangeVariable", null, new TreeDumperNode[] { new TreeDumperNode("rangeVariableSymbol", node.RangeVariableSymbol, null), new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }), @@ -13015,51 +13202,51 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitParameter(BoundParameter node, object arg) => new TreeDumperNode("parameter", null, new TreeDumperNode[] + public override TreeDumperNode VisitParameter(BoundParameter node, object? arg) => new TreeDumperNode("parameter", null, new TreeDumperNode[] { new TreeDumperNode("parameterSymbol", node.ParameterSymbol, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitLabelStatement(BoundLabelStatement node, object arg) => new TreeDumperNode("labelStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitLabelStatement(BoundLabelStatement node, object? arg) => new TreeDumperNode("labelStatement", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitGotoStatement(BoundGotoStatement node, object arg) => new TreeDumperNode("gotoStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitGotoStatement(BoundGotoStatement node, object? arg) => new TreeDumperNode("gotoStatement", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null), new TreeDumperNode("caseExpressionOpt", null, new TreeDumperNode[] { Visit(node.CaseExpressionOpt, null) }), new TreeDumperNode("labelExpressionOpt", null, new TreeDumperNode[] { Visit(node.LabelExpressionOpt, null) }) } ); - public override TreeDumperNode VisitLabeledStatement(BoundLabeledStatement node, object arg) => new TreeDumperNode("labeledStatement", null, new TreeDumperNode[] + public override TreeDumperNode VisitLabeledStatement(BoundLabeledStatement node, object? arg) => new TreeDumperNode("labeledStatement", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null), new TreeDumperNode("body", null, new TreeDumperNode[] { Visit(node.Body, null) }) } ); - public override TreeDumperNode VisitLabel(BoundLabel node, object arg) => new TreeDumperNode("label", null, new TreeDumperNode[] + public override TreeDumperNode VisitLabel(BoundLabel node, object? arg) => new TreeDumperNode("label", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitStatementList(BoundStatementList node, object arg) => new TreeDumperNode("statementList", null, new TreeDumperNode[] + public override TreeDumperNode VisitStatementList(BoundStatementList node, object? arg) => new TreeDumperNode("statementList", null, new TreeDumperNode[] { new TreeDumperNode("statements", null, from x in node.Statements select Visit(x, null)) } ); - public override TreeDumperNode VisitConditionalGoto(BoundConditionalGoto node, object arg) => new TreeDumperNode("conditionalGoto", null, new TreeDumperNode[] + public override TreeDumperNode VisitConditionalGoto(BoundConditionalGoto node, object? arg) => new TreeDumperNode("conditionalGoto", null, new TreeDumperNode[] { new TreeDumperNode("condition", null, new TreeDumperNode[] { Visit(node.Condition, null) }), new TreeDumperNode("jumpIfTrue", node.JumpIfTrue, null), new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitSwitchExpression(BoundSwitchExpression node, object arg) => new TreeDumperNode("switchExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchExpression(BoundSwitchExpression node, object? arg) => new TreeDumperNode("switchExpression", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("switchArms", null, from x in node.SwitchArms select Visit(x, null)), @@ -13070,7 +13257,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSwitchExpressionArm(BoundSwitchExpressionArm node, object arg) => new TreeDumperNode("switchExpressionArm", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchExpressionArm(BoundSwitchExpressionArm node, object? arg) => new TreeDumperNode("switchExpressionArm", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("pattern", null, new TreeDumperNode[] { Visit(node.Pattern, null) }), @@ -13079,25 +13266,25 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitDecisionDag(BoundDecisionDag node, object arg) => new TreeDumperNode("decisionDag", null, new TreeDumperNode[] + public override TreeDumperNode VisitDecisionDag(BoundDecisionDag node, object? arg) => new TreeDumperNode("decisionDag", null, new TreeDumperNode[] { new TreeDumperNode("rootNode", node.RootNode, null) } ); - public override TreeDumperNode VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node, object arg) => new TreeDumperNode("evaluationDecisionDagNode", null, new TreeDumperNode[] + public override TreeDumperNode VisitEvaluationDecisionDagNode(BoundEvaluationDecisionDagNode node, object? arg) => new TreeDumperNode("evaluationDecisionDagNode", null, new TreeDumperNode[] { new TreeDumperNode("evaluation", null, new TreeDumperNode[] { Visit(node.Evaluation, null) }), new TreeDumperNode("next", null, new TreeDumperNode[] { Visit(node.Next, null) }) } ); - public override TreeDumperNode VisitTestDecisionDagNode(BoundTestDecisionDagNode node, object arg) => new TreeDumperNode("testDecisionDagNode", null, new TreeDumperNode[] + public override TreeDumperNode VisitTestDecisionDagNode(BoundTestDecisionDagNode node, object? arg) => new TreeDumperNode("testDecisionDagNode", null, new TreeDumperNode[] { new TreeDumperNode("test", null, new TreeDumperNode[] { Visit(node.Test, null) }), new TreeDumperNode("whenTrue", null, new TreeDumperNode[] { Visit(node.WhenTrue, null) }), new TreeDumperNode("whenFalse", null, new TreeDumperNode[] { Visit(node.WhenFalse, null) }) } ); - public override TreeDumperNode VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node, object arg) => new TreeDumperNode("whenDecisionDagNode", null, new TreeDumperNode[] + public override TreeDumperNode VisitWhenDecisionDagNode(BoundWhenDecisionDagNode node, object? arg) => new TreeDumperNode("whenDecisionDagNode", null, new TreeDumperNode[] { new TreeDumperNode("bindings", node.Bindings, null), new TreeDumperNode("whenExpression", null, new TreeDumperNode[] { Visit(node.WhenExpression, null) }), @@ -13105,93 +13292,93 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("whenFalse", null, new TreeDumperNode[] { Visit(node.WhenFalse, null) }) } ); - public override TreeDumperNode VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node, object arg) => new TreeDumperNode("leafDecisionDagNode", null, new TreeDumperNode[] + public override TreeDumperNode VisitLeafDecisionDagNode(BoundLeafDecisionDagNode node, object? arg) => new TreeDumperNode("leafDecisionDagNode", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null) } ); - public override TreeDumperNode VisitDagTemp(BoundDagTemp node, object arg) => new TreeDumperNode("dagTemp", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagTemp(BoundDagTemp node, object? arg) => new TreeDumperNode("dagTemp", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("source", null, new TreeDumperNode[] { Visit(node.Source, null) }), new TreeDumperNode("index", node.Index, null) } ); - public override TreeDumperNode VisitDagTypeTest(BoundDagTypeTest node, object arg) => new TreeDumperNode("dagTypeTest", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagTypeTest(BoundDagTypeTest node, object? arg) => new TreeDumperNode("dagTypeTest", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagNonNullTest(BoundDagNonNullTest node, object arg) => new TreeDumperNode("dagNonNullTest", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagNonNullTest(BoundDagNonNullTest node, object? arg) => new TreeDumperNode("dagNonNullTest", null, new TreeDumperNode[] { new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagExplicitNullTest(BoundDagExplicitNullTest node, object arg) => new TreeDumperNode("dagExplicitNullTest", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagExplicitNullTest(BoundDagExplicitNullTest node, object? arg) => new TreeDumperNode("dagExplicitNullTest", null, new TreeDumperNode[] { new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagValueTest(BoundDagValueTest node, object arg) => new TreeDumperNode("dagValueTest", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagValueTest(BoundDagValueTest node, object? arg) => new TreeDumperNode("dagValueTest", null, new TreeDumperNode[] { new TreeDumperNode("value", node.Value, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node, object arg) => new TreeDumperNode("dagDeconstructEvaluation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagDeconstructEvaluation(BoundDagDeconstructEvaluation node, object? arg) => new TreeDumperNode("dagDeconstructEvaluation", null, new TreeDumperNode[] { new TreeDumperNode("deconstructMethod", node.DeconstructMethod, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagTypeEvaluation(BoundDagTypeEvaluation node, object arg) => new TreeDumperNode("dagTypeEvaluation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagTypeEvaluation(BoundDagTypeEvaluation node, object? arg) => new TreeDumperNode("dagTypeEvaluation", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagFieldEvaluation(BoundDagFieldEvaluation node, object arg) => new TreeDumperNode("dagFieldEvaluation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagFieldEvaluation(BoundDagFieldEvaluation node, object? arg) => new TreeDumperNode("dagFieldEvaluation", null, new TreeDumperNode[] { new TreeDumperNode("field", node.Field, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node, object arg) => new TreeDumperNode("dagPropertyEvaluation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagPropertyEvaluation(BoundDagPropertyEvaluation node, object? arg) => new TreeDumperNode("dagPropertyEvaluation", null, new TreeDumperNode[] { new TreeDumperNode("property", node.Property, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitDagIndexEvaluation(BoundDagIndexEvaluation node, object arg) => new TreeDumperNode("dagIndexEvaluation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDagIndexEvaluation(BoundDagIndexEvaluation node, object? arg) => new TreeDumperNode("dagIndexEvaluation", null, new TreeDumperNode[] { new TreeDumperNode("property", node.Property, null), new TreeDumperNode("index", node.Index, null), new TreeDumperNode("input", null, new TreeDumperNode[] { Visit(node.Input, null) }) } ); - public override TreeDumperNode VisitSwitchSection(BoundSwitchSection node, object arg) => new TreeDumperNode("switchSection", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchSection(BoundSwitchSection node, object? arg) => new TreeDumperNode("switchSection", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("switchLabels", null, from x in node.SwitchLabels select Visit(x, null)), new TreeDumperNode("statements", null, from x in node.Statements select Visit(x, null)) } ); - public override TreeDumperNode VisitSwitchLabel(BoundSwitchLabel node, object arg) => new TreeDumperNode("switchLabel", null, new TreeDumperNode[] + public override TreeDumperNode VisitSwitchLabel(BoundSwitchLabel node, object? arg) => new TreeDumperNode("switchLabel", null, new TreeDumperNode[] { new TreeDumperNode("label", node.Label, null), new TreeDumperNode("pattern", null, new TreeDumperNode[] { Visit(node.Pattern, null) }), new TreeDumperNode("whenClause", null, new TreeDumperNode[] { Visit(node.WhenClause, null) }) } ); - public override TreeDumperNode VisitSequencePointExpression(BoundSequencePointExpression node, object arg) => new TreeDumperNode("sequencePointExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitSequencePointExpression(BoundSequencePointExpression node, object? arg) => new TreeDumperNode("sequencePointExpression", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSequence(BoundSequence node, object arg) => new TreeDumperNode("sequence", null, new TreeDumperNode[] + public override TreeDumperNode VisitSequence(BoundSequence node, object? arg) => new TreeDumperNode("sequence", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("sideEffects", null, from x in node.SideEffects select Visit(x, null)), @@ -13200,7 +13387,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitSpillSequence(BoundSpillSequence node, object arg) => new TreeDumperNode("spillSequence", null, new TreeDumperNode[] + public override TreeDumperNode VisitSpillSequence(BoundSpillSequence node, object? arg) => new TreeDumperNode("spillSequence", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("sideEffects", null, from x in node.SideEffects select Visit(x, null)), @@ -13209,7 +13396,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node, object arg) => new TreeDumperNode("dynamicMemberAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicMemberAccess(BoundDynamicMemberAccess node, object? arg) => new TreeDumperNode("dynamicMemberAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiver", null, new TreeDumperNode[] { Visit(node.Receiver, null) }), new TreeDumperNode("typeArgumentsOpt", node.TypeArgumentsOpt, null), @@ -13220,7 +13407,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicInvocation(BoundDynamicInvocation node, object arg) => new TreeDumperNode("dynamicInvocation", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicInvocation(BoundDynamicInvocation node, object? arg) => new TreeDumperNode("dynamicInvocation", null, new TreeDumperNode[] { new TreeDumperNode("argumentNamesOpt", node.ArgumentNamesOpt, null), new TreeDumperNode("argumentRefKindsOpt", node.ArgumentRefKindsOpt, null), @@ -13231,7 +13418,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConditionalAccess(BoundConditionalAccess node, object arg) => new TreeDumperNode("conditionalAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitConditionalAccess(BoundConditionalAccess node, object? arg) => new TreeDumperNode("conditionalAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiver", null, new TreeDumperNode[] { Visit(node.Receiver, null) }), new TreeDumperNode("accessExpression", null, new TreeDumperNode[] { Visit(node.AccessExpression, null) }), @@ -13239,7 +13426,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node, object arg) => new TreeDumperNode("loweredConditionalAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitLoweredConditionalAccess(BoundLoweredConditionalAccess node, object? arg) => new TreeDumperNode("loweredConditionalAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiver", null, new TreeDumperNode[] { Visit(node.Receiver, null) }), new TreeDumperNode("hasValueMethodOpt", node.HasValueMethodOpt, null), @@ -13250,14 +13437,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConditionalReceiver(BoundConditionalReceiver node, object arg) => new TreeDumperNode("conditionalReceiver", null, new TreeDumperNode[] + public override TreeDumperNode VisitConditionalReceiver(BoundConditionalReceiver node, object? arg) => new TreeDumperNode("conditionalReceiver", null, new TreeDumperNode[] { new TreeDumperNode("id", node.Id, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node, object arg) => new TreeDumperNode("complexConditionalReceiver", null, new TreeDumperNode[] + public override TreeDumperNode VisitComplexConditionalReceiver(BoundComplexConditionalReceiver node, object? arg) => new TreeDumperNode("complexConditionalReceiver", null, new TreeDumperNode[] { new TreeDumperNode("valueTypeReceiver", null, new TreeDumperNode[] { Visit(node.ValueTypeReceiver, null) }), new TreeDumperNode("referenceTypeReceiver", null, new TreeDumperNode[] { Visit(node.ReferenceTypeReceiver, null) }), @@ -13265,7 +13452,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitMethodGroup(BoundMethodGroup node, object arg) => new TreeDumperNode("methodGroup", null, new TreeDumperNode[] + public override TreeDumperNode VisitMethodGroup(BoundMethodGroup node, object? arg) => new TreeDumperNode("methodGroup", null, new TreeDumperNode[] { new TreeDumperNode("typeArgumentsOpt", node.TypeArgumentsOpt, null), new TreeDumperNode("name", node.Name, null), @@ -13279,7 +13466,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPropertyGroup(BoundPropertyGroup node, object arg) => new TreeDumperNode("propertyGroup", null, new TreeDumperNode[] + public override TreeDumperNode VisitPropertyGroup(BoundPropertyGroup node, object? arg) => new TreeDumperNode("propertyGroup", null, new TreeDumperNode[] { new TreeDumperNode("properties", node.Properties, null), new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), @@ -13288,7 +13475,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitCall(BoundCall node, object arg) => new TreeDumperNode("call", null, new TreeDumperNode[] + public override TreeDumperNode VisitCall(BoundCall node, object? arg) => new TreeDumperNode("call", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("method", node.Method, null), @@ -13305,7 +13492,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node, object arg) => new TreeDumperNode("eventAssignmentOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitEventAssignmentOperator(BoundEventAssignmentOperator node, object? arg) => new TreeDumperNode("eventAssignmentOperator", null, new TreeDumperNode[] { new TreeDumperNode("@event", node.Event, null), new TreeDumperNode("isAddition", node.IsAddition, null), @@ -13316,7 +13503,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAttribute(BoundAttribute node, object arg) => new TreeDumperNode("attribute", null, new TreeDumperNode[] + public override TreeDumperNode VisitAttribute(BoundAttribute node, object? arg) => new TreeDumperNode("attribute", null, new TreeDumperNode[] { new TreeDumperNode("constructor", node.Constructor, null), new TreeDumperNode("constructorArguments", null, from x in node.ConstructorArguments select Visit(x, null)), @@ -13329,7 +13516,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitObjectCreationExpression(BoundObjectCreationExpression node, object arg) => new TreeDumperNode("objectCreationExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitObjectCreationExpression(BoundObjectCreationExpression node, object? arg) => new TreeDumperNode("objectCreationExpression", null, new TreeDumperNode[] { new TreeDumperNode("constructor", node.Constructor, null), new TreeDumperNode("constructorsGroup", node.ConstructorsGroup, null), @@ -13345,7 +13532,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTupleLiteral(BoundTupleLiteral node, object arg) => new TreeDumperNode("tupleLiteral", null, new TreeDumperNode[] + public override TreeDumperNode VisitTupleLiteral(BoundTupleLiteral node, object? arg) => new TreeDumperNode("tupleLiteral", null, new TreeDumperNode[] { new TreeDumperNode("argumentNamesOpt", node.ArgumentNamesOpt, null), new TreeDumperNode("inferredNamesOpt", node.InferredNamesOpt, null), @@ -13354,7 +13541,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node, object arg) => new TreeDumperNode("convertedTupleLiteral", null, new TreeDumperNode[] + public override TreeDumperNode VisitConvertedTupleLiteral(BoundConvertedTupleLiteral node, object? arg) => new TreeDumperNode("convertedTupleLiteral", null, new TreeDumperNode[] { new TreeDumperNode("sourceTuple", null, new TreeDumperNode[] { Visit(node.SourceTuple, null) }), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13362,7 +13549,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node, object arg) => new TreeDumperNode("dynamicObjectCreationExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicObjectCreationExpression(BoundDynamicObjectCreationExpression node, object? arg) => new TreeDumperNode("dynamicObjectCreationExpression", null, new TreeDumperNode[] { new TreeDumperNode("name", node.Name, null), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13374,7 +13561,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node, object arg) => new TreeDumperNode("noPiaObjectCreationExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitNoPiaObjectCreationExpression(BoundNoPiaObjectCreationExpression node, object? arg) => new TreeDumperNode("noPiaObjectCreationExpression", null, new TreeDumperNode[] { new TreeDumperNode("guidString", node.GuidString, null), new TreeDumperNode("initializerExpressionOpt", null, new TreeDumperNode[] { Visit(node.InitializerExpressionOpt, null) }), @@ -13382,14 +13569,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node, object arg) => new TreeDumperNode("objectInitializerExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitObjectInitializerExpression(BoundObjectInitializerExpression node, object? arg) => new TreeDumperNode("objectInitializerExpression", null, new TreeDumperNode[] { new TreeDumperNode("initializers", null, from x in node.Initializers select Visit(x, null)), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitObjectInitializerMember(BoundObjectInitializerMember node, object arg) => new TreeDumperNode("objectInitializerMember", null, new TreeDumperNode[] + public override TreeDumperNode VisitObjectInitializerMember(BoundObjectInitializerMember node, object? arg) => new TreeDumperNode("objectInitializerMember", null, new TreeDumperNode[] { new TreeDumperNode("memberSymbol", node.MemberSymbol, null), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13404,7 +13591,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node, object arg) => new TreeDumperNode("dynamicObjectInitializerMember", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicObjectInitializerMember(BoundDynamicObjectInitializerMember node, object? arg) => new TreeDumperNode("dynamicObjectInitializerMember", null, new TreeDumperNode[] { new TreeDumperNode("memberName", node.MemberName, null), new TreeDumperNode("receiverType", node.ReceiverType, null), @@ -13412,14 +13599,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node, object arg) => new TreeDumperNode("collectionInitializerExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitCollectionInitializerExpression(BoundCollectionInitializerExpression node, object? arg) => new TreeDumperNode("collectionInitializerExpression", null, new TreeDumperNode[] { new TreeDumperNode("initializers", null, from x in node.Initializers select Visit(x, null)), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node, object arg) => new TreeDumperNode("collectionElementInitializer", null, new TreeDumperNode[] + public override TreeDumperNode VisitCollectionElementInitializer(BoundCollectionElementInitializer node, object? arg) => new TreeDumperNode("collectionElementInitializer", null, new TreeDumperNode[] { new TreeDumperNode("addMethod", node.AddMethod, null), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13433,7 +13620,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node, object arg) => new TreeDumperNode("dynamicCollectionElementInitializer", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicCollectionElementInitializer(BoundDynamicCollectionElementInitializer node, object? arg) => new TreeDumperNode("dynamicCollectionElementInitializer", null, new TreeDumperNode[] { new TreeDumperNode("applicableMethods", node.ApplicableMethods, null), new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), @@ -13442,13 +13629,13 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitImplicitReceiver(BoundImplicitReceiver node, object arg) => new TreeDumperNode("implicitReceiver", null, new TreeDumperNode[] + public override TreeDumperNode VisitImplicitReceiver(BoundImplicitReceiver node, object? arg) => new TreeDumperNode("implicitReceiver", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node, object arg) => new TreeDumperNode("anonymousObjectCreationExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitAnonymousObjectCreationExpression(BoundAnonymousObjectCreationExpression node, object? arg) => new TreeDumperNode("anonymousObjectCreationExpression", null, new TreeDumperNode[] { new TreeDumperNode("constructor", node.Constructor, null), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13457,21 +13644,21 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node, object arg) => new TreeDumperNode("anonymousPropertyDeclaration", null, new TreeDumperNode[] + public override TreeDumperNode VisitAnonymousPropertyDeclaration(BoundAnonymousPropertyDeclaration node, object? arg) => new TreeDumperNode("anonymousPropertyDeclaration", null, new TreeDumperNode[] { new TreeDumperNode("property", node.Property, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNewT(BoundNewT node, object arg) => new TreeDumperNode("newT", null, new TreeDumperNode[] + public override TreeDumperNode VisitNewT(BoundNewT node, object? arg) => new TreeDumperNode("newT", null, new TreeDumperNode[] { new TreeDumperNode("initializerExpressionOpt", null, new TreeDumperNode[] { Visit(node.InitializerExpressionOpt, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node, object arg) => new TreeDumperNode("delegateCreationExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitDelegateCreationExpression(BoundDelegateCreationExpression node, object? arg) => new TreeDumperNode("delegateCreationExpression", null, new TreeDumperNode[] { new TreeDumperNode("argument", null, new TreeDumperNode[] { Visit(node.Argument, null) }), new TreeDumperNode("methodOpt", node.MethodOpt, null), @@ -13480,7 +13667,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArrayCreation(BoundArrayCreation node, object arg) => new TreeDumperNode("arrayCreation", null, new TreeDumperNode[] + public override TreeDumperNode VisitArrayCreation(BoundArrayCreation node, object? arg) => new TreeDumperNode("arrayCreation", null, new TreeDumperNode[] { new TreeDumperNode("bounds", null, from x in node.Bounds select Visit(x, null)), new TreeDumperNode("initializerOpt", null, new TreeDumperNode[] { Visit(node.InitializerOpt, null) }), @@ -13488,14 +13675,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitArrayInitialization(BoundArrayInitialization node, object arg) => new TreeDumperNode("arrayInitialization", null, new TreeDumperNode[] + public override TreeDumperNode VisitArrayInitialization(BoundArrayInitialization node, object? arg) => new TreeDumperNode("arrayInitialization", null, new TreeDumperNode[] { new TreeDumperNode("initializers", null, from x in node.Initializers select Visit(x, null)), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node, object arg) => new TreeDumperNode("stackAllocArrayCreation", null, new TreeDumperNode[] + public override TreeDumperNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreation node, object? arg) => new TreeDumperNode("stackAllocArrayCreation", null, new TreeDumperNode[] { new TreeDumperNode("elementType", node.ElementType, null), new TreeDumperNode("count", null, new TreeDumperNode[] { Visit(node.Count, null) }), @@ -13504,7 +13691,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node, object arg) => new TreeDumperNode("convertedStackAllocExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitConvertedStackAllocExpression(BoundConvertedStackAllocExpression node, object? arg) => new TreeDumperNode("convertedStackAllocExpression", null, new TreeDumperNode[] { new TreeDumperNode("elementType", node.ElementType, null), new TreeDumperNode("count", null, new TreeDumperNode[] { Visit(node.Count, null) }), @@ -13513,7 +13700,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitFieldAccess(BoundFieldAccess node, object arg) => new TreeDumperNode("fieldAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitFieldAccess(BoundFieldAccess node, object? arg) => new TreeDumperNode("fieldAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("fieldSymbol", node.FieldSymbol, null), @@ -13525,14 +13712,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node, object arg) => new TreeDumperNode("hoistedFieldAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitHoistedFieldAccess(BoundHoistedFieldAccess node, object? arg) => new TreeDumperNode("hoistedFieldAccess", null, new TreeDumperNode[] { new TreeDumperNode("fieldSymbol", node.FieldSymbol, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitPropertyAccess(BoundPropertyAccess node, object arg) => new TreeDumperNode("propertyAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitPropertyAccess(BoundPropertyAccess node, object? arg) => new TreeDumperNode("propertyAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("propertySymbol", node.PropertySymbol, null), @@ -13541,7 +13728,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitEventAccess(BoundEventAccess node, object arg) => new TreeDumperNode("eventAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitEventAccess(BoundEventAccess node, object? arg) => new TreeDumperNode("eventAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("eventSymbol", node.EventSymbol, null), @@ -13551,7 +13738,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitIndexerAccess(BoundIndexerAccess node, object arg) => new TreeDumperNode("indexerAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitIndexerAccess(BoundIndexerAccess node, object? arg) => new TreeDumperNode("indexerAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("indexer", node.Indexer, null), @@ -13566,7 +13753,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node, object arg) => new TreeDumperNode("indexOrRangePatternIndexerAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitIndexOrRangePatternIndexerAccess(BoundIndexOrRangePatternIndexerAccess node, object? arg) => new TreeDumperNode("indexOrRangePatternIndexerAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiver", null, new TreeDumperNode[] { Visit(node.Receiver, null) }), new TreeDumperNode("lengthOrCountProperty", node.LengthOrCountProperty, null), @@ -13576,7 +13763,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node, object arg) => new TreeDumperNode("dynamicIndexerAccess", null, new TreeDumperNode[] + public override TreeDumperNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess node, object? arg) => new TreeDumperNode("dynamicIndexerAccess", null, new TreeDumperNode[] { new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), new TreeDumperNode("arguments", null, from x in node.Arguments select Visit(x, null)), @@ -13587,7 +13774,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitLambda(BoundLambda node, object arg) => new TreeDumperNode("lambda", null, new TreeDumperNode[] + public override TreeDumperNode VisitLambda(BoundLambda node, object? arg) => new TreeDumperNode("lambda", null, new TreeDumperNode[] { new TreeDumperNode("unboundLambda", null, new TreeDumperNode[] { Visit(node.UnboundLambda, null) }), new TreeDumperNode("symbol", node.Symbol, null), @@ -13598,14 +13785,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitUnboundLambda(UnboundLambda node, object arg) => new TreeDumperNode("unboundLambda", null, new TreeDumperNode[] + public override TreeDumperNode VisitUnboundLambda(UnboundLambda node, object? arg) => new TreeDumperNode("unboundLambda", null, new TreeDumperNode[] { new TreeDumperNode("data", node.Data, null), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitQueryClause(BoundQueryClause node, object arg) => new TreeDumperNode("queryClause", null, new TreeDumperNode[] + public override TreeDumperNode VisitQueryClause(BoundQueryClause node, object? arg) => new TreeDumperNode("queryClause", null, new TreeDumperNode[] { new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }), new TreeDumperNode("definedSymbol", node.DefinedSymbol, null), @@ -13614,12 +13801,12 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node, object arg) => new TreeDumperNode("typeOrInstanceInitializers", null, new TreeDumperNode[] + public override TreeDumperNode VisitTypeOrInstanceInitializers(BoundTypeOrInstanceInitializers node, object? arg) => new TreeDumperNode("typeOrInstanceInitializers", null, new TreeDumperNode[] { new TreeDumperNode("statements", null, from x in node.Statements select Visit(x, null)) } ); - public override TreeDumperNode VisitNameOfOperator(BoundNameOfOperator node, object arg) => new TreeDumperNode("nameOfOperator", null, new TreeDumperNode[] + public override TreeDumperNode VisitNameOfOperator(BoundNameOfOperator node, object? arg) => new TreeDumperNode("nameOfOperator", null, new TreeDumperNode[] { new TreeDumperNode("argument", null, new TreeDumperNode[] { Visit(node.Argument, null) }), new TreeDumperNode("constantValueOpt", node.ConstantValueOpt, null), @@ -13627,14 +13814,14 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitInterpolatedString(BoundInterpolatedString node, object arg) => new TreeDumperNode("interpolatedString", null, new TreeDumperNode[] + public override TreeDumperNode VisitInterpolatedString(BoundInterpolatedString node, object? arg) => new TreeDumperNode("interpolatedString", null, new TreeDumperNode[] { new TreeDumperNode("parts", null, from x in node.Parts select Visit(x, null)), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitStringInsert(BoundStringInsert node, object arg) => new TreeDumperNode("stringInsert", null, new TreeDumperNode[] + public override TreeDumperNode VisitStringInsert(BoundStringInsert node, object? arg) => new TreeDumperNode("stringInsert", null, new TreeDumperNode[] { new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }), new TreeDumperNode("alignment", null, new TreeDumperNode[] { Visit(node.Alignment, null) }), @@ -13643,7 +13830,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitIsPatternExpression(BoundIsPatternExpression node, object arg) => new TreeDumperNode("isPatternExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitIsPatternExpression(BoundIsPatternExpression node, object? arg) => new TreeDumperNode("isPatternExpression", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("pattern", null, new TreeDumperNode[] { Visit(node.Pattern, null) }), @@ -13654,19 +13841,19 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitConstantPattern(BoundConstantPattern node, object arg) => new TreeDumperNode("constantPattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitConstantPattern(BoundConstantPattern node, object? arg) => new TreeDumperNode("constantPattern", null, new TreeDumperNode[] { new TreeDumperNode("value", null, new TreeDumperNode[] { Visit(node.Value, null) }), new TreeDumperNode("constantValue", node.ConstantValue, null), new TreeDumperNode("inputType", node.InputType, null) } ); - public override TreeDumperNode VisitDiscardPattern(BoundDiscardPattern node, object arg) => new TreeDumperNode("discardPattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitDiscardPattern(BoundDiscardPattern node, object? arg) => new TreeDumperNode("discardPattern", null, new TreeDumperNode[] { new TreeDumperNode("inputType", node.InputType, null) } ); - public override TreeDumperNode VisitDeclarationPattern(BoundDeclarationPattern node, object arg) => new TreeDumperNode("declarationPattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitDeclarationPattern(BoundDeclarationPattern node, object? arg) => new TreeDumperNode("declarationPattern", null, new TreeDumperNode[] { new TreeDumperNode("variable", node.Variable, null), new TreeDumperNode("variableAccess", null, new TreeDumperNode[] { Visit(node.VariableAccess, null) }), @@ -13675,7 +13862,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("inputType", node.InputType, null) } ); - public override TreeDumperNode VisitRecursivePattern(BoundRecursivePattern node, object arg) => new TreeDumperNode("recursivePattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitRecursivePattern(BoundRecursivePattern node, object? arg) => new TreeDumperNode("recursivePattern", null, new TreeDumperNode[] { new TreeDumperNode("declaredType", null, new TreeDumperNode[] { Visit(node.DeclaredType, null) }), new TreeDumperNode("deconstructMethod", node.DeconstructMethod, null), @@ -13686,7 +13873,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("inputType", node.InputType, null) } ); - public override TreeDumperNode VisitITuplePattern(BoundITuplePattern node, object arg) => new TreeDumperNode("iTuplePattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitITuplePattern(BoundITuplePattern node, object? arg) => new TreeDumperNode("iTuplePattern", null, new TreeDumperNode[] { new TreeDumperNode("getLengthMethod", node.GetLengthMethod, null), new TreeDumperNode("getItemMethod", node.GetItemMethod, null), @@ -13694,26 +13881,26 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("inputType", node.InputType, null) } ); - public override TreeDumperNode VisitSubpattern(BoundSubpattern node, object arg) => new TreeDumperNode("subpattern", null, new TreeDumperNode[] + public override TreeDumperNode VisitSubpattern(BoundSubpattern node, object? arg) => new TreeDumperNode("subpattern", null, new TreeDumperNode[] { new TreeDumperNode("symbol", node.Symbol, null), new TreeDumperNode("pattern", null, new TreeDumperNode[] { Visit(node.Pattern, null) }) } ); - public override TreeDumperNode VisitDiscardExpression(BoundDiscardExpression node, object arg) => new TreeDumperNode("discardExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitDiscardExpression(BoundDiscardExpression node, object? arg) => new TreeDumperNode("discardExpression", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitThrowExpression(BoundThrowExpression node, object arg) => new TreeDumperNode("throwExpression", null, new TreeDumperNode[] + public override TreeDumperNode VisitThrowExpression(BoundThrowExpression node, object? arg) => new TreeDumperNode("throwExpression", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitOutVariablePendingInference(OutVariablePendingInference node, object arg) => new TreeDumperNode("outVariablePendingInference", null, new TreeDumperNode[] + public override TreeDumperNode VisitOutVariablePendingInference(OutVariablePendingInference node, object? arg) => new TreeDumperNode("outVariablePendingInference", null, new TreeDumperNode[] { new TreeDumperNode("variableSymbol", node.VariableSymbol, null), new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), @@ -13721,7 +13908,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node, object arg) => new TreeDumperNode("deconstructionVariablePendingInference", null, new TreeDumperNode[] + public override TreeDumperNode VisitDeconstructionVariablePendingInference(DeconstructionVariablePendingInference node, object? arg) => new TreeDumperNode("deconstructionVariablePendingInference", null, new TreeDumperNode[] { new TreeDumperNode("variableSymbol", node.VariableSymbol, null), new TreeDumperNode("receiverOpt", null, new TreeDumperNode[] { Visit(node.ReceiverOpt, null) }), @@ -13729,19 +13916,19 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node, object arg) => new TreeDumperNode("outDeconstructVarPendingInference", null, new TreeDumperNode[] + public override TreeDumperNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node, object? arg) => new TreeDumperNode("outDeconstructVarPendingInference", null, new TreeDumperNode[] { new TreeDumperNode("type", node.Type, null), new TreeDumperNode("isSuppressed", node.IsSuppressed, null) } ); - public override TreeDumperNode VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node, object arg) => new TreeDumperNode("nonConstructorMethodBody", null, new TreeDumperNode[] + public override TreeDumperNode VisitNonConstructorMethodBody(BoundNonConstructorMethodBody node, object? arg) => new TreeDumperNode("nonConstructorMethodBody", null, new TreeDumperNode[] { new TreeDumperNode("blockBody", null, new TreeDumperNode[] { Visit(node.BlockBody, null) }), new TreeDumperNode("expressionBody", null, new TreeDumperNode[] { Visit(node.ExpressionBody, null) }) } ); - public override TreeDumperNode VisitConstructorMethodBody(BoundConstructorMethodBody node, object arg) => new TreeDumperNode("constructorMethodBody", null, new TreeDumperNode[] + public override TreeDumperNode VisitConstructorMethodBody(BoundConstructorMethodBody node, object? arg) => new TreeDumperNode("constructorMethodBody", null, new TreeDumperNode[] { new TreeDumperNode("locals", node.Locals, null), new TreeDumperNode("initializer", null, new TreeDumperNode[] { Visit(node.Initializer, null) }), @@ -13749,7 +13936,7 @@ private BoundTreeDumperNodeProducer() new TreeDumperNode("expressionBody", null, new TreeDumperNode[] { Visit(node.ExpressionBody, null) }) } ); - public override TreeDumperNode VisitExpressionWithNullability(BoundExpressionWithNullability node, object arg) => new TreeDumperNode("expressionWithNullability", null, new TreeDumperNode[] + public override TreeDumperNode VisitExpressionWithNullability(BoundExpressionWithNullability node, object? arg) => new TreeDumperNode("expressionWithNullability", null, new TreeDumperNode[] { new TreeDumperNode("expression", null, new TreeDumperNode[] { Visit(node.Expression, null) }), new TreeDumperNode("nullableAnnotation", node.NullableAnnotation, null), diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/BoundTreeGenerator/BoundNodeClassWriter.cs b/src/Tools/Source/CompilerGeneratorTools/Source/BoundTreeGenerator/BoundNodeClassWriter.cs index 336de319010bf..63a136b0fdd95 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/BoundTreeGenerator/BoundNodeClassWriter.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/BoundTreeGenerator/BoundNodeClassWriter.cs @@ -26,7 +26,7 @@ internal sealed class BoundNodeClassWriter private readonly TextWriter _writer; private readonly Tree _tree; private readonly Dictionary _typeMap; - private Dictionary _valueTypes; + private HashSet _valueTypes; private readonly TargetLanguage _targetLang; private BoundNodeClassWriter(TextWriter writer, Tree tree, TargetLanguage targetLang) @@ -42,50 +42,51 @@ private BoundNodeClassWriter(TextWriter writer, Tree tree, TargetLanguage target private void InitializeValueTypes() { - _valueTypes = new Dictionary(); + _valueTypes = new HashSet(); foreach (ValueType t in _tree.Types.Where(t => t is ValueType)) - _valueTypes.Add(t.Name, true); + _valueTypes.Add(t.Name); switch (_targetLang) { case TargetLanguage.CSharp: - _valueTypes.Add("bool", true); - _valueTypes.Add("int", true); - _valueTypes.Add("uint", true); - _valueTypes.Add("short", true); - _valueTypes.Add("ushort", true); - _valueTypes.Add("long", true); - _valueTypes.Add("ulong", true); - _valueTypes.Add("byte", true); - _valueTypes.Add("sbyte", true); - _valueTypes.Add("char", true); - _valueTypes.Add("Boolean", true); + _valueTypes.Add("bool"); + _valueTypes.Add("int"); + _valueTypes.Add("uint"); + _valueTypes.Add("short"); + _valueTypes.Add("ushort"); + _valueTypes.Add("long"); + _valueTypes.Add("ulong"); + _valueTypes.Add("byte"); + _valueTypes.Add("sbyte"); + _valueTypes.Add("char"); + _valueTypes.Add("Boolean"); break; case TargetLanguage.VB: - _valueTypes.Add("Boolean", true); - _valueTypes.Add("Integer", true); - _valueTypes.Add("UInteger", true); - _valueTypes.Add("Short", true); - _valueTypes.Add("UShort", true); - _valueTypes.Add("Long", true); - _valueTypes.Add("ULong", true); - _valueTypes.Add("Byte", true); - _valueTypes.Add("SByte", true); - _valueTypes.Add("Char", true); + _valueTypes.Add("Boolean"); + _valueTypes.Add("Integer"); + _valueTypes.Add("UInteger"); + _valueTypes.Add("Short"); + _valueTypes.Add("UShort"); + _valueTypes.Add("Long"); + _valueTypes.Add("ULong"); + _valueTypes.Add("Byte"); + _valueTypes.Add("SByte"); + _valueTypes.Add("Char"); break; } - _valueTypes.Add("Int8", true); - _valueTypes.Add("Int16", true); - _valueTypes.Add("Int32", true); - _valueTypes.Add("Int64", true); - _valueTypes.Add("UInt8", true); - _valueTypes.Add("UInt16", true); - _valueTypes.Add("UInt32", true); - _valueTypes.Add("UInt64", true); - _valueTypes.Add("ImmutableArray", true); - _valueTypes.Add("PropertyAccessKind", true); + _valueTypes.Add("Int8"); + _valueTypes.Add("Int16"); + _valueTypes.Add("Int32"); + _valueTypes.Add("Int64"); + _valueTypes.Add("UInt8"); + _valueTypes.Add("UInt16"); + _valueTypes.Add("UInt32"); + _valueTypes.Add("UInt64"); + _valueTypes.Add("ImmutableArray"); + _valueTypes.Add("PropertyAccessKind"); + _valueTypes.Add("TypeWithAnnotations"); } public static void Write(TextWriter writer, Tree tree, TargetLanguage targetLang) @@ -146,7 +147,9 @@ private void WriteFile() switch (_targetLang) { case TargetLanguage.CSharp: - WriteLine("// "); break; + WriteLine("// "); + WriteLine("#nullable enable"); + break; case TargetLanguage.VB: WriteLine("' "); break; default: @@ -407,7 +410,8 @@ private void WriteConstructorWithHasErrors(TreeType node, bool isPublic, bool ha Write("{0} {1}", isPublic ? "public" : "protected", node.Name); IEnumerable fields = isPublic ? new[] { "SyntaxNode syntax" } : new[] { "BoundKind kind", "SyntaxNode syntax" }; fields = fields.Concat(from field in AllSpecifiableFields(node) - select field.Type + " " + ToCamelCase(field.Name)); + let mostSpecific = GetField(node, field.Name) + select mostSpecific.Type + " " + ToCamelCase(field.Name)); if (hasErrorsIsOptional) fields = fields.Concat(new[] { "bool hasErrors = false" }); @@ -543,7 +547,8 @@ private void WriteConstructorWithoutHasErrors(TreeType node, bool isPublic) Write("{0} {1}", isPublic ? "public" : "protected", node.Name); IEnumerable fields = isPublic ? new[] { "SyntaxNode syntax" } : new[] { "BoundKind kind", "SyntaxNode syntax" }; fields = fields.Concat(from field in AllSpecifiableFields(node) - select field.Type + " " + ToCamelCase(field.Name)); + let mostSpecific = GetField(node, field.Name) + select mostSpecific.Type + " " + ToCamelCase(field.Name)); ParenList(fields, x => x); Blank(); Indent(); @@ -655,7 +660,7 @@ private void WriteNullChecks(TreeType node) if (isROArray) WriteLine("Debug.Assert(!{0}.IsDefault, \"Field '{0}' cannot be null (use Null=\\\"allow\\\" in BoundNodes.xml to remove this check)\");", ToCamelCase(field.Name)); else - WriteLine("Debug.Assert((object){0} != null, \"Field '{0}' cannot be null (use Null=\\\"allow\\\" in BoundNodes.xml to remove this check)\");", ToCamelCase(field.Name)); + WriteLine("Debug.Assert({0} is object, \"Field '{0}' cannot be null (make the type nullable in BoundNodes.xml to remove this check)\");", ToCamelCase(field.Name)); break; case TargetLanguage.VB: @@ -740,7 +745,7 @@ private IEnumerable AllNodeOrNodeListFields(TreeType node) private IEnumerable AllTypeFields(TreeType node) { - return AllFields(node).Where(field => field.Type == "TypeSymbol"); + return AllFields(node).Where(field => TypeIsTypeSymbol(field)); } private NullHandling FieldNullHandling(TreeType node, string fieldName) @@ -766,6 +771,10 @@ private NullHandling FieldNullHandling(TreeType node, string fieldName) } } + if (f.Type.EndsWith('?')) + { + return NullHandling.Allow; + } if (f.Override) return FieldNullHandling(BaseType(node), fieldName); else if (!IsValueType(f.Type) || GetGenericType(f.Type) == "ImmutableArray") @@ -796,6 +805,17 @@ private void WriteField(Field field) WriteLine("private readonly {0} _{1};", field.Type, field.Name); WriteLine("public override {0}{1} {2} {{ get {{ return _{2};}} }}", (IsNew(field) ? "new " : ""), field.Type, field.Name); } + else if (field.Override) + { + // We emit a suppression here because the bound nodes use a pattern which is safe, but can't be tracked. + + // The point of overriding a property is to change its nullability, usually + // from nullable to non-nullable. The base is annotated as nullable, + // but since the base property is always set via the base call in the + // constructor, as long as the parameter to the current class's constructor is not + // nullable, the base property is always non-null. + WriteLine($"public new {field.Type} {field.Name} => base.{field.Name}!;"); + } else { WriteLine("public {0}{1} {2} {{ get; }}", (IsNew(field) ? "new " : ""), field.Type, field.Name); @@ -827,7 +847,7 @@ private void WriteAccept(string name) { case TargetLanguage.CSharp: WriteLine("[DebuggerStepThrough]"); - WriteLine("public override BoundNode Accept(BoundTreeVisitor visitor) => visitor.Visit{0}(this);", StripBound(name)); + WriteLine("public override BoundNode? Accept(BoundTreeVisitor visitor) => visitor.Visit{0}(this);", StripBound(name)); break; case TargetLanguage.VB: @@ -865,8 +885,11 @@ private void WriteType(TreeType node) WriteConstructor(node, isPublic: true, hasChildNodes); } - foreach (var field in Fields(node)) + // Only C# can express nullable reference types + foreach (var field in (_targetLang == TargetLanguage.CSharp ? FieldsIncludingOverrides(node) : Fields(node))) + { WriteField(field); + } if (node is Node) { WriteAccept(node.Name); @@ -926,7 +949,7 @@ private void WriteUpdateMethod(Node node) Blank(); Write("public{1} {0} Update", node.Name, emitNew ? " new" : ""); Paren(); - Comma(AllSpecifiableFields(node), field => string.Format("{0} {1}", field.Type, ToCamelCase(field.Name))); + Comma(AllSpecifiableFields(node), field => string.Format("{0} {1}", GetField(node, field.Name).Type, ToCamelCase(field.Name))); UnParen(); Blank(); Brace(); @@ -993,11 +1016,13 @@ private void WriteUpdateMethod(Node node) string wasUpdatedCheck(Field field) { - var format = field.Type.EndsWith("TypeSymbol") ? "!TypeSymbol.Equals({0}, this.{1}, TypeCompareKind.ConsiderEverything)" : "{0} != this.{1}"; + var format = TypeIsTypeSymbol(field) ? "!TypeSymbol.Equals({0}, this.{1}, TypeCompareKind.ConsiderEverything)" : "{0} != this.{1}"; return string.Format(format, ToCamelCase(field.Name), field.Name); } } + private static bool TypeIsTypeSymbol(Field field) => field.Type.TrimEnd('?') == "TypeSymbol"; + private string StripBound(string name) { if (name.StartsWith("Bound", StringComparison.Ordinal)) @@ -1028,12 +1053,12 @@ private void WriteVisitor() { WriteLine("case BoundKind.{0}: ", FixKeyword(StripBound(node.Name))); Indent(); - WriteLine("return Visit{0}(node as {1}, arg);", StripBound(node.Name), node.Name); + WriteLine("return Visit{0}(({1})node, arg);", StripBound(node.Name), node.Name); Outdent(); } Unbrace(); Blank(); // end switch - WriteLine("return default(R);"); + WriteLine("return default(R)!;"); Unbrace(); // end method Unbrace(); // end class @@ -1042,7 +1067,7 @@ private void WriteVisitor() Brace(); foreach (var node in _tree.Types.OfType()) { - WriteLine("public virtual R Visit{0}({1} node, A arg) => this.DefaultVisit(node, arg);", StripBound(node.Name), node.Name); + WriteLine($"public virtual R Visit{StripBound(node.Name)}({node.Name} node, A arg) => this.DefaultVisit(node, arg);"); } Unbrace(); @@ -1051,7 +1076,7 @@ private void WriteVisitor() Brace(); foreach (var node in _tree.Types.OfType()) { - WriteLine("public virtual BoundNode Visit{0}({1} node) => this.DefaultVisit(node);", StripBound(node.Name), node.Name); + WriteLine($"public virtual BoundNode? Visit{StripBound(node.Name)}({node.Name} node) => this.DefaultVisit(node);"); } Unbrace(); break; @@ -1184,7 +1209,7 @@ private void WriteTreeDumperNodeProducer() { case TargetLanguage.CSharp: Blank(); - WriteLine("internal sealed class BoundTreeDumperNodeProducer : BoundTreeVisitor"); + WriteLine("internal sealed class BoundTreeDumperNodeProducer : BoundTreeVisitor"); Brace(); WriteLine("private BoundTreeDumperNodeProducer()"); Brace(); @@ -1192,7 +1217,7 @@ private void WriteTreeDumperNodeProducer() WriteLine("public static TreeDumperNode MakeTree(BoundNode node) => (new BoundTreeDumperNodeProducer()).Visit(node, null);"); foreach (var node in _tree.Types.OfType()) { - Write("public override TreeDumperNode Visit{0}({1} node, object arg) => new TreeDumperNode(\"{2}\", null, ", StripBound(node.Name), node.Name, ToCamelCase(StripBound(node.Name))); + Write("public override TreeDumperNode Visit{0}({1} node, object? arg) => new TreeDumperNode(\"{2}\", null, ", StripBound(node.Name), node.Name, ToCamelCase(StripBound(node.Name))); var allFields = AllFields(node).ToArray(); if (allFields.Length > 0) { @@ -1335,7 +1360,7 @@ private void WriteRewriter() if (hadField) { Write("return node.Update"); - ParenList(AllSpecifiableFields(node), field => IsDerivedOrListOfDerived("BoundNode", field.Type) || field.Type == "TypeSymbol" ? ToCamelCase(field.Name) : string.Format("node.{0}", field.Name)); + ParenList(AllSpecifiableFields(node), field => IsDerivedOrListOfDerived("BoundNode", field.Type) || TypeIsTypeSymbol(field) ? ToCamelCase(field.Name) : string.Format("node.{0}", field.Name)); WriteLine(";"); } else @@ -1601,18 +1626,12 @@ private bool IsAnyList(string typeName) return IsNodeList(typeName); } - private bool IsValueType(string typeName) - { - string genericType = GetGenericType(typeName); - - if (_valueTypes.TryGetValue(genericType, out bool isValueType)) - return isValueType; - else - return false; - } + private bool IsValueType(string typeName) => _valueTypes.Contains(GetGenericType(typeName)); private bool IsDerivedType(string typeName, string derivedTypeName) { + typeName = typeName.TrimEnd('?'); + derivedTypeName = derivedTypeName?.TrimEnd('?'); if (typeName == derivedTypeName) return true; if (derivedTypeName != null && _typeMap.TryGetValue(derivedTypeName, out var baseType)) @@ -1712,7 +1731,7 @@ private string GetVisitFunctionDeclaration(string nodeName, bool isOverride) switch (_targetLang) { case TargetLanguage.CSharp: - return $"public {(isOverride ? "override" : "virtual")} BoundNode Visit{StripBound(nodeName)}({nodeName} node)"; + return $"public {(isOverride ? "override" : "virtual")} BoundNode? Visit{StripBound(nodeName)}({nodeName} node)"; case TargetLanguage.VB: return $"Public {(isOverride ? "Overrides" : "Overridable")} Function Visit{StripBound(nodeName)}(node As {nodeName}) As BoundNode";