Skip to content
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

Create a XAML language service #3338

Open
stevenbrix opened this issue Oct 11, 2019 · 30 comments
Open

Create a XAML language service #3338

stevenbrix opened this issue Oct 11, 2019 · 30 comments

Comments

@stevenbrix
Copy link

It would be awesome to start working towards a proper XAML editor in VS Code.

A few things off the top of my head that this would need to accomplish:

  1. Provide intellisense when user is editing xaml files
  2. Provide syntax highlighting
  3. Not be tied to a particular XAML dialect, and be extensible so we can build UWP/WPF/Xamarin.Forms/Avalonia experiences inside VS Code on top of it.

I'm not entirely familiar with how a VS code language service operates. I've only very briefly dabbled with them a few months ago, but I feel like the Omnisharp project is the right place for this to reside.

/cc @kekekeks @michael-hawker @danwalmsley @grokys

@danwalmsley
Copy link

AFAIK Syntax highlighting of XAML is quite straight forward, and prob VS code has a grammer file already to do this. Unlike C# where some of the highlighting actually relies on having a syntax tree.

Here is a link to the "language server" we use for avalonia...

https://github.com/kekekeks/Avalonia.Ide/tree/master/src

it has a simple xml parser, and provided it can locate the binaries for the project, can do a pretty good job of completion. Works cross platform, would need to understand wpf, xamarin and uwp binaries though.

@michael-hawker
Copy link

michael-hawker commented Oct 11, 2019

VS Code's Monaco editor does a pretty descent job of syntax highlighting XML already.

I've been looking at swapping out the default XDocument parsing I'm using in XAML Studio for this XmlParser which supports partial XML parsing as well. There's also this existing XAML Parser as well, but I liked the idea of the partial syntax support for XAML Studio of the general Roslyn-based XML parser instead.

Currently, I'm doing all the introspection in C# and using reflection on the UWP types to try and do the intellisense currently, but it's not the best approach at the moment. WPF used to ship an XSD definition which was nice, but UWP doesn't do that.

It'd be great if we could all use the same general solution though that could support all the XAML flavors.

@liquidboy
Copy link

liquidboy commented Oct 11, 2019

I love this idea.. Like Michael Im currently using Monaco editor to render my custom xaml , using the html Lang def because there's no xaml and is nicer on the eyes compared to the xml ld.

Sample seeing Monaco using html Lang def, rendering my custom xaml (click on bottom right link to see xaml). https://as-xamlgl.azurewebsites.net/index2.html?xaml=sample-bjs-11.xap&v=1&t=11

next step is to Create my own Lang definition in Monaco tailored for xaml ... https://microsoft.github.io/monaco-editor/monarch.html

whatever u build here I would love to use

@stevenbrix
Copy link
Author

Here is a link to the "language server" we use for avalonia...

Plus plus! What does your language server do, is it just intellisense and auto-completion, or does it do more than that?

Works cross platform, would need to understand wpf, xamarin and uwp binaries though.

@danwalmsley at what point does it "understand avalonia" binaries?

VS Code's Monaco editor does a pretty descent job of syntax highlighting XML already.

True, this grammar document could be re-purposed for XAML, that might be good enough.

It'd be great if we could all use the same general solution though that could support all the XAML flavors.

@michael-hawker I totally agree :) I added you cause I know you're passionate about this space too.

@yatli
Copy link

yatli commented Oct 13, 2019

at what point does it "understand avalonia" binaries?

Custom controls, properties etc. that are only visible to XAML after parsing the compiled assembly.

@stevenbrix
Copy link
Author

Custom controls, properties etc. that are only visible to XAML after parsing the compiled assembly.

@yatli thanks! This sounds similar to what our tooling does as well (no surprise there really), although we don't have anything for VS Code yet. Are there things that are hard-coded specifically to Avalonia or does it just understand the types once the assemblies are loaded?

@yatli
Copy link

yatli commented Oct 14, 2019

I'm not sure about the details :)
But I guess it's somewhat hard-coded -- although it follows the convension (static member NamedProperty vs. property "Named"), the types are different (e.g. AvaloniaProperty)

@stevenbrix
Copy link
Author

stevenbrix commented Oct 14, 2019

I'm not sure about the details :)
But I guess it's somewhat hard-coded -- although it follows the convension (static member NamedProperty vs. property "Named"), the types are different (e.g. AvaloniaProperty)

Thanks @yatli, I'll try and take a look. I'm fairly confident we could come up with a way to specify the platform specific "DependencyProperties" in a way that doesn't require them to be hardcoded (maybe via an attribute on the type?).

@danwalmsley do you have instructions on how to test out your language service? I haven't looked into yet, it could be fairly simple, but every time I think that I tend to waste more time than I probably should :)

@jtbrower
Copy link

