runtime: Blazor - Ternary operator crashes
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The commented code below fails 100% of the time. It is replaced with the expanded if
statements in subsequent lines.
There is no error message. The debugger simply stops working. The method does not finish executing. IDK where it resumes since the debugger just stops.
public void DimensionsChanged(Tuple<List<Dimension<T>>, Dimension<T>, DropZone> args)
{
List<Dimension<T>> axisDimensions = null;
Dimension<T> dim = args.Item2;
DropZone dropZone = args.Item3;
List<Dimension<T>> enabledDimensions = Dimensions.Where(x => x.IsEnabled).ToList();
//if (dropZone == DropZone.Hidden)
// axisDimensions = dim.IsRow ? RowDimensions : ColumnDimensions;
//else
// axisDimensions = dropZone == DropZone.Rows ? RowDimensions : ColumnDimensions;
if (dropZone == DropZone.Hidden)
{
if (dim.IsRow)
axisDimensions = RowDimensions;
else
axisDimensions = ColumnDimensions;
}
else
{
axisDimensions = args.Item1;
}
if (dropZone != DropZone.Hidden)
{
bool isRows = dropZone == DropZone.Rows;
List<Dimension<T>> crossAxisDimensions = null;
//crossAxisDimensions = isRows ? ColumnDimensions : RowDimensions;
if (isRows)
crossAxisDimensions = ColumnDimensions;
else
crossAxisDimensions = RowDimensions;
Expected Behavior
Ternary operator should work like a simple if
statement.
Steps To Reproduce
Clone this repo and this one. In the demo project remove the reference to the nuget and and add a reference to the project in the second repo. Uncomment code as shown above in LeaderPivot.razor.cs
. Run the project and drag the blue buttons.
Exceptions (if any)
No response
.NET Version
7.0.203
Anything else?
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23 (12 by maintainers)
Yes
By worked well do you mean pausing on breakpoints on razor.cs files right?
@lambdageek The code you show should demo the problem. I may have changed it after commenting. Running without debugging will demo the problem also.