Skip to content

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

Merged
merged 1 commit into from
May 27, 2020

Conversation

pranavkm
Copy link
Contributor

Fixes #14827

@pranavkm pranavkm requested a review from javiercn May 27, 2020 02:02
@pranavkm pranavkm added this to the 5.0.0-preview6 milestone May 27, 2020
@davidfowl
Copy link
Member

We should also handle the location being empty

@pranavkm pranavkm force-pushed the prkrishn/assemblylocation branch from 04d05e0 to a5065fc Compare May 27, 2020 13:52
@pranavkm
Copy link
Contributor Author

We should also handle the location being empty

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))
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Why check IsDynamic?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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?

@pranavkm pranavkm merged commit dc29f03 into master May 27, 2020
@pranavkm pranavkm deleted the prkrishn/assemblylocation branch May 27, 2020 19:01
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.

[MVC] Replace usages of Assembly.CodeBase with Assembly.Location
3 participants