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

Add PSObject boxing support in PesterConfiguration #1978

Merged

Conversation

indented-automation
Copy link
Contributor

@indented-automation indented-automation commented Jun 7, 2021

PR Summary

Fixes #1977

  • Adds PSObject unboxing support to the GetIDictionaryOrNull extension method.
  • Adds custom deserializer for the PesterConfiguration object (requires PowerShell 5 or greater).

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@indented-automation
Copy link
Contributor Author

Bear with me a bit, fixing.

@nohwnd nohwnd marked this pull request as draft June 7, 2021 14:33
@nohwnd
Copy link
Member

nohwnd commented Jun 7, 2021

Made it a Draft PR, mark it as ready for review when done.

@indented-automation
Copy link
Contributor Author

I was going to pull out the deserializer code I've written, but instead I've changed it so it's only available to PS 5 and higher. It can, of course, be culled if it's not appropriate.

I wanted to rewrite it into C#, but it was giving me such a hard time, death by reflection.

I'll add some tests in the morning. It'll be interesting to see how the large scale test run works out. A lot of the failures I saw locally are speculatively nothing to do with me :)

@indented-automation indented-automation marked this pull request as ready for review June 8, 2021 09:00
@nohwnd
Copy link
Member

nohwnd commented Jun 14, 2021

I've changed it so it's only available to PS 5 and higher. It can, of course, be culled if it's not appropriate.

Yeah, we need to solve this for PS3 and up. I think the same thing happens when you pass the values via -ArgumentList, so it can happen on PS3 as well.

@indented-automation
Copy link
Contributor Author

Yeah, we need to solve this for PS3 and up. I think the same thing happens when you pass the values via -ArgumentList, so it can happen on PS3 as well.

I'll have another crack at the C# version. It's going to be horrible ;)

@indented-automation
Copy link
Contributor Author

Just a brief note on this version.

I still use the Update-TypeData commands rather than a Types file.

I found when I used the Types file that the assembly implementing the deserializer had to be loaded before the root module (for psm1) which may have worked if it were possible to require the assembly in the manifest, but not otherwise.

Anyway, it's all compatible with PS 3 now, or at least it is if the test results are accurate :)

@nohwnd nohwnd added this to the 5.3 milestone Jun 16, 2021
@nohwnd nohwnd merged commit 8634da0 into pester:main Jun 24, 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.

PesterConfiguation is not Serializable
2 participants