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

Safeguards loading of assemblies during load script generation. #3098

Merged
merged 3 commits into from
Feb 28, 2018
Merged

Safeguards loading of assemblies during load script generation. #3098

merged 3 commits into from
Feb 28, 2018

Conversation

ChrSteinert
Copy link
Contributor

This is a super naive approach to the problem of loading native assembies that will fail with a BadImageFormatException.

Fixes #3097 .
I confirmed, that this fixes the error for https://github.com/ChrSteinert/Paket-3097

Copy link
Member

@matthid matthid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching everything is error prone

try
(AssemblyDefinition.ReadAssembly path, FileInfo(path)) |> Some
with
| _ -> None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that pattern, can we at least catch only the relevant exception or otherwise log the error as warning?

try
(AssemblyDefinition.ReadAssembly (f.FullName:string), f) |> Some
with
| _ -> None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, getting rid of them is hard, because you do not know what you have catched previously ;).
A PR or adding the other case is welcome as well ;)

@matthid
Copy link
Member

matthid commented Feb 28, 2018

Thanks for taking care of this :)

@ChrSteinert
Copy link
Contributor Author

My pleasure!

@@ -98,7 99,13 @@ type DependencyCache (lockFile:LockFile) =
installModel
|> InstallModel.getLegacyReferences (TargetProfile.SinglePlatform framework)
|> Seq.map (fun l -> l.Path)
|> Seq.map (fun path -> AssemblyDefinition.ReadAssembly path, FileInfo(path))
|> Seq.map (fun path ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wh not choose/pick here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more question: What path is it here? Why is someone putting invalid references into the /lib folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are invalid in the sense that they are native x64 or x86 dlls that the assembly loader might not like to load.

And yes, the direct choose is obviously a better way.

@@ -121,7 128,11 @@ type DependencyCache (lockFile:LockFile) =

let assemblyFilePerAssemblyDef =
libs |> Seq.map (fun (f:FileInfo) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not choose/pick directly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously here as well.

@forki forki merged commit 12c8c02 into fsprojects:master Feb 28, 2018
@forki
Copy link
Member

forki commented Feb 28, 2018

thanks

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.

Generate Load Scripts fails with BadImageFormatException on Microsoft.TestPlatform.TestHost
3 participants