Skip to content

Commit

Permalink
Update Rolsyn to 4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Aug 17, 2024
1 parent f6b5a6f commit ca6a050
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DnSpyCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<MSVSTextVersion>15.5.27130</MSVSTextVersion>
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
<OokiiDialogsWpfVersion>5.0.1</OokiiDialogsWpfVersion>
<RoslynVersion>4.10.0</RoslynVersion>
<RoslynVersion>4.11.0</RoslynVersion>
<SCCompositionVersion>8.0.0</SCCompositionVersion>
<NuGetVersion>6.11.0</NuGetVersion>
<DbgShimVersion>8.0.532401</DbgShimVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -90,7 +91,7 @@ public IList<TextChange> FormatToken(SyntaxToken token, CancellationToken cancel
}
}

var smartTokenformattingRules = new SmartTokenFormattingRule().Concat(_formattingRules);
ImmutableArray<AbstractFormattingRule> smartTokenFormattingRules = [new SmartTokenFormattingRule(), .. _formattingRules];
var adjustedStartPosition = previousToken.SpanStart;
if (token.IsKind(SyntaxKind.OpenBraceToken) && _options.IndentStyle != FormattingOptions2.IndentStyle.Smart) {
RoslynDebug.AssertNotNull(token.SyntaxTree);
Expand All @@ -101,7 +102,7 @@ public IList<TextChange> 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);
}

Expand All @@ -127,7 +128,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(in SyntaxToke
}

private class SmartTokenFormattingRule : NoLineChangeFormattingRule {
public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node,
public override void AddSuppressOperations(ArrayBuilder<SuppressOperation> list, SyntaxNode node,
in NextSuppressOperationAction nextOperation) {
// don't suppress anything
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SuppressOperation> list, SyntaxNode node,
ref NextSuppressOperationAction nextOperation) {
// don't suppress anything
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
' 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

Public Sub New(indentStyle As FormattingOptions2.IndentStyle)
_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

Expand Down

0 comments on commit ca6a050

Please sign in to comment.