Skip to content

Commit f17ff18

Browse files
committed
Added Test for #116
1 parent 2d59afe commit f17ff18

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All of our [.NET clients can be installed](https://www.nuget.org/profiles/except
1616

1717
**This section is for development purposes only! If you are trying to use the Exceptionless .NET libraries, please get them from NuGet.**
1818

19-
1. You will need to have [Visual Studio 2015](http://www.visualstudio.com/products/visual-studio-community-vs) and [.NET Core SDK](https://www.microsoft.com/net/core) installed.
19+
1. You will need to have [Visual Studio 2015](http://www.visualstudio.com/products/visual-studio-community-vs) and [.NET Core SDK with VS Tooling](https://www.microsoft.com/net/core) installed.
2020
2. Open the `Exceptionless.Net.sln` Visual Studio solution file.
2121
3. Select `Exceptionless.SampleConsole` as the startup project.
2222
4. Run the project by pressing `F5` to start the console.

src/Exceptionless.Tests/Plugins/PluginTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,28 @@ public void HandleAggregateExceptionsPlugin_SingleInnerException() {
289289
plugin.Run(context);
290290
Assert.True(context.Cancel);
291291
}
292+
293+
[Fact (Skip = "There is a bug in the .NET Framework where non thrown exceptions with non custom stack traces cannot be computed #116")]
294+
public void CanHandleExceptionWithOverriddenStackTrace() {
295+
var client = CreateClient();
296+
var plugin = new ErrorPlugin();
297+
298+
var context = new EventPluginContext(client, new Event());
299+
context.ContextData.SetException(GetExceptionWithOverriddenStackTrace());
300+
plugin.Run(context);
301+
Assert.False(context.Cancel);
302+
303+
var error = context.Event.GetError();
304+
Assert.True(error.StackTrace.Count > 0);
305+
306+
context.ContextData.SetException(new ExceptionWithOverriddenStackTrace("test"));
307+
plugin.Run(context);
308+
Assert.False(context.Cancel);
292309

310+
error = context.Event.GetError();
311+
Assert.True(error.StackTrace.Count > 0);
312+
}
313+
293314
[Fact]
294315
public void HandleAggregateExceptionsPlugin_MultipleInnerException() {
295316
var submissionClient = new InMemorySubmissionClient();
@@ -758,6 +779,14 @@ public void VerifyDeduplicationFromFiles() {
758779
}
759780
}
760781

782+
private ExceptionWithOverriddenStackTrace GetExceptionWithOverriddenStackTrace(string message = "Test") {
783+
try {
784+
throw new ExceptionWithOverriddenStackTrace(message);
785+
} catch (ExceptionWithOverriddenStackTrace ex) {
786+
return ex;
787+
}
788+
}
789+
761790
private Exception GetException(string message = "Test") {
762791
try {
763792
throw new Exception(message);
@@ -816,5 +845,12 @@ public MyApplicationException(string message) : base(message) {
816845

817846
public override IDictionary Data { get { return SetsDataProperty; } }
818847
}
848+
849+
[Serializable]
850+
public class ExceptionWithOverriddenStackTrace : Exception {
851+
private readonly string _stackTrace = Environment.StackTrace;
852+
public ExceptionWithOverriddenStackTrace(string message) : base(message) { }
853+
public override string StackTrace => _stackTrace;
854+
}
819855
}
820856
}

0 commit comments

Comments
 (0)