ashmind / SharpLab

.NET language playground
https://sharplab.io
BSD 2-Clause "Simplified" License
2.74k stars 202 forks source link

"Exceeded limit on consecutive []" with five attribute lists #1340

Open colejohnson66 opened 3 months ago

colejohnson66 commented 3 months ago

Using five or more attribute lists causes RoslynSourceTextGuardException:

MirrorSharp.Advanced.EarlyAccess.RoslynSourceTextGuardException: Exceeded limit on consecutive [].
   at SharpLab.Server.MirrorSharp.Guards.RoslynSourceTextGuard.ValidatingSourceTextWriter.ValidateBrackets(Char char, Char openBracket, Char closeBracket, Int32& nestingLevel, Int32[] adjacentPairCounts, Boolean allowTopLevelAdjacentPairs) in D:\a\SharpLab\SharpLab\source\Server\MirrorSharp\Guards\RoslynSourceTextGuard.cs:line 67
   at Microsoft.CodeAnalysis.Text.SourceText.Write(TextWriter writer, TextSpan span, CancellationToken cancellationToken)
   at SharpLab.Server.MirrorSharp.Guards.RoslynSourceTextGuard.ValidateSourceText(SourceText sourceText) in D:\a\SharpLab\SharpLab\source\Server\MirrorSharp\Guards\RoslynSourceTextGuard.cs:line 18
   at MirrorSharp.Internal.Handlers.RequestInfoTipHandler.ExecuteForRoslynAsync(Int32 cursorPosition, WorkSession session, ICommandResultSender sender, CancellationToken cancellationToken)
   at MirrorSharp.Internal.Connection.ReceiveAndProcessInternalAsync(CancellationToken cancellationToken) in D:\a\SharpLab\SharpLab\source\#external\mirrorsharp-codemirror-6-preview\Common\Internal\Connection.cs:line 96
   at MirrorSharp.Internal.Connection.ReceiveAndProcessAsync(CancellationToken cancellationToken) in D:\a\SharpLab\SharpLab\source\#external\mirrorsharp-codemirror-6-preview\Common\Internal\Connection.cs:line 54

This appears to be the same as #1222.

Reproduction Code

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACAZQAtsoAHAGW2ADoASgFcAdhgCW+GAG4aNYgGYGZBgGEANnlw0A3jQYGGAbQBS4jAHEYImFHFgAFBgCeHGBABmDgBLZ1HgEoAgF19Q1NzKxs7Rxc3TwcPdQhsDCDQ6kNjM0trW3snV3cvABMIIWB1GHSwgwjc6IK44ocSmDBJPxrM8Jyo/NiihPExbqzFZRQGAFkYDBYIEoAeABUAPgcA2oY9HoMAXxp9oA==

using System;
using SharpLab.Runtime;

public class Class
{
    [JitGeneric(typeof(Half))]
    [JitGeneric(typeof(float))]
    [JitGeneric(typeof(double))]
    [JitGeneric(typeof(decimal))]
    [JitGeneric(typeof(int))]
    public void Method<T>()
    {
    }
}
OwnageIsMagic commented 3 months ago

use

[JitGeneric(typeof(Half)), JitGeneric(typeof(float)), JitGeneric(typeof(double))]
colejohnson66 commented 3 months ago

That is what I ended up doing when I found #1222. I’m not necessarily saying the limit should be increased, but the error message is extremely cryptic, and could be improved.