razor icon indicating copy to clipboard operation
razor copied to clipboard

Formatting does a 5k across the screen for some more complex fields

Open NTaylorMullen opened this issue 3 years ago • 2 comments

A user submitted another issue on GitHub and I found that after formatting their document that things got a bit wonky. C#:

namespace RazorClassLibrary2.Models
{
    public class Gopt<T>
    {
        public string Name { get; set; }
    }

    public static class GoptExtensions
    {
        public static Gopt<T> Editor<T>(this Gopt<T> gopt, Func<T, RenderFragment> renderFunc)
        {
            return gopt;
        }
    }
}

Razor:

@page "/"
@using RazorClassLibrary2.Models

@code{
    private DateTime? date1;

    Gopt<int> gopt = new Gopt<int>()
    {
        Name = "hi"
    }
    .Editor(m =>
    {
    return
    @<text>hi</text>
    ; }
    );    
}

Format the document: devenv_QylqT8Ja3h

NTaylorMullen avatar Mar 08 '22 18:03 NTaylorMullen

Confirmed its the render fragment being a problem here, doesn't repro with a "normal" object initializer. Probably lowers the priority a bit.

Those damned lambdas.

davidwengier avatar Mar 11 '22 04:03 davidwengier

Revisit once the tooling and compilers repos merge.

arunchndr avatar Sep 06 '22 23:09 arunchndr