-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Replace usages of Assembly.CodeBase with Assembly.Location #22258
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
Conversation
We should also handle the location being empty |
04d05e0
to
a5065fc
Compare
MVC already did this. I updated the StaticAssets code to manage it. The remainder of the changes are in test code. |
@@ -66,7 +66,7 @@ public static IReadOnlyList<Assembly> GetRelatedAssemblies(Assembly assembly, bo | |||
|
|||
// MVC will specifically look for related parts in the same physical directory as the assembly. | |||
// No-op if the assembly does not have a location. | |||
if (assembly.IsDynamic || string.IsNullOrEmpty(assembly.CodeBase)) | |||
if (assembly.IsDynamic || string.IsNullOrEmpty(assembly.Location)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Will this not fail with the new publish single file work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure how that works, but we should tackle that separately. This doesn't make the code more incorrect than before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, can we file an issue to track that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why check IsDynamic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had issues where users had controllers in dynamically generated assemblies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what does that check have to do with anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The way you add the controller assembly is by registering it as an application part.
- MVC will attempt to look up related parts by using the assembly's location.
- Accessing the location property on a dynamically generated assembly throws.
If the stars align, MVC will throw. Does that help?
Fixes #14827