-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Wasm]Adjust AppContext.BaseDirectory and enable Microsoft.Extensions tests #38721
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
Changes from all commits
3f67297
d7960c6
3f7e5a7
db4159e
f6ad87e
3dcbda4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using Xunit; | ||
|
|
||
| [assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using Xunit; | ||
|
|
||
| [assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.IO; | ||
| using System.Reflection; | ||
|
|
||
| namespace System | ||
| { | ||
| public static partial class AppContext | ||
| { | ||
| private static string GetBaseDirectoryCore() | ||
| { | ||
| // Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly | ||
| string? directory = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); | ||
|
|
||
| if (directory == null) | ||
| return string.Empty; | ||
|
|
||
| if (!Path.EndsInDirectorySeparator(directory)) | ||
| directory += PathInternal.DirectorySeparatorCharAsString; | ||
|
|
||
| return directory; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace System | ||
| { | ||
| public static partial class AppContext | ||
| { | ||
| private static string GetBaseDirectoryCore() | ||
| { | ||
| // GetEntryAssembly().Location returns an empty string for wasm | ||
| // Until that can be easily changed, work around the problem here. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this working around Would it make more sense for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the wording is incorrect. AppContext.BaseDirectory is returning "", which is causing a bunch of tests to fail. I feel returning "/" isn't any less wrong than "". The benefit of "/" being that it works within other parts of libraries.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that returning "/" is more wrong than "". If we were optimizing for making maximum tests to pass without any changes, we would also change Assembly.Location to return What are the tests that fail before this change and pass with this change?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ll follow up with a list. Since the emscripten vfs mounts at /, I think my change does make sense.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the application binaries show up as files at The docs for AppContext.BaseDirectory say: Gets the pathname of the base directory that the assembly resolver uses to probe for assemblies.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are the tests that fail expecting some sort of value out of BaseDirectory. Regarding application binaries, my understanding is that we load everything essentially from an in-memory byte array. That strikes me as an implementation detail though. If the user, for example, downloads I still think setting "/" is the way to go. That said, there definitely does seem to be a bunch of little hosting twists that we should try to understand / surface better.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the types exercised by there tests actually work on Wasm Browser? E.g. can I add configuration file to my .csproj file and then get the file picked up by the default
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. If you look at the test results, we're likely at least somewhat functional. https://gist.github.com/steveisok/370622cdb0c41ff2bc3b439c730484e4
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have issues opened on making sure that the end-to-end works for these libraries. More passing tests does not necessarily mean that these libraries are actually usable by customers. The linker analysis for single file unfriendly APIs (#38405) should help us get a better handle on this eventually. If you believe that returning |
||
| return "/"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add explicit test for this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I think it's acceptable to just rely on the tests that use this property to pass. |
||
| } | ||
| } | ||
| } | ||
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 think this can be removed as well, it doesn't do anything useful anymore since this is about the old .NET Framework-based Mono. We can do that in a separate PR, filed #38878.