Supported way to load ExtendedTypeDefinition · Issue #7845 · PowerShell/PowerShell · GitHub
Skip to content

Supported way to load ExtendedTypeDefinition #7845

Description

@SeeminglyScience

PowerShell internally loads format data via the assorted PSControl classes. While that API is public, I haven't been able to find a public way of importing them in an existing runspace.

I was able to export them first with Export-FormatData, but I'm hoping for a way to load them without writing to a file first.

Here's an example of what I'm looking for

// Existing public API
TableControl table = TableControl.Create()
    .AddHeader()
    .AddHeader()
    .StartRowDefinition()
        .AddPropertyColumn("Name")
        .AddPropertyColumn("Description")
    .EndRowDefinition()
.EndTable()

var etd = new ExtendedTypeDefinition(
    "MyModule.MyType",
    new[] { new FormatViewDefinition("Default", table) });

// Pseudo code, not a real API
Runspace.DefaultRunspace.UpdateFormatData(etd, shouldPrepend: false);

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions