This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from techno-dwarf-works/dev
Update v1.2.3
- Loading branch information
Showing
10 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
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,33 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Better.Extensions.Runtime | ||
{ | ||
public static class ExceptionExtensions | ||
{ | ||
private const string ExceptionMessageFieldName = "_message"; | ||
private static readonly FieldInfo _messageField; | ||
|
||
static ExceptionExtensions() | ||
{ | ||
_messageField = GetExceptionMessageField(); | ||
} | ||
|
||
private static FieldInfo GetExceptionMessageField() | ||
{ | ||
var type = typeof(Exception); | ||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; | ||
return type.GetField(ExceptionMessageFieldName, flags); | ||
} | ||
|
||
public static void ReplaceExceptionMessageField(this Exception exception, string message) | ||
{ | ||
_messageField.SetValue(exception, message); | ||
} | ||
|
||
public static void ReplaceExceptionMessageField(this Exception exception, object message) | ||
{ | ||
exception.ReplaceExceptionMessageField(message.ToString()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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.Text; | ||
|
||
namespace Better.Extensions.Runtime | ||
{ | ||
public static class StringBuilderExtensions | ||
{ | ||
public static StringBuilder AppendLine(this StringBuilder builder, int value) | ||
{ | ||
return builder.AppendLine(value.ToString()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,72 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Debug = UnityEngine.Debug; | ||
using Object = UnityEngine.Object; | ||
|
||
namespace Better.Extensions.Runtime | ||
{ | ||
public static class DebugUtility | ||
{ | ||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException<T>(string message) where T : Exception, new() | ||
{ | ||
var exception = new T(); | ||
exception.ReplaceExceptionMessageField(message); | ||
Debug.LogException(exception); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException<T>(object message) where T : Exception, new() | ||
{ | ||
LogException<T>(message.ToString()); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException<T>(string message, Object context) where T : Exception, new() | ||
{ | ||
var exception = new T(); | ||
exception.ReplaceExceptionMessageField(message); | ||
Debug.LogException(exception, context); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException<T>(object message, Object context) where T : Exception, new() | ||
{ | ||
LogException<T>(message.ToString(), context); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException(string message) | ||
{ | ||
var exception = new Exception(message); | ||
Debug.LogException(exception); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException(object message) | ||
{ | ||
LogException(message.ToString()); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException(string message, Object context) | ||
{ | ||
var exception = new Exception(message); | ||
Debug.LogException(exception, context); | ||
} | ||
|
||
[DebuggerHidden] | ||
[DebuggerNonUserCode] | ||
public static void LogException(object message, Object context) | ||
{ | ||
LogException(message.ToString(), context); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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