KirillOsenkov / RoslynQuoter

Roslyn tool that for a given C# program shows syntax tree API calls to construct its syntax tree
http://roslynquoter.azurewebsites.net
Apache License 2.0
918 stars 118 forks source link

Any reason for the 2000 character limit? #81

Open MichaelHochriegl opened 1 year ago

MichaelHochriegl commented 1 year ago

I really love that you published RoslynQuoter on the web for easy access. What I often stumble over is the fact that "only" 2000 chars are supported.

Is there a reason to not allow larger texts?

KirillOsenkov commented 1 year ago

it’s more or less arbitrary, the limit is needed because the resulting program becomes too large and generating and validating it takes too long

KirillOsenkov commented 1 year ago

You could also build locally and use as a console app without the limit.

Normally I thought quoter is most useful to show small samples of how to deal with a particular language construct.

If you have a larger program, perhaps think of another way to simplify it or generalize somehow?

MichaelHochriegl commented 1 year ago

Thanks for the quick reply. I mostly run into the limit when I want to get the roslyn code for my source gens and I have comments in my sample class.

To work around the limit I currently pulled the repo and upped the limit in the QuoterController to 5k. Seems to work fine for now.

dodexahedron commented 8 months ago

Normally I thought quoter is most useful to show small samples of how to deal with a particular language construct.

This, for sure. Once that seemingly obvious point hit me, I face-palmed and then started using it exactly like that, because it usually is just one little snippet I need to figure out (since intellisense is essentially useless for those libraries - WTF is Green?).

KirillOsenkov commented 8 months ago

You can read about red and green trees here: https://ericlippert.com/2012/06/08/red-green-trees/

and here for deeper technical info: https://github.com/KirillOsenkov/Bliki/wiki/Roslyn-Immutable-Trees

dodexahedron commented 8 months ago

Thanks for that!

I hadn't bothered to dive into that, yet, once I realized "the way" it's done, using all the SyntaxFactory and all the appropriate WithX methods and whatnot, but still had that idle curiosity in the back of my mind. I'll have to check those out some time. Anything from Eric is usually a good read.

I just wish that things in that API were mutable, because I tend to end up writing my own extension methods to allow a more fluent and much more concise use of it for the most common cases.