rick_o_max
❔ Can't catch Unity Coroutine (IEnumerator) error
Hi!
I'm running some
Func
inside a Unity Coroutine.
I'm using an approach I've used before to get the errors the code might throw and handle them, but by some reason, I can't catch the errors.
You guys have any idea why?7 replies
❔ System.Linq.Expressions custom expression
Hi guys!
I'm parsing a custom language and building an Expression Tree based on it, but I came into an issue:
My language can use Labels, but since I parse the file line by line, I can't reference a label that hasn't been parsed yet when creating a
Goto
expression.
So parsing something like that would give issues:
So, my idea was to inherit the Expression
class to create a kind of LazyGotoExpression
, where the LabelTarget
would be evaluated by the time the expression is compiled, but I have no clue how to do that.
Could you guys give me a hand?
Current parsing code:
If there is a way to make a custom Expression
return another Expression
instance, that would be perfect.140 replies
❔ Generator setting wrong (not existing) source path in the PDB file
Hi!
I'm generating some classes with a custom generator (Roslyn).
When the PDB file is generated, the path to the generated document is wrong, making impossible to debug it.
In the PDB file, the path to the generated source is relative to the generator project, and not to the project that is consuming the generator:
Also, this file doesn't seem to exist.
Enabling the
EmitCompilerGeneratedFiles
project option and setting the path manually will generate the file inside the current project path, and not the generator project path. Also, changing the CompilerGeneratedFilesOutputPath
does not change the PDB document path.4 replies
❔ Best strategy to move methods to IEnumerator
Hi guys!
I appreciate the help you have been giving on this server. You guys rock!
I'm trying to tackle down an architecture issue this time.
I have a big codebase (approx. 100k lines of code) which contains processing-intensive methods that might halt the main thread (I'm using Unity).
The issue is not Unity specific, as it is a feature from the .NET Framework.
On Unity, one can spread large processing across various frames on the main thread by using Couroutines (https://docs.unity3d.com/Manual/Coroutines.html).
Inside a Coroutine, the code can suspend it until the yield instruction is accepted.
I'm looking for ways to convert my codebase to
IEnumerator
, so I can make use of Coroutines, but I think putting lots of conditional compilation stuff like #if
s will make the library management almost impossible. (The conditional compilation is meant to keep compatibility with the current userbase)
Unity has this helper class as well, that allows suspending a Coroutine using any custom logic: https://docs.unity3d.com/ScriptReference/CustomYieldInstruction.html
I can definetely take the most processing-intensive methods and convert them to Coroutines, but because all the Coroutine chain is made using IEnumerators
, that would require converting all methods on the stack as well.
What would you guys use to handle such situation?
Something that injects code or dependencies came to my mind, but I'm not sure, as I haven't made anything like that yet.4 replies