You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[mono] Test failed on Helix: System.Reflection.Tests.AssemblyTests.LoadFile_NoSuchPath_ThrowsFileNotFoundException #31650
We seem to throw the correct exception, but the test is failing because the error message itself does not contain the filename and instead has it specified below. This seems unnecessarily strict (though our message isn't great), but if we really want the path included in both places it should be an easy enough fix.
ryan@kenshin:~/git/runtime/src/mono/netcore$ make run-sample-coreclr
/Users/ryan/git/runtime/.dotnet/dotnet run -c Debug -p sample/HelloWorld
/Users/ryan/git/runtime/src/mono/netcore/b2505d63f1334c23ab1081e6a9ad738e
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly '/Users/ryan/git/runtime/src/mono/netcore/b2505d63f1334c23ab1081e6a9ad738e'. The system cannot find the file specified.
File name: '/Users/ryan/git/runtime/src/mono/netcore/b2505d63f1334c23ab1081e6a9ad738e'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFile(String path)
at HelloWorld.Program.Main(String[] args) in /Users/ryan/git/runtime/src/mono/netcore/sample/HelloWorld/Program.cs:line 13
make: *** [run-sample-coreclr] Error 134
ryan@kenshin:~/git/runtime/src/mono/netcore$ make run-sample
/Users/ryan/git/runtime/.dotnet/dotnet msbuild /t:PatchLocalMonoDotnet /p:CoreClrTestConfig=Release /p:Configuration=Debug ../mono.proj
Microsoft (R) Build Engine version 16.6.0-preview-20071-03+4400fa4e1 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
COMPlus_DebugWriteToStdErr=1 ../../../.dotnet-mono/dotnet run -c Debug -p sample/HelloWorld
/Users/ryan/git/runtime/src/mono/netcore/91adbc16a9bc4d40b000352dae4f4021
Unhandled Exception:
System.IO.FileNotFoundException: Invalid Image
File name: '/Users/ryan/git/runtime/src/mono/netcore/91adbc16a9bc4d40b000352dae4f4021'
at System.Runtime.Loader.AssemblyLoadContext.InternalLoadFromPath(String assemblyPath, String nativeImagePath)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFile(String path)
at HelloWorld.Program.Main(String[] args)
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Invalid Image
File name: '/Users/ryan/git/runtime/src/mono/netcore/91adbc16a9bc4d40b000352dae4f4021'
at System.Runtime.Loader.AssemblyLoadContext.InternalLoadFromPath(String assemblyPath, String nativeImagePath)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFile(String path)
at HelloWorld.Program.Main(String[] args)
make: *** [run-sample] Error 1
I think I made the CoreCLR change -- where we have the file, we put it in the message, and where it's in the message, ToString doesn't bother repeating it on the next line. The reasoning behind this (beyond compact is nice) is that it's common to see an exception stringized into a log, and sometimes logs contain output from several concurrent activities that can get interleaved (eg., build logs). Having the value on the same line as the message keeps them together. I did something similar for some others, eg the argument for ArgumentException.
Having said that, I can't find such a change, but that's the philosophy. (It's good to have the file name in FileName, also in the message, and ToString should only show the latter.)
Makes sense to me. It's an easy enough change and I don't see any harm in it, so if you want to leave the tests I'll add it to our messages (and maybe clean them up a bit in the process - I'm not a big fan of just "Invalid Image" everywhere).
Activity
CoffeeFlux commentedon Feb 7, 2020
We seem to throw the correct exception, but the test is failing because the error message itself does not contain the filename and instead has it specified below. This seems unnecessarily strict (though our message isn't great), but if we really want the path included in both places it should be an easy enough fix.
Sample program:
Mono/CoreCLR output:
danmoseley commentedon Feb 10, 2020
I think I made the CoreCLR change -- where we have the file, we put it in the message, and where it's in the message, ToString doesn't bother repeating it on the next line. The reasoning behind this (beyond compact is nice) is that it's common to see an exception stringized into a log, and sometimes logs contain output from several concurrent activities that can get interleaved (eg., build logs). Having the value on the same line as the message keeps them together. I did something similar for some others, eg the argument for ArgumentException.
danmoseley commentedon Feb 10, 2020
Having said that, I can't find such a change, but that's the philosophy. (It's good to have the file name in FileName, also in the message, and ToString should only show the latter.)
CoffeeFlux commentedon Feb 10, 2020
Makes sense to me. It's an easy enough change and I don't see any harm in it, so if you want to leave the tests I'll add it to our messages (and maybe clean them up a bit in the process - I'm not a big fan of just "Invalid Image" everywhere).
[mono] Include filename in Invalid image error messages (#19112)