I have now been writing WPF Desktop applications for about 12 years. I have extensive experience using Visual Studio with large enterprise applications and I honestly cannot say enough bad things about using Visual Studio with XAML in those 12 years. As each year passes I have sat quiet continually hoping that the product will improve but it doesn't. When I say "improve" all I really want is for the Designer to not crash and take Visual Studio down with it. Years ago, only the designer would crash but in the last couple years it takes visual studio down with it. To make matters worse you can't kill the hung process with the task manager so I always have sys Internals process explorer on my task bar ready to take it down.

Opening Blend and hoping the same issue doesn't occur I end up crashing blend to. I am a pretty positive person, don't really like to complain but I have had it with Visual Studio. When I report problems to the team I get the "needs more information" reply along with telling me that including crash dumps are not helpful and they want me to use the "report a problem tool" . How can I use that tool when the entire interface is frozen?

For me, the cost of the tool isn't an issue. My reason for looking deeply into VsCode comes from no hope that Visual Studio will change anytime soon. I know there must be more people out there like myself who have experienced such a productivity drag that they too would be grateful to your team if you could provide designer support for XAML. I would be filled with joy if you could just display the XAML without crashing. I am so use to hand editing XAML that just being able to see a Visual Representation without needing to recompile and launch every time would boost my productivity greatly.

I recently discovered the free XAML studio that I think was developed by a Microsoft Employee too, I was really impressed with that tool but it isn't enough to handle enterprise sized applications. However, maybe some lessons can be taken from how it was designed because its a great start to a good product.

I have been listening to Podcasts about the new Visual Studio designer features and I know the team must be working hard. I mean no frustration towards those developers or the manager. I am sure I indirectly insulted someone on this thread, if I did I apologize. I am sure part of the problem is the fact that Visual Studio is such a mammoth app, locked into a 32-bit process and married to decades of code baggage, I can only guess.

In a nutshell you would have one huge fan if you could add designer support. I trust in Microsoft, but I think they need to throw a wad of cash at this problem.

@liquidboy
Copy link

Blend in the Silverlight days was amazing.. Things dropped in quality post SL...

@michael-hawker
Copy link

@stevenbrix I looked at the XmlParser library, and I created a C# sample here. I started swapping out XAML Studio to use this library for parsing, but I need to understand it a bit better.

@stevenbrix
Copy link
Author

stevenbrix commented Feb 6, 2020

@jtbrower thanks for your feedback. I've worked on this from the WinUI side of things and there's no offense taken, I'm sorry the work we've done hasn't been enough yet. Which version of Visual Studio are you on? Would you be willing to share your project and some repro steps, so we can get a better understanding of what your issues are? Or maybe something like VS Live Share would work for this? Not really sure :)

@stevenbrix
Copy link
Author

The way I see it, there are two parts to this problem:

  1. A XAML language server that knows nothing of the underlying platform. The language server understands the basic XAML syntax, but can provide intellisense and auto-complete for any XAML dialect (WPF, WinUI, Avalonia, Xamarin, Uno). This is what this issue is about.
  2. Xaml Designer and/or Xaml Hot Reload support in VS Code. I imagine this would be fairly platform specific. If we could do it in a way where we could share code that would be cool, but not a requirement.

@jtbrower
Copy link

jtbrower commented Feb 9, 2020

@jtbrower thanks for your feedback. I've worked on this from the WinUI side of things and there's no offense taken, I'm sorry the work we've done hasn't been enough yet. Which version of Visual Studio are you on? Would you be willing to share your project and some repro steps, so we can get a better understanding of what your issues are? Or maybe something like VS Live Share would work for this? Not really sure :)

@stevenbrix thank you for the response. When I saw your message in my inbox this week, I figured I would work the weekend to put together a document detailing some of the issues I experience. When I fired up Visual Studio today I initially thought it was going to let me down and suddenly perform without issue. However, it didn't take long before I was able to cause a few problems that completely lock up the app such that the UI Freezes and must be killed with the Process Explorer.

These problems have haunted me for years because they occur on a regular basis, yet I have been unable to pinpoint any specific cause that can reproduce the issue on every attempt. That said, the attached document contains information on my day using Visual Studio 16.5 Preview 2.0. For anyone who indicates that my issues are expected with previews, please read my document as it may put this in a better perspective. In other words, the stable versions were not a fix.

BTW Steven, I want to migrate all of my WPF over to WinUI. I am 100% NetStandard/NetCore now and attended the first WinUI community town hall. I just remain a bit confused with all of the options available to us these days, Blazor being one of them. Anyway, I think WinUI is going to be my choice.

Visual Studio Bugs_2_8_2020.pdf

@mikadumont
Copy link
Collaborator

@jtbrower I read your document. Is there anything missing from your experience that you currently rely on ReSharper for?

@jtbrower
Copy link

Hello @mikadumont, thank you for taking the time to read my rant document. I know of you through Microsoft so I really appreciate you reading my frustrations.

