Skip to content

Commit ccadee5

Browse files
author
David Karlaš
committed
Bug 50464 - Running xunit.runner.console.exe on xunit.net test DLL from Xamarin Studio as a Default Run Configuration causes exception
In theory at time of AssemblyUnloadEvent exception ERR_UNLOADED when fetching Location should never happen since we fetched and cached location value at time of AssemblyLoadEvent. But since there is bug in runtime which sometimes doesn’t sent AssemblyLoad event, we can get exception… Since we never received assembly it’s reasonable to assume source_to_type doesn’t have type of that assembly, hence it doesn’t need remove. For Unloaded assembly message, it’s better to say “<unknown>” then crash.
1 parent 3051621 commit ccadee5

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Mono.Debugging.Soft/SoftDebuggerSession.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,16 @@ void HandleAssemblyUnloadEvents (AssemblyUnloadEvent[] events)
19201920
var asm = events [0].Assembly;
19211921
if (events.Length > 1 && events.Any (a => a.Assembly != asm))
19221922
throw new InvalidOperationException ("Simultaneous AssemblyUnloadEvents for multiple assemblies");
1923-
1923+
1924+
string assemblyLocation;
1925+
try {
1926+
assemblyLocation = asm.Location;
1927+
} catch (CommandException ex) {
1928+
if (ex.ErrorCode != ErrorCode.ERR_UNLOADED)
1929+
throw ex;
1930+
assemblyLocation = null;
1931+
}
1932+
19241933
if (assemblyFilters != null) {
19251934
int index = assemblyFilters.IndexOf (asm);
19261935
if (index != -1)
@@ -1962,10 +1971,12 @@ void HandleAssemblyUnloadEvents (AssemblyUnloadEvent[] events)
19621971
}
19631972
}
19641973

1965-
foreach (var pair in source_to_type) {
1966-
pair.Value.RemoveAll (m => PathComparer.Equals (m.Assembly.Location, asm.Location));
1974+
if (assemblyLocation != null) {
1975+
foreach (var pair in source_to_type) {
1976+
pair.Value.RemoveAll (m => PathComparer.Equals (m.Assembly.Location, assemblyLocation));
1977+
}
19671978
}
1968-
OnDebuggerOutput (false, string.Format ("Unloaded assembly: {0}\n", asm.Location));
1979+
OnDebuggerOutput (false, string.Format ("Unloaded assembly: {0}\n", assemblyLocation ?? "<unknown>"));
19691980
}
19701981

19711982
void HandleVMStartEvents (VMStartEvent[] events)

0 commit comments

Comments
 (0)