-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Improve authoring experience for Format.ps1xml and Types.ps1xml files #7749
Copy link
Copy link
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
The Format.ps1xml and Types.ps1xml system in PowerShell is incredibly powerful. It's awesome how we can output objects, then totally separate from that define how these should be displayed in similar ways to how UIs are declared in XAML or JSX. Some really cool things are possible with it:
However, authoring these files is incredibly frustrating. There is no autocompletion, hovers or validation for these files in your editor. The reference documentation is incredibly hard to find, browse and search (a bunch of duplicate
element Foo for Bar for Baz for Quz (Format). Error messages are often very confusing.The way this could be improved a lot would be with an XSD for these files, which would allow validation, hovers and autocompletion. I started working on this:
This is with the vscode-xml extension.
Schemas are here: https://github.com/felixfbecker/PowerShellXSD
I currently just autogenerated this schema from the Format file in that repo.
I will investigate writing a script that parses the official schema markdown reference here and converts it into an XSD (probably with manual edits afterwards).
I couldn't find reference docs for Types.ps1xml files unfortunately, but they also seem simpler.
What's in the way of using this is that any attribute declaration on the root
Configurationelement will cause an error:Which means the schema instance attributes need to be removed again before loading the Format file. It would be great if PowerShell could instead just ignore attributes on the root element:
Another unfortunate thing to mention is that schema validation won't work if you want to use ANSI color codes in Format files because of #7526
I am posting this here in case someone wants to help out and because it would be great if eventually these schemas would be versioned in the PowerShell repo and hosted by Microsoft.