Skip to content

Commit 401c2a9

Browse files
Oscar Morantespacepluk
authored andcommitted
do not crash if Assembly has no Location
1 parent 6faace0 commit 401c2a9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Clojure/Clojure/Lib/RT.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,16 +3529,25 @@ public static IEnumerable<string> GetFindFilePaths()
35293529
return GetFindFilePathsRaw().Distinct();
35303530
}
35313531

3532+
static string GetAssemblyPath(Assembly assy) {
3533+
if (assy == null || String.IsNullOrEmpty(assy.Location)) {
3534+
return null;
3535+
}
3536+
3537+
return Path.GetDirectoryName(assy.Location);
3538+
}
3539+
35323540
static IEnumerable<string> GetFindFilePathsRaw()
35333541
{
35343542
yield return System.Environment.CurrentDirectory;
35353543
yield return Path.Combine(System.Environment.CurrentDirectory, "bin");
35363544
yield return Directory.GetCurrentDirectory();
3537-
yield return Path.GetDirectoryName(typeof(RT).Assembly.Location);
35383545

3539-
Assembly assy = Assembly.GetEntryAssembly();
3540-
if ( assy != null )
3541-
yield return Path.GetDirectoryName(assy.Location);
3546+
string assyPath;
3547+
assyPath = GetAssemblyPath(typeof(RT).Assembly);
3548+
if (assyPath != null) yield return assyPath;
3549+
assyPath = GetAssemblyPath(Assembly.GetEntryAssembly());
3550+
if (assyPath != null) yield return assyPath;
35423551

35433552
string rawpaths = (string)System.Environment.GetEnvironmentVariable(ClojureLoadPathString);
35443553
if (rawpaths == null)

0 commit comments

Comments
 (0)