Giter VIP home page Giter VIP logo

t4editor's Introduction

t4editor's People

Contributors

themodestmouse avatar tim-maes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

t4editor's Issues

Very poor scrolling performance in VS2019 16.11.27

Since installing the extension I find that code-editor scrolling performance in VS2019 suffers badly when scrolling a T4 file with even a moderate amount of T4 code-blocks.

When dragging the scrollbar down it starts behaving erratically (e.g. the scrollbar thumb just jumps around, top to bottom) and the document view sometimes goes blank for a half-second.

I can make a screen recording and share the T4 files I'm working with if you like.

Nice to have: Support for custom tt file extensions

I received some anonymous feedback through my blog regarding custom file extensions. Some users like to suffix their .T4 template with an extra character to exclude them from being handled during build events etc.

It would be nice if the user could specify custom extensions (eg. .T4i, .T4x, .tt1) in some way.

Theme detection failing

Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview
Version 17.10.0 Preview 2.0

use light theme by default after extension install though clearly defaulting to dark theme:

image

I see I can manually adjust each color but no manual theme selection.

Nice to have: Defaults for light/dark VS theme's

Default colorization settings are based on a dark IDE theme. When a user installs the extension on a light IDE, the default text colors are too light/bright on a white background.

A nice to have would be default settings for both themes, some sort of detection on install or ask the user on first install what defaults are preferred.

Add command to format T4 template

Ideal: you can right click in the editor on a T4 file and there should be an option 'Format T4 template'.

This command should put control block and class feature block tags on new lines and indent the code with 1 tab in between tags.

Optional: attach the command to the format command in Visual Studio (eg; CTRL+K+D)

Performance issues with T4Classifier's regular expressions

(This doesn't seem to be the same issue as #16)

I had a T4 file open and just held-down the spacebar in the editor and experienced performance issues (high CPU, slow VS editor updates, etc) so I started a profiler session and I see that the regular-expressions in T4Classifier.GetClassificationSpans were being evaluated via the regex interpreter instead of being compiled in-memory.

image

image


I'm confident that converting the regexs in T4Classifier.cs to be precompiled should provide an immediate perf. boost here, though I'm not currently able to test this hypothesis.

To do this, hide the const String patterns as private (so other code can't accidentally call non-compiled versions) and use RegexOptions.Compiled (though there are some gotchas too: https://stackoverflow.com/questions/40953573/why-does-the-c-sharp-regexoptions-compiled-makes-the-match-slower )


Also, as the regex patterns are const String values, you can improve your dev UX by adding /* language=regex */ right before the literal. The literals look like they could be converted to verbatim literals which makes them more readable as it eliminates the escaped backslashes, like so:

internal const string ControlBlockRegex = /* language=regex */ @"(?<openingtag>(?<!\")<#((?!\"|=|@|\+)))(?<code>((?!(?!)<#(?!\+|=)|#>)[\s|\w|\d|\n|().,<>\-:;@#$%^&=*\[\]\"'+\/\®°⁰!?{}|`~\\u2000-\\u206F\\u2E00-\\u2E7F])*)(?<closingtag>(?=\s?|\w?|\n?)(?<!\")#>(?!\"))";

Implement custom token based parser instead of RegEx filtering

Currently T4Editor is leaning heavily on the use of RegEx patterns to filter out codeblocks from the textView and colorize them.

A better approach would be to create something that parses the textView on a token based implemenation. We only catch the T4 open/close tags and this leaves room to try and introduce C# language features inside these blocks.

Special unicode character breaks coloring

This piece of code was not processed properly:

<#+
static string CreateSummaryText(string s)
{
    return s.Length < 51 ? s : "…";
}
#>

The ellipsis is the culprit here.

The ¦ char in T4 output breaks code-coloring

I noticed when I type a ¦ character into the plaintext/output part of a T4 script (i.e. not in a <# block) it causes the extension to lose syntax coloring of that run of text. This also happens when reloading a T4 file with those chars in it.

In the screenshot below, observe that I have Output set to ForestGreen, which is used for most of the output text runs on the right-hand editor pane - but notice that whenever an output run has ¦ in it the editor will render the text as black-on-white and not ForestGreen-on-white.

(I use the ¦ char to denote an alignment point which is used by a tool I wrote).

image

Wrong standard control blocks (<# ... #>) detection if in touch with double-quote (") symbol

There is a problem when a standard control block open tag <# or close tag #> is in touch with the double-quote character " on any side of any of the tags. The result is the color is not set for this code block it is colored as the result (white by default on my dark theme).
The problem seems to affect only the standard control blocks <# ... #> or as you call it on the config window "Statements blocks".
I not tested on other themes than the dark.

To demonstrate the problem I attach a T4 Text Template and its output.
You need to open this file on the Visual Studio with the T4Editor extension installed.
You will see the color inconsistency related to the double-quote symbol.
If you don't want to open it in VS, I added the comments for each case. "WRONG" means it is colored as result (white by default on my dark theme) instead of as code.

I also included the execution result to demonstrate that the template will execute as expected and will not ignore the tags in touch with double-quote characters as the color information suggests.

TextTemplate.tt

//Tests with no quotes
//<# #>	<- Displays ok

//Tests with double quotes:
//"<# #>"	<- Displays WRONG!
//" <# #> "	<- Displays ok
//"<# #>	<- Displays WRONG!
//" <# #>	<- Displays ok
//<# #>"	<- Displays WRONG!
//<# #> "	<- Displays ok

//Tests with other quotes/tildes:
//'<# #>'	<- Displays ok
//´<# #>´	<- Displays ok
//`<# #>`	<- Displays ok
//¨<# #>¨	<- Displays ok

Result:

//Tests with no quotes
//	<- Displays ok

//Tests with double quotes:
//""	<- Displays WRONG!
//"  "	<- Displays ok
//"	<- Displays WRONG!
//" 	<- Displays ok
//"	<- Displays WRONG!
// "	<- Displays ok

//Tests with other quotes/tildes:
//''	<- Displays ok
//´´	<- Displays ok
//``	<- Displays ok
//¨¨	<- Displays ok

Screenshot on my VS with dark theme:
image

After Visual Studio version update colors reset to default values

After Visual Studio 2022 version update from 17.0.2 to 17.0.4 Colors reset to default values.
Reproduced with Visual Studio 2019 update 16.11.7->16.11.8
defaultColorScheme
Either one solution will be better than now: different default colors for light scheme, load/save colors to file, or just don't reset values after update.

Posibility to exclude code in RELEASE mode

When you write one code with debugging lines, you don't want to appear these lines in the final release.
It is not possible the use "#if DEBUG ... #endif" just the T4 is a compiler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.