LoggingExtensions.

Dump<T>(T) Method

Summary

Get a basic string representation of specified object.

Syntax

public static string Dump<T>(this T obj)

Examples

Generates a string representation of objects public properties and values.
 var person = new Person { Name = "Bob", Age = 24, Food = new[] { "Lasagne", "Pizza"} };
 var data = person.Dump();

 // output:
 "Name: Bob\r\nAge: 24\r\nFood: Lasagne, Pizza";
Useful in for logging objects, e.g.
 var gitVersionResults = GitVersion(new GitVersionSettings());
 Information("GitResults -> {0}", gitVersionResults.Dump());

 // output:
 GitResults -> Major: 0
 Minor: 1
 Patch: 0
 PreReleaseTag: dev-19.1
 PreReleaseTagWithDash: -dev-19.1
 PreReleaseLabel: dev-19
 PreReleaseNumber: 1
 BuildMetaData: 26
 ..snip..

Type Parameters

Name Description
T Type of object

Parameters

Name Type Description
obj T Object to generate string representation of

Return Value

Type Description
string String representation of object in format in format `Prop: PropValue\r\nArrayProp: ArrayVal1, ArrayVal2`