-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Change Assembly.GetFile(s) to throw when in-memory #40593
Conversation
This is technically a breaking change, although a minor one, as the previous behavior also threw an exception. The previous exception was an IOException and this is an InvalidOperationException, so if users were catching the previous exception they would not succeed now. Fixes dotnet#40154
Tagging subscribers to this area: @vitek-karas, @agocke |
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
Outdated
Show resolved
Hide resolved
This is a little strange -- I seem to have somehow changed the order that interface implementations here are returned. Not sure how that could have happened. Ideas? |
That is really weird - does it repro locally? |
@@ -425,6 +431,12 @@ public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? vers | |||
|
|||
public override FileStream[] GetFiles(bool getResourceModules) | |||
{ | |||
if (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.
Nit: Maybe file an issue that this code should move to the shared corelib - for example the GetFiles is basically identical (just different coding style a bit).
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 generally agree. /cc @CoffeeFlux in case I'm missing anything.
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.
Some of this should be able to move, just have to keep in mind that changing the layout is hard because we want to match the legacy mono BCL in some cases (or at least, having them differ would result in a bunch of netcore-specific runtime code).
Huh, it still seems like interfaces have been re-ordered somehow, but I can't seem to get the mono tests to run locally |
src/libraries/System.Reflection/tests/TestAssembly/TestAssembly.cs
Outdated
Show resolved
Hide resolved
@@ -425,6 +431,12 @@ public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? vers | |||
|
|||
public override FileStream[] GetFiles(bool getResourceModules) | |||
{ | |||
if (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.
Some of this should be able to move, just have to keep in mind that changing the layout is hard because we want to match the legacy mono BCL in some cases (or at least, having them differ would result in a bunch of netcore-specific runtime code).
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
Co-authored-by: Dan Moseley <danmose@microsoft.com>
@danmosemsft I'm stuck on this Mono issue. Can you recommend someone to help out? |
@CoffeeFlux the mono test failures look weird. Any thoughts? |
Definitely strange. I'll take a look tomorrow. |
@CoffeeFlux Any luck? |
Interestingly, these pass locally for me even with the debug configuration.
gives me
|
@CoffeeFlux The same is true for me. Should I temporarily disable this test? |
Yeah, let's disable it for now. I'm trying to get the artifacts off CI so I can figure out what's actually going on here, and maybe I'll get somewhere this weekend—think I'm done for today though. If I can't get it sorted out this weekend and it ends up being a serious issue, I'll figure out the backport. |
@@ -490,6 +490,12 @@ public void IsEnumDefined_Invalid() | |||
[InlineData(typeof(CompoundClass4<string>), new Type[] { typeof(GenericInterface1<string>), typeof(TI_NonGenericInterface1) })] | |||
public void ImplementedInterfaces(Type type, Type[] expected) | |||
{ | |||
if (PlatformDetection.IsMonoRuntime) |
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 believe the proper way to exclude this is to open an issue on Github with the specifics and then apply the ActiveIssue attribute to the method? That file has another example.
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.
Sounds good
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 can remove this condition since ActiveIssue is added?
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 has been fixed as part of #40632
Tests failing on wasm:
|
Hmm, I'll claim that this is the right behavior -- wasm is basically load from memory. But how do I exclude these tests from running on wasm? |
You can either mark them with Or you can make the test robust against assemblies loaded from memory in general case and suppress the failing checks when Location is empty string. It would be nice to be able to run all tests in single file mode eventually, even outside Browser. |
Opened #40885 on the test failure |
This code path already threw an exception in most cases, but mostly accidentally.
This changes the code to deliberately throw an exception when the assembly is
in-memory.
Fixes #40154