Support `HostingEnvironment.MapPath`
AvremelM opened this issue · 8 comments
Summary
Support HostingEnvironment.MapPath
in SystemWebAdapters.
Motivation and goals
- This was (I believe) intended to be added as part of #368, but was omitted for some reason, perhaps unintentionally.
- It builds on #184, which added
HttpServerUtility.MapPath
- In the ReferenceSource
HttpServerUtility.MapPath
(and all other similar methods, e.g.,HttpRequest.MapPath
andVirtualPath.MapPath
) all actually useHostingEnvironment.MapPath
/HostingEnvironment.MapPathInternal
internally.- See HttpServerUtility.cs -> HttpRequest.cs -> VirtualPath.cs
- For that reason, it has long been popular "wisdom" to prefer HostingEnvironment.MapPath, see e.g., here.
Examples
HostingEnvironment.MapPath("~/foo");
HostingEnvironment.MapPath("/foo");
This was (I believe) intended to be added as part of #368, but was omitted for some reason, perhaps unintentionally.
Yup, it was planned to be a part of that, but got left out. I believe the building blocks should be there - would you be able to submit a PR to enable it?
I may be able to if I find time. I'll have to take a closer look at how things are usually done in this repo, I'd rather not submit noncompliant code if I can help it.
@twsouthwick Is there any documentation or discussions in this project about copying over (and adapting) code from @microsoft/referencesource?
I.e., Are we allowed to? Is it even worth the effort? Is it a bad idea to even try?
Is there any documentation or discussions in this project about copying over (and adapting) code from @microsoft/referencesource?
I.e., Are we allowed to? Is it even worth the effort? Is it a bad idea to even try?
Yup that's how we've done it. microsoft/referencesource was changed to the MIT license a few years back specifically for these kinds of efforts (https://github.com/microsoft/referencesource?tab=readme-ov-file#license). There are still some files that are licensed differently, but as long as you're not using one of those, it's fine