mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Added custom UIX debug bridge
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#if ZUNE5
|
||||
|
||||
using OwlCore.Remoting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Debug
|
||||
{
|
||||
[RemoteProperty]
|
||||
[RemoteMethod]
|
||||
[RemoteOptions(RemotingDirection.Bidirectional)]
|
||||
public class Bridge : IDisposable
|
||||
{
|
||||
private readonly MemberRemote _memberRemote;
|
||||
|
||||
public Bridge(RemotingMode mode)
|
||||
{
|
||||
// Pass the instance you want to remote into MemberRemote() with an ID that is identical on both machines for that instance.
|
||||
// An instance will not receive member changes until you do this.
|
||||
// Optionally leave out the message handler. Uses the default set by MemberRemote.SetDefaultMessageHandler(handler);
|
||||
IrisDebugRemoteMessageHandler handler = new(mode);
|
||||
_memberRemote = new MemberRemote(this, typeof(Bridge).Assembly.FullName, handler);
|
||||
}
|
||||
|
||||
[RemoteMethod, RemoteOptions(RemotingDirection.HostToClient)]
|
||||
public void LogInterpreterOpCode(object context, Data.InterpreterEntry entry)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[HOST] [Interpreter] [{context}] {entry}");
|
||||
}
|
||||
|
||||
[RemoteMethod, RemoteOptions(RemotingDirection.HostToClient)]
|
||||
public void LogDispatcher(string message)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[HOST] [Dispatcher] {message}");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose of the MemberRemote when finished. Forgetting to do this WILL result in a memory leak.
|
||||
_memberRemote.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Iris.Debug.Data
|
||||
{
|
||||
public class InterpreterEntry
|
||||
{
|
||||
public InterpreterEntry(object opCode, params OpCodeArgument[] args)
|
||||
{
|
||||
OpCode = opCode;
|
||||
Arguments = args;
|
||||
}
|
||||
|
||||
public object OpCode { get; private set; }
|
||||
public OpCodeArgument[] Arguments { get; private set; }
|
||||
|
||||
public override string ToString() => $"{OpCode}({string.Join(", ", (IEnumerable<OpCodeArgument>)Arguments)})";
|
||||
}
|
||||
|
||||
public class OpCodeArgument
|
||||
{
|
||||
public Type Type { get; private set; }
|
||||
public object Value { get; private set; }
|
||||
|
||||
public override string ToString() => $"{Type} {Value}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Weavers>
|
||||
<Cauldron.Interception />
|
||||
</Weavers>
|
||||
@@ -0,0 +1,46 @@
|
||||
#if ZUNE5
|
||||
|
||||
using OwlCore.Remoting;
|
||||
using OwlCore.Remoting.Transfer;
|
||||
using OwlCore.Remoting.Transfer.MessageConverters;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Iris.Debug
|
||||
{
|
||||
internal class IrisDebugRemoteMessageHandler : IRemoteMessageHandler
|
||||
{
|
||||
public RemotingMode Mode { get; set; }
|
||||
public MemberSignatureScope MemberSignatureScope { get; set; }
|
||||
|
||||
public IRemoteMessageConverter MessageConverter { get; }
|
||||
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public event EventHandler<IRemoteMessage> MessageReceived;
|
||||
|
||||
public IrisDebugRemoteMessageHandler(RemotingMode mode)
|
||||
{
|
||||
// The inbox newtonsoft converter. Tested with various types, structs, primitives, classes and more.
|
||||
// Provided by the lib for convenience, the underlying OwlCore.Remoting system doesn't use this property.
|
||||
MessageConverter = new NewtonsoftRemoteMessageConverter();
|
||||
|
||||
Mode = mode;
|
||||
}
|
||||
|
||||
public Task InitAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
IsInitialized = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task SendMessageAsync(IRemoteMessage memberMessage, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
// Serialize and send the message.
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net35;net40;net6.0;netstandard2.0</TargetFrameworks>
|
||||
<RootNamespace>Microsoft.Iris.Debug</RootNamespace>
|
||||
|
||||
<UseZune5>false</UseZune5>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net6.0' ">
|
||||
<UseZune5>true</UseZune5>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(UseZune5)' == 'true' ">
|
||||
<PackageReference Include="OwlCore" Version="0.0.67" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(UseZune5)' == 'true' ">
|
||||
<ApplicationVersion>5.0.0.0</ApplicationVersion>
|
||||
<DefineConstants>$(DefineConstants);ZUNE5</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user