Lisa
Lisa
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
When I have a CharacterActionResult I actually want CharacterActionResultData
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
When I have a FightResult I actually want FightResultData.
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
The abstraction should include:
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
}
}
}
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
}
}
}
While the inheriting object should be able to add extras, such that the complete object contains:
// EXAMPLE 1
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
},
"fight": {
// Some big object
}
}
}

// EXAMPLE 2
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
},
"destination": {
// Some big object
}
}
}
// EXAMPLE 1
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
},
"fight": {
// Some big object
}
}
}

// EXAMPLE 2
{
"data": {
"cooldown": {
// Some big object
},
"character": {
// Some big object
},
"destination": {
// Some big object
}
}
}
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
Solved by not hard locking on trying to make records work for no reason:
public abstract class ApiResponse<T>(T data)
{
[property: JsonPropertyName("data")]
public T Data { get; } = data;
}

public abstract class CharacterActionResult(Cooldown cooldown, Character character)
{
[JsonPropertyName("cooldown")]
public Cooldown Cooldown { get; } = cooldown;

[JsonPropertyName("character")]
public Character Character { get; } = character;
}

public class FightResult(Cooldown cooldown, Character character, Fight fight) : CharacterActionResult(cooldown, character)
{
[JsonPropertyName("fight")]
public Fight Fight { get; } = fight;
}
public abstract class ApiResponse<T>(T data)
{
[property: JsonPropertyName("data")]
public T Data { get; } = data;
}

public abstract class CharacterActionResult(Cooldown cooldown, Character character)
{
[JsonPropertyName("cooldown")]
public Cooldown Cooldown { get; } = cooldown;

[JsonPropertyName("character")]
public Character Character { get; } = character;
}

public class FightResult(Cooldown cooldown, Character character, Fight fight) : CharacterActionResult(cooldown, character)
{
[JsonPropertyName("fight")]
public Fight Fight { get; } = fight;
}
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
:salute2: Throwing it into a class then, Couldn't find that limitation in the documentation so I figured I was missing something
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
public record FightResult(FightResultData Data) : CharacterActionResult(Data);

public record FightResultData(
[property: JsonPropertyName("fight")] Fight Fight,
Cooldown Cooldown, // This one
Character Character // This one
) : CharacterActionResultData(Cooldown, Character);
public record FightResult(FightResultData Data) : CharacterActionResult(Data);

public record FightResultData(
[property: JsonPropertyName("fight")] Fight Fight,
Cooldown Cooldown, // This one
Character Character // This one
) : CharacterActionResultData(Cooldown, Character);
So I can
CharacterActionResult someResult = GetResult<T>();
someResult.Data.Cooldown;
someResult.Data.Character;
CharacterActionResult someResult = GetResult<T>();
someResult.Data.Cooldown;
someResult.Data.Character;
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
And if that reduces some duplication, that's a bonus
19 replies
CC#
Created by Lisa on 5/8/2025 in #help
✅ Nested Record Inheritance
I mostly just want a contract so I can access Cooldown/Character across the different result types
19 replies
CC#
Created by Lisa on 6/28/2024 in #help
✅ Unable to create migration - 'Unable to resolve service for type 'DbContextOptions'
Created a context factory, seems to work fine now:
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace Treehouse_Guardian.Database;

public class DatabaseContextFactory : IDesignTimeDbContextFactory<DatabaseContext>
{
public DatabaseContext CreateDbContext(string[] args)
{
var configuration = new ConfigurationManager()
.AddJsonFile("appsettings.json", false)
.Build();

var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
optionsBuilder.UseNpgsql(configuration["Postgres:ConnectionString"]);

return new DatabaseContext(optionsBuilder.Options);
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace Treehouse_Guardian.Database;

public class DatabaseContextFactory : IDesignTimeDbContextFactory<DatabaseContext>
{
public DatabaseContext CreateDbContext(string[] args)
{
var configuration = new ConfigurationManager()
.AddJsonFile("appsettings.json", false)
.Build();

var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
optionsBuilder.UseNpgsql(configuration["Postgres:ConnectionString"]);

return new DatabaseContext(optionsBuilder.Options);
}
}
2 replies
CC#
Created by harelc2005 on 5/12/2024 in #help
✅ Help with a project
Have you tried looking at libraries instead of apis? You can easily get the notes out with something like https://github.com/melanchall/drywetmidi
11 replies
CC#
Created by Letieri on 5/8/2024 in #help
Issue with unit test for Argon2-based password hash service
As you can see the salt is included in plaintext in the encoded string.
25 replies
CC#
Created by Letieri on 5/8/2024 in #help
Issue with unit test for Argon2-based password hash service
No description
25 replies
CC#
Created by Letieri on 5/8/2024 in #help
Issue with unit test for Argon2-based password hash service
This is because you are using argon2Config.EncodeString EncodeString includes information about how the hash was computed, including the salt. In this case the provided salt is ignored and the salt from the hashstring is used.
25 replies
CC#
Created by Letieri on 4/23/2024 in #help
Argon2
What makes you say so? I do not think your conclusion is correct.
11 replies
CC#
Created by zakatinhio on 4/26/2024 in #help
✅ ‘Step Test Data’
So, what's your question?
16 replies
CC#
Created by Haxo on 4/25/2024 in #help
How to Read byte by byte until EOF?
It depends on the filemode
19 replies
CC#
Created by Haxo on 4/25/2024 in #help
How to Read byte by byte until EOF?
:nodd:
19 replies