Optimize PrintStub logging function
This commit is contained in:
parent
0a49f45866
commit
32a0bb1594
1 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -70,16 +71,17 @@ namespace Ryujinx.Common.Logging
|
||||||
public static void PrintStub<T>(LogClass logClass, T obj, [CallerMemberName] string caller = "")
|
public static void PrintStub<T>(LogClass logClass, T obj, [CallerMemberName] string caller = "")
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
PropertyInfo[] props = typeof(T).GetProperties();
|
||||||
|
|
||||||
sb.Append("Stubbed. ");
|
sb.Append("Stubbed. ");
|
||||||
|
|
||||||
foreach (var prop in typeof(T).GetProperties())
|
foreach (var prop in props)
|
||||||
{
|
{
|
||||||
sb.Append($"{prop.Name}: {prop.GetValue(obj)}");
|
sb.Append($"{prop.Name}: {prop.GetValue(obj)}");
|
||||||
sb.Append(" - ");
|
sb.Append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(T).GetProperties().Length > 0)
|
if (props.Length > 0)
|
||||||
{
|
{
|
||||||
sb.Remove(sb.Length - 3, 3);
|
sb.Remove(sb.Length - 3, 3);
|
||||||
}
|
}
|
||||||
|
@ -90,18 +92,19 @@ namespace Ryujinx.Common.Logging
|
||||||
public static void PrintStub<T>(LogClass logClass, string message, T obj, [CallerMemberName] string caller = "")
|
public static void PrintStub<T>(LogClass logClass, string message, T obj, [CallerMemberName] string caller = "")
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
PropertyInfo[] props = typeof(T).GetProperties();
|
||||||
|
|
||||||
sb.Append("Stubbed. ");
|
sb.Append("Stubbed. ");
|
||||||
sb.Append(message);
|
sb.Append(message);
|
||||||
sb.Append(' ');
|
sb.Append(' ');
|
||||||
|
|
||||||
foreach (var prop in typeof(T).GetProperties())
|
foreach (var prop in props)
|
||||||
{
|
{
|
||||||
sb.Append($"{prop.Name}: {prop.GetValue(obj)}");
|
sb.Append($"{prop.Name}: {prop.GetValue(obj)}");
|
||||||
sb.Append(" - ");
|
sb.Append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(T).GetProperties().Length > 0)
|
if (props.Length > 0)
|
||||||
{
|
{
|
||||||
sb.Remove(sb.Length - 3, 3);
|
sb.Remove(sb.Length - 3, 3);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue