Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

DependencyContextAssemblyProvider assumes the entry assembly has a .deps.json file #4136

Closed
DavidObando opened this issue Feb 22, 2016 · 9 comments
Assignees
Milestone

Comments

@DavidObando
Copy link
Member

Tests in the aspnet/Performance repo are failing because DependencyContextAssemblyProvider.GetCandidateLibraries() assumes that DependencyContext.Default is not null. Our tests are throwing a System.NullReferenceException when accessing DependencyContext.Default as it's null.

Note that the current implementation of DependencyContext.get_Default() allows for it to be null when the entry assembly (in our case xunit.console.exe) doesn't provide a dependencies description file (in our case xunit.console.deps.json).

Let me know if I'm interpreting something wrong, this has the Performance repository blocked aspnet/Performance#62.

@NTaylorMullen @muratg @sajayantony

@davidfowl
Copy link
Member

That's fixed in #4088

@muratg
Copy link
Contributor

muratg commented Feb 22, 2016

@pranavkm will check his change in soon, so this should be a non-issue soon.

@pranavkm
Copy link
Contributor

Fixed in 5b805bb

@pranavkm pranavkm reopened this Feb 25, 2016
@pranavkm
Copy link
Contributor

We still null ref with this change. Should we throw an exception stating you should set the preserveCompilationContext flag if DependencyContext.Load returns null?

@pranavkm pranavkm added the bug label Feb 25, 2016
@pranavkm pranavkm added this to the 1.0.0-rc2 milestone Feb 25, 2016
@pranavkm pranavkm self-assigned this Feb 25, 2016
@pranavkm
Copy link
Contributor

Self assigning since this would be a relatively small fix.

@davidfowl
Copy link
Member

Then we need 2 APIs. TryLoad and Load

@davidfowl
Copy link
Member

Why are we still null reffing?

@pranavkm
Copy link
Contributor

There's an obvious bug in my code (I call DependencyContext.Default) - but what happens when DependencyContext.Load returns null? Do we only look at the assembly specified by IApplicationEnvironment.ApplicationName for controllers? Or should we throw an error saying you probably forgot to include the setting in project.json?

@davidfowl
Copy link
Member

There's an obvious bug in my code (I call DependencyContext.Default) - but what happens when DependencyContext.Load returns null?

There's no deps file so act like it returns 0 results.

Do we only look at the assembly specified by IApplicationEnvironment.ApplicationName for controllers?

Yes. IApplicationEnvironment.ApplicationName is ASP.NET's abstraction over entry assembly.

Or should we throw an error saying you probably forgot to include the setting in project.json?

This is tricky. Right now I would say don't throw. Especially in light of this dotnet/cli@acd581c

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

No branches or pull requests

4 participants