Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Snippets improvements

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Uniwares Posted - Aug 27 2020 : 04:26:15 AM
I am missing some macros in the snippets that allow me to manipulate the classname, or, support for Test frameworks (the later is probably the harder to implement).

I am doing lots of unit testing lately and have quite a few snippets prepared for that, but one thing I always miss is to insert into the test class, the name of the class I am testing. Like this:

Snippet:

	[TestMethod()]
	public void TestSingleton()
	{
		$ClassName$ sng = $ClassName$.Instance;
		Assert.IsNotNull(sng);
		Assert.AreEqual(sng, $ClassName$.Instance);
	}


Now point is that this snippet is inserted into classes that tests another class (with a patterned similar name), so $classname$ does not resolve to the correct one. So I need MySingletone as classname but I have MySingletonTest instead.

If I could do something like: $left($classname$, $len($classname$)-4) I am settled. Of course, something like $TestClassName$ would be more elegant :)

7   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Sep 02 2020 : 2:41:24 PM
I don't think we do have telemetry. Maybe worth thinking about, but I remember a lot of concern in some tech news reports when Windows 10 telemetry was first introduced.

As for examples, this is a good point. Do you do anything particularly clever or interesting with the current VA Snippets?
Uniwares Posted - Aug 28 2020 : 06:51:00 AM
I actually think that people dont use it because they dont know where and whats the benefit. Good examples can change that. Personally I use them a lot for repeating tasks that I can not solve through other means. Like Unit tests for example, its the same all over again and again, just with different classes. Perfect application for snippets, macros, whatever you call them. The "cookiecutter" (stupid name) is not much else, just downloads some more stuff and copies templates.
So may a brainstorming session on what can be done with snippets may be the way to go. I guess there is not too much feedback on snippets from users.
Do you do telemetry in VA? You should. Might give you some insights to the snippets too.
feline Posted - Aug 28 2020 : 06:37:36 AM
My personal reaction is "not another macro language to learn" when this idea comes up.

I understand why people didn't like that the old IDE macros used VBScript, but at least this was a known language you could get a book on, not a program specific macro language you have to learn just enough of to do something useful. It seems that most other programs that I use that support macros use their own languages, which is just another barrier to entry.

I find myself in two minds here. I made good use of IDE macros back in the day, but saw very little evidence that our users used them, or were interested in using them as solutions for problems. I just wonder if the investment would be worth the effort.
Uniwares Posted - Aug 27 2020 : 11:02:32 AM
I guess its a matter of use-case. Maybe more examples and more complex ones can improve acceptance?
feline Posted - Aug 27 2020 : 10:56:39 AM
I have added this example to the feature requests for programming inside snippets, but still not sure it's the "right" approach, simply given that IDE macros were so little used Microsoft removed them. Plus as a rule when I used to suggest solving problems with IDE macros it tended to get a less than eager reaction. Still:

case=68740
Uniwares Posted - Aug 27 2020 : 08:44:14 AM
This actually kinda works, not as smooth as string operations, but feasible. Even works when using $TargetClass$ in comments in the snippet. Thanks for the idea.
feline Posted - Aug 27 2020 : 07:55:08 AM
How about getting the Snippet to prompt you for the target class name, using the current, test class name, as the default value? Then you can just edit the test class name to become the class name that is going to be tested, and this edited value will be inserted everywhere you want inside the snippet?

This example snippet does this, via the key bit:

$TargetClass=$ClassName$$

and here is the full test snippet, just copy and paste the XML into your VA Snippet editor:

<VA_Snippet>
<Language>C#</Language>
<Title />
<Shortcut>single</Shortcut>
<Description />
<Code>[TestMethod()]
public void TestSingleton()
{
	$TargetClass=$ClassName$$ sng = $TargetClass$.Instance;
	Assert.IsNotNull(sng);
	Assert.AreEqual(sng, $TargetClass$.Instance);
}
</Code>
</VA_Snippet>

When using this snippet edit the test class name by pressing backspace 4 times to take off the "Test" at the end, then press Enter to accept this value, which will then be used for all instances of $TargetClass$ in the inserted snippet.

© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000