Skip to content

Commit

Permalink
Version 2.0.5: .NET Standard Support + minidump type option in the Ba…
Browse files Browse the repository at this point in the history
…cktrace menu
  • Loading branch information
konraddysput committed Mar 19, 2020
1 parent 193a35a commit 63f1b11
Show file tree
Hide file tree
Showing 41 changed files with 133 additions and 62 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Version 2.0.5

- Unity compatibility patch / .NET 2 + 2 Subset (https://github.com/backtrace-labs/backtrace-unity/pull/10)
- Untiy .NET Standard 2.0 support,
- Expose minidump type option to Backtrace Client configuration in the UI,
- Changes LangVersion to Mono/Il2CPP depends on scripting backend - right now we will use Mono or IL2CPP - not Mono/IL2CPP value.

## Version 2.0.4

Expand Down
1 change: 1 addition & 0 deletions Editor/Menu/BacktraceClientConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BacktraceClientConfigurationEditor : UnityEditor.Editor
#if UNITY_2018_4_OR_NEWER
public const string LABEL_IGNORE_SSL_VALIDATION = "Ignore SSL validation";
#endif
public const string LABEL_MINIDUMP_SUPPORT = "Minidump type";
public const string LABEL_DEDUPLICATION_RULES = "Deduplication rules";
public const string LABEL_GAME_OBJECT_DEPTH = "Game object depth limit";

Expand Down
8 changes: 8 additions & 0 deletions Editor/Menu/BacktraceConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class BacktraceConfigurationEditor : UnityEditor.Editor

public const string LABEL_DESTROY_CLIENT_ON_SCENE_LOAD = "Destroy client on new scene load (false - Backtrace managed)";

public const string LABEL_MINIDUMP_SUPPORT = "Minidump type";

public const string LABEL_PATH = "Backtrace database path";
public const string LABEL_AUTO_SEND_MODE = "Auto send mode";
public const string LABEL_CREATE_DATABASE_DIRECTORY = "Create database directory";
Expand Down Expand Up @@ -83,6 +85,12 @@ public override void OnInspectorGUI()
EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
}

#if UNITY_STANDALONE_WIN
EditorGUILayout.HelpBox("Minidump support works only on Windows machines.", MessageType.Warning);
SerializedProperty miniDumpType = serializedObject.FindProperty("MinidumpType");
EditorGUILayout.PropertyField(miniDumpType, new GUIContent(LABEL_MINIDUMP_SUPPORT));
#endif

SerializedProperty autoSendMode = serializedObject.FindProperty("AutoSendMode");
EditorGUILayout.PropertyField(autoSendMode, new GUIContent(LABEL_AUTO_SEND_MODE));

Expand Down
7 changes: 7 additions & 0 deletions Editor/Menu/BacktraceDatabaseConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
}

#if UNITY_STANDALONE_WIN
settings.MinidumpType = (MiniDumpType)EditorGUILayout.EnumPopup(LABEL_MINIDUMP_SUPPORT, settings.MinidumpType);
#else
settings.MinidumpType = MiniDumpType.None;

#endif
settings.AutoSendMode = EditorGUILayout.Toggle(LABEL_AUTO_SEND_MODE, settings.AutoSendMode);
settings.CreateDatabase = EditorGUILayout.Toggle(LABEL_CREATE_DATABASE_DIRECTORY, settings.CreateDatabase);
settings.MaxRecordCount = EditorGUILayout.IntField(LABEL_MAX_REPORT_COUNT, settings.MaxRecordCount);
Expand Down
8 changes: 8 additions & 0 deletions src/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Backtrace.Unity
public class BacktraceClient : MonoBehaviour, IBacktraceClient
{
public BacktraceConfiguration Configuration;

public bool Enabled { get; private set; }

/// <summary>
Expand Down Expand Up @@ -193,6 +194,13 @@ public void Refresh()
}

Enabled = true;
#if UNITY_STANDALONE_WIN
MiniDumpType = Configuration.MinidumpType;
#else
MiniDumpType = MiniDumpType.None;

#endif

