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

Approval methods fail with TypeInitializationException under .NET 5 #717

Closed
slang25 opened this issue Nov 14, 2020 · 4 comments
Closed

Approval methods fail with TypeInitializationException under .NET 5 #717

slang25 opened this issue Nov 14, 2020 · 4 comments
Labels
Milestone

Comments

@slang25
Copy link
Member

slang25 commented Nov 14, 2020

As found by @gkinsman, when using things like .ShouldMatchApproved() results in an exception being thrown when targetting net5:

System.TypeInitializationException : The type initializer for 'EmptyFiles.AllFiles' threw an exception.

Repo: https://github.com/gkinsman/ShouldlyRepro

This is because the EmptyFiles package is expected to copy an EmptyFile directory to the bin folder on build, and does this via targets files in the nuget package.

Something has changed in .NET 5 around the behavior of transitive dependencies here, if we explicitly reference EmptyFile as a top-level dependency then it works. That would be a quick workaround for Shouldly users.

I'm just creating a PR in EmptyFiles which I think will handle .NET5 appropriately.

@slang25
Copy link
Member Author

slang25 commented Nov 14, 2020

Potential fix: VerifyTests/EmptyFiles#71

@SimonCropp
Copy link
Contributor

@gkinsman this should be fixed now. thanks @slang25 for the fix

@slang25
Copy link
Member Author

slang25 commented Nov 15, 2020

Brilliant, confirmed using that repo updating with just a top-level dependency on Shouldly now does the right thing 🙂

@gkinsman
Copy link

Awesome news, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants