-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
review & fix mono compatibility issues
- Loading branch information
1 parent
da7abf1
commit 988ff7c
Showing
14 changed files
with
115 additions
and
107 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace TechTalk.SpecFlow.Reporting | ||
{ | ||
static class ReflectionHelperExtensions | ||
{ | ||
public static T GetProperty<T>(this object source, string propertyName) | ||
{ | ||
return (T)source.GetType().GetProperty(propertyName).GetValue(source, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace TechTalk.SpecFlow.Compatibility | ||
{ | ||
internal static class ExceptionHelper | ||
{ | ||
public static void PreserveStackTrace(this Exception ex) | ||
{ | ||
//do nothing | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace TechTalk.SpecFlow.Compatibility | ||
{ | ||
internal static class ExceptionHelper | ||
{ | ||
public static void PreserveStackTrace(this Exception ex) | ||
{ | ||
// Mono's implementation of System.Exception doesn't contain the method InternalPreserveStackTrace | ||
if (MonoHelper.IsMono) | ||
MonoHelper.PreserveStackTrace(ex); | ||
else | ||
typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(ex, new object[0]); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace TechTalk.SpecFlow.Compatibility | ||
{ | ||
internal class MonoHelper | ||
{ | ||
public static bool IsMono { get; private set; } | ||
|
||
static MonoHelper() | ||
{ | ||
IsMono = Type.GetType("Mono.Runtime") != null; | ||
} | ||
|
||
public static void PreserveStackTrace(Exception ex) | ||
{ | ||
typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ex, ex.StackTrace + Environment.NewLine); | ||
} | ||
|
||
public static Assembly GetLoadedAssembly(string assemblyName) | ||
{ | ||
Assembly locatedAssembly = null; | ||
|
||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) | ||
{ | ||
AssemblyName loadedAssemblyName = assembly.GetName(); | ||
|
||
if (!loadedAssemblyName.Name.Equals(assemblyName, StringComparison.CurrentCultureIgnoreCase)) | ||
continue; | ||
|
||
locatedAssembly = assembly; | ||
} | ||
|
||
return locatedAssembly; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters