From 2e8059403fe32b32ddad727df69855bb1dcfd3b3 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Mar 2019 00:20:50 +0000 Subject: [PATCH 1/5] Removed try/catch to see what is wrong with the StackTrace. --- src/FakerDotNet/Fakers/FakeFaker.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/FakerDotNet/Fakers/FakeFaker.cs b/src/FakerDotNet/Fakers/FakeFaker.cs index 8d5fae9..05fc5b0 100644 --- a/src/FakerDotNet/Fakers/FakeFaker.cs +++ b/src/FakerDotNet/Fakers/FakeFaker.cs @@ -80,8 +80,8 @@ private static FakerMatch GetFakerMatch(string calleeFaker, string placeholder, private string Parse(string input, FakerMatch match) { - try - { + // try + // { if (!match.Success) return input; var faker = GetFaker(match.Name); @@ -90,11 +90,11 @@ private string Parse(string input, FakerMatch match) var end = input.Substring(match.Index + match.Length); return $"{start}{value}{end}"; - } - catch - { - return input; - } + // } + // catch + // { + // return input; + // } } private PropertyInfo GetFaker(string name) From 2502f645c9c107a774287319e48effacb262de14 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Mar 2019 00:28:53 +0000 Subject: [PATCH 2/5] Added FakerTests to regex replace call. --- src/FakerDotNet/Fakers/FakeFaker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FakerDotNet/Fakers/FakeFaker.cs b/src/FakerDotNet/Fakers/FakeFaker.cs index 05fc5b0..954dc3f 100644 --- a/src/FakerDotNet/Fakers/FakeFaker.cs +++ b/src/FakerDotNet/Fakers/FakeFaker.cs @@ -44,7 +44,7 @@ private string GetCalleeFaker() { var callee = _stackTraceWrapper.GetClassAtFrame(2) ?? ""; - return Regex.Replace(callee, @"Faker$", ""); + return Regex.Replace(callee, @"(Faker|FakerTests)$", ""); } private static IEnumerable GetPlaceholders(string input) From e72e990610de6f43c01480e0ca96dd9e4c1ed9c9 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Mar 2019 00:30:37 +0000 Subject: [PATCH 3/5] Added the try/catch back in. --- src/FakerDotNet/Fakers/FakeFaker.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/FakerDotNet/Fakers/FakeFaker.cs b/src/FakerDotNet/Fakers/FakeFaker.cs index 954dc3f..52335c7 100644 --- a/src/FakerDotNet/Fakers/FakeFaker.cs +++ b/src/FakerDotNet/Fakers/FakeFaker.cs @@ -80,8 +80,8 @@ private static FakerMatch GetFakerMatch(string calleeFaker, string placeholder, private string Parse(string input, FakerMatch match) { - // try - // { + try + { if (!match.Success) return input; var faker = GetFaker(match.Name); @@ -90,11 +90,11 @@ private string Parse(string input, FakerMatch match) var end = input.Substring(match.Index + match.Length); return $"{start}{value}{end}"; - // } - // catch - // { - // return input; - // } + } + catch + { + return input; + } } private PropertyInfo GetFaker(string name) From b637f54432a51d12f33fcfad41d5e894615f0d8c Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Mar 2019 00:41:07 +0000 Subject: [PATCH 4/5] Commented out the try/catch during PR. --- src/FakerDotNet/Fakers/FakeFaker.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/FakerDotNet/Fakers/FakeFaker.cs b/src/FakerDotNet/Fakers/FakeFaker.cs index 52335c7..f830cb7 100644 --- a/src/FakerDotNet/Fakers/FakeFaker.cs +++ b/src/FakerDotNet/Fakers/FakeFaker.cs @@ -61,9 +61,6 @@ private static FakerMatch GetFakerMatch(string calleeFaker, string placeholder, { var pattern = Regex.Escape(placeholder); var match = Regex.Match(input, pattern); - - if (!match.Success) return new FakerMatch(); - var split = match.Value.Replace("{", "").Replace("}", "").Split('.'); var name = split.Length > 1 ? split[0] : calleeFaker; var method = split.Length > 1 ? split[1] : split[0]; @@ -80,21 +77,19 @@ private static FakerMatch GetFakerMatch(string calleeFaker, string placeholder, private string Parse(string input, FakerMatch match) { - try - { - if (!match.Success) return input; - + // try + // { var faker = GetFaker(match.Name); var value = GetValue(faker, match.Method); var start = input.Substring(0, match.Index); var end = input.Substring(match.Index + match.Length); return $"{start}{value}{end}"; - } - catch - { - return input; - } + // } + // catch + // { + // return input; + // } } private PropertyInfo GetFaker(string name) From cefceded743376f289a27d10d667fa38370ad7ca Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Mar 2019 00:45:33 +0000 Subject: [PATCH 5/5] Put the try/catch back in. --- src/FakerDotNet/Fakers/FakeFaker.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/FakerDotNet/Fakers/FakeFaker.cs b/src/FakerDotNet/Fakers/FakeFaker.cs index f830cb7..f38d3f3 100644 --- a/src/FakerDotNet/Fakers/FakeFaker.cs +++ b/src/FakerDotNet/Fakers/FakeFaker.cs @@ -77,19 +77,19 @@ private static FakerMatch GetFakerMatch(string calleeFaker, string placeholder, private string Parse(string input, FakerMatch match) { - // try - // { + try + { var faker = GetFaker(match.Name); var value = GetValue(faker, match.Method); var start = input.Substring(0, match.Index); var end = input.Substring(match.Index + match.Length); return $"{start}{value}{end}"; - // } - // catch - // { - // return input; - // } + } + catch + { + return input; + } } private PropertyInfo GetFaker(string name)