Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Source Generator Files with debugger
Joreyk
#1 Posted : Tuesday, April 16, 2024 2:19:57 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/24/2023(UTC)
Posts: 11
Location: Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
The new debugger works correctly and flawless until an invocation happens to a method that is in a file that is source generated


lets say i have an object which source generated and i invoke a method on it and the test runs through that

then i click on the arrow and all that happens is that all the arrows disappear ( probably just a stop call of the debugging )
it would be better if i can jump into the source generated files as well
Remco
#2 Posted : Wednesday, April 17, 2024 12:23:16 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi, thanks for posting.

Can you share some more detail about where this is going wrong and what you would expect to see? Is NCrunch's instrumentation interfering with your debug session, or are you referring to the new RDI features?
Joreyk
#3 Posted : Friday, April 19, 2024 10:32:19 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/24/2023(UTC)
Posts: 11
Location: Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Its about the new RDI and ncrunch itself when using source generator.

For Reproduction my repo https://github.com/NexStandard/NexYamlSerializer
( you will have to build Source generator => nexvyaml => core => NexVYaml => restart VS else ncrunch wont work with the nugetting that i have )

here is one test failing Compact_RecordWithMember

When going to the analyzers, generated by my serializer in NexYamlSourceGenerator , not a single class is bubbled, no green no red bubbles , even though i have 80% test coverage and my serializer needs these classes to work, so they are used
all the normal classes are bubbled and checked correctly, just the source generated ones are problematic

When using RDI , the failing test in YamlSerializer<T> in the third invocation cant find the log
this happens always when the next invocation is a source generated class
https://postimg.cc/4HPf739B
Remco
#4 Posted : Friday, April 19, 2024 11:15:43 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Thanks for sharing the codebase. This really helps with understanding what is happening here.

Because the generated source files aren't actually a part of the solution, NCrunch has no representation for them inside the runtime environment. This means that these files can't be instrumented and they aren't represented in the RDI logs.

When projects are loaded, NCrunch establishes a list of all source files for each project (as provided by MSBuild). We then pass representations of these files downstream into the instrumentation system (which happens after projects are built). The instrumentation system then builds metastructures that are used during test execution to tie the execution path of tests back to the source files.

The manner in which this source generator is working sidesteps this process, as the source files can't be discovered until a project has been fully built, so they cannot be included in the representation passed into the instrumentor. As far as NCrunch is concerned, this is external code that isn't a part of your solution.

The only way I could see this system working with NCrunch is if you found a way to include the generated source files inside your solution itself. The source generation step would then need to be performed upfront on the files in your foreground solution, so that NCrunch could then sync the changes into its workspaces and build them as normal. It would be very messy.

I actually cannot suggest a feasible way for you to get coverage data on this code under NCrunch. You may simply need to accept that the code is functional but not browsable with available code coverage, much as we have currently with other external code.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.035 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download