Annotations.GameObjectDepth = Configuration.GameObjectDepth;
HandleUnhandledExceptions();
_reportLimitWatcher = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));
Expand Down
33 changes: 33 additions & 0 deletions src/Common/MiniDumpExceptionInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ namespace Backtrace.Unity.Common
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct MiniDumpExceptionInformation
{

//====================================================================
// Win32 Exception stuff
// These are mostly interesting for Structured exception handling,
// but need to be exposed for all exceptions (not just SEHException).
//====================================================================
//[System.Security.SecurityCritical] // auto-generated_required
//[System.Runtime.Versioning.ResourceExposure(System.Runtime.Versioning.ResourceScope.None)]
//[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
//[System.Runtime.InteropServices.ComVisible(true)]
//public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers();

/// <summary>
/// current thread id
/// </summary>
Expand Down Expand Up @@ -44,6 +56,27 @@ internal static MiniDumpExceptionInformation GetInstance(MinidumpException excep
exp.ThreadId = SystemHelper.GetCurrentThreadId();
exp.ClientPointers = false;
exp.ExceptionPointers = IntPtr.Zero;
// right now Unity environment doesn't support
// GetExceptionPointers
// because of that we cannot pass exception pointer to minidump write method

//right now GetExceptionPointers method is not available in .NET Standard
//#if !NET_STANDARD_2_0
// try
// {
// if (exceptionInfo == MinidumpException.Present)
// {
// exp.ExceptionPointers = GetExceptionPointers();
// }
// }
// catch (Exception e)
// {
//#if DEBUG
// UnityEngine.Debug.Log(string.Format("Cannot add exception information to minidump file. Reason: {0}", e));
//#endif
// ///Operation not supported;
// }
//#endif
return exp;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/Bson/BsonBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void Flush()

public void Close()
{
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
_writer.Close();
#else
_writer.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/Bson/BsonReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public override void Close()

if (CloseInput && _reader != null)
{
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
_reader.Close();
#else
_reader.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/Bson/BsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public override void WriteValue(char value)
{
base.WriteValue(value);
string s = null;
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
s = value.ToString(CultureInfo.InvariantCulture);
#else
s = value.ToString();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/Converters/BinaryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
using System;
using System.Globalization;
using Backtrace.Newtonsoft.Utilities;
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/JsonConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ internal static string ToString(Guid value, char quoteChar)
{
string text;
string qc;
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
text = value.ToString("D", CultureInfo.InvariantCulture);
qc = quoteChar.ToString(CultureInfo.InvariantCulture);
#else
Expand Down
4 changes: 2 additions & 2 deletions src/JsonNet/JsonException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Backtrace.Newtonsoft
/// <summary>
/// The exception thrown when an error occurs during JSON serialization or deserialization.
/// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
[Serializable]
#endif
[Preserve]
Expand Down Expand Up @@ -70,7 +70,7 @@ public JsonException(string message, Exception innerException)
{
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
/// <summary>
/// Initializes a new instance of the <see cref="JsonException"/> class.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/JsonReaderException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public JsonReaderException(string message, Exception innerException)
{
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
/// <summary>
/// Initializes a new instance of the <see cref="JsonReaderException"/> class.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/JsonNet/JsonSerializationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Backtrace.Newtonsoft
/// <summary>
/// The exception thrown when an error occurs during JSON serialization or deserialization.
/// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
[Serializable]
#endif
[Preserve]
Expand Down Expand Up @@ -68,7 +68,7 @@ public JsonSerializationException(string message, Exception innerException)
{
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializationException"/> class.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/JsonTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ public override void Close()

if (CloseInput && _reader != null)
{
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
_reader.Close();
#else
_reader.Dispose();
Expand Down
4 changes: 2 additions & 2 deletions src/JsonNet/JsonTextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public override void Close()

if (CloseOutput && _writer != null)
{
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
_writer.Close();
#else
_writer.Dispose();
Expand Down Expand Up @@ -664,7 +664,7 @@ public override void WriteValue(Guid value)

string text = null;

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
text = value.ToString("D", CultureInfo.InvariantCulture);
#else
text = value.ToString("D");
Expand Down
4 changes: 2 additions & 2 deletions src/JsonNet/JsonWriterException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Backtrace.Newtonsoft
/// <summary>
/// The exception thrown when an error occurs while reading JSON text.
/// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
[Serializable]
#endif
[Preserve]
Expand Down Expand Up @@ -74,7 +74,7 @@ public JsonWriterException(string message, Exception innerException)
{
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
/// <summary>
/// Initializes a new instance of the <see cref="JsonWriterException"/> class.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/JsonNet/Linq/BacktraceJObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Backtrace.Newtonsoft.Linq
/// </summary>
[Preserve]
public class BacktraceJObject : BacktraceJContainer, IDictionary<string, JToken>, INotifyPropertyChanged
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
, ICustomTypeDescriptor
#endif
#if !(NET20 || PORTABLE40 || PORTABLE)
Expand Down Expand Up @@ -215,7 +215,7 @@ internal override void MergeItem(object content, JsonMergeSettings settings)
internal void InternalPropertyChanged(BacktraceJProperty childProperty)
{
OnPropertyChanged(childProperty.Name);
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
if (_listChanged != null)
{
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, IndexOfItem(childProperty)));
Expand Down Expand Up @@ -721,7 +721,7 @@ protected virtual void OnPropertyChanging(string propertyName)
}
#endif

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
// include custom type descriptor on JObject rather than use a provider because the properties are specific to a type

#region ICustomTypeDescriptor
Expand Down
18 changes: 9 additions & 9 deletions src/JsonNet/Linq/JContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ namespace Backtrace.Newtonsoft.Linq
/// </summary>
[Preserve]
public abstract class BacktraceJContainer : JToken, IList<JToken>
#if !(DOTNET || PORTABLE || PORTABLE40)
#if !(DOTNET || PORTABLE || PORTABLE40 || NET_STANDARD_2_0)
, ITypedList, IBindingList
#endif
, IList
#if !UNITY_WINRT || UNITY_EDITOR || (UNITY_WP8 && !UNITY_WP_8_1)
, INotifyCollectionChanged
#endif
{
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
internal ListChangedEventHandler _listChanged;
#pragma warning disable CS0436 // Type conflicts with imported type
internal AddingNewEventHandler _addingNew;
Expand Down Expand Up @@ -142,7 +142,7 @@ internal virtual IList<JToken> CreateChildrenCollection()
return new List<JToken>();
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
#pragma warning disable CS0436 // Type conflicts with imported type
/// <summary>
/// Raises the <see cref="AddingNew"/> event.
Expand Down Expand Up @@ -400,7 +400,7 @@ internal virtual void InsertItem(int index, JToken item, bool skipParentCheck)

children.Insert(index, item);

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
if (_listChanged != null)
{
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
Expand Down Expand Up @@ -448,7 +448,7 @@ internal virtual void RemoveItemAt(int index)

children.RemoveAt(index);

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
if (_listChanged != null)
{
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
Expand Down Expand Up @@ -528,7 +528,7 @@ internal virtual void SetItem(int index, JToken item)
existing.Previous = null;
existing.Next = null;

#if !(DOTNET || PORTABLE || PORTABLE40)
#if !(DOTNET || PORTABLE || PORTABLE40 || NET_STANDARD_2_0)
if (_listChanged != null)
{
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
Expand Down Expand Up @@ -557,7 +557,7 @@ internal virtual void ClearItems()

children.Clear();

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
if (_listChanged != null)
{
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
Expand Down Expand Up @@ -891,7 +891,7 @@ internal int ContentsHashCode()
return hashCode;
}

#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
string ITypedList.GetListName(PropertyDescriptor[] listAccessors)
{
return string.Empty;
Expand Down Expand Up @@ -1067,7 +1067,7 @@ object ICollection.SyncRoot
#endregion

#region IBindingList Members
#if !(DOTNET || PORTABLE || PORTABLE40)
#if !(DOTNET || PORTABLE || PORTABLE40 || NET_STANDARD_2_0)
void IBindingList.AddIndex(PropertyDescriptor property)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/JsonNet/Linq/JToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Backtrace.Newtonsoft.Linq
/// </summary>
[Preserve]
public abstract class JToken : IJEnumerable<JToken>, IJsonLineInfo
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
, ICloneable
#endif
#if !((NET35 || NET_2_0 || NET_2_0_SUBSET) || NET20 || PORTABLE40 )
Expand Down Expand Up @@ -2105,7 +2105,7 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)
}
#endif

#if !(DOTNET || PORTABLE || PORTABLE40)
#if !(DOTNET || PORTABLE || PORTABLE40 || NET_STANDARD_2_0)
object ICloneable.Clone()
{
return DeepClone();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonNet/Linq/JTokenWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public override void WriteValue(char value)
{
base.WriteValue(value);
string s = null;
#if !(DOTNET || PORTABLE40 || PORTABLE)
#if !(DOTNET || PORTABLE40 || PORTABLE || NET_STANDARD_2_0)
s = value.ToString(CultureInfo.InvariantCulture);
#else
s = value.ToString();
Expand Down
Loading

0 comments on commit 63f1b11

Please sign in to comment.