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

Intellisense doesn't work for XML literals using a schema definition #34816

Closed
VBAndCs opened this issue Apr 6, 2019 · 21 comments
Closed

Intellisense doesn't work for XML literals using a schema definition #34816

VBAndCs opened this issue Apr 6, 2019 · 21 comments
Labels
Area-IDE IDE-IntelliSense Completion, Signature Help, Quick Info Resolution-By Design The behavior reported in the issue matches the current design Resolution-External The behavior lies outside the functionality covered by this repository Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@VBAndCs
Copy link

VBAndCs commented Apr 6, 2019

Version Used:
VS.NET 2019 Community

Steps to Reproduce:
I am trying a sample to provide intellisense for XML literals, by using a schema definition.
But, when I tested with the simple example described here:
https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/bb531325%28v%3dvs.120%29#enabling-xml-intellisense-in-visual-basic
intellisense didn't show any completion at all, both in .NET framework and .NET Core apps.
This is the xsd file I used:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" 
           elementFormDefault="qualified" 
           targetNamespace="http://SamplePurchaseOrder" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="PurchaseOrders">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="PurchaseOrder">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Address" />
              <xs:element name="Items" />
              <xs:element name="Comment" />
            </xs:sequence>
            <xs:attribute name="PurchaseOrderNumber" type="xs:unsignedShort" use="required" />
            <xs:attribute name="OrderDate" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

and this is VB code I tested:

Imports <xmlns="http://SamplePurchaseOrder">

Module Module1

    Sub Main()
        Dim po = <PurchaseOrder/>


        Dim x = <?xml version="1.0"?>
                <PurchaseOrders>
                    <PurchaseOrder PurchaseOrderNumber="12345" OrderDate="2000-1-1">
                        <Address/>
                        <Items/>
                        <Comment/>
                    </PurchaseOrder>
                </PurchaseOrders>
    End Sub

End Module

Did I do something wrong, or this feature stopped working in Roslyn?

Expected Behavior:
Auto complete list should appear and offer the names defined in the schema.

Actual Behavior:
No auto complete whatever.

@vatsalyaagrawal
Copy link
Contributor

@dpoeschl is this a regression?

@vatsalyaagrawal vatsalyaagrawal added this to the Backlog milestone Apr 8, 2019
@VBAndCs
Copy link
Author

VBAndCs commented Apr 8, 2019

I think this feature was forgotten while moving to Roslyn.
But the label Feature Request is misleading. It is a bug because it breaks the old behavior. A feature request may or may not happen, but this is a lost feature and I think it must be restored as soon as possible.

@CyrusNajmabadi
Copy link
Member

@VBAndCs at this point, it would be a feature request to return this behavior.

@dpoeschl
Copy link
Contributor

dpoeschl commented Apr 9, 2019

@vatsalyaagrawal I think it's a "regression" from the pre-Roslyn days.

@CyrusNajmabadi
Copy link
Member

IIRC, this was a known and intentional thing that was not brought over.

@VBAndCs
Copy link
Author

VBAndCs commented Apr 30, 2019

So, is this a bug or not? If it is a bug, is there a plan to be fixed?
Please, I need this feature back ASAP. Is there any workaround?

@jmarolf
Copy link
Contributor

jmarolf commented Apr 30, 2019

So, is this a bug or not? If it is a bug, is there a plane to be fixed?

I believe this is "by design" in that we intentionally didn't add this feature in 2015 for the 1.0 release of roslyn because we wanted to see how many people missed it.

Is there any workaround?

There is no workaround, the feature is not implemented

@VBAndCs
Copy link
Author

VBAndCs commented Apr 30, 2019

This issue is not XML literal specific. Intelligence also ignores xsd schemas used to verify xml documents oppened in xml editor. Html also has the same issue with xsd schemas defined in package/schemes folder in Vs folder. And maybe more. There could be many reports about this but in other places of. Net.
So, this is a wide spread issue related to roslyn and vs, and I don not think it was intended.
This issue wouldn't break old code, but it makes xml literal useless, and using stribg literal can be easier as long as there is no intellisense available.
I hope you restore this feature soon, and consider a more customizable design of vs.ner editors so that we apply them on any part of string or xml literals, with coloring and auto complete and syntax check. There are a punsh of vs powerful editors, and it is a waste of effort to write new extension just to apply them in vb or cs files. I am facing these difficulties now in two different projets vaspr and zml. I think roslyn can offer a mechanism to attach some built in editor in a definite scope inside another.

@CyrusNajmabadi
Copy link
Member

This issue is not XML literal specific. Intelligence also ignores xsd schemas used to verify xml documents oppened in xml editor. Html also has the same issue with xsd schemas defined in package/schemes folder in Vs folder.

Roslyn doesn't power the xml editor or html editor.

So, this is a wide spread issue related to roslyn and vs,

Please file an suggestion here if you would like this to be supported. The Xml and Html editor teams can decide if they want to invest in this:

image

I think roslyn can offer a mechanism to attach some built in editor in a definite scope inside another.

I would be happy to work with you to provide such an extensibility model. I can point you at the places you can look at to make this possible.

@VBAndCs
Copy link
Author

VBAndCs commented Apr 30, 2019

@CyrusNajmabadi

The Xml and Html editor teams can decide if they want to invest in this:

I am not requesting a new features. Documentations state that theses are already working features but they are not! The xml editor successfully uses the XSD schema to validate the xml file, but doesn't offer tag and attributes names in auto complete. It seems as a general issue in intellisense, and should be addressed by the team who is programming the "Intellisense Provider / Engine" if this is its name.

I can point you at the places you can look at to make this possible.

I have no background about this. Are there any preliminary resources to read about this topic?

@jmarolf
Copy link
Contributor

jmarolf commented Apr 30, 2019

should be addressed by the team who is programming the "Intellisense Provider / Engine" if this is its name.

Unfortunately that team is not on github. As @CyrusNajmabadi says filing a feedback item is the fastest way to get this fixed. If you reply on here with a link to the feedback item I can make sure the right teams see it.

@CyrusNajmabadi
Copy link
Member

I am not requesting a new features. Documentations state that theses are already working features but they are not! The xml editor successfully uses the XSD schema to validate the xml file, but doesn't offer tag and attributes names in auto complete. It seems as a general issue in intellisense, and should be addressed by the team who is programming the "Intellisense Provider / Engine" if this is its name.

This is not the roslyn team, as i already stated. If you want these teams to fix these issues please follow the steps i listed above.

I have no background about this. Are there any preliminary resources to read about this topic?

No. But i'm happy to help walk you through how this could work. Feel free to reach out on gitter.im if you do want to try adding support for this.

@VBAndCs
Copy link
Author

VBAndCs commented May 1, 2019

@jmarolf

If you reply on here with a link to the feedback item I can make sure the right teams see it.

Here it is:
https://developercommunity.visualstudio.com/content/problem/554115/intellisense-ignores-xsd-schema-definitions.html

Thanks.

@VBAndCs
Copy link
Author

VBAndCs commented Mar 25, 2020

Any hope about this after nearly one year?

@CyrusNajmabadi CyrusNajmabadi added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Mar 25, 2020
@CyrusNajmabadi
Copy link
Member

@VBAndCs it hasn't been a priority. If you would like to contribute a pr here, I would be happy to review it!

@VBAndCs
Copy link
Author

VBAndCs commented Mar 25, 2020

I am looking in xsd format now, and I will try to implement it in a VS extention myself.
Thanks.

@CyrusNajmabadi
Copy link
Member

Sounds good. I'm closing this. We have CompletionProvider which can eb used to create completions, and we have DiagnosticAnalyzer which can be used to report schema validation errors.

This a prime example of a use case we built these extension points for for third parties like yourself.

Good luck!

@CyrusNajmabadi CyrusNajmabadi added Resolution-By Design The behavior reported in the issue matches the current design Resolution-External The behavior lies outside the functionality covered by this repository Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Mar 26, 2020
@VBAndCs
Copy link
Author

VBAndCs commented Mar 27, 2020

@lorcanmooney @sharwell @dibarbet @tmat @mattwar @jmarolf
I think it will be easy to write the xsd completion provider for XML literals based on XML Document cooments already working.
I am trying to do it, but I have no experience in the matter.

@VBAndCs
Copy link
Author

VBAndCs commented Apr 6, 2020

@atsalyaagrawal @dpoeschl @CyrusNajmabadi @marolf @inujoseph lorcanmooney @sharwell @dibarbet @tmat @mattwar @jmarolf
I made most of the work, and you can take it from there if you are willing to solve this issue:
I added a VbXmlCompletionProvider to this repo
You can add these two files to the in your Roslyn fork, in the folder Completion/CompletionProviders in the project Microsoft.CodeAnalysis.VisualBasic.Features

It will provide HTML5 auto completion in VB.NET XML Literals, but only inside the <vbxml></vbxml> tag.

I did this for two reasons:

  1. not to mess with other xml literals that doesn't deal with html.
  2. to support Vazor.

I will make a VSIX for this to allow install it as a VS extension (in progress now), but my aim from publishing this, is to allow contributors to build upon to provide a generic XML literals completion provider, based on the xsd that user supplies in the context as this missing feature was described in the docs

@CyrusNajmabadi
Copy link
Member

Great. I'm glad you got it working. Good luck with the extension! :-)

@VBAndCs
Copy link
Author

VBAndCs commented Apr 7, 2020

@CyrusNajmabadi
The VSIX is available now dotnet/vblang#527 (comment)
Thanks for your help.
My work is done here. a few lines of code can make this provider work for any given xsd file instead of just html_5.xsd file.
Hope you give VB.NET a Span(Of your_attention) :). At least consider the ration between C# issues and VB issues when doing fixes. And note that MS said it will maintain enhancing VB.NET experience in VS.NET.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE IDE-IntelliSense Completion, Signature Help, Quick Info Resolution-By Design The behavior reported in the issue matches the current design Resolution-External The behavior lies outside the functionality covered by this repository Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

5 participants