parent
43c92b54e5
commit
1b99d61cf3
@ -511,6 +511,11 @@ namespace System.Diagnostics
|
||||
|
||||
private static string GetPrefix(ParameterInfo parameter)
|
||||
{
|
||||
if (Attribute.IsDefined(parameter, typeof(ParamArrayAttribute), false))
|
||||
{
|
||||
return "params";
|
||||
}
|
||||
|
||||
if (parameter.IsOut)
|
||||
{
|
||||
return "out";
|
||||
|
||||
40
test/Ben.Demystifier.Test/ParameterParamTests.cs
Normal file
40
test/Ben.Demystifier.Test/ParameterParamTests.cs
Normal file
@ -0,0 +1,40 @@
|
||||
namespace Ben.Demystifier.Test
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Xunit;
|
||||
|
||||
public class ParameterParamTests
|
||||
{
|
||||
[Fact]
|
||||
public void DemistifiesMethodWithParams()
|
||||
{
|
||||
Exception dex = null;
|
||||
try
|
||||
{
|
||||
MethodWithParams(1, 2, 3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dex = e.Demystify();
|
||||
}
|
||||
|
||||
// Assert
|
||||
var stackTrace = dex.ToString();
|
||||
stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace);
|
||||
var trace = string.Join(string.Empty, stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
|
||||
|
||||
var expected = string.Join(string.Empty, new[] {
|
||||
"System.ArgumentException: Value does not fall within the expected range.",
|
||||
" at bool Ben.Demystifier.Test.ParameterParamTests.MethodWithParams(params int[] numbers)",
|
||||
" at void Ben.Demystifier.Test.ParameterParamTests.DemistifiesMethodWithParams()"});
|
||||
|
||||
Assert.Equal(expected, trace);
|
||||
}
|
||||
|
||||
private bool MethodWithParams(params int[] numbers)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user