You ask a good question regarding Resharper/Visual Studio that I could not immediately answer as I failed to recall the explicit differences. As a result, I just logged into my JetBrains account to get more details. Apparently it was October 9th of 2019 where I felt conflicted feelings with respect to Resharper vs Visual Studio. I had just spent several months without Resharper while using only Visual Studio tooling. On one hand I had experienced enough issues with Resharper in recent years that I wasn't willing to spend money on another year/multi-year license. Yet overall stability of Visual Studio hadn't improved as much as I hoped and I was finding myself missing some of the Resharper features. I then noticed that JetBrains had a monthly license so I figured I would sign back up and continue to use the tool until I had time to revaluate new VS features as they came in.

With that said, whatever the latest Visual Studio Pro preview version that was out on October 9th didn't have all of the features I needed. The problem is, I cannot be more specific than that and my response is stale considering VS 16.5 Preview 2 is out now. If I remember correctly (which is debatable) I think I was missing LINQ query features and likely other refactoring tools.

Ironically I opened up a solution to give Visual Studio another comparison and I am looking at the warning at the top of the page telling me that Visual Studio stopped responding for 6 seconds because of Resharper. So I think now is as good of a time as any to try to live without Resharper again. I will report back here once I feel I have more specific feedback.

Note, one thing I noticed right away when I disabled Resharper was that Resharper shows unused classes by making the class name a lighter color. Let me spend a bit of time without it and report back. Thanks for your ear.

@chryw
Copy link

chryw commented Mar 2, 2020

A bit late to the party but I have a slightly edge scenario to share:

I often need to do some quick edits to xaml icons for Visual Studio. However my main machine is Mac (I'm on the design team). Most of my icon production work is done in VS Code on a Mac. So I have to use a VS with a heavy workload installed (Blend, etc.) running an Azure VM (or a second PC) to just preview/validate some simple xaml files.

I know this is super edge case but I think there might be more people who just want to quickly edit/lint xaml for UI tweaks. If there was IntelliSense for XAML in VS Code that would save a lot of time. Just my 2 cents 😉

@yasamoka
Copy link

A bit late to the party but I have a slightly edge scenario to share:

I often need to do some quick edits to xaml icons for Visual Studio. However my main machine is Mac (I'm on the design team). Most of my icon production work is done in VS Code on a Mac. So I have to use a VS with a heavy workload installed (Blend, etc.) running an Azure VM (or a second PC) to just preview/validate some simple xaml files.

I know this is super edge case but I think there might be more people who just want to quickly edit/lint xaml for UI tweaks. If there was IntelliSense for XAML in VS Code that would save a lot of time. Just my 2 cents

I'm in a somewhat similar situation here. I'm editing XAML from a Linux machine while running Windows 10 in a VM. Windows is available as dual boot too (same install) but I tend to have several services running on my Linux install throughout the day.

I use Remote-SSH in VS Code to edit and compile from the comforts of KDE Plasma. I've just started dabbling with XAML and I'm only working with very simple UIs. The XAML designer tool only being available on Visual Studio forces me to run Visual Studio in Remmina Remote Desktop connected to the Windows VM (other options are cumbersome / not optimal) and perform edits there.

Having a VS Code plugin would be great.

@feoh
Copy link

feoh commented Nov 4, 2020

For what it's worth IMO the Uno Platform makes a reasonably compelling argument for why one would want a cross platform tool like VSCode to be able to design a UI using XAML.

@chryw
Copy link

chryw commented Nov 6, 2020

@feoh Thanks! That web playground is pretty handy 👍

@michael-hawker
Copy link

@microhobby is making waves here in this space! https://twitter.com/math_castello/status/1333551031477825538 this looks amazing already!

@microhobby
Copy link

Thanks for pointing @michael-hawker I did it very quickly as a proof of concept and for fun. I will go over the next few days to do some cleanup and acknowledgments of pieces of software from other projects and then the plan is definitely to publish it as open-source.

@Agagamand
Copy link

and then the plan is definitely to publish it as open-source.

There is progress?

@biltongza
Copy link

I think this is going to get more important with Maui arriving. You can set up a project with the CLI just fine, but you get absolutely no help from Omnisharp when editing XAML, which is arguably the point of Maui.

@ziaulhasanhamim
Copy link

What is the progress on this?

@michael-hawker
Copy link

🦙 The Uno VS Code extension is available in preview here: https://marketplace.visualstudio.com/items?itemName=unoplatform.vscode

Their getting started doc is here: https://platform.uno/docs/articles/get-started-vscode.html

@AntonKosenkoDX
Copy link

I tried to open MAUI project using OmniSharp and struggled with InitializeComponent() method. OmniSharp can't find it and it leads to inability to get any staff from xaml in code behind.

@jhm-ciberman
Copy link

Any update on this?

@heartacker
Copy link
Contributor

Any update on this?

MS just want you to use VS。that is the point

@jhm-ciberman
Copy link

MS just want you to use VS。that is the point

Visual Studio is ultra laggy and the UI is cumbersome and lacks a lot of features. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests