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 #546

Merged
merged 18 commits into from Sep 26, 2021
Merged

Intellisense #546

merged 18 commits into from Sep 26, 2021

Conversation

MarkMpn
Copy link
Collaborator

@MarkMpn MarkMpn commented Aug 25, 2021

Added Intellisense-style autocompletion to the FetchXML text editor using some new shared projects.

As before, if you edit the FetchXML directly you still need to either click OK or have Live Update Query checked for the Query Builder pane to be updated. This will only work once you've entered a full valid FetchXML document though.

The autocomplete suggestions are taken from the FetchXML object model for the list of possible element and attribute names, and the metadata of the current connection for the possible table/column names.

image

If the full metadata for an entity/attribute is available, the tooltip for those items will show the display name and description. If only the partial metadata is available, only the display name is shown.

With "Friendly Names" enabled, the friendly name is shown in the list but the logical name is still inserted into the FetchXML. I'm not convinced this is the appropriate thing to do - I'm open to suggestions.

image

I've also added an "Autocomplete" event that will be sent to Application Insights the first time the autocomplete menu is shown in each session so you can track usage.

@rappen
Copy link
Owner

rappen commented Sep 18, 2021

Hi - not checked into the code yet, but some Q :)

Right - Friendly makes no sense in this case, shouldn't be relevant here.

Will it only allow "existing" entity/attribute? I ask for you may want to write "other" than just what is available from the official meta. Must be possible to write anything and to execute it, even without a correct XML-doc.

Still possible to have "Live" on/off?

The fetch.cs is changed, but I guess the fetch from MS is not updated? So how do we trust it...?

@MarkMpn
Copy link
Collaborator Author

MarkMpn commented Sep 18, 2021

Agree on the friendly names, they looked weird there to me too. I've removed them now.

It won't stop you typing anything you want. It will only show suggestions based on the metadata, but you can ignore the suggestions and keep typing whatever you want:

image

If you have "Live Update Query" ticked, as soon as you have a valid XML document the Query Builder pane will be refreshed. If you're half way through typing so your query can't be parsed the Query Builder will keep showing the previous state of the query until you've finished. If "Live Update Query" isn't ticked you need to click OK after finishing your changes. This is the same as the existing behaviour if you edit the FetchXML directly.

Good question on the fetch.cs changes. The changes I've made don't affect the structure of the XML it will accept, but it produces named types in the schema for each element rather than having them as anonymous types as they were originally presented in the MS version - this is needed to help keep the autocomplete code simpler. The FetchXML schema is still documented so I can only assume it's still the authoritative source of information?

@rappen
Copy link
Owner

rappen commented Sep 18, 2021

Good.
I guess then that you have not changes anything around The Live feature.

The fetch.cs was changed, but the code is auto-generated from fetch.xsd.
Could it be reverted if generating again? How make sure for future?

@MarkMpn
Copy link
Collaborator Author

MarkMpn commented Sep 18, 2021

Yes, fetch.cs would be overwritten if it needs to be regenerated from a new schema in the future. If/when that happens the various AnonymousType = true properties would need to be manually removed again. I've added a test to ensure this works - if fetch.cs is regenerated without these manual changes being re-applied the constructor of the Autocomplete class will throw an exception and the test will fail.

// Autocomplete entity names for <entity> and <link-entity> elements
if ((e.Element.Name == "entity" || e.Element.Name == "link-entity") && e.Attribute.Name == "name")
{
e.Suggestions.AddRange(fxb.entities.Values.Select(entity => new EntityMetadataSuggestion(entity)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I come again... 😉
But it would be good to respect the settings of which entity and attribute to show.
See code for ex: https://github.com/rappen/FetchXMLBuilder/blob/master/FetchXmlBuilder/Controls/entityControl.cs#L24 (ok, old code, but anyway...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I've also applied the same filtering for attributes as well now.

@ThreeTen22
Copy link

ThreeTen22 commented Sep 23, 2021

Hopefully I'm not butting in, but I actually really like the idea of showing the display name during autocomplete. There are times in which I just don't remember the logical names of something or have a brain fart when trying to remember the logical name of a field...particularly when working with clients who have changed practically all of the standard entity/attribute display names to fit their needs.

Perhaps instead of tying it to an all in or all out setting you could press a specific key while typing?..something like alt?...and the autocomplete switches to the display names and functions like how you described above. Once the autocomplete box goes away it goes back to being logical names again.

@rappen
Copy link
Owner

rappen commented Sep 23, 2021

Interesting @ThreeTen22 !
I guess my best would be +F (change the "Friendly" quickly) showing "Account Name (name)" etc.

image

It should then be search for both name and logicalname.

@ThreeTen22
Copy link

ThreeTen22 commented Sep 23, 2021

That works too! So long as the search pop-up that usually happens when you are editing is suppressed.
Ideally the system bleep that comes with switching can get suppressed as well...cause that can get really annoying really quickly :D

@MarkMpn
Copy link
Collaborator Author

MarkMpn commented Sep 24, 2021

Thanks for the feedback! I've put the friendly name option back in but it now shows the friendly and logical names together. You can also find suggestions by typing the friendly name even if it's completely unrelated to the logicalname:

image

It's still controlled by the global Use Friendly Names option to keep it consistent.

@rappen rappen merged commit 5afa5a6 into rappen:master Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants