Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CallerInfo.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Runtime.CompilerServices;
4 
5 namespace SiliconStudio.Core.Diagnostics
6 {
7  /// <summary>
8  /// A class to store <a href="http://msdn.microsoft.com/en-us/library/hh534540%28v=vs.110%29.aspx">Caller Information</a> attributes.
9  /// </summary>
10  public sealed class CallerInfo
11  {
12  /// <summary>
13  /// Initializes a new instance of the <see cref="CallerInfo" /> class.
14  /// </summary>
15  /// <param name="filePath">The file path.</param>
16  /// <param name="memberName">Name of the member.</param>
17  /// <param name="lineNumber">The line number.</param>
18  private CallerInfo(string filePath, string memberName, int lineNumber)
19  {
20  FilePath = filePath;
21  MemberName = memberName;
22  LineNumber = lineNumber;
23  }
24 
25  /// <summary>
26  /// Full path of the source file that contains the caller. This is the file path at compile time.
27  /// </summary>
28  public readonly string FilePath;
29 
30  /// <summary>
31  /// Method or property name of the caller. See Member Names later in this topic.
32  /// </summary>
33  public readonly string MemberName;
34 
35  /// <summary>
36  /// Line number in the source file at which the method is called.
37  /// </summary>
38  public readonly int LineNumber;
39 
40  /// <summary>
41  /// Gets the caller information.
42  /// </summary>
43  /// <param name="sourceFilePath">The source file path.</param>
44  /// <param name="memberName">Name of the member.</param>
45  /// <param name="sourceLineNumber">The source line number.</param>
46  /// <returns>A caller information.</returns>
47  public static CallerInfo Get([CallerFilePath] string sourceFilePath = "", [CallerMemberName] string memberName = "", [CallerLineNumber] int sourceLineNumber = 0)
48  {
49  return new CallerInfo(sourceFilePath, memberName, sourceLineNumber);
50  }
51 
52  public override string ToString()
53  {
54  return string.Format("{0}:{1}:{2}", FilePath, MemberName, LineNumber);
55  }
56  }
57 }
A class to store Caller Information attributes.
Definition: CallerInfo.cs:10
readonly int LineNumber
Line number in the source file at which the method is called.
Definition: CallerInfo.cs:38
readonly string FilePath
Full path of the source file that contains the caller. This is the file path at compile time...
Definition: CallerInfo.cs:28
static CallerInfo Get([CallerFilePath] string sourceFilePath="", [CallerMemberName] string memberName="", [CallerLineNumber] int sourceLineNumber=0)
Gets the caller information.
Definition: CallerInfo.cs:47
readonly string MemberName
Method or property name of the caller. See Member Names later in this topic.
Definition: CallerInfo.cs:33