We use a embedded mono source built library (not executable) inside an UnrealEngine(rather than Unity)
From this feature issue RIDER-11810 Support mixed-mode debugging we find that rider supported the mixed mode debugging, then started trying this feature eagerly.
But found out, this feature currently only support mono executable version for non-Unity environment, making it kind of inconvenient to configure the mono listening port for the mono SDB, as it should be setup when launching the mono runtime, but we have no way to inspect the port that the debuggerwork picked at the launch time, nor able to config the port in the debug configuration.
It could be better to expose the mono address and port config in the debug configuration just like Mono Remote or Attach Unity Player, but at the moment I can only think of develop a plugin to hookup the debug launch procedual and manage to get the UnityStartInfo, then pass the monoPort to our mono launch variable.
Lacking of Debugger-related documentation, I need some guidance to develop this feature.
After digging around rider plugin sample and intellij-community repo HEAVILY with no documentation help, though tired but I managed to came up a solution.
In short, dotnet-based plugin is not the solution, (though i still not figured out why), use intellij-plugin approach instead.
search bring up by double shift is very convenient, it is able to FAST grab all api and types roughly match your keyword, this feature helps a lot.
For my specific goal that reach the start info, XMixedModeCombinedDebugProcess, DebuggerWorkerProcessHandler is where to look into:
if (debugProcess is XMixedModeCombinedDebugProcess){
var processHandler = debugProcess.processHandler
if (processHandler is XMixedModeProcessHandler){
for(handler in processHandler.handlers){
if (handler is DebuggerWorkerProcessHandler) {
val model = handler.workerModel
val session = model.activeSession
session.view(lifetime){
lt, sessionModel ->
info = sessionModel?.startInfo
}
}
}
}
if (info != null){
try{
val prop = info!!::class.memberProperties.firstOrNull{ it.name == "monoPort"}
val casted = prop?.getter?.call(info) as? Int
val dir = project.solutionDirectoryPath.toString()
var writePath = Paths.get(dir, "..", "Content", "monoPort").toString()
File(writePath).writeText(casted.toString(), Charsets.UTF_8)
}catch(e: Exception){
val msg = e.message
}
}
as type UnityStartInfo is not exposed, I have to use reflection to reach what I want