LSP hover text markdown links from C# not working - c#

I'm working on a VSCode extension with an LSP (implemented in C#/Omnisharp). I've implemented my language hover provider in the LSP and it's working fine. However, I want to add a clickable [vscode] command link to the hover. I've done this before using markdown in extension Typescript code like [Label](command:some-command), but it's not working from the LSP C# code. From there it just displays flat text as Label, but not as a clickable URI link. If the Uri is a regular https link it works, but not if it's a vscode Uri. Anyone know the magic to enable vscode command links in markdown from LSP C# code?

You need to set the markdown content isTrusted flag to get links to work. For a language extension server you need edit the LanguageClientOptions in the client's typescript file.
let clientOptions: LanguageClientOptions = {
markdown: {
isTrusted: true,
},
}
let client = new LanguageClient('myClient', 'My Client', serverOptions, clientOptions);
It's described on their GitHub in this issue

Related

How can one syntax highlight and format GraphQL queries on an HTML page with C# on .NET Core / Blazor?

Basically what the title says; I would like to syntax highlight aka colourize the GraphQL queries like they do it in the "GraphiQL Explorer", and print it on an HTML page with .NET Core using C#. Im working with Blazor, so the pages are .razor.
See this screenshot:
And I also want to auto-format the queries so that the queries aren't on a single line, but with line-breaks and indentations as the button "prettify" does in the "GraphiQL explorer".
So here's a sample.
Convert this => {human(id: "1000") {name height(unit: FOOT)}}
to this =>
Edit:
Here's a blazorFiddle i created. BlazorFiddleSample
Basically format\indent the graphql queries in a component page like this converter does, freetooldev
This could be achieved using BlazorMonaco
https://github.com/serdarciplak/BlazorMonaco
the code setup should look like this for the options
private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
{
return new StandaloneEditorConstructionOptions
{
AutomaticLayout = true,
Language = "graphql",
};
}
please follow the instructions to get it setup if this is something you want to try.
you can get more info on the use of Monaco Editor here:
https://microsoft.github.io/monaco-editor/

How to open links in bot framework in a seperate tab

Is there a configuration in the bot framework that makes it open links in a seperate tab?
Looking at this link, seems there is no way to specify in markdown to open a link in a new window and that it is possible using html.
We do not want to specify that long HTML configuration in each link, and we cannot call a function that does that because some of the links appear as a prompt which expects const only (so calling a function is not possible).
Therefore, we are looking for some general configuration in the bot frameowrk that would make links appear in a new window.
Links should open in a new tab by default. There is a GitHub issue tracking this here: https://github.com/Microsoft/BotFramework-WebChat/issues/454
Here is the PullRequest that fixes the issue: configure MarkdownIt to open links in new tab
There is a class in bot framework named CardAction.
If you want to open some link, you should have something like this :
List<CardAction> listButtons = new List<CardAction>();
listButtons.Add(new CardAction
{
Value = "https://google.com",
Type = "openUrl",
Title = "open google",
});

Cannot set Word Style's Base Style From C#

Microsoft.Office.Interop.Word version 14.0.0.0. .NET 4.0 VS 2010.
The MS Word API's Style class has a BaseStyle property that can be used to set the style's base (based on) style. That property works fine for me in VBA.
However from C# using Word interopt there is no BaseStyle property. However, there are two (undocumented as far as I can tell) functions set_BaseStyle() and get_BaseStyle().
When I call set_BaseStyle() I get a COMException with the message:
"This command is not available."
I think this means that the COM interface does not support the procedure (command). But why? Why does it appear in intellisense and compile? Is there a workaround?
This simple example works on my machine (VS 2012, Office 2007)
Application application = new Application {Visible = true};
string styleName1 = "Heading 1";
object styleNameObject1 = styleName1;
string styleName2 = "Heading 2";
object styleNameObject2 = styleName2;
var document = application.Documents.Add();
document.Select();
application.Selection.set_Style(ref styleNameObject2);
Style style = (Style)application.Selection.get_Style();
Style baseStyle = style.get_BaseStyle();
style.set_BaseStyle(ref styleNameObject1);
application.Selection.Range.Text = "This is the title";
application.Quit(false);
So the problem probably lies in your setup. The message is rather vague and it says word cannot do stuff, for other examples look at C# and Word2010 : DeleteAllComments throws "This command is not available." or search and replace in Word documents via .NET automation.
Is the file readonly? Does it happen with other styles or simpler files (such as my example)? Are Macros allowed in Word?
I found the problem.
The sample code posted by Vadim was a big help, as it did work, and I slowly slowly converted in to my code and eventually broke it, them moved back and forth until I homed in on the problem.
However, I can't explain what I found!
I was specifying all parameters when I opened the (existing) document with Application.Documents.Open(). It turns out that if I specify false (0) for the isvisible parameter, the code fails. If I secify true (-1) it works.
Note that in either case I can make 100s of other changes to the document. For some reason I cannot change the base style if it is invisible.
strange.
Thanks for your help.

watin not working with live.com

I am trying to use watin to mimic login to live.com using c#. code is below.
IE myIE = new IE("http://login.live.com/");
myIE.TextField(Find.ByName("login")).TypeText("abc#abc.com");
myIE.TextField(Find.ByName("passwd")).TypeText("1234");
myIE.Button(Find.ByValue("Sign in")).Click();
However it always failed to find the textfield:
WatiN.Core.Exceptions.ElementNotFoundException: Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute 'name' equals 'login' at http://login.live.com/
The sample code in home page of http://watin.org/ works fine for www.google.com.
Did I miss something or is there anything special on http://login.live.com that prevents watin to work?
PS: I am running windows 7 64bit. VS 2008 with .net 3.5
You're hitting issues because the email field you're trying to type in is an HTML5 element.
Create the TextFieldExtended class as defined in this SO question: WatiN support for HTML5 tags
Then your code will be like the below:
ie.GoTo("http://login.live.com/");
ie.ElementOfType<TextFieldExtended>(Find.ByName("login")).TypeText("thisismyusername#here.com");
ie.TextField(Find.ByName("passwd")).TypeText("thisismypassword");
ie.Button(Find.ByValue("Sign in")).Click();
Tested on Watin2.1, IE9, Win7-64.
You may want to try this: I got it to work on my end:
ie.Div(Find.ByCustom("innertext","someone#example.com")).Click();
ie.TextField(Find.ById("i0116")).TypeText("hello");
ie.TextField(Find.ById("i0118")).Click();
ie.TextField(Find.ById("i0118")).TypeText("Hello!");
I recommend using this test Recorder. It will give you the elemnt names to use in your source:
http://www.codeproject.com/Articles/19180/WatiN-Test-Recorder
Edit:
I was also able to get this to work when finding by divID.
ie.Element(Find.ById("idDiv_PWD_UsernameExample")).Click()

Create HTML webpage programmatically in C#

I was wondering: is there a way to create HTML files programmatically in C# as you can do with XML? Mine is a console application, so maybe some of the options are not available. Basically, I would like to do something smarter than just building a big string.
Possible scenario:
Instead of writing:
string html="<html><head>Blah</head><body>{0}</html>", myotherstring
I would like to work as in XML
XmlTextWriter w = new XmlTextWriter(xml_file_path + xml_file_name,
System.Text.Encoding.UTF8);
w.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
// construct xml
XmlElement root = xmlDoc.CreateElement("element");
...
xmlDoc.Save(w);
w.Close();
Apologies for the naive question.
Don't forget: You can generate XHTML just as easily as plain XML using the XmlTextWriter approach.
You could use NVelocity. It is a .Net port of the Java Velocity templating system. The API will not be similar to XmlWriter. Instead, you'll write a text file in a simple scripting language, put your objects into a 'context' and then merge the template and the context to generate the HTML file.
NVelocity
You could use some third party open-source libraries to generated strong typed verified (X)HTML, such as CityLizard Framework or Sharp DOM.
For example
html
[head
[title["Title of the page"]]
[meta_(
content: "text/html;charset=UTF-8",
http_equiv: "Content-Type")
]
[link_(href: "css/style.css", rel: "stylesheet", type: "text/css")]
[script_(type: "text/javascript", src: "/JavaScript/jquery-1.4.2.min.js")]
]
[body
[div
[h1["Test Form to Test"]]
[form_(action: "post", id: "Form1")
[div
[label["Parameter"]]
[input_(type: "text", value: "Enter value")]
[input_(type: "submit", value: "Submit!")]
]
]
[div
[p["Textual description of the footer"]]
[a_(href: "http://google.com/")
[span["You can find us here"]]
]
[div["Another nested container"]]
]
]
];
I realise that this question is old, however the recent release of the ASP.Net MVC 3 Razor view engine now gives you the option to use this same Razor view engine to generate HTML for any purpose.
See Hosting Razor outside of ASP.Net for a guide on how to do this.
What I did a few months back, I had an asp.net file (aspx) saved as a template in a text file, whenever the user needed a new page, I would just copy that template into the user specified folder, change the extension .txt to .aspx, and programmatically add a few options depending on the user's needs. It was a simple page though. Of course, the more complex you go, the more complex the code will be.

Categories

Resources