Check whether file is found before trying to dereference it #759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #758
The current code causes a NullReferenceException when the assembly cannot be found so this switches the logic slightly and also adds some additional detail to describe how the DOTNET_ASSEMBLY_SEARCH_PATHS environment variable is set to help users understand why their dll's are not being loaded.
I wasn't sure on writing a test for this, if it needs a test let me know, I did think about adding a check for a FileNotFoundException for a file that doesn't exist and call
UdfSerDe.Deserialize(UdfData udfData)
.I was also unsure what to throw if the assembly had been loaded but the type couldn't for some reason, I went with TypeLoadException but let me know if you think something else is more appropriate.
The point of this really is that I have seen this pop up a few times and the NullReferenceException hides a genuinely useful FileNotFoundException.
Ed