Table of Contents

Class CodeRef

Namespace
ToSic.Lib.Logging
Assembly
ToSic.Lib.Core.dll

Reference to source code. It contains the path to the file, the method name and the line in the code.

This is used to track the exact location in the code where a log was added/created.

[InternalApi_DoNotUse_MayChangeWithoutNotice("This is just FYI")]
public class CodeRef
Inheritance
CodeRef

Remarks

This is a very internal plumbing-object important for referencing code in log entries.

Constructors

CodeRef(string, string, int)

Reference to source code. It contains the path to the file, the method name and the line in the code.

This is used to track the exact location in the code where a log was added/created.

public CodeRef(string cPath = null, string cName = null, int cLine = 0)

Parameters

cPath string

auto pre-filled by the compiler - path to the code file

cName string

auto pre-filled by the compiler - method name

cLine int

auto pre-filled by the compiler - code line number

Remarks

This is a very internal plumbing-object important for referencing code in log entries.

Fields

Line

Line of code where the code was running

public readonly int Line

Field Value

int

Message

public const string Message = "Message"

Field Value

string

Name

Name of the method/property accessed

public readonly string Name

Field Value

string

Path

Path to the code file

public readonly string Path

Field Value

string

Methods

Create(string, string, int)

Manually create a CodeRef using an already available set of path/name/line. Mainly used for very internal APIs.

public static CodeRef Create(string cPath, string cName, int cLine)

Parameters

cPath string
cName string
cLine int

Returns

CodeRef

A new CodeRef object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UseOrCreate(CodeRef, string, string, int)

Special helper to choose from an already existing CodeRef object or to create a new one if it was null.

public static CodeRef UseOrCreate(CodeRef codeRef, string cPath, string cName, int cLine)

Parameters

codeRef CodeRef

Exiting CodeRef object or null

cPath string

auto pre-filled by the compiler - path to the code file

cName string

auto pre-filled by the compiler - method name

cLine int

auto pre-filled by the compiler - code line number

Returns

CodeRef