-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Generic script with embedded language support in .NET #34821
Comments
You can already do this today. Just use FormattableStrings and template literals. Other languages/platforms environments (like JavaScript) already have libraries like this like so: https://wesbos.com/template-strings-html/ So there's no real need to introduce yet another way to do this when the language already shipped hte feature for this purpose.
Why? The language already has
The language shouldn't add redundant features just because you don't want to write a VS plugin. |
No, I can't. There is no editor support to the script I am writing on the string. This proposal is about that: give us syntax check, coloring and auto complete for the script type we write in the string, as specified by the properties of the EmbeddedScript object.
Where is that? Is there is an example to achieve what I mentioned above?
Not enough. If I want to design a HTML page with xml literals it is impossible to remember all tag and attribute names without intellisense support. This is the major problem I am facing in Vazor now . Noting that I have some support for xml structure in VB, but it is not enough. So, what about plain text?
The language should fulfill the needs for its developers. This is a repeated request, and all the components to make it exists and just need to be put in place. Besides, this is not about one language. It is a core feature that should be built in Roslyn and VS.Net to make intellisnse truly (intelli)gent and (sens)ible to make the life of programmers easier. |
How would that work?
Then write a VS plugin. How would roslyn know all the tags and attribute names here?
This feature already exists. Roslyn Completion is extensible. So you can add your own completion providers. This is desirable so that Roslyn itself doesn't have to be in the job of understanding every random language you want to plug into it. Instead, you can supply the VS and Roslyn plugins to do this. That's the idea. To make it so that you can put in the legwork here for the languages you care about, instead of expecting Roslyn (and the limited dev team it has) to do it for you.
Yes, and both the language and the tooling is extensible here so that the work can be distributed to provide these features. Otherwise, you're just saying "hey... roslyn needs to go implement and support all these languages". That's just not cost effective. If there's a language you care about, put in the legwork and effort to make it happen. If you think that's too costly for you, then ask yourself why the roslyn team would think it wasn't too costly for them. |
You are asking for app developer to convert to a environment/language designer. This is a waste of time and resources . This is not the layer most developers work in. Besides, there is a limited resources about these topics. I wasted days searching in vain, and the extendvs room you told me about is nearly empty, and I got no answer. The worst thing is that editor factories are written in C++. Why should thousands of developers reinvent the wheel every time they face something like that?
Roslyn should know nothing about that.. All I want is to make Roslyn reuse the plugins it already has. This is how:
|
You are asking for roslyn devs to have to implement language support for all languages you want, regardless of their knowledge or experience of that language. You're also asking the roslyn team to take on the cost of implementing and maintaining all that work.
This is not the layer Roslyn devs work in either. The layer roslyn devs work in is to make the extensible platform to make it possible for other to plug in like this. That's why the Editor team, for example, doesn't implement the language support. They just make the extensibility system and core pieces.
You got no answer because your questions were vague and open ended. No one is going to do your homework for you. You need to do a lot of legwork on your own. And when you run into problems, you'll need to dig a lot and provide a lot of information to help others so that they don't just have to vaguely guess in the dark as to what problem you were having.
Roslyn isn't C++. You can implement a completion provider in managed code.
Roslyn has no plugins for html editing.
Roslyn has nothing to do with the html editor.
Again, you can do that today with interpolated strings.
VS.net is not roslyn. You have the layering reversed.
Sounds like you know how to do it. I would recommend making a prototype demonstrating how this would work. If desirable, it might get picked up. |
You searching in vain is not a reason for others to do work for you. I don't get how that's a valid argument at all.
There are around 20 people there. They commonly answer many questions every week. But you'll notice that a common aspect of questions is that they they are focused, specific, and solution-oriented. They're not questions like: First, it's very unclear what you even want. Second, you haven't explained what you've even tried, or what existing APIs you've used. Third, you finish with a vague 'how can i do it?'. You need to really explain to people what you're trying to accomplish. You need to show how far you've been able to get, but where you've reached a blocked point. You'll have to show what you've tried to do to address this, but why they haven't worked. Finally, you should offer some ideas on how you think you might be able to solve things, with specific questions looking for the help you need from the experts in this topic. -- With your last github account, you would commonly open Roslyn issues asking people to just do work for you. IIRC, pretty much all of them went absolutely nowhere. You're now doing it again, but also doing it for VS plugins. This simply won't get anywhere. No one on the team is going to sign up for this work, and no one on the extensibility team will be able to help you without more details. |
Thanks for your response. |
Hi, I commend your massive effort to research previous tickets related to this feature. I made one of those. But I think we have reached ways' end here. Perhaps the best way for you would be to use razor as an xml generator? Also, for the record, if we would stop to talk about jsx for a moment, then that's just a transpiling (?) step before js gets executed the normal way. It's not got anything to do with the javascript language engine(s) per se. It seems that the best fit for your development style is not .NET Core and related technologies, but traditional ASP.NET WebForms in .NET Nothing wrong with that, but keep in mind that times have changed and people (to a large extent) have left many of those paradigms behind. Tight coupling of backend code with frontend logic is one of those paradigms, which seem to have had a large impact on you (as well as me). All the best! |
@bjorn-ali-goransson
Razor Pages apps has brought this model back, claming that there is bo real separation betwwn model and view in practice. Anyway, this is not the concern of this proposal. I can get html intellisense in xal literals by using an xsd schema. It is supposed to work! I reported this in a previous issue and waiting for feeadback. Untill then, I am using the open with command from the solution explorer to open my vbxml files in html editor, and it does the purpose. So, I have many workarounds to go with. |
Another suggestion for the syntax is: Dim x = "test"
Dim s As string = $.JavaScript
"var I =5;
document.writeln({x});" where $ is the interpolated string symbol, and JavaScript is the editor we want to use to format, color, validate and auto-complete the tokens inside the string. We can also use:
I will edit the original proposal to add this. |
Closing out. As mentiond in other conversations, completion/intellisense is something completely supported for third parties using the CompletionProvider API. So, as per the discussions above, this can be done by using template literals, embedding whatever you want in them, and then writing teh appropriate completion plugins to give you things like "tag and attribute names". This should be sufficient for your vazor effort. |
I saw many proposals to add XML literals or JSON support in C#, which are rejected. I have an idea to support any type of literals with embedded language code without altering the langue syntax!
Suppose we have a method named EmbeddedScript.Parse, used like this:
This should evaluated as:
<p>test 1</p>
Another suggestion for the syntax is:
where $ is the interpolated string symbol, and JavaScript is the editor we want to use to format, color, validate and auto-complete the tokens inside the string. We can also use:
$.Html, $ .CSS, $.JSON, $ .CS, $.FS, $ .Razor, $.XML (this one will makes the interpolated string literal acts as the XML literal)… etc.
XML literal can also benefit from this, by using and editor attr like this:
These are the rules:
embed language code in <%= n %>. But EmbeddedScript can have properties like StartQute and EndQuote to set the start and end embed quotes, so every one can use the scheme he like most.
The ScriptType enum can have values for Html, XML, JSON, Js, String, and any other formula supported. It also can contain CSharp, VisualBasic, FSharp... etc, to allow use some pieces of another language with embedded expression with the current one. The Return Value of the Parse method should be an interface that have a Value property to return the evaluated expression.
Another way, is to have EmbeddedScript.ParseHtml, EmbeddedScript.ParseXml, EmbeddedScript.ParseVB..... etc methodes, with syitable return types.
Maybe it can have a UserDefined to use a new script but this needs setting rules on how to define it to Roslyn.
The script is written as a string, and parsed to the desired type like XElement, HtmlElemnt, Json, String , etc. So, it is not a part oc C# ,VB or F# syntax.
Roslyn is supposed to handle the script witten in the string quotes, to offer intellisnese and syntax check. Most of this work is already done in Html, xml, Json editors, So, put it in action ion this scope.
C# or VB evaluates the embedded expressions only and the parsing process is done by the EmbeddedScript.Parse, which, I think, is a matter of calling some CoreFx methods.
If the script depends on some other data like an xsd file for xml, we can point to its path in a EmbeddedScript.Resources property and reference its key in the xmln namespace.
Embeded C# or VB inside a closed quotes should allow us to write any of these:
a. an expression like
<%= n %>
b. implicit function like:
c. implicit enumerator like
d. a block of code to define som vars used in other embedded expression, and return "" is assumed:
These are the basics, and you can refine these rules as desired.
I think this idea can offer powerful tools to .net languages, and will save many future efforts to embrace new kind of scripts.
In fact this idea came to me because I am suffering now to find away to add intellisense support for THML written inside xml literals in VB. VS.NET has all the tools but I don't find an easy way to apply them on xml literals without writing a new editor factory with C++! Why write a new useless editor while VS already has editors for nearly every thing?
The text was updated successfully, but these errors were encountered: