Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress differences due to [CallerFilePath] and [CallerLineNumber] #26

Open
chrishdmicrosoftcom opened this issue Aug 3, 2017 · 0 comments

Comments

@chrishdmicrosoftcom
Copy link

C# has a feature, which is particularly useful in logging frameworks, but which renders the JustAssembly comparison functionality almost useless.

The C# feature works like this:
You define a method on your logger API:
public void LogMessage(string message, [CallerFilePath] string filePath = "")
{
}
And you call it just like this:
myLogger.LogMessage("thisisthemessage");
The C# compiler then automatically determines the file path your call is in, and hard-codes that in the IL code. Similarly for [CallerMemberName] and [CallerLineNumber].

If you use e.g. VS Team Services build, it will create a temporary folder and build your code in that. So two consecutive builds will have different paths.

When you then compare two assemblies with JustAssembly, it will show that
myLogger.LogMessage("thisisthemessage", @"c:\temp\randomfolder1\application\file.cs");
is different from
myLogger.LogMessage("thisisthemessage", @"c:\temp\randomfolder2\application\file.cs");
And it does this all over the place, because you emit logs all over the place.

It would be nice if JustAssembly would suppress such differences when it can see that the difference in the .dll is not due to a difference in the .cs, but rather due to the callee using the [CallerFilePath] feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants