Title: Exporting all format-data definitions and importing them into a pristine session results in missing definitions · Issue #11308 · PowerShell/PowerShell · GitHub
Open Graph Title: Exporting all format-data definitions and importing them into a pristine session results in missing definitions · Issue #11308 · PowerShell/PowerShell
X Title: Exporting all format-data definitions and importing them into a pristine session results in missing definitions · Issue #11308 · PowerShell/PowerShell
Description: The following is an adapted version of a test in Export-FormatData.Tests.ps1 that tests round-tripping of exporting all format data and importing it into a new session, to ensure that all data is preserved. If you use -PowerShellVersion ...
Open Graph Description: The following is an adapted version of a test in Export-FormatData.Tests.ps1 that tests round-tripping of exporting all format data and importing it into a new session, to ensure that all data is p...
X Description: The following is an adapted version of a test in Export-FormatData.Tests.ps1 that tests round-tripping of exporting all format data and importing it into a new session, to ensure that all data is p...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11308
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exporting all format-data definitions and importing them into a pristine session results in missing definitions","articleBody":"The following is an adapted version of a test in `Export-FormatData.Tests.ps1` that tests round-tripping of exporting all format data and importing it into a new session, to ensure that all data is preserved.\r\n\r\nIf you use `-PowerShellVersion 5.1` to ensure that _all_ format-data definitions are reported (the need for which will go away with #11270), round-tripping no longer works properly - certain types no longer have format data associated with them after importing.\r\n\r\nThis _may_ be related to duplicate data existing among the built-in formats - see #11307 - and that perhaps duplicates that cover _additional_ types are not getting imported.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n$tmpFile = [IO.Path]::GetTempFileName() + '.ps1xml'\r\n$fd = Get-FormatData -PowerShellVersion 5.1\r\n\r\n$fd | Export-FormatData -path $tmpFile -IncludeScriptBlock\r\n\r\n$sessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()\r\n$sessionState.Formats.Clear()\r\n$sessionState.Types.Clear()\r\n\r\n$runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($sessionState)\r\n$runspace.Open()\r\n\r\n$runspace.CreatePipeline(\"Update-FormatData -AppendPath $tmpFile\").Invoke()\r\n$actualAllFormat = $runspace.CreatePipeline(\"Get-FormatData -PowerShellVersion 5.1\").Invoke()\r\n\r\nRemove-Item $tmpFile\r\n\r\n$typesBefore = $fd | % TypeNames | Sort-Object -Unique\r\n$typesAfter = $actualAllFormat | % TypeNames | Sort-Object -Unique\r\n\r\nCompare-Object $typesBefore $typesAfter -PassThru | Should -Be $null\r\n```\r\n\r\n# Expected behavior\r\n\r\nThe test should succeed.\r\n\r\n# Actual behavior\r\n\r\nThe test fails, because several types no longer have format data associated with them in the new session.\r\n\r\n```none\r\nExpected $null, but got @(\r\n'Deserialized.System.RuntimeType', \r\n'Microsoft.Win32.RegistryKey', \r\n'System.IO.FileInfo', \r\n'System.Management.Automation.LineBreakpoint',\r\n'System.Management.Automation.TreatAs.RegistryValue', \r\n'System.Management.Automation.VariableBreakpoint', 'System.Security.Cryptography.X509Certificates.X509Store'\r\n)\r\n```\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core v7.0.0-preview.6\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-12-10T15:58:38Z","url":"https://github.com/PowerShell/PowerShell/issues/11308"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a5de888-69de-a001-3383-d895a6fb950d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD70:A067:28F2DDA:391273C:6AFD51E5 |
| html-safe-nonce | 37689cac4679538eafc1bc8c41aef1cbfbd67093d9c28cb4ceb9ca3cdffaaf8f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDcwOkEwNjc6MjhGMkREQTozOTEyNzNDOjZBRkQ1MUU1IiwidmlzaXRvcl9pZCI6Ijg3MDk1MzM1NTQ0OTQ0OTMxNTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 499cd0578a616410155ab5e2e3d0396813ed3384dde988262eaef645fc7bc898 |
| hovercard-subject-tag | issue:535822991 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/11308/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df7165acee4d902d60c99e2d8a2aef266502aef120cc9883ca48005b0567e9d3/PowerShell/PowerShell/issues/11308 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df7165acee4d902d60c99e2d8a2aef266502aef120cc9883ca48005b0567e9d3/PowerShell/PowerShell/issues/11308 |
| og:image:alt | The following is an adapted version of a test in Export-FormatData.Tests.ps1 that tests round-tripping of exporting all format data and importing it into a new session, to ensure that all data is p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width