From ca6a050a118a373cf8e29081265e391560e7680b Mon Sep 17 00:00:00 2001 From: ElektroKill Date: Sat, 17 Aug 2024 20:20:22 +0200 Subject: [PATCH] Update Rolsyn to 4.11 --- DnSpyCommon.props | 2 +- dnSpy/Roslyn/Roslyn.ExpressionCompiler | 2 +- .../SmartIndent/CSharpSmartTokenFormatter.cs | 7 ++++--- .../VBHackCompatAbstractFormattingRule.cs | 12 ++++++++++++ .../SmartIndent/SpecialFormattingOperation.vb | 13 +++++++------ 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 dnSpy/Roslyn/dnSpy.Roslyn.Internal/SmartIndent/VBHackCompatAbstractFormattingRule.cs diff --git a/DnSpyCommon.props b/DnSpyCommon.props index b6d6436f0c..c0dcfaadef 100644 --- a/DnSpyCommon.props +++ b/DnSpyCommon.props @@ -55,7 +55,7 @@ 15.5.27130 13.0.3 5.0.1 - 4.10.0 + 4.11.0 8.0.0 6.11.0 8.0.532401 diff --git a/dnSpy/Roslyn/Roslyn.ExpressionCompiler b/dnSpy/Roslyn/Roslyn.ExpressionCompiler index abc68a46d7..2855a033a7 160000 --- a/dnSpy/Roslyn/Roslyn.ExpressionCompiler +++ b/dnSpy/Roslyn/Roslyn.ExpressionCompiler @@ -1 +1 @@ -Subproject commit abc68a46d7addc4c4268e2991f26545670fcef45 +Subproject commit 2855a033a749c7a3eb25993b584352e4e9cf6b86 diff --git a/dnSpy/Roslyn/dnSpy.Roslyn.CSharp.Internal/SmartIndent/CSharpSmartTokenFormatter.cs b/dnSpy/Roslyn/dnSpy.Roslyn.CSharp.Internal/SmartIndent/CSharpSmartTokenFormatter.cs index d1ba214e32..48747e37ab 100644 --- a/dnSpy/Roslyn/dnSpy.Roslyn.CSharp.Internal/SmartIndent/CSharpSmartTokenFormatter.cs +++ b/dnSpy/Roslyn/dnSpy.Roslyn.CSharp.Internal/SmartIndent/CSharpSmartTokenFormatter.cs @@ -16,6 +16,7 @@ using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; @@ -90,7 +91,7 @@ public IList FormatToken(SyntaxToken token, CancellationToken cancel } } - var smartTokenformattingRules = new SmartTokenFormattingRule().Concat(_formattingRules); + ImmutableArray smartTokenFormattingRules = [new SmartTokenFormattingRule(), .. _formattingRules]; var adjustedStartPosition = previousToken.SpanStart; if (token.IsKind(SyntaxKind.OpenBraceToken) && _options.IndentStyle != FormattingOptions2.IndentStyle.Smart) { RoslynDebug.AssertNotNull(token.SyntaxTree); @@ -101,7 +102,7 @@ public IList FormatToken(SyntaxToken token, CancellationToken cancel var formatter = CSharpSyntaxFormatting.Instance; var result = formatter.GetFormattingResult( - _root, new[] { TextSpan.FromBounds(adjustedStartPosition, adjustedEndPosition) }, _options.FormattingOptions, smartTokenformattingRules, cancellationToken); + _root, [ TextSpan.FromBounds(adjustedStartPosition, adjustedEndPosition) ], _options.FormattingOptions, smartTokenFormattingRules, cancellationToken); return result.GetTextChanges(cancellationToken); } @@ -127,7 +128,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(in SyntaxToke } private class SmartTokenFormattingRule : NoLineChangeFormattingRule { - public override void AddSuppressOperations(List list, SyntaxNode node, + public override void AddSuppressOperations(ArrayBuilder list, SyntaxNode node, in NextSuppressOperationAction nextOperation) { // don't suppress anything } diff --git a/dnSpy/Roslyn/dnSpy.Roslyn.Internal/SmartIndent/VBHackCompatAbstractFormattingRule.cs b/dnSpy/Roslyn/dnSpy.Roslyn.Internal/SmartIndent/VBHackCompatAbstractFormattingRule.cs new file mode 100644 index 0000000000..50d0258e3d --- /dev/null +++ b/dnSpy/Roslyn/dnSpy.Roslyn.Internal/SmartIndent/VBHackCompatAbstractFormattingRule.cs @@ -0,0 +1,12 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.PooledObjects; +using Microsoft.CodeAnalysis.Formatting.Rules; + +namespace dnSpy.Roslyn.Internal.SmartIndent { + internal class VBHackCompatAbstractFormattingRule : CompatAbstractFormattingRule { + public override void AddSuppressOperationsSlow(ArrayBuilder list, SyntaxNode node, + ref NextSuppressOperationAction nextOperation) { + // don't suppress anything + } + } +} diff --git a/dnSpy/Roslyn/dnSpy.Roslyn.VisualBasic.Internal/SmartIndent/SpecialFormattingOperation.vb b/dnSpy/Roslyn/dnSpy.Roslyn.VisualBasic.Internal/SmartIndent/SpecialFormattingOperation.vb index 0acbc10583..857272fbbc 100644 --- a/dnSpy/Roslyn/dnSpy.Roslyn.VisualBasic.Internal/SmartIndent/SpecialFormattingOperation.vb +++ b/dnSpy/Roslyn/dnSpy.Roslyn.VisualBasic.Internal/SmartIndent/SpecialFormattingOperation.vb @@ -2,18 +2,18 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports dnSpy.Roslyn.Internal.SmartIndent Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules -Imports Microsoft.CodeAnalysis.Options +Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Imports Roslyn.Utilities Namespace Global.dnSpy.Roslyn.VisualBasic.Internal.SmartIndent Friend Class SpecialFormattingRule - Inherits CompatAbstractFormattingRule + Inherits VBHackCompatAbstractFormattingRule Private ReadOnly _indentStyle As FormattingOptions2.IndentStyle @@ -21,9 +21,10 @@ Namespace Global.dnSpy.Roslyn.VisualBasic.Internal.SmartIndent _indentStyle = indentStyle End Sub - Public Overrides Sub AddSuppressOperationsSlow(list As List(Of SuppressOperation), node As SyntaxNode, ByRef nextOperation As NextSuppressOperationAction) - ' don't suppress anything - End Sub + ' VBHackCompatAbstractFormattingRule implements this to avoid a ambiguity +' Public Overrides Sub AddSuppressOperationsSlow(list As ArrayBuilder(Of SuppressOperation), node As SyntaxNode, ByRef nextOperation As NextSuppressOperationAction) +' ' don't suppress anything +' End Sub Public Overrides Function GetAdjustNewLinesOperationSlow(ByRef previousToken As SyntaxToken, ByRef currentToken As SyntaxToken, ByRef nextOperation As NextGetAdjustNewLinesOperation) As AdjustNewLinesOperation