PixxelKick
PixxelKick
CC#
Created by PixxelKick on 5/24/2024 in #help
Installing a testlogger/adapter system wide on linux?
Anyone know the right place to install *.testlogger.dll files on linux? My which dotnet points me to ~/.dotnet/, so I've installed my dll at ~/.dotnet/sdk/8.0.203/Extensions/clogger.testlogger.dll However when I run dotnet test --logger clogger I get:
Could not find a test logger with AssemblyQualifiedName, Uri or FriendlyName 'clogger'
Note: if I put the dll in the project bin output it works fine, so the dll is intact, it's just not working in the Extensions folder :/
2 replies
CC#
Created by PixxelKick on 4/26/2024 in #help
Normalizing OpenApi Spec File
Effectively speaking I have 2 OpenApi Spec json files. The first is one my team maintains by hand, to define api behavior. The second is the one swagger generates for my aspnet app. However the latter, due to its behavior, does generate a totally different looking file as it chooses different points to use $refs, doesn't make use of $allOf, etc etc, so I end up with 2 different spec files that should resolve to the same api in practice. Is there a tool anyone knows of to normalize these json files though in a deterministic way, to make them easier to compare A to B and different them to sus out deficiencies? Examples would include: 1. Collapsing all allOfs to just be the things. 2. Collapsing refs to also just be the thing declared 3. Normalizing property declared orders to be consistent, I assume alphabetically or whatever. So on and so forth, I'd expect the output to no longer have the schema section now as a result as everything is now directly declared. Anyone know of such a tool?
1 replies
CC#
Created by PixxelKick on 4/18/2024 in #help
Define a Many to Many navigation in EF Core without any Join Table
Restrictions 1. The model is Db First 2. I cannot modify the Db Schema (Im not in charge of it) Challenge Currently speaking I have a pseudo "Many to Many" relationship between 2 tables via a non unique column they both share and I LEFT JOIN on it. It looks something like so:
[PrimaryKey(nameof(A_Id), nameof(A_Version))]
public class DataModelA
{
public int A_Id { get; set; }

public int A_Version { get; set; }

public ICollection<DataModelB> Bs { get; set; } = [];
}

[PrimaryKey(nameof(B_Id), nameof(B_Version))]
public class DataModelB
{
public int B_Id { get; set; }

public int B_Version { get; set; }

public int A_Id { get; set; }
public ICollection<DataModelA> As { get; set; } = [];
}
[PrimaryKey(nameof(A_Id), nameof(A_Version))]
public class DataModelA
{
public int A_Id { get; set; }

public int A_Version { get; set; }

public ICollection<DataModelB> Bs { get; set; } = [];
}

[PrimaryKey(nameof(B_Id), nameof(B_Version))]
public class DataModelB
{
public int B_Id { get; set; }

public int B_Version { get; set; }

public int A_Id { get; set; }
public ICollection<DataModelA> As { get; set; } = [];
}
Note that both have a composite key, but they only join on half of the composite key, A_Id As a result, I could for example, have 5x DataModelA with A_Id = 1, and I could have 5x DataModelB with A_Id = 1, which would then produce a 5 <-> 5 relationship when I LEFT JOIN on this column. This pattern unfortunately is present across multiple tables on my db in this same way, the architect really liked to do this stuff and now I have to live with it and try and make it work with EF Core, I cannot modify the schema Current Solution Right now all over my database I have a bunch of Join operations like so:
var asToBs = db.As.Join(
db.Bs,
a => a.A_Id,
b => b.A_Id,
(a, b) => new { a, b }
)
var asToBs = db.As.Join(
db.Bs,
a => a.A_Id,
b => b.A_Id,
(a, b) => new { a, b }
)
Which works but its a lot of extra boilerplate as I have to do this for each navigation which very quickly produces a lot of code bloat to do basic stuff. I have tried to setup a property based navigation for this with the above schema but unfortunately it seems EF Core just has no API exposed to define a Many to Many relationship without an intermediary join table, and instead just define it as a basic LEFT JOIN from A to B. If anyone knows a way to do this, lemme know.
16 replies
CC#
Created by PixxelKick on 4/13/2024 in #help
nvim-dap + netcoredbg: Unit Test Breakpoints not getting hit (sometimes)
Im currently using nvim-dap running netcoredbg, in order to debug net core apps. Here's the weird thing, I have the exact same identical nvim configuration (version controlled from github) on two devices. The first is my work laptop, running Ubuntu on WSL. The second is my personal machine, running normal Debian. The WSL Ubuntu machine does hit breakpoints inside of unit tests when I dotnet test with VSTEST_RUNNER_DEBUG=1 and I use "Attach to Process" The Debian machine, however, does not. Both are running the same SDK (8.0203), latest netcoredbg (3.1.0-1), and same nvim config. However I have set a bunch of different env vars over time on both machines, and I know there are random sporadic ones that matter for dotnet, so its distinctly possible I have one floating around messing with the debian machine, or, I have a "magic sauce" env var set on the WSL machine that is making stuff work. I have tried this with both nunit and xunit, neither have worked. The extra weird part is even though the breakpoints dont get hit on the Debian machine, it still does attach successfully. Dotnet waits and only proceeds with the tests after I attach, and the debugger disconnects and goes back to normal edit mode when the tests finish running. So dotnet test is detecting it got attached to... It's just specifically not wiring into the breakpoints? Breakpoints do get hit if I run normal "run the process with netcoredbg" via just running a plain ole net core app. However this doesnt of course work with unit tests since its a totally different command and would require a bunch of bespoke configuration if I wanna do stuff like pass in --filter or --logger or etc to dotnet test so Im not super interested in going down that alley... Especially since I know it clearly can work on one machine, I just cant figure out what secret sauce I am missing >_>;
11 replies
CC#
Created by PixxelKick on 11/15/2023 in #help
Decoupling Nuget Packages from .csproj for Docker Optimization
Aight so this is a puzzle I have been noodling on for awhile and I am curious if anyone has come up with an easy to maintain, platform agnostic solution that doesnt add additional onboarding steps for new developers. Which means: 1. It doesnt require a powershell or bash script 2. It doesnt require installing of extra software on the machine 3. Literally just docker build should be sufficient enough to achieve the desired result The challenge: Right now, nuget packages are tightly coupled to a .csproj file for projects. csproj files also handle a lot of other random stuff like file includes and build steps and whatnot. When you try and optimize a dockerfile, you typically start things off via these 4 steps: 1. Copy just the .csproj over 2. nuget restore the project to load in nuget packages, which takes a long time usually for large projects 3. Okay now copy all the rest of the project over 4. dotnet publish to build the project This has the upside of optimizing out the nuget packages as a "cached" first couple layers, so theoretically steps 1 and 2 only ever run if you make changes to the nuget packages... Except... any modification to the .csproj file itself will still trigger a recache of steps 1-2 as it "dirty"s step 1, since the file's hash has changed. And turns out, a whole lot of random stuff can cause your .csproj file to change... So, is there a way you: 1. sanely and easily extract out all the nuget package data to its own file, that only gets changes specifically when nuget packages get changed, uninstalled, added, updated 2. Keep the rest of the project intact and a fresh git checkout of the project still can build and run as is with visual studio (if you run it, it will still be able to automatically detect missing packages and install them for local dev) Thoughts?
32 replies