benaadams / Ben.Demystifier

High performance understanding for stack traces (Make error logs more productive)
Apache License 2.0
2.74k stars 118 forks source link

Demystify Changes "\" to "/" #190

Open LorneCash opened 2 years ago

LorneCash commented 2 years ago

After some testing I've found that Demystify converts traces to have forward-slashes "/" instead of the original back-slashes "\" in paths. Please correct this or give me an option to not do this. See example traces below:

Trace Original: at MyNamespace.Test.GenerateExceptions.Method03_6() in C:\DevOps\MySolution\MyNamespace.Test\TestMethods\GenerateExceptions_Method03_6.cs:line 9 at MyNamespace.Test.GenerateExceptions.Method03_5() in C:\DevOps\MySolution\MyNamespace.Test\TestMethods\GenerateExceptions_Method03_5.cs:line 7 at MyNamespace.Test.GenerateExceptions.Method03_4() in C:\DevOps\MySolution\MyNamespace.Test\TestMethods\GenerateExceptions_Method03_4.cs:line 7 at MyNamespace.Test.GenerateExceptions.Method03_3() in C:\DevOps\MySolution\MyNamespace.Test\TestMethods\GenerateExceptions_Method03_3.cs:line 13

Trace Demystified: at void MyNamespace.Test.GenerateExceptions.Method03_6() in C:/DevOps/MySolution\MyNamespace.Test/TestMethods/GenerateExceptions_Method03_6.cs:line 9 at void MyNamespace.Test.GenerateExceptions.Method03_5() in C:/DevOps/MySolution\MyNamespace.Test/TestMethods/GenerateExceptions_Method03_5.cs:line 7 at void MyNamespace.Test.GenerateExceptions.Method03_4() in C:/DevOps/MySolution\MyNamespace.Test/TestMethods/GenerateExceptions_Method03_4.cs:line 7 at void MyNamespace.Test.GenerateExceptions.Method03_3() in C:/DevOps/MySolution\MyNamespace.Test/TestMethods/GenerateExceptions_Method03_3.cs:line 13

potatopeelings commented 2 years ago

I believe this is because of https://github.com/benaadams/Ben.Demystifier/blob/8db93654c2869d3bc5ddb1462682f421c99a056b/src/Ben.Demystifier/EnhancedStackTrace.cs#L135 If you use LocalPath instead of AbsolutePath, it would return the local operating-system representation which is what you are looking for (see https://docs.microsoft.com/en-us/dotnet/api/system.uri.localpath?view=net-6.0).

However if you decide (to fork and) do this change, and you are logging from both Windows and Linux, you will have a mix of / and \ separated paths