-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
I just ran into a razor error when doing ctrl-k-ctrl-d in VS 18.3.0
StreamJsonRpc.RemoteInvocationException: Unexpected false - file IndentBlockOperation.cs line 38
at StreamJsonRpc.JsonRpc.d__1711.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection1.d__181.MoveNext() RPC server exception: System.InvalidOperationException: Unexpected false - file IndentBlockOperation.cs line 38 at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath) at Microsoft.CodeAnalysis.Formatting.Rules.IndentBlockOperation..ctor(SyntaxToken baseToken, SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, Int32 indentationDelta, IndentBlockOption option) at Microsoft.CodeAnalysis.CSharp.Formatting.IndentBlockFormattingRule.AddBracketIndentationOperation(List1 list, SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.Formatting.IndentBlockFormattingRule.AddIndentBlockOperations(List1 list, SyntaxNode node, NextIndentBlockOperationAction& nextOperation) at Microsoft.CodeAnalysis.Formatting.Rules.NextIndentBlockOperationAction.Invoke() at Microsoft.CodeAnalysis.CSharp.Formatting.IndentUserSettingsFormattingRule.AddIndentBlockOperations(List1 list, SyntaxNode node, NextIndentBlockOperationAction& nextOperation)
at Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules.AddIndentBlockOperations(List1 list, SyntaxNode currentNode) at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.AddOperations[T](SegmentedList1 operations, List1 scratch, SyntaxNode node, Action2 addOperations)
at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.CreateNodeOperations(CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.Format(CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormatting.GetFormattingResult(SyntaxNode node, IEnumerable1 spans, SyntaxFormattingOptions options, ImmutableArray1 rules, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(SyntaxNode node, IEnumerable1 spans, SolutionServices services, SyntaxFormattingOptions options, ImmutableArray1 rules, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(SyntaxNode node, TextSpan span, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Razor.Formatting.CSharpFormattingPass.FormatCSharpAsync(SourceText generatedCSharpText, RazorFormattingOptions options, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Razor.Formatting.CSharpFormattingPass.ExecuteAsync(FormattingContext context, ImmutableArray1 changes, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Razor.Formatting.RazorFormattingService.GetDocumentFormattingChangesAsync(DocumentContext documentContext, ImmutableArray1 htmlChanges, Nullable1 range, RazorFormattingOptions options, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_01.<g__ProcessSolutionAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func2 implementation, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func2 implementation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.RemoteWorkspaceManager.RunServiceAsync[T](ServiceBrokerClient client, Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
on this file:
@using ThisType = Styling
@using CODie.Blazor.Common;
@if (OnClick.HasDelegate)
{
<div class=@ClassStr style=@StyleStr data-name=@Name @onclick=OnClick>
@ChildContent
</div>
}
else
{
<div class=@ClassStr style=@StyleStr data-name=@Name>
@ChildContent
</div>
}
@code
{
// additional properties need to be registered in DivStylingInheritance.css
[Parameter, EditorRequired] public required RenderFragment? ChildContent { get; set; }
private string ClassStr => $"styling {(DontInherit ? "" : "IsInherited")}{(CssClass is null ? null : $" {CssClass}")}";
private string StyleStr => $"display:contents; {HeightStr} {WidthStr} {ColorStr} {BackgroundColorStr} {CursorStr} {Style} {ZoomStr} {PaddingStr} {BorderStr}";
[Parameter] public string? CssClass { get; set; }
[Parameter] public string? Style { get; set; }
[Parameter] public string? Cursor { get; set; }
private string CursorStr => Cursor.GetCssStr();
[Parameter] public int? Height { get; set; }
[Parameter] public int? HeightPercent { get; set; }
private string HeightStr => Height.GetCssStr() ?? HeightPercent.GetCssStrPercent();
[Parameter] public Colors? Color { get; set; }
private string ColorStr => Color.GetCssStr(ColorSystem.ColorString);
[Parameter] public Colors? BackgroundColor { get; set; }
private string BackgroundColorStr => BackgroundColor.GetCssStr(ColorSystem.ColorString, "background");
[Parameter] public int? Width { get; set; }
private string WidthStr => Width.GetCssStr();
[Parameter] public bool DontInherit { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
[Parameter] public string? Name { get; set; }
[Parameter] public int? Zoom { get; set; }
private string ZoomStr => Zoom.GetCssStr();
[Parameter] public Choice<(int Top, int Right, int Bottom, int Left), (int, int), int>? Padding { get; set; }
private string PaddingStr => Padding.Do(
pd => $"padding:{pd.Top}px {pd.Right}px {pd.Bottom}px {pd.Left}px;",
pd => $"padding:{pd.Top}px {pd.Right}px {pd.Bottom}px {pd.Left}px;",
pd => $"padding:{pd.Top}px {pd.Right}px {pd.Bottom}px {pd.Left}px;"
:
[Parameter] public bool BorderBottom { get; set; }
[Parameter] public bool BorderRight { get; set; }
[Parameter] public bool BorderLeft { get; set; }
[Parameter] public bool BorderTop { get; set; }
[Parameter] public bool Border { get; set; }
private string BorderStr => Border
? BorderStringCss()
: $"{(BorderTop ? BorderStringCss(BorderDirections.Top) : "")}{(BorderBottom ? BorderStringCss(BorderDirections.Bottom) : "")}{(BorderLeft ? BorderStringCss(BorderDirections.Left) : "")}{(BorderRight ? BorderStringCss(BorderDirections.Right) : "")}";
private string BorderStringCss(BorderDirections dir, BorderStyles style = BorderStyles.Solid, int width = 1, Colors color = Colors.BorderPrimaryGrey)
=> $"border-{dir.GetCssValueStr()}:{width}px {style.GetCssValueStr()} {color.GetCssValueStr(ColorSystem.ColorString)};";
private string BorderStringCss(BorderStyles style = BorderStyles.Solid, int width = 1, Colors color = Colors.BorderPrimaryGrey)
=> $"border:{width}px {style.GetCssValueStr()} {color.GetCssValueStr(ColorSystem.ColorString)};";
}in line 60 (the selected line in the screenshot
this is syntactically wrong, i know.
removing the colon and doing ctrl-k-c then at least doesn't produce the error bar.