Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

Breakpoints fail to hit in classes inheriting NetworkBehaviour with partial classes

Open lumeriith opened this issue 4 years ago • 1 comments

Describe the bug Visual Studio breakpoints fail to hit with partial classes in certain circumstances. If a NetworkBehaviour inheriting class is split up into several files using partial classes, only the breakpoints in the last file in alphabetical ascending order are hit. After making a breakpoint in the last file, breakpoints in other files will work until the next recompile.

Example 5 scripts containing partial class implementations for class 'Test' inheriting NetworkBehaviour

Tes.cs - Breakpoints are not hit
Test.cs - Breakpoints are not hit
Test2.cs - Breakpoints are not hit
Test3.cs - Breakpoints are not hit
Test4.cs - Breakpoints are hit

After making a breakpoint in Test4.cs, breakpoints in the rest of the files start working until a recompile is triggered.

Repro project ReproProj.zip

To Reproduce Steps to reproduce the behavior:

  1. Open the attached project 'ReproProj'
  2. Open 'Tes.cs', 'Test.cs', 'Test2.cs', 'Test3.cs' and 'Test4.cs' with Microsoft Visual Studio.
  3. Attach debugger to Unity.
  4. Make breakpoint(s) in 'Tes.cs', 'Test.cs', 'Test2.cs' or 'Test3.cs', none of them will be hit.
  5. Make breakpoint(s) in 'Test4.cs', the breakpoint(s) will be hit and the others will also start working.

Expected behavior Breakpoints are hit in any scripts implementing Test no matter the order they are made in.

Screenshots image image image image

Environment:

  • OS: Windows 10
  • Platform: Windows
  • Unity version: 2019.2.21f1
  • Mirror version: Release v16.2.2

EDIT The bug is somewhat reliably reproducible, but the breakpoints sometimes get put just fine or sometimes doesn't work at all, not fixing itself even after putting a breakpoint in 'Test4.cs'.

If the project doesn't reproduce the bug as stated, try closing Visual Studio and restarting Unity.

lumeriith avatar Jun 20 '20 18:06 lumeriith

This probably has something to do with Weaver, Mirror re-complies the dlls that unity builds to process networking stuff so the final dll is not always the same code as what visual studio shows.

I will look more into it later to confirm, but if this is the case there isnt much we can do to fix it.

James-Frowen avatar Jun 24 '20 11:06 James-Frowen

Closing this. If the issue still persists, it's either due to weaver-generated code or a Unity bug, and there's nothing we can do about it in either case.

MrGadget1024 avatar Feb 09 '23 15:02 MrGadget1024