Added Microsoft.Iris.Debug

This commit is contained in:
Yoshi Askharoun
2021-10-06 13:55:48 -05:00
parent 4f90ad2127
commit ee3e4de91e
10 changed files with 1545 additions and 0 deletions
+204
View File
@@ -0,0 +1,204 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.Assert
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
using System.Diagnostics;
namespace Microsoft.Iris.Debug
{
// FIXME: Use WCT's Guard APIs
internal static class Assert
{
[Conditional("DEBUG")]
public static void IsNotNull<T>(T value, string valueName) where T : class
{
// ISSUE: variable of a boxed type
var local = (object)value;
}
[Conditional("DEBUG")]
public static void IsNotNullMessage<T>(T value, string message) where T : class
{
// ISSUE: variable of a boxed type
var local = (object)value;
}
[Conditional("DEBUG")]
public static void IsNotNullMessage<T>(T value, string message, object param) where T : class
{
// ISSUE: variable of a boxed type
var local = (object)value;
}
[Conditional("DEBUG")]
public static void IsNull<T>(T value, string valueName) where T : class
{
// ISSUE: variable of a boxed type
var local = (object)value;
}
[Conditional("DEBUG")]
public static void IsNullMessage<T>(T value, string message) where T : class
{
// ISSUE: variable of a boxed type
var local = (object)value;
}
[Conditional("DEBUG")]
public static void IsType(object value, Type type)
{
int num = value != null || type.IsValueType ? (value == null ? (false ? 1 : 0) : (type.IsAssignableFrom(value.GetType()) ? 1 : 0)) : (true ? 1 : 0);
}
[Conditional("DEBUG")]
public static void IsInRange(int value, int min, int max, string valueName)
{
if (value < min)
;
}
[Conditional("DEBUG")]
public static void IsInRange(float value, float min, float max, string valueName)
{
if (value < (double)min)
;
}
[Conditional("DEBUG")]
public static void IsNotNegative(int value, string valueName)
{
}
[Conditional("DEBUG")]
public static void IsNotNegative(float value, string valueName)
{
}
[Conditional("DEBUG")]
public static void IsNotNegativeMessage(int value, string message)
{
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition, string message)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition, string message, object param)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition, string message, object param1, object param2)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void IsTrue(
bool condition,
string message,
object param1,
object param2,
object param3)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void IsTrue(
bool condition,
string message,
object param1,
object param2,
object param3,
object param4)
{
int num = condition ? 1 : 0;
}
[Conditional("DEBUG")]
public static void Fail(string message)
{
}
[Conditional("DEBUG")]
public static void Fail(string format, object param)
{
}
[Conditional("DEBUG")]
public static void Fail(string format, object param1, object param2)
{
}
[Conditional("DEBUG")]
public static void Fail(string format, object param1, object param2, object param3)
{
}
[Conditional("DEBUG")]
private static void ReportFailure(string message)
{
StackTrace trace = new StackTrace(true);
if (!DebugHelpers.DisplayStackTrace("Iris Framework Assert", message, trace, 1))
return;
DebugHelpers.Break();
}
[Conditional("DEBUG")]
private static void ReportFailure(string format, object param)
{
}
[Conditional("DEBUG")]
private static void ReportFailure(string format, object param1, object param2)
{
}
[Conditional("DEBUG")]
private static void ReportFailure(string format, object param1, object param2, object param3)
{
}
[Conditional("DEBUG")]
private static void ReportFailure(
string format,
object param1,
object param2,
object param3,
object param4)
{
}
[Conditional("DEBUG")]
public static void IsApplicationThread()
{
}
[Conditional("DEBUG")]
public static void IsApplicationShuttingDown(string message)
{
}
[Conditional("DEBUG")]
public static void IsApplicationThreadOrShuttingDown()
{
}
[Conditional("DEBUG")]
public static void CompatibleArray(Array array, int indexStart, Type objectType, int numItems) => array.GetType().GetElementType();
}
}
@@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.DebugHelpers
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.OS;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
namespace Microsoft.Iris.Debug
{
[SuppressUnmanagedCodeSecurity]
internal class DebugHelpers
{
public static void Break()
{
if (Debugger.IsAttached || !Win32Api.IsDebuggerPresent())
Debugger.Break();
else
Win32Api.DebugBreak();
}
public static bool DisplayStackTrace(
string title,
string messageName,
StackTrace trace,
int ignoreFramesCount)
{
return false;
}
[DllImport("UIXsup.dll")]
private static extern bool DebugDisplayErrorStack(
string messageName,
string filename,
int line,
string title,
string traceStack);
public static object DEBUG_ObjectToString(object obj)
{
if (obj == null)
return "null";
if ((object)(obj as Delegate) != null)
obj = DEBUG_DelegateToString((Delegate)obj, null);
else if (obj is Type)
obj = ((Type)obj).Name;
return obj;
}
public static string DEBUG_DelegateToString(Delegate d, object args)
{
if ((object)d == null)
return "null";
Delegate[] invocationList = d.GetInvocationList();
string str = "ERROR DISPLAYING DELEGATE";
if (invocationList != null && invocationList.Length > 0)
{
if (invocationList.Length == 1)
{
str = DEBUG_UnicastToString(invocationList[0], args);
}
else
{
string[] strArray = new string[invocationList.Length];
for (int index = 0; index < invocationList.Length; ++index)
strArray[index] = "\r\n" + DEBUG_UnicastToString(invocationList[index], args);
str = " MULTICAST:" + string.Concat(strArray);
}
}
return str;
}
private static string DEBUG_UnicastToString(Delegate d, object args)
{
if ((object)d == null)
return "null";
object target = d.Target;
MethodInfo method = d.Method;
return target == null ? Trace.DEBUG_SafeFormat("{0}.{1}({2})", method.DeclaringType.Name, method.Name, args) : Trace.DEBUG_SafeFormat("{0}.{1}({2}) -> {3}", method.DeclaringType.Name, method.Name, args, target);
}
public static string DEBUG_EscapeString(string text) => text;
}
}
@@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.DebugLabelFormat
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Debug
{
internal enum DebugLabelFormat
{
None,
Name,
Full,
}
}
@@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.DebugOutlineScope
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Debug
{
internal enum DebugOutlineScope
{
FlaggedOnly,
Input,
Hosts,
All,
}
}
@@ -0,0 +1,490 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.DebugOutlines
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Drawing;
using Microsoft.Iris.Markup;
using Microsoft.Iris.OS;
using Microsoft.Iris.Render;
using Microsoft.Iris.RenderAPI.Drawing;
using Microsoft.Iris.Session;
using Microsoft.Iris.UI;
using Microsoft.Iris.ViewItems;
using System;
namespace Microsoft.Iris.Debug
{
internal class DebugOutlines : ViewItem
{
private const int TotalScopeModes = 4;
private const int TotalLabelModes = 3;
private static bool _enabled;
private ViewItem _rootItem;
private DebugOutlineScope _scope;
private DebugLabelFormat _label;
private RichText _sharedRichText;
private Color _outlineColor;
private Color _hostOutlineColor;
private Color _textColor;
private Font _textFont;
private UIImage _mouseInteractiveImage;
private UIImage _mouseFocusImage;
private UIImage _keyInteractiveImage;
private UIImage _keyFocusImage;
private int _thickness = 1;
private Map<object, RawImage> _outlineImageEffectCache = new Map<object, RawImage>();
private static DebugOutlines.SomethingChangedHandler SomethingChanged;
public DebugOutlines()
{
_sharedRichText = new RichText(false);
_textFont = new Font("Arial", 30f);
_outlineColor = Color.White;
_hostOutlineColor = Color.White;
_textColor = Color.Black;
SomethingChanged += new DebugOutlines.SomethingChangedHandler(OnSomethingChanged);
}
protected override void OnDispose()
{
base.OnDispose();
SomethingChanged -= new DebugOutlines.SomethingChangedHandler(OnSomethingChanged);
_sharedRichText.Dispose();
}
public ViewItem Root
{
get => _rootItem;
set
{
if (_rootItem == value)
return;
_rootItem = value;
FireNotification(NotificationID.Root);
MarkPaintInvalid();
}
}
public static bool Enabled
{
get => _enabled;
set
{
if (_enabled == value)
return;
_enabled = value;
SomethingChanged(null);
}
}
public DebugOutlineScope OutlineScope
{
get => _scope;
set
{
if (_scope == value)
return;
_scope = value;
FireNotification(NotificationID.OutlineScope);
MarkPaintInvalid();
}
}
public void NextScopeMode() => OutlineScope = (DebugOutlineScope)((int)(_scope + 1) % 4);
public DebugLabelFormat OutlineLabel
{
get => _label;
set
{
if (_label == value)
return;
_label = value;
FireNotification(NotificationID.OutlineLabel);
MarkPaintInvalid();
}
}
public void NextLabelMode() => OutlineLabel = (DebugLabelFormat)((int)(_label + 1) % 3);
public Color OutlineColor
{
get => _outlineColor;
set
{
if (!(_outlineColor != value))
return;
_outlineColor = value;
FireNotification(NotificationID.OutlineColor);
MarkPaintInvalid();
}
}
public Color HostOutlineColor
{
get => _hostOutlineColor;
set
{
if (!(_hostOutlineColor != value))
return;
_hostOutlineColor = value;
FireNotification(NotificationID.HostOutlineColor);
MarkPaintInvalid();
}
}
public Color TextColor
{
get => _textColor;
set
{
if (!(_textColor != value))
return;
_textColor = value;
FireNotification(NotificationID.TextColor);
MarkPaintInvalid();
}
}
public Font TextFont
{
get => _textFont;
set
{
if (_textFont == value)
return;
_textFont = value;
FireNotification(NotificationID.TextFont);
MarkPaintInvalid();
}
}
public UIImage MouseInteractiveImage
{
get => _mouseInteractiveImage;
set
{
if (_mouseInteractiveImage == value)
return;
_mouseInteractiveImage = value;
FireNotification(NotificationID.MouseInteractiveImage);
MarkPaintInvalid();
}
}
public UIImage MouseFocusImage
{
get => _mouseFocusImage;
set
{
if (_mouseFocusImage == value)
return;
_mouseFocusImage = value;
FireNotification(NotificationID.MouseFocusImage);
MarkPaintInvalid();
}
}
public UIImage KeyInteractiveImage
{
get => _keyInteractiveImage;
set
{
if (_keyInteractiveImage == value)
return;
_keyInteractiveImage = value;
FireNotification(NotificationID.KeyInteractiveImage);
MarkPaintInvalid();
}
}
public UIImage KeyFocusImage
{
get => _keyFocusImage;
set
{
if (_keyFocusImage == value)
return;
_keyFocusImage = value;
FireNotification(NotificationID.KeyFocusImage);
MarkPaintInvalid();
}
}
protected override void OnPaint(bool visible)
{
base.OnPaint(visible);
VisualContainer.RemoveAllChildren();
if (!_enabled || _rootItem == null || !_rootItem.HasVisual)
return;
SizeF extentPtr = new SizeF(_rootItem.VisualSize.X, _rootItem.VisualSize.Y);
PaintWorker(_rootItem, PointF.Zero, extentPtr);
}
private void PaintWorker(ViewItem vi, PointF offsetPointF, SizeF extentPtr)
{
if (vi == this)
return;
PaintOutline(vi, offsetPointF, extentPtr);
foreach (ViewItem child in vi.Children)
{
if (child.HasVisual)
{
PointF offsetPointF1 = offsetPointF;
offsetPointF1.X += child.VisualPosition.X;
offsetPointF1.Y += child.VisualPosition.Y;
SizeF extentPtr1 = new SizeF(child.VisualSize.X, child.VisualSize.Y);
PaintWorker(child, offsetPointF1, extentPtr1);
}
}
}
private void PaintOutline(ViewItem vi, PointF offsetPointF, SizeF extentPtr)
{
Color outlineColor;
string name;
UIImage[] iconsList;
if (!ShouldPaintOutlines(vi, out outlineColor, out name, out iconsList))
return;
RawImage outlineImage = CreateOutlineImage(outlineColor);
DrawImage(outlineImage.RenderImage, offsetPointF, extentPtr, outlineImage.NineGrid);
IImage image = null;
RectangleF rectangle = RectangleF.Zero;
float num = 0.0f;
if (name != null)
{
TextMeasureParams measureParams = new TextMeasureParams();
measureParams.Initialize();
measureParams.SetConstraint(new SizeF(4095f, 8191f));
measureParams.SetFormat(LineAlignment.Near, new TextStyle()
{
FontFace = _textFont.FontName,
FontSize = _textFont.FontSize,
Color = _textColor
});
TextFlow textFlow = _sharedRichText.Measure(name, ref measureParams);
measureParams.Dispose();
TextRun run = textFlow[0];
image = Text.GetImageForRun(UISession.Default, run, Color.FromArgb(byte.MaxValue, run.Color));
rectangle = RectangleF.FromRectangle(textFlow.Bounds);
rectangle.Offset(offsetPointF);
num = textFlow.Bounds.Width;
}
if (iconsList != null)
{
foreach (UIImage uiImage in iconsList)
{
if (uiImage != null)
{
uiImage.Load();
rectangle.Width += uiImage.Width;
rectangle.Height = Math.Max(rectangle.Height, uiImage.Height);
}
}
}
rectangle.Y -= rectangle.Height;
if (name != null || iconsList != null)
DrawEffect(EffectManager.CreateColorFillEffect(this, outlineColor), rectangle);
if (image != null)
{
SizeF size = new SizeF(image.Size.Width, image.Size.Height);
DrawImage(image, rectangle.Location, size);
}
if (iconsList == null)
return;
foreach (UIImage uiImage in iconsList)
{
if (uiImage != null)
{
DrawImage(uiImage.RenderImage, new RectangleF(rectangle.X + num, rectangle.Y, uiImage.Width, uiImage.Height));
num += uiImage.Width;
}
}
}
private void DrawImage(IImage image, RectangleF rectangle) => DrawImage(image, rectangle.Location, rectangle.Size);
private void DrawImage(IImage image, PointF position, SizeF size) => DrawImage(image, position, size, Inset.Zero);
private void DrawImage(IImage image, PointF position, SizeF size, Inset nineGrid) => DrawEffect(EffectManager.CreateBasicImageEffect(this, image), position, size, nineGrid);
private void DrawEffect(IEffect effect, RectangleF rectangle) => DrawEffect(effect, rectangle.Location, rectangle.Size, Inset.Zero);
private void DrawEffect(IEffect effect, PointF position, SizeF size, Inset nineGrid)
{
ISprite sprite = UISession.RenderSession.CreateSprite(this, this);
sprite.Effect = effect;
sprite.Effect.UnregisterUsage(this);
sprite.Position = new Vector3(position.X, position.Y, 0.0f);
sprite.Size = new Vector2(size.Width, size.Height);
if (nineGrid != Inset.Zero)
sprite.SetNineGrid(nineGrid.Left, nineGrid.Top, nineGrid.Right, nineGrid.Bottom);
VisualContainer.AddChild(sprite, null, VisualOrder.First);
sprite.UnregisterUsage(this);
}
private unsafe RawImage CreateOutlineImage(Color outlineColor)
{
RawImage rawImage;
_outlineImageEffectCache.TryGetValue(outlineColor, out rawImage);
if (rawImage == null)
{
int num1 = _thickness + 1;
int num2 = num1 * 2 + 1;
int[] data = new int[(uint)(num2 * num2 * 4)];
for (int index = 0; index < num2 * num2; ++index)
{
int num3 = index / num2;
int num4 = index % num2;
if (num3 < _thickness || num3 >= num2 - _thickness || (num4 < _thickness || num4 >= num2 - _thickness))
data[index] = outlineColor.ToArgb();
}
byte[] bytes = new byte[data.Length * sizeof(int)];
Buffer.BlockCopy(data, 0, bytes, 0, bytes.Length);
rawImage = new RawImage("OutlineImage" + outlineColor, new Size(num2, num2), num2 * 4, SurfaceFormat.ARGB32, bytes, true, new Inset(num1, num1, num1, num1), new Size(num2, num2), false, false);
_outlineImageEffectCache[outlineColor] = rawImage;
}
return rawImage;
}
private bool ShouldPaintOutlines(
ViewItem vi,
out Color outlineColor,
out string name,
out UIImage[] iconsList)
{
outlineColor = Color.Transparent;
name = null;
iconsList = null;
bool flag = false;
switch (_scope)
{
case DebugOutlineScope.FlaggedOnly:
flag = vi.DebugOutline != Color.Transparent;
break;
case DebugOutlineScope.Input:
bool mouseInteractiveFlag1;
bool keyInteractiveFlag1;
DetermineInteractivity(vi, out mouseInteractiveFlag1, out bool _, out keyInteractiveFlag1, out bool _);
flag = mouseInteractiveFlag1 || keyInteractiveFlag1;
break;
case DebugOutlineScope.Hosts:
flag = vi is Host;
break;
case DebugOutlineScope.All:
flag = true;
break;
}
if (flag)
{
Host host = vi as Host;
outlineColor = !(vi.DebugOutline != Color.Transparent) ? (host == null ? _outlineColor : _hostOutlineColor) : vi.DebugOutline;
switch (_label)
{
case DebugLabelFormat.Name:
name = vi.Name;
if (host != null)
{
string str = host.Source;
if (host.ChildUI != null)
str = host.ChildUI.TypeSchema.Name;
name = name == null ? str : str + " ('" + name + "')";
break;
}
break;
case DebugLabelFormat.Full:
bool mouseInteractiveFlag2;
bool mouseFocusFlag;
bool keyInteractiveFlag2;
bool keyFocusFlag;
int interactivity = DetermineInteractivity(vi, out mouseInteractiveFlag2, out mouseFocusFlag, out keyInteractiveFlag2, out keyFocusFlag);
if (interactivity > 0)
{
iconsList = new UIImage[interactivity];
int num1 = 0;
if (mouseInteractiveFlag2)
iconsList[num1++] = !mouseFocusFlag ? _mouseInteractiveImage : _mouseFocusImage;
int num2;
if (keyInteractiveFlag2)
{
if (keyFocusFlag)
{
UIImage[] uiImageArray = iconsList;
int index = num1;
num2 = index + 1;
UIImage keyFocusImage = _keyFocusImage;
uiImageArray[index] = keyFocusImage;
goto case DebugLabelFormat.Name;
}
else
{
UIImage[] uiImageArray = iconsList;
int index = num1;
num2 = index + 1;
UIImage interactiveImage = _keyInteractiveImage;
uiImageArray[index] = interactiveImage;
goto case DebugLabelFormat.Name;
}
}
else
goto case DebugLabelFormat.Name;
}
else
goto case DebugLabelFormat.Name;
}
}
return flag;
}
private int DetermineInteractivity(
ViewItem vi,
out bool mouseInteractiveFlag,
out bool mouseFocusFlag,
out bool keyInteractiveFlag,
out bool keyFocusFlag)
{
int num = 0;
mouseInteractiveFlag = false;
mouseFocusFlag = false;
keyInteractiveFlag = false;
keyFocusFlag = false;
if (vi is Host host && host.ChildUI != null)
{
UIClass childUi = host.ChildUI;
if (childUi != null)
{
mouseInteractiveFlag = childUi.MouseInteractive;
if (mouseInteractiveFlag)
{
mouseFocusFlag = childUi.DirectMouseFocus;
++num;
}
keyInteractiveFlag = childUi.KeyInteractive;
if (keyInteractiveFlag)
{
keyFocusFlag = childUi.DirectKeyFocus;
++num;
}
}
}
return num;
}
public static void NotifyLayoutChange(ViewItem vi) => SomethingChanged(vi);
public static void NotifyInteractivityChange(ViewItem vi) => SomethingChanged(vi);
private void OnSomethingChanged(ViewItem vi)
{
if (vi != null && !IsViewItemUnderRoot(vi))
return;
MarkPaintInvalid();
}
private bool IsViewItemUnderRoot(ViewItem vi) => _rootItem != null && _rootItem.HasDescendant(vi);
private delegate void SomethingChangedHandler(ViewItem vi);
}
}
@@ -0,0 +1,114 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.RegistryKey
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.OS;
using System;
using System.Security;
namespace Microsoft.Iris.Debug
{
[SuppressUnmanagedCodeSecurity]
internal class RegistryKey
{
private IntPtr _hkey;
public static IntPtr HKEY_CLASSES_ROOT = new IntPtr(int.MinValue);
public static IntPtr HKEY_CURRENT_USER = new IntPtr(-2147483647);
public static IntPtr HKEY_LOCAL_MACHINE = new IntPtr(-2147483646);
private RegistryKey(IntPtr hkey) => _hkey = hkey;
~RegistryKey() => Close();
public static RegistryKey Open(IntPtr hive, string path) => OpenWorker(hive, path);
private static RegistryKey OpenWorker(IntPtr parentKey, string path)
{
RegistryKey registryKey = null;
IntPtr result;
if (Win32Api.RegOpenKeyExW(parentKey, path, 0, 131097, out result) == 0)
registryKey = new RegistryKey(result);
return registryKey;
}
public RegistryKey OpenSubKey(string path) => OpenWorker(_hkey, path);
public bool ReadByte(string valueName, out byte value)
{
bool flag = false;
value = 0;
int num = 0;
if (ReadInt(valueName, out num) && num >= 0 && num <= byte.MaxValue)
{
value = (byte)num;
flag = true;
}
return flag;
}
public bool ReadBool(string valueName, out bool value)
{
bool flag = false;
value = false;
int num = 0;
if (ReadInt(valueName, out num))
{
value = num != 0;
flag = true;
}
return flag;
}
public bool ReadInt(string valueName, out int value)
{
bool flag = false;
value = 0;
int lpcbData = 4;
int lpType;
int lpData;
if (Win32Api.RegQueryValueExW(_hkey, valueName, IntPtr.Zero, out lpType, out lpData, ref lpcbData) == 0 && lpType == 4)
{
value = lpData;
flag = true;
}
return flag;
}
public bool ReadString(string valueName, out string value)
{
bool flag = false;
value = null;
int lpcbData = 0;
int lpType;
if (Win32Api.RegQueryValueExW(_hkey, valueName, IntPtr.Zero, out lpType, null, ref lpcbData) == 0 && lpType == 1)
flag = ReadStringValueWorker(valueName, lpcbData, out value);
return flag;
}
private bool ReadStringValueWorker(string valueName, int dataBytes, out string value)
{
value = null;
bool flag = false;
int length = dataBytes / 2;
char[] lpData = new char[length];
int lpType;
if (Win32Api.RegQueryValueExW(_hkey, valueName, IntPtr.Zero, out lpType, lpData, ref dataBytes) == 0 && lpType == 1)
{
if (lpData[length - 1] == char.MinValue)
--length;
value = new string(lpData, 0, length);
flag = true;
}
return flag;
}
public void Close()
{
Win32Api.RegCloseKey(_hkey);
_hkey = IntPtr.Zero;
GC.SuppressFinalize(this);
}
}
}
@@ -0,0 +1,38 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.RendererDebugCategory
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Debug
{
internal enum RendererDebugCategory
{
Animation,
Critical,
Deprecated,
Dispatcher,
Dump,
Dx9Wrapper,
DynamicSurface,
Failure,
FormWindow,
GraphicsCache,
IFC,
ObjectCache,
Performance,
Profile,
Queues,
Render,
Sounds,
Surface,
SurfacePool,
SurfaceRestoration,
TimeOuts,
Transport,
WindowState,
EffectSystem,
HTTP,
Count,
}
}
+429
View File
@@ -0,0 +1,429 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.Trace
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Input;
using Microsoft.Iris.OS;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Security;
using System.Text;
namespace Microsoft.Iris.Debug
{
[SuppressUnmanagedCodeSecurity]
internal static class Trace
{
public const byte c_defaultTraceLevelFlag = 1;
private const string c_ehDebugDllFileName = "UIXsup.dll";
private static StringBuilder s_safeFormatBuilder;
private static object s_safeFormatLockObj;
private static bool s_isInitialized;
private static object[][] s_arrayCache = new object[7][];
static Trace()
{
s_safeFormatLockObj = new object();
s_safeFormatBuilder = new StringBuilder();
}
public static void Initialize()
{
if (s_isInitialized)
return;
s_isInitialized = true;
//NativeApi.SpInitializeTracing();
TraceSettings.Refresh();
TraceSettings.ListenForRegistryUpdates();
}
public static void Shutdown()
{
if (!s_isInitialized)
return;
TraceSettings.StopListeningForRegistryUpdates();
//NativeApi.SpUninitializeTracing();
s_isInitialized = false;
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, object valueObject) => WriteLine(cat, 1, valueObject);
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, string format, object param) => WriteLine(cat, 1, format, param);
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, string format, object param1, object param2) => WriteLine(cat, 1, format, param1, param2);
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, string format, object param1, object param2, object param3)
{
WriteLine(cat, 1, format, param1, param2, param3);
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, string format, params object[] pars)
{
WriteLine(cat, 1, format, pars);
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, byte levelFlag, object valueObject)
{
if (IsCategoryEnabled(cat, levelFlag))
System.Diagnostics.Debug.WriteLine(BuildLine(valueObject.ToString()));
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, byte levelFlag, string format, object param)
{
if (IsCategoryEnabled(cat, levelFlag))
{
string content = string.Format(format, param);
System.Diagnostics.Debug.WriteLine(BuildLine(content));
}
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, byte levelFlag, string format, object param1, object param2)
{
if (IsCategoryEnabled(cat, levelFlag))
{
string content = string.Format(format, param1, param2);
System.Diagnostics.Debug.WriteLine(BuildLine(content));
}
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, byte levelFlag, string format, object param1, object param2, object param3)
{
if (IsCategoryEnabled(cat, levelFlag))
{
string content = string.Format(format, param1, param2, param3);
System.Diagnostics.Debug.WriteLine(BuildLine(content));
}
}
[Conditional("DEBUG")]
public static void WriteLine(TraceCategory cat, byte levelFlag, string format, params object[] pars)
{
if (IsCategoryEnabled(cat, levelFlag))
{
string content = string.Format(format, pars);
System.Diagnostics.Debug.WriteLine(BuildLine(content));
}
}
public static int IndentLevel { get; set; }
public static bool IsCategoryEnabled(TraceCategory cat) => IsCategoryEnabled(cat, 1);
public static bool IsCategoryEnabled(TraceCategory cat, byte requestLevel)
{
return TraceSettings.GetCategoryLevel(cat) >= requestLevel;
}
public static void EnableCategory(TraceCategory cat, bool enabled)
{
byte level = 0;
if (enabled) level = 1;
TraceSettings.SetCategoryLevel(cat, level);
}
[Conditional("DEBUG")]
public static void Indent(TraceCategory cat)
{
}
[Conditional("DEBUG")]
public static void Indent(TraceCategory cat, byte levelFlag) => IsCategoryEnabled(cat, levelFlag);
[Conditional("DEBUG")]
public static void Unindent(TraceCategory cat)
{
}
[Conditional("DEBUG")]
public static void Unindent(TraceCategory cat, byte levelFlag) => IsCategoryEnabled(cat, levelFlag);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, string message) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, string format, object param) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, string format, object param, object param2) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, string format, object param, object param2, object param3)
{
IsCategoryEnabled(cat, 1);
}
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, string format, object param, object param2, object param3, object param4)
{
IsCategoryEnabled(cat, 1);
}
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, byte levelFlag, string message) => IsCategoryEnabled(cat, levelFlag);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, byte levelFlag, string format, object param) => IsCategoryEnabled(cat, levelFlag);
[Conditional("DEBUG")]
public static void OpenBrace(TraceCategory cat, byte levelFlag, string format, object param, object param2)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
public static void OpenBrace(
TraceCategory cat,
byte levelFlag,
string format,
object param,
object param2,
object param3)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
public static void OpenBrace(
TraceCategory cat,
byte levelFlag,
string format,
object param,
object param2,
object param3,
object param4)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
private static void OpenBraceWorker(TraceCategory cat, string message)
{
}
[Conditional("DEBUG")]
public static void DeferOpenBrace(TraceCategory cat) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void DeferOpenBrace(TraceCategory cat, string message) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void DeferOpenBrace(TraceCategory cat, string format, object param) => IsCategoryEnabled(cat, 1);
[Conditional("DEBUG")]
public static void DeferOpenBrace(
TraceCategory cat,
string format,
object param,
object param2)
{
IsCategoryEnabled(cat, 1);
}
[Conditional("DEBUG")]
public static void DeferOpenBrace(
TraceCategory cat,
string format,
object param,
object param2,
object param3)
{
IsCategoryEnabled(cat, 1);
}
[Conditional("DEBUG")]
public static void DeferOpenBrace(TraceCategory cat, byte levelFlag, string message) => IsCategoryEnabled(cat, levelFlag);
[Conditional("DEBUG")]
public static void DeferOpenBrace(
TraceCategory cat,
byte levelFlag,
string format,
object param)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
public static void DeferOpenBrace(
TraceCategory cat,
byte levelFlag,
string format,
object param,
object param2)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
public static void DeferOpenBrace(
TraceCategory cat,
byte levelFlag,
string format,
object param,
object param2,
object param3)
{
IsCategoryEnabled(cat, levelFlag);
}
[Conditional("DEBUG")]
private static void DeferOpenBraceWorker(TraceCategory cat, string message)
{
}
[Conditional("DEBUG")]
public static void FlushBraces()
{
}
[Conditional("DEBUG")]
public static void CloseBrace(TraceCategory cat)
{
}
[Conditional("DEBUG")]
public static void CloseBrace(TraceCategory cat, byte levelFlag)
{
}
internal static byte GetTraceLevelForEvent(InputInfo info) => 0;
[Conditional("DEBUG")]
private static void WriteLineWorker(TraceCategory cat, object value)
{
}
[Conditional("DEBUG")]
private static void Indent()
{
IndentLevel++;
}
[Conditional("DEBUG")]
private static void Unindent()
{
IndentLevel--;
}
private static string BuildLine(string content)
{
return new string('\t', IndentLevel) + content;
}
internal static string DEBUG_SafeFormat(string format, object param)
{
object[] cachedObjectArray = GetCachedObjectArray(1);
cachedObjectArray[0] = param;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
internal static string DEBUG_SafeFormat(string format, object param1, object param2)
{
object[] cachedObjectArray = GetCachedObjectArray(2);
cachedObjectArray[0] = param1;
cachedObjectArray[1] = param2;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
internal static string DEBUG_SafeFormat(
string format,
object param1,
object param2,
object param3)
{
object[] cachedObjectArray = GetCachedObjectArray(3);
cachedObjectArray[0] = param1;
cachedObjectArray[1] = param2;
cachedObjectArray[2] = param3;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
internal static string DEBUG_SafeFormat(
string format,
object param1,
object param2,
object param3,
object param4)
{
object[] cachedObjectArray = GetCachedObjectArray(4);
cachedObjectArray[0] = param1;
cachedObjectArray[1] = param2;
cachedObjectArray[2] = param3;
cachedObjectArray[3] = param4;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
internal static string DEBUG_SafeFormat(
string format,
object param1,
object param2,
object param3,
object param4,
object param5)
{
object[] cachedObjectArray = GetCachedObjectArray(5);
cachedObjectArray[0] = param1;
cachedObjectArray[1] = param2;
cachedObjectArray[2] = param3;
cachedObjectArray[3] = param4;
cachedObjectArray[4] = param5;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
internal static string DEBUG_SafeFormat(
string format,
object param1,
object param2,
object param3,
object param4,
object param5,
object param6)
{
object[] cachedObjectArray = GetCachedObjectArray(6);
cachedObjectArray[0] = param1;
cachedObjectArray[1] = param2;
cachedObjectArray[2] = param3;
cachedObjectArray[3] = param4;
cachedObjectArray[4] = param5;
cachedObjectArray[5] = param6;
return DEBUG_SafeFormatWorker(format, cachedObjectArray);
}
private static string DEBUG_SafeFormatWorker(string format, object[] args)
{
lock (s_safeFormatLockObj)
{
s_safeFormatBuilder.Length = 0;
s_safeFormatBuilder.AppendFormat(CultureInfo.InvariantCulture, format, args);
Array.Clear(args, 0, args.Length);
s_arrayCache[args.Length] = args;
return s_safeFormatBuilder.ToString();
}
}
private static object[] GetCachedObjectArray(int length)
{
object[] objArray = s_arrayCache[length];
if (objArray != null)
s_arrayCache[length] = null;
else
objArray = new object[length];
return objArray;
}
}
}
@@ -0,0 +1,67 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.TraceCategory
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Debug
{
internal enum TraceCategory
{
AnimationRendering = 0,
Critical = 1,
Deprecated = 2,
Dispatcher = 3,
Dump = 4,
Dx9Wrapper = 5,
DynamicSurface = 6,
Failure = 7,
FormWindow = 8,
GraphicsCache = 9,
IFC = 10, // 0x0000000A
ObjectCache = 11, // 0x0000000B
Performance = 12, // 0x0000000C
Profile = 13, // 0x0000000D
Queues = 14, // 0x0000000E
Render = 15, // 0x0000000F
Sounds = 16, // 0x00000010
Surface = 17, // 0x00000011
SurfacePool = 18, // 0x00000012
SurfaceRestoration = 19, // 0x00000013
TimeOuts = 20, // 0x00000014
Transport = 21, // 0x00000015
WindowState = 22, // 0x00000016
EffectSystem = 23, // 0x00000017
HTTP = 24, // 0x00000018
Animation = 25, // 0x00000019
Accessibility = 26, // 0x0000001A
Bugs = 27, // 0x0000001B
CodeModel = 28, // 0x0000001C
DataBinding = 29, // 0x0000001D
Disposal = 30, // 0x0000001E
EventRouting = 31, // 0x0000001F
Focus = 32, // 0x00000020
GroupedList = 33, // 0x00000021
ImageCache = 34, // 0x00000022
Input = 35, // 0x00000023
InputHandler = 36, // 0x00000024
Markup = 37, // 0x00000025
MarkupCompiler = 38, // 0x00000026
MarkupDebug = 39, // 0x00000027
MarkupEncoding = 40, // 0x00000028
MemoryUsage = 41, // 0x00000029
NativeCodeModel = 42, // 0x0000002A
Navigation = 43, // 0x0000002B
Painting = 44, // 0x0000002C
Protocol = 45, // 0x0000002D
Repeating = 46, // 0x0000002E
Resource = 47, // 0x0000002F
Selection = 48, // 0x00000030
Text = 49, // 0x00000031
ViewItemTreeDump = 50, // 0x00000032
VirtualList = 51, // 0x00000033
Tool = 52, // 0x00000034
Count = 53, // 0x00000035
Max = 1024, // 0x00000400
}
}
@@ -0,0 +1,83 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Debug.TraceSettings
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.OS;
using System;
using System.Collections.Generic;
using System.Security;
namespace Microsoft.Iris.Debug
{
[SuppressUnmanagedCodeSecurity]
internal static class TraceSettings
{
private static Dictionary<TraceCategory, byte> CategoryLevels = new();
private static string s_debugTraceFile;
public static void ListenForRegistryUpdates()
{
}
public static void StopListeningForRegistryUpdates()
{
}
public static void Refresh()
{
s_debugTraceFile = Environment.GetEnvironmentVariable("SPLASH_TRACE_FILE");
WriteLinePrefix = string.Empty;
SendOutputToDebugger = true;
ShowCategories = false;
TimedWriteLines = false;
}
public static byte GetCategoryLevel(TraceCategory cat)
{
if (CategoryLevels.TryGetValue(cat, out byte level))
{
return level;
}
else
{
CategoryLevels.Add(cat, 0);
return GetCategoryLevel(cat);
}
}
public static void SetCategoryLevel(TraceCategory cat, byte level)
{
if (CategoryLevels.ContainsKey(cat))
{
CategoryLevels[cat] = level;
}
else
{
CategoryLevels.Add(cat, level);
}
}
public static bool IsFlagsCategory(TraceCategory cat) => false;
private static bool IsExternalCategory(TraceCategory cat) => (uint)cat < 25U;
public static bool SendOutputToDebugger { get; set; } = true;
public static bool TimedWriteLines { get; set; } = false;
public static bool ShowCategories { get; set; } = false;
public static bool AlwaysShowBraces { get; set; } = false;
public static string WriteLinePrefix { get; set; } = "";
public static string RendererWriteLinePrefix { get; set; } = "";
public static bool DebugTraceToFile => !string.IsNullOrEmpty(s_debugTraceFile);
public static string DebugTraceFile => s_debugTraceFile;
}
}