Posted 3 years ago by Jamal Banna - MD, WebX Systems Ltd.
Version: 16.1.0330
Avatar

There doesn't seem to be an out of the box dynamic lexer for the C# Razor syntax. Are there any plans to add this?

If I have to create the dynamic lexer myself would I start with the HTML/CSS lexer and add Razor as a child language, or start with a Razor definition and add HTML/CSS as a child language?

Any other hints or tips you can provide to help me create the Razor lexer would be helpful.

Comments (4)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jamal,

No we don't have an out-of-the-box or sample implementation of that.  It can get fairly complex.  There's nothing on the near roadmap to implement a Razor language.  At one point Microsoft actually used SyntaxEditor in their Web Matrix tool, which was the first one that used Razor syntax.  Our suggestion would be to probably start with HTML as your root language and transition into Razor when appropriate.

I know we have another customer who has made a Razor language using SyntaxEditor too, but it might have been in the WPF version of SyntaxEditor.  I'll contact him to see if he has any tips.


Actipro Software Support

Posted 3 years ago by Nick
Avatar

We built one in the WPF version which supported C#/VB, so it can be done. It's a fairly complicated process but you can use the HTML sample to get started. You'll need to implement a parser for the Razor sections and build up a C#/VB class behind the scenes to represent the code sections. I'm not sure how compatible the WinForm and WPF versions are but it may be possible to share portions of what we've done.

Posted 3 years ago by Jamal Banna - MD, WebX Systems Ltd.
Avatar

Hi Nick.

Any code samples or hints and tips you could provide would be greatly appreciated.

Posted 3 years ago by Nick
Avatar

Hi Jamal - I think at this level hints aren't too useful. I know I started with the sample provided by Bill which is now part of the sample application. I use an existing razor parsing engine to build up a C# class which represents all of the non-markup and then point the C# language at that (well I think it's actually a new language which registers many of the same services as the C# language). You need to handle the transitions just like in the samples. It may be possible to proxy something though Bill but I think he's quite busy.

The latest build of this product (v2020.1 build 0400) was released 22 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.