C
C#3mo ago
kate!

✅ Unreferenced classes not being included

How I have my codebase setup for reflection is to get all types that have a specific attribute (XeniaControllerAttribute) and extend a specific class (BaseService), it then creates an instance of all of those types found and calls a method on it. When I do that, it seems like classes that aren't referenced don't get called, and aren't even included in the main project (XeniaBot.Core) when compiling. Even the breakpoint doesn't work. Currently I have the debugger broken on the method that's called on one of those classes XeniaVersionService.InitializeAsync() and it never gets called. Hell, the breakpoint doesn't even work. https://res.kate.pet/upload/dda1477d3f2e/rider64_fz1KLaArzx.png When I add a breakpoint into my function that fetches all the services to load, it doesn't show XeniaVersionService at all when fetching all the types for the assembly that XeniaVersionService is in. https://res.kate.pet/upload/0471946350b5/eQHcs2gxgy.png I've disassembled the XeniaBot.Data library by itself and it includes the XeniaVersionService. https://res.kate.pet/upload/d45c9de1d711/dotPeek-232.0.20231101.171432_GRKD9P5Alc.png But the XeniaBot.Data.dll that is in the XeniaBot.Core bin folder, doesn't have XeniaVersionService. https://res.kate.pet/upload/f18fa620b99d/dotPeek-232.0.20231101.171432_VAkXvaFiZC.png
20 Replies
reflectronic
reflectronic3mo ago
But the XeniaBot.Data.dll that is in the XeniaBot.Core bin folder, doesn't have XeniaVersionService.
how is it supposed to get there it feels lke the issue is just that you are looking at an old version
kate!
kate!3mo ago
I'm directly referencing the XeniaBot.Data project in XeniaBot.Core
reflectronic
reflectronic3mo ago
is XeniaBot.Core a library or an application
kate!
kate!3mo ago
If I make changes somewhere else in XeniaBot.Data then check in XeniaBot.Core/bin/Deubg/net8.0/XeniaBot.Data.dll, it shows XeniaBot.Core is a console application, XeniaBot.Data is a class library.
reflectronic
reflectronic3mo ago
what do you mean by 'it shows'
kate!
kate!3mo ago
I'll send screenshot I'm using dotpeek to actually check if its included in the assembly
kate!
kate!3mo ago
Made this change in XeniaBot.Data/Services/BanSyncService.cs, built the XeniaBot.Core project, and this is inside of XeniaBot.Core/bin/Debug/net8.0/XeniaBot.Data.dll https://res.kate.pet/upload/775bbcb063b0/dotPeek-232.0.20231101.171432_SS32Qf6KGo.png
reflectronic
reflectronic3mo ago
but the classes are not there?
kate!
kate!3mo ago
Nope All classes that aren't directly referenced, don't show when the XeniaBot.Data DLL is built for XeniaBot.Core
reflectronic
reflectronic3mo ago
can you show the csproj for XeniaBot.Core and XeniaBot.Data
reflectronic
reflectronic3mo ago
<ItemGroup>
<Reference Include="XeniaBot.Data">
<HintPath>..\XeniaBot.WebPanel\bin\Debug\net8.0\XeniaBot.Data.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="XeniaBot.Data">
<HintPath>..\XeniaBot.WebPanel\bin\Debug\net8.0\XeniaBot.Data.dll</HintPath>
</Reference>
</ItemGroup>
this is a little sus, do you know why it's there \ it seems bad that you are referencing two DLLs named XeniaBot.Data.dll which are seemingly not the same
kate!
kate!3mo ago
I'm not sure why that's there at all tbh, because when I added the project reference, I used the GUI in Rider
reflectronic
reflectronic3mo ago
if you delete it what happens
kate!
kate!3mo ago
Checking rn Yep, it shows now (and the breakpoint works)
kate!
kate!3mo ago
Thank you
reflectronic
reflectronic3mo ago
i am not sure how that was the cause of the issue, but i guess as long as it works it’s OK
kate!
kate!3mo ago
From what I can tell it uses the DLL that was built by the web panel, which I last did about an hour ago (before XeniaVersionService existed)
reflectronic
reflectronic3mo ago
i am not sure how your changes to the method would have shown up the n