For all files: HTML, JS, CSS, LESS, CSHTML, ASCX, ASPX, CS (SVC) And config files XML, JSON
Write a webpack loader to load backend templates dependencies.
Entry points: ^[^_].*\.cshtml$
and .aspx$
should be an entries points
-
WebForm templates (ASPX use ASCX controls) files are HTML/XML with processing instruction nodes
-
MVC templates (Razor cshtml or vbhtml) are HTML file, where HTML tags can contains inscruction block start with
@
(contains special instruction C# or VB or an HTML tag or inscruction block but not all or<text></text>
) -
aspx to razor c# - Aspx to Razor syntax converter? - Stack Overflow
-
dotnet/csharplang: The official repo for the design of the C# programming language
-
<script runat="server"> <script language="C#" runat="server">
: code block Code Blocks in ASP.NET -
<xxx runat="server">
: parse as rendered control (where xxx could be "asp:Foo" or "form") -
<% %>
: code blocks -
<%= %>
: evaluate code expression -
<%: %>
: evaluate code expression without escape (ASP.NET 4) -
<%$ %>
: configuration file expression -
<%@ %>
: page directive -
<%# %>
: Data binding -
<%-- --%>
: server side comments -
Qu'est-ce que le scriptlet d'instructions <% instruction %> ? - FAQ ASP.NET/C#
-
Introduction to ASP.NET inline expressions in the .NET Framework nuggets
-
asp classic - Escape asp/vbscript script tags - Stack Overflow
-
The difference between <%= and <%# in ASP.NET – Dan Crevier's Blog
-
PositiveTechnologies/AspxParser: Aspx files (aspx, ascx, etc.) parser.
-
asp.net - Convert a single file aspx to code behind - Stack Overflow
-
happycollision/atom-language-asp-html: Atom language package for ASP HTML files (.ascx and .aspx) - Atom language package, replace jbalboni/atom-language-aspx that have issue with if condition
Generate .cs from .aspx/.ascx (Aka precompile, auto-generated class):
- https://github.com/microsoft/referencesource/blob/master/System.Web/UI/BaseTemplateParser.cs#L97
- https://github.com/microsoft/referencesource/blob/master/System.Web/Compilation/BuildManager.cs
Razor syntax:
@(...)
: Explicit Razor expressions@if(){...}
,@each(){...}
,@for(){...}
,@functions{...}
, etc.@*...*@
@{...}
@@
: escape@
@myVar
: implicit Razor expressions
Code block:
@
followed by identifiers, keywords, comments, "(" and "{"- code block body can contains:
- special tag
<text>...</text>
to output inside (remove enclosing tag) - tags
- explicit line transition:
@:...
- implicit Razor expressions
@myVar
: (le@
n'est pas précédé par un caractère alpha num: [a-z0-9])
- special tag
Tags:
- start with "<" + alphanum (else it's a text node)
- attributes open quotes must be closed (not required at root level)
- can be void/empty elements (without end tag:
<link>
or<link/>
or<link></link>
, seeTagStructure.WithoutEndTag
(= 2),<area>
,<base>
,<br>
,<col>
,<command>
,<embed>
,<hr>
,<img>
,<input>
,<keygen>
,<link>
,<meta>
,<param>
,<source>
,<track>
,<wbr>
) - can contains Razor expressions in in body, as attribute (but comments are rendered in attribute value:
<div class="one two @* foo *@ three"></div>
,<div test=@* foo *@></div>
, see https://github.com/aspnet/Razor/blob/master/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) - body can contains tags, code blocks or text node
Root level is similar to a tag body:
- body can contains tags (just the attributes value are parsed, EOF are ignored), code blocks or text node
See also:
- ScottGu's Blog - ASP.NET MVC 3: Layouts and Sections with Razor
- ScottGu's Blog - ASP.NET MVC 3: Razor’s @: and <text> syntax
- ScottGu's Blog - ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor
- AspNetCore.Docs/razor.md at master · aspnet/AspNetCore.Docs - Razor syntax reference for ASP.NET Core | Microsoft Docs
- aspnet/Razor: Parser and code generator for CSHTML files used in view pages for MVC web apps.
- Ten Tricks for Razor Views
- C# Razor Syntax Quick Reference | You’ve Been Haacked
Use Roslyn:
- Building a C# Interactive shell in a browser with Blazor (WebAssembly) and Roslyn | StrathWeb. A free flowing web tech monologue.
- svenheden/csharp-models-to-typescript: C# models to TypeScript
- Getting Started with Roslyn: Transforming C# Code - DZone Web Dev
- Roslyn Overview · dotnet/roslyn Wiki
- Getting Started C# Syntax Analysis · dotnet/roslyn Wiki
- roslyn/Lexer.cs at master · dotnet/roslyn and roslyn/LanguageParser.cs at master · dotnet/roslyn
- oleg-shilo/cs-script.npp: CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)
- Roslyn Syntax Visualizers | Visual Studio Blog
- Getting Started Writing a Custom Analyzer & Code Fix · dotnet/roslyn Wiki
- ashmind/SharpLab: SharpLab (previously known as TryRoslyn)
- Easy way to create a C# lambda expression from a string (with Roslyn) | StrathWeb. A free flowing web tech monologue.
- Implementing custom #load behavior in Roslyn scripting | StrathWeb. A free flowing web tech monologue.
- Building strongly typed application configuration utility with Roslyn | StrathWeb. A free flowing web tech monologue.
Generate CSharp from Razor with RazorTemplateEngine
then read the CodeCompileUnit to output AST or JS:
- RazorTemplates/TemplateCompiler.cs at 47c91d62820897d3a0794e4433e7f8427e80edd0 · volkovku/RazorTemplates
- toddams/RazorLight: Template engine based on Microsoft's Razor parsing engine for .NET Core
- Get started with syntax analysis (Roslyn APIs) | Microsoft Learn
- Microsoft.CodeAnalysis | .NET API browser | Microsoft Learn
- C# parsing and evaluating using Roslyn · hello world
- Learn Roslyn Now: Part 5 CSharpSyntaxRewriter – Shotgun Debugging
- c# - Getting a SemanticModel of a cshtml file? - Stack Overflow
Generate CSharp from Razor with RazorTemplateEngine
then tokenize with CSharpSyntaxTree.ParseText()
to output AST or JS:
- RoslynRazorViewEngine/RoslynRazorViewEngine.cs at master · davidebbo/RoslynRazorViewEngine - See c# - Getting a SemanticModel of a cshtml file? - Stack Overflow
- RazorClientTemplates/RazorClientTemplateEngine.cs at master · jchadwick/RazorClientTemplates
- c# - RazorTemplateEngine parser produces unusual syntax tree - Stack Overflow
- milkshakesoftware/razorjs at 9f93fc6d08963c3e08497ff2ad6bbf9025cd357d
Use RazorJS:
- andyedinborough/RazorJS: A simple JavaScript implementation of the Razor view engine for browsers and Node.
- A simple JavaScript implementation of the Razor view engine.
Generate .cs from .cshtml (Aka precompile, auto-generated class):
- https://stackoverflow.com/a/17139797/470117
- Pre-compiled Razor View in ASP.NET MVC - CodeProject
- Precompiling Your Website (C#) | Microsoft Docs
- Use razor to generate code? - Stack Overflow
- AspNetCore-Tooling/RazorProjectEngine.cs at 5f74fae0d26c72c45329b7c63661833645d2f7fc · aspnet/AspNetCore-Tooling
- AspNetCore-Tooling/RazorParser.cs at 5f74fae0d26c72c45329b7c63661833645d2f7fc · aspnet/AspNetCore-Tooling
- Razor/RazorParser.cs at master · aspnet/Razor
- Antaris/RazorEngine: Open source templating engine based on Microsoft's Razor parsing engine
- Parse cshtml to C# RazorGenerator/RazorGenerator: A Custom Tool for Visual Studio that allows processing Razor files at design time instead of runtime, allowing them to be built into an assembly for simpler reuse and distribution.
- System.Web.Razor.Tokenizer Namespace ()
- Microsoft.CodeAnalysis.Razor Namespace | Microsoft Docs
- Precompiling Your Website (C#) | Microsoft Docs
- Turn on Compile-time View Checking for ASP.NET MVC Projects in TFS Build 2010 – Jim Lamb
- ASP.NET Compilation Tool (Aspnet_compiler.exe) | Microsoft Docs
- How can I see the code generated for a Razor Page when using Asp.Net Core? - Stack Overflow
- volkovku/RazorTemplates: Open source templating engine based on Microsoft's Razor parsing engine. Thread safe. Allows run Razor templates outside ASP.Net MVC Projects. - use Microsoft.CSharp
WASM / Blazor:
#!/usr/bin/env node
// https://github.com/evanw/esbuild/blob/master/npm/esbuild-wasm/bin/esbuild
// Forward to the automatically-generated WebAssembly loader from the Go compiler
const wasm_exec = require.resolve('esbuild-wasm/wasm_exec.js');
const esbuild_wasm = require.resolve('esbuild-wasm/esbuild.wasm');
const code = require('fs').readFileSync(wasm_exec, 'utf8');
const wrapper = new Function('require', 'process', code);
const argv = ['node', wasm_exec, esbuild_wasm].concat(process.argv.slice(2));
wrapper(require, Object.assign(Object.create(process), { argv }));
- ncave/dna-redux: Running C#/F# code in Node.js or Browser with WebAssembly
- webassembly - Running C# dll in browser for calculations only - Stack Overflow
- corert/how-to-build-WebAssembly.md at master · dotnet/corert
- Introduction to ASP.NET Core Blazor | Microsoft Docs
- Compiling C# to WASM with Mono and Blazor then Debugging .NET Source with Remote Debugging in Chrome DevTools - Scott Hanselman - on Reddit, Hello, world!
- Building a C# Interactive shell in a browser with Blazor (WebAssembly) and Roslyn | StrathWeb. A free flowing web tech monologue.
- migueldeicaza/mono-wasm
- Running ASP.NET Core 2.0 Via Mono
- Learn how to build your first Blazor WebAssembly app in .Net Core 3.0 - https://github.com/softchris/softchris.github.io/tree/master/pages
- compile
*.razor
to C#ComponentBase
class withprotected override void BuildRenderTree(RenderTreeBuilder builder)
... or to Tag Helper:- code behind (.cshtml + .cshtml.cs, .razor + .razor.cs)
- Building Components Manually via RenderTreeBuilder
- c# - Creating a component by overriding BlazorComponent.BuildRenderTree(RenderTreeBuilder builder) - Stack Overflow
- Introduction to ASP.NET Core Blazor | Microsoft Docs
- C# to TypeScript - Visual Studio Marketplace
Compile C# to JS:
- JSIL - .NET to JavaScript compiler
- List of languages that compile to JS · jashkenas/coffeescript Wiki
- Javascript and C# Cross Compiling and Conversion - Stack Overflow
- praeclarum/Netjs: Compile .NET assemblies to TypeScript and JavaScript
- CodeTranslator: Code Translation From VB.NET <-> C# <-> TypeScript <-> Java
Other:
- Evil Eval() Vol. 2 @ PeachPie | PHP compiler to .NET
- dotnet/csharp-tmLanguage: Syntax grammar used for C# colorization
- joseph-turner/Razor: Syntax Definition for Razor (cshtml) in SublimeText
- vscode/extensions at master · Microsoft/vscode - TextMate Bundles for Razor and C# used by Visual Studio Code based on demyte/language-cshtml and dotnet/csharp-tmLanguage
- birkenfeld / pygments-main / issues / #865 - new lexer request: cshtml (Razor) — Bitbucket
- Request Language Support: grammar "ASP.NET Razor" and extension "cshtml" · Issue #612 · Glavin001/atom-beautify
- https://github.com/tree-sitter/tree-sitter-razor
- https://docs.microsoft.com/fr-fr/aspnet/core/mvc/views/razor
- https://github.com/jordansjones/Mvc4j/blob/master/Razor/src/main/java/nextmethod/web/razor/parser/ParserHelpers.java
- https://github.com/CityRay/gulp-cshtml-minifier/blob/master/index.js
- https://github.com/MattsGitCode/razorscript
- http://www.cs.vu.nl/grammarware/browsable/CSharp/grammar.html
- kirbysayshi/vash: Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
- Grammar Definitions for C#, F#, VB - .NET Foundation Forums
- atom/language-csharp: C# language support for Atom
- Bridge.NET - Open Source C# to JavaScript Compiler
- https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/antlr4/com/github/jknack/handlebars/internal/HbsLexer.g4
- https://github.com/mariusae/mustache.scala/blob/master/src/main/antlr/Mustache.g
- https://github.com/zalando/beard/tree/master/src/main/antlr4/de/zalando/beard
- https://github.com/mustache/spec/tree/master/specs
- dmarcotte/idea-handlebars: Handlebars and Mustache template support for Intellij IDEA platform IDEs
Aka LSP (Language Server Protocol)
Note: LSP doesn't expose AST
- Langserver.org
- Add preview Razor support by SteveSandersonMS · Pull Request #2554 · OmniSharp/omnisharp-vscode
- OmniSharp/omnisharp-roslyn: OmniSharp based on roslyn workspaces
- Specification
- microsoft/vscode-languageserver-node-example: Sample language server implemented in Node
- aspnet/Razor.VSCode: Razor tooling for Visual Studio Code
- Language Server Extension Guide | Visual Studio Code Extension API
- Extending a client with the language server protocol - LogRocket Blog
Stdio (RPC/IPC):
- sbt-server-stdio.js
- go - server client connection through stdio - Stack Overflow
- teambition/jsonrpc-lite: Parse and Serialize JSON-RPC2 messages in node.js, or browser.
Parsers produce syntax trees, Lexers produce tokens.
| (E)BNF | ANTLR
-----------------+--------+------
'a' zero or once | [a] | a?
'a' zero or more | {a} | a*
'a' once or more | a {a} | a+
Need context-free grammars, not just an highlighter
- webpack/fastparse: A very simple and stupid parser, based on a statemachine and regular expressions.
- tree-sitter/tree-sitter: An incremental parsing system for programmings tools
- appden/less.tmbundle: LESS TextMate Bundle
- sublime-packages/HTML-ASP.tmLanguage at master · bradrobertson/sublime-packages and sublime/ASP.tmLanguage at master · cj/sublime
- TextMate Manual » Language Grammars
- parsing - Where can I find a library that parses source code and is able to extract the scope of where your cursor is currently in the code? - Stack Overflow
- limetext/lime: Open source API-compatible alternative to the text editor Sublime Text - Parse
tmLanguage
, https://github.com/limetext/backend/blob/master/parser/parser.go - Parsing absolutely anything in JavaScript using Earley algorithm
- Available lexers — Pygments
- ShowUsYour<Blog> - Using BNF to create regex's
- BNF Grammar - Rosetta Code
- Web Assembly in ASP.NET Core - Samuele Resca Web Assembly in ASP.NET Core aspnet/Blazor: An experimental web UI framework using C#/Razor and HTML, running in the browser via WebAssembly
- The BNF Converter
- c# 4.0 - C# grammar in BNF or EBNF Parser generator for F# - Stack Overflow
- Razor syntax reference for ASP.NET Core | Microsoft Docs - Razor Syntax
- New language - CSHTML Razor by romanresh · Pull Request #1631 · isagalaev/highlight.js
- .net - Dependency graph of Visual Studio projects - Stack Overflow
- How to Write Custom Language Support Plugins | IntelliJ IDEA Blog, ReSharper: Visual Studio Extension for .NET Developers by JetBrains and Rider: Cross-platform .NET IDE by JetBrains
- code-prettify/src at master · google/code-prettify
- acornjs/acorn: A small, fast, JavaScript-based JavaScript parser eslint/espree: An Esprima-compatible JavaScript parser estree/estree: The ESTree Spec
- cherow/cherow: Very fast and lightweight, standards-compliant, self-hosted javascript parser with high focu on both performance and stability Cherow - A fast, Typescript-based Javascript parser
- inikulin/parse5: HTML parsing/serialization toolset for Node.js. WHATWG HTML Living Standard (aka HTML5)-compliant. https://github.com/inikulin/parse5/blob/master/lib/extensions/location_info/parser_mixin.js
- Web Dev Report - Integrate HTML5 into Existing ASP.NET Web Forms and ASP.NET MVC Applications
- amphtml/validator/engine at master · ampproject/amphtml
- AST explorer
- Web Dev Report - Integrate HTML5 into Existing ASP.NET Web Form and ASP.NET MVC Applications
- https://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2
- prettier/prettier: Prettier i an opinionated code formatter.
- https://github.com/nikic/PHP-Parser https://github.com/z7zmey/php-parser/blob/master/README.md
- https://www.jetbrains.com/help/devguide/PSI/SyntaxTrees.html
- https://www.npmjs.com/package/php-parser
- https://www.npmjs.com/package/node-c-parser
- http://www.parse2.com
- https://github.com/cederberg/grammatica https://grammatica.percederberg.net
- https://stackoverflow.com/questions/23456868/c-sharp-5-0-ebnf-grammar
- https://forums.dotnetfoundation.org/t/grammar-definitions-for-c-f-vb/2632/2
- https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y
- https://github.com/luscoma/pyRazor/blob/master/README.md
- csstree/csstree: A tool set to work with CSS, including fast detailed parser, walker, generator and lexer based on knowledge of spec and browser implementations
- ianh/owl: A parser generator for visibly pushdown languages.
- Microsoft/monaco-languages: Basic colorization support for many Monaco Editor languages.
- warrenseine/prettier-plugin-csharp: Prettier C# Plugin - use unofficial C# 6 grammar from ANTLR
Parse using native libs:
- Run LLVM Assembly In Your Browser
- Integrating Node.js with a C# dll | juri.strumpflohner
- Edge.js
- call dotnet from node - Google Search
- Child Process | Node.js v12.2.0 Documentation
Stuff related to webpack:
- Show your modules tree · Issue #690 · webpack/webpack
- Webpack analyzer
- How to easily visualize a project's dependency graph with dependency-cruiser | Netlify
- Module Dependency Diagrams - Help | WebStorm
- NPMGraph - Visualize NPM Module Dependencies
- auchenberg/dependo: Visualize your CommonJS or AMD module dependencies in a force directed graph report.
- auchenberg/dependo: Visualize your CommonJS or AMD module dependencies in a force directed graph report.
- Any library for visualizing module dependencies in Node.js? - Stack Overflow
- pahen/madge: Create graphs from your CommonJS, AMD or ES6 module dependencies
- Analyzing ES6 Circular Dependencies | Blog by Railsware
- circular-dependency-plugin - npm
- analyze-es6-modules - npm
Antlr:
- An introduction to language lexing and parsing with ANTLR
- antlr4/runtime/JavaScript at master · antlr/antlr4
- grammars-v4/csharp at master · antlr/grammars-v4
- https://www.npmjs.com/package/antlr4-c3
- http://www.antlr3.org/grammar/list.html
- Generate EBNF from ANTLR - Stack Overflow
- antlr/grammars-v4: Grammars written for ANTLR v4; expectation that the grammars are free of actions.
- antlr/grammars-v4: Grammars written for ANTLR v4; expectation that the grammars are free of actions.
- Lexical to an AST with C# - Matthew Campbell - Medium
- Peter van der Zee on Twitter: "Just published the first version of Tenko, my spec compliant JS parser written in JS. Used to be ZeParser, you may have heard of it :) https://t.co/bLbB7t9Veg https://t.co/eRMprSXpce" / Twitter
- syntax-tree/unist: Universal Syntax Tree used by @unifiedjs
- see also Universal Syntax Tree derivated formats (HAST)
- babylon/spec.md at master · babel/babylon
- UAST Querying · Babelfish (aka. bblfsh)
- PT.Doc/English.md at master · PositiveTechnologies/PT.Doc · GitHub
- PT.Doc/English.md at master · PositiveTechnologies/PT.Doc
- PT.Doc/English.md at master · PositiveTechnologies/PT.Doc
- PT.Doc/The proper way to develop grammars of any kind using ANTLR.tex at master · PositiveTechnologies/PT.Doc
- tree-sitter/tree-sitter: An incremental parsing system for programmings tools tree-sitter/node-tree-sitter: Node.js bindings for tree-sitter
- antlr/antlr4: ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
- Boost.Spirit Spirit 2.5.4 - 1.66.0 - LL parser framework represents parsers directly as EBNF grammars in inlined C++.
- srcML
- Mapper of XPath expressions onto AST nodes · Issue #4369 · checkstyle/checkstyle · GitHub
- XPath - Wikipedia
- ThierryGoubier/SmaCC: Smalltalk Compiler Compiler : a parser generator
- Add simple comparison table for alternatives · Issue #35 · bblfsh/documentation · GitHub
- dchester/jsonpath: Query and manipulate JavaScript objects with JSONPath expressions. Robust JSONPath engine for Node.js. JSONPath - XPath for JSON
- Mapper of XPath expressions onto AST nodes · Issue #4369 · checkstyle/checkstyle · GitHub
- dfilatov/jspath: DSL that enables you to navigate and find data within your JSON documents
- JSONiq - The JSON Query Language
digraph G {
size="100,50"
center=""
ratio=All
node[width=.25,hight=.375,fontsize=12,color=lightblue2,style=filled]
1 -> 3;
1 -> 17;
3 -> 15;
1 [label="Drew.DependencyAnalyser.Tests"];
3 [label="Drew.DependencyAnalyser"];
15 [label="Interop.WINGRAPHVIZLib"];
17 [label="nunit.framework"];
}
digraph "graph" {
"test1" -> "test2";
"test1" -> "test3";
"test2" -> "test4";
"test3" -> "test4";
}
Use Hierarchical Edge Bundling or Collapsible Force Layout or Drag and Drop Collapsible Tree Layout
- Graphviz - Graph Visualization Software - Online: Webgraphviz or Viz.js
- Google Code Archive - Long-term storage for Google Code Project Hosting.
- pahen/madge: Create graphs from your CommonJS, AMD or ES6 module dependencies
- npm2dot
- twopi(1): filter for drawing directed graphs - Linux man page
- DOT (graph description language) - Wikipedia
- itchyny/rexdep: Roughly extract dependency relation from source code
- https://github.com/d3/d3/wiki/Gallery
- https://github.com/d3/d3-hierarchy/blob/master/README.md#treemap
- CodeFlower Source code visualization
- grgrdvrt/dot: interface to build dot document for graphviz
- Yoichi Kobayashi sur Twitter : "My recent project wa released. I wa in charge of building a WebGL content "Request Viewer"… https://t.co/Hc7yfz3L8n"
- sᴄᴏᴛᴛ ᴅᴀʀʙʏ on Twitter: "Check out the repo for webgl gource here: https://t.co/yySWpOa3Tl It's essentially a GPGPU force directed graph simulation using data pulled from the Github API: #threejs #javascript #creativecoding #iohk #glsl"
WebStorm: Code > Find duplicates...
Aka Similar Data Detection (SDD)
Compare tokens:
- ignore spaces
- ignore braces:
if (foo) {x++}
is same asif(foo)x++;
- ignore function/variable names
Find files with similarities (ex: same parts without whitespaces), find peak (number) or tokens occurence (text: words)
- Audio Fingerprinting with Python and Numpy worldveil/dejavu: Audio fingerprinting and recognition in Python
- PMD – Finding duplicated code and PMD – Howto add a new language to PMD
- Duplicate code - Wikipedia
- java - Parsing Razor-style Templates - Software Engineering Stack Exchange
- danielstjules/jsinspect: Detect copy-pasted and structurally similar code
- SDD: High performance code clone detect download | SourceForge.net
- Continuous Code Quality | SonarQube SonarSource/sonarqube: Continuous Code Quality
- Microsoft Word - pp44-lee.doc - sdd_slee_2005.pdf
- aspnet/Razor: Parser and code generator for CSHTML files used in view pages for MVC web apps.
- Anti-Twin - find similar files and images
- Simian: Get It Now!