Skip to content

Handle assembly loading errors at composition time #280

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

Merged
merged 1 commit into from
Jul 16, 2015

Conversation

daviwil
Copy link
Contributor

@daviwil daviwil commented Jul 16, 2015

The default implementation of MEF's DirectoryCatalog does not
handle ReflectionTypeLoadExceptions that occur when assemblies
in the specified directory are loaded. This causes the full
assembly loading process to stop, meaning that no rules will
be found. When running Script Analyzer in a folder with a lot
of DLLs, this type of error becomes more likely. This change
introduces a new SafeDirectoryCatalog type which is more
resilient to this problem.

Also, there is a check that determines whether any rules have
been loaded before continuing. This check was prone to throwing
NullReferenceExceptions when MEF composition fails. I changed
that logic to be more resilient to potential null values.

The default implementation of MEF's DirectoryCatalog does not
handle ReflectionTypeLoadExceptions that occur when assemblies
in the specified directory are loaded.  This causes the full
assembly loading process to stop, meaning that no rules will
be found.  When running Script Analyzer in a folder with a lot
of DLLs, this type of error becomes more likely.  This change
introduces a new SafeDirectoryCatalog type which is more resilient
to this problem.

Also, there is a check that determines whether any rules have
been loaded before continuing.  This check was prone to throwing
NullReferenceExceptions when MEF composition fails.  I changed
that logic to be more resilient to potential null values.
@msftclas
Copy link

Hi @daviwil, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (David Wilson (WSSC)). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@raghushantha
Copy link
Member

Looks good. Will Merge the PR.

raghushantha added a commit that referenced this pull request Jul 16, 2015
Handle assembly loading errors at composition time
@raghushantha raghushantha merged commit 96652e2 into PowerShell:development Jul 16, 2015
@daviwil
Copy link
Contributor Author

daviwil commented Jul 16, 2015

Thanks Raghu!

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.

3 participants