Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Make the potential loss of type fidelity clearer in the read-me #7

Closed

Description

@mklement0

It is implied by your Get-UICulture example, for instance, but I suggest pointing out the constraints on type fidelity explicitly (which types can actually be fully round-tripped).

Activity

  1. self-assigned this
    on Oct 22, 2020
  2. iRon7 commented on Jul 20, 2022

    @iRon7
    Owner

    This is actually a very interesting point that I am also trying to get better implemented(/defined) from the script.
    Taken the Get-UICulture example should actually not expand (as it can be round-tripped in the current environment), meaning:

    [CultureInfo]'nl-NL' |ConvertTo-Expression #Should just return
    [CultureInfo]'nl-NL' 

    Unless:

    • a property divers from the current system's default (e.g. $Object.Calendar.CalendarType -ne ([CultureInfo]'nl-NL').Calendar.CalendarType). This feature requires to investigate the object (and each recursive property) in -Depth prior possibly outputting it's own properties.
      • This should also apply to (e.g. string) decorations
    • The class doesn't exist --> transfer to [pscustomobject]
    • Certain switches and modes (I am also working on language modes) are set.

    But it is getting pretty complex here and restarted this project several times. I think that I have a general view of what need to be done but I can't get my head around all the recursive functions and all conditions involved...

  3. iRon7 commented on Apr 11, 2024

    @iRon7
    Owner

    I have dropped the thought to automatically investigate the concerned properties whether they have any modifications in comparison the default, because:

    • It is too expensive
    • The result is still questionable as e.g. the default might differ on another system (e.g. due to the culture).

    Anyhow, this whole question leads to a rabbit hole as there are a lot of exceptions for any direction you choose.
    In a nutshell: it is almost impossible to set a solid common definition for the output fidelity.

    Nevertheless, I completely recoded the ConvertTo-Expression cmdlet as part of a larger ObjectGraphTools set and copied your (this) question to there: iRon7/ObjectGraphTools#73. Where I tried to better document the fidelity.

    Basically:
    The PowerShell object parser behind the ConvertTo-Expression has a very high fidelity but the default fidelity of the ConvertTo-Expression cmdlet is bound to whether an object is able to roundtrip (based on the default output or a specific property.
    (For details see the linked issue).

    Btw the Get-UICulture output is a very good example of the HighFidelity switch (of the new ObjectGraphTools\ConvertTo-Expression cmdlet:

    Get-UICulture | ConvertTo-Expression -HighFidelity

    Which also is an example of all the exceptions as Get-UICulture returns a different base type in Windows PowerShell 5.1:

    (Get-UICulture).PSTypeNames
    Microsoft.PowerShell.VistaCultureInfo
    System.Globalization.CultureInfo
    System.Object
  4. iRon7 commented on Apr 11, 2024

    @iRon7
    Owner

    I will soon deplete this ConvertTo-Expression cmdlet

  5. mklement0 commented on Apr 11, 2024

    @mklement0
    Author

    Thanks, @iRon7, good stuff (I assume you meant deprecate, and that you're referring to this stand-alone, Install-Script-based version of ConvertTo-Expression).

  6. iRon7 commented on Apr 11, 2024

    @iRon7
    Owner

    Thanks, @iRon7, good stuff (I assume you meant deprecate, and that you're referring to this stand-alone, Install-Script-based version of ConvertTo-Expression).

    Correct
    (Yes, I meant deprecate.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions