Repository navigation
Tests for not calling AssemblyResolve event for CoreLib resources - #22552
Conversation
| return typeof(AppDomainTests).Assembly; | ||
| }; | ||
|
|
||
| CultureInfo previousUICulture = CultureInfo.CurrentUICulture; |
There was a problem hiding this comment.
I believe @tarekgh previously told me that this pattern is problematic for UWP, as UWP doesn't have the notion of per-thread culture and thus changing the thread's culture actually ends up changing the process' culture. You might need to either restrict the platforms on which this test runs, or use RemoteInvoke to move it out-of-proc.
There was a problem hiding this comment.
Right, we should use RemoteInvoke for this test.
|
|
||
| [Fact] | ||
| public void AssemblyResolve_LoadFromHandlerChecksForNullRequestingAssembly() | ||
| { |
There was a problem hiding this comment.
Is this going to test the right thing on Unix?
| { | ||
| Assert.ThrowsAny<Exception>(() => Assembly.LoadFrom(@"nonexistent.dll")); | ||
|
|
||
| CultureInfo previousUICulture = CultureInfo.CurrentUICulture; |
There was a problem hiding this comment.
please use RemoteInvoke for this test too. thanks.
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/corefx/issues/22555", TargetFrameworkMonikers.Uap)] | ||
| public void AssemblyResolve_LoadFromHandlerChecksForNullRequestingAssembly() | ||
| { |
There was a problem hiding this comment.
do we expect a specific exception to test against? (e.g. FileNotFound)
There was a problem hiding this comment.
I do not think this test exercises the fix - I think it will be passing even without the fix.
To exercise the fix, the file has to exist so that LoadFrom starts running at least.
There was a problem hiding this comment.
LoadFrom registers the AssemblyResolve event handler, and runs up to the last line where it throws FileNotFoundException. The handler gets called later and throws ArgumentNullException because the requesting assembly is null.
| }).Dispose(); | ||
| } | ||
|
|
||
| [Fact] |
There was a problem hiding this comment.
does this test will fail on Uap-Aot? I am asking because of TargetFrameworkMonikers.Uap will skip the test for both aot and none aot
There was a problem hiding this comment.
Also please have this test run inside the remote invoke. I prefer setting current culture in isolation in general. Also, this will simplify the code so you don't have to do finally block to rest it back
There was a problem hiding this comment.
I just wanted to unblock the CoreCLR fix, I'll be looking at the that issue for uap next
There was a problem hiding this comment.
Actually the tests should pass on uap so I'll disable only for uapaot against that issue, after switching to RemoteInvoke
There was a problem hiding this comment.
by the way, does this change need to be ported to .Net Native (I mean corert)?
There was a problem hiding this comment.
Please track it to make sure we'll not miss it there. Thanks.
There was a problem hiding this comment.
It should be the same issue linked in the attribute
There was a problem hiding this comment.
Looks like AssemblyResolve is not raised at all in CoreRT and Assembly.LoadFrom is not supported. Feels to me like both are by design to disallow changing assembly resolution. @jkotas, does that sound right?
There was a problem hiding this comment.
And because it's only aot I guess
| } | ||
|
|
||
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/corefx/issues/22555", TargetFrameworkMonikers.UapAot)] |
There was a problem hiding this comment.
Is this test still exercising the LoadFrom handler? I do not think that the LoadFrom handler is going to be called in this test - given the other half of the fix.
There was a problem hiding this comment.
The other half of the fix prevents the handler from running. I'll see if I can find a way to exercise the handler.
There was a problem hiding this comment.
I didn't find a way to exercise the handler to test this particular issue after the other half of the fix. The requesting assembly is null only for domain-neutral assemblies, which I guess is only CoreLib, and the recursion issue following the exception from the AssemblyResolve handler only happens if it's trying to resolve CoreLib resources.
There was a problem hiding this comment.
Ok. Delete the test then?
I suspect that there are other rare situations where the requesting assembly is null that we cannot think of, so I would keep the null check in the LoadFrom handler.
| Assert.Throws<NullReferenceException>(() => ((string)null).Contains("a")); | ||
| Assert.False(assemblyResolveHandlerCalled); | ||
| } | ||
| finally |
There was a problem hiding this comment.
you don't need to restore the current culture. you may get rid of the whole previousUICulture code
There was a problem hiding this comment.
this comment apply to the other test case too.
There was a problem hiding this comment.
If it doesn't hurt to keep it, I'd rather have the test undo any external changes it made even if it has no effect
There was a problem hiding this comment.
it will not hurt but it is really not needed.
…tested for with the other half of the fix
|
@dotnet-bot test this please |
|
Is this good to merge? |
|
Looks it passed all tests so I think it is good to go. Did we got coreclr fix in corefx? |
|
Yea the fix is there now, thanks! |
…tnet/corefx#22552) Tests for not calling AssemblyResolve event for CoreLib resources Part of fix for dotnet/corefx#12668 Commit migrated from dotnet/corefx@183a04e
Part of fix for dotnet/coreclr#12668
Depends on dotnet/coreclr#12999