I am attempting to create a new NewGist using Octokit.net however I can't seem to find a way to specify a language (Text, C#, C++, Java, etc) so whenever it is created it simply creates it as Text.
Am I missing something or is there no functionality with this API to specify it? Thanks!
Based on a test that I just carried out, it looks as though the language for a file contained with a gist is being inferred from the extension of the filename.
For example, I just created a gist using octokit which contained a filename of install.ps1. On checking the created gist, the language dropdown was already pre-selected with PowerShell.
Related
In VS2017 I've made a C# Project Template project, that uses forms and the IWizard interface to pop up a dialog as soon as the user types a project name and hits OK. The form gathers info from the user and then sets up the new project accordingly.
I haven't really detoured from the guide mentioned in the next line, except it doesn't cover what I'd like to do.
Note to future readers: This How To Use Wizards With Project Templates guide is the only version of the page I have found that points out the need for the System and System.Drawing references. And even then it says "assemblies" when it means "references". Other duplicates of the same page have a strangely blank space at the crucial moment.
So inside IWizard's RunStarted() function, I create custom template parameters that look $like$ $this$, add them to the replacementsDictionary, and assign values to them that I retrieved from my whiz-bang pop up dialog. The wizard will then substitute appearances of those custom parameters that it finds in files of the new project (I wrote those appearances earlier), with the values I assigned to them. There are also built-in template parameters that I can use in the same way.
What I can do (source files == .cpp, project file == .vcxproj):
Use built-in template parameters to substitute values into my template's source files and project file.
Define custom template parameters inside the .vstemplate file that substitute values into my template's source files and project files.
Define custom template parameters inside IWizard's RunStarted() function that substitute values only into my template's source files.
What I can't do:
Define custom template parameters within IWizard's RunStarted() function that substitute values into my template's project file.
From what I understand, the first moment I can turn user-defined values into custom parameter values is via the RunStarted() function. This is the crux of the problem, as this is apparently too late to sub anything new into the project file. In the end product project file, all built-in template parameters get substituted as expected. All my custom template parameters that I defined in advance in the .vstemplate file are also subbed as expected. But the custom template parameters that I need to set up in RunStarted()... they still all look $like$ $this$.
In other words, if I write this inside RunStarted():
replacementsDictionary.Add("$custommessage$", "Custard");
then my source files will now have occurrences of Custard, but the project file will still only have $custommessage$.
This is forcing an XML-writing work around that is bringing its own problems, so I have come back to this. How can I get user-defined custom template parameter values into the project file?
It's the question that is broken. Template parameters do work in the project file straight off the bat. If they aren't working, it means something is wrong somewhere else. Ie., double check all your template parameters are working, are getting values, etc. It's typically one of them going wrong that causes the grief that inspired this question.
How to get list of macros names that's displayed in tab "Developer" by button "macros"? I found some solution (https://social.msdn.microsoft.com/Forums/vstudio/en-US/ef1de29a-81c7-424a-b7ab-f85286a1d8de/how-to-retrieve-a-list-of-macros-in-an-excel-workbook?forum=vsto), but it's work with button "Visual basic" in same tab. Maybe we can extract macros names from there?
"Maybe we can extract macros names from there?"
Obviously no, you can't.
And the answer in your link already said this "As far as I know, there is no a property which can be used to get the names of macros.".
So there is no built-in way to extract them.
The only way I can imagine is parsing all the code and looking for Function and Sub to collect their names. But this can be cumbersome.
Maybe studying the source code of the Rubberduck AddIn at GitHub can help. I know that such a parsing is implemented there (in C# aswell) as they need it to generate a list of functions/procedures too, so maybe this can help you getting an idea how to implement this.
Working on an extension that deals with text editor colors. I found the VsFontAndColorStorage interface, but don't fully understand how to use it.
Is there an example somewhere, or some example program that I can look at to understand how to store and retrieve colors?
Have a look at this there it shows to write your new fonts to the registry and read it using the
IVsFontAndColorStorage interface
I'm looking for a way to dynamically generate javascript. I didn't find any information on this by browsing through Script#'s documentation, so here are my questions:
1) Is it possible to generate javascript code during runtime?
2) Is it possible to dynamically set a file name to which generated code would be saved to? Or can I get the generated code as a string?
A scenario would be: A user goes to a web site, enters a name in a text box, hits a button and a javascript is generated that would say alert("Hello name"). (which can be offered as a download)
I'm using the version I got through NuGet (0.7.5).
If it is possible, I would appreciate any hints or examples.
Thank you!
1) Yes, its possible. The script# compiler is packaged in ScriptSharp.dll and you can use the API it exposes. For an example of doing so, check out the sources of the script# msbuild tasks in the script# repository.
2) When you use the API, you effectively pass in a Stream - so you get the generated content, which you can use as you wish.
I'll recommend cloning the repository and using the "cc" branch to pick up the latest changes. The wiki on github has steps to build. 0.7.5 is a bit old now.
Hope that helps.
I have built a small HTTP server based on the HTTPListener class.
What I would like to know is, is there any scripting language I can put in my HTML files that can be natively executed in C#?
Something similar to how PHP works when it is mixed with HTML code.
lee
You could use any of the available templating engines for .NET such as WebForms, Razor, ...
There is one you can use: T4.
If you want to have templated defined at runtime, you will need a reference to Microsoft.VisualStudio.TextTemplating to be present, you can learn how to use it pragmatically from the article Processing Text Templates by using a Custom Host (at msdn).
From the article:
To execute a text template, you call the ProcessTemplate method of
Microsoft.VisualStudio.TextTemplating.Engine:
using Microsoft.VisualStudio.TextTemplating;
...
Engine engine = new Engine();
string output = engine.ProcessTemplate(templateString, host);
In the host parameter, you must provide a class that implements
ITextTemplatingEngineHost. This is called back by the Engine.
By this method you can have make your program read the template from a file or load it from a resource.
The article Walkthrough: Creating a Custom Text Template Host (also at msdn) will help you to implement the interface ITextTemplatingEngineHost.
As an alternative, if you will have fixed templates defined beforehand, you can create the tt files and use the following method:
TestTemplate testTemplate = new TestTemplate();
string output = testTemplate.TransformText();
Where TestTemplate is a class generated by VisualStudio from a TestTemplate.tt file. Using this method the template is fixed at compile time. So you will not be able to define it at runtime, from example by reading it from a file.
If you want something simple I recommend you to take a look at T4 templates. You can start from here and here