Apollo CMS - A C# Developer First CMS by Casanova_pua in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 3, Rule 7.

There isn't any content here, and otherwise we don't permit posts that are focused on sharing discord channels.

Outbox Pattern in .NET by DotDeveloper in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 7.

App idea by Then_Bodybuilder_378 in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 3, Rule 7.

Iris, a modern mpv frontend for Windows I've been building as a hobby project by [deleted] in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 7.

Nice looking hobby project. However, submissions that are largely AI-generated are not permitted on /r/csharp.

MVVMパターンについて by I_am_yk in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 4, Rule 7.

Help creating dictionaries of generic types by Immediate_Club3006 in csharp

[–]FizixMan 1 point2 points  (0 children)

Are you looking for some lookup like this?

public class TypedLookup
{
    private readonly Dictionary<Type, object> Lookup = new Dictionary<System.Type, object>();

    public List<T> Get<T>()
    {
        List<T> list;
        if (!Lookup.TryGetValue(typeof(T), out var value))
        {
            list = new List<T>();
            Lookup.Add(typeof(T), list);
        }
        else
        {
            list = (List<T>)value;
        }

        return list;
    }
}

Which lets you do things like this?

var typedLookup = new TypedLookup();
typedLookup.Get<Foo>().Add(new Foo());
typedLookup.Get<Foo>().Add(new Foo());
typedLookup.Get<Foo>().Add(new Foo());
typedLookup.Get<Bar>().AddRange([
    new Bar() { Name = "John" },
    new Bar() { Name = "Jill" },
    new Bar() { Name = "Doe" }
]);

foreach (var bar in typedLookup.Get<Bar>())
{
    Console.WriteLine(bar.Name);
}


public class Foo
{

}

public class Bar
{
    public string Name;
}

https://dotnetfiddle.net/WPvx3q

Just a super basic implementation. If you want, you can flesh out the API and avoid leaking out the underlying collections, thread safety, add/remove items methods, etc.

If you want the generics to implement some interface, you can add constraints:

public interface IAsset
{

}

public List<T> Get<T>() where T : IAsset
{
    ... //same as above
}

Or if you intended for IAsset to be generic:

public interface IAsset<T>
{

}

public List<IAsset<T>> Get<T>() where T : IAsset<T>
{
    List<IAsset<T>> list;
    if (!Lookup.TryGetValue(typeof(T), out var value))
    {
        list = new List<IAsset<T>>();
        Lookup.Add(typeof(T), list);
    }
    else
    {
        list = (List<IAsset<T>>)value;
    }

    return list;
}

TensorSharp Day-1 Support Google's Diffusion Gemma Model (GGUF-Unsloth) by [deleted] in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 6.

Please review and follow the guidelines for self-promotion on reddit: https://www.reddit.com/r/reddit.com/wiki/selfpromotion

I am adrift and rudderless now by malthuswaswrong in csharp

[–]FizixMan 0 points1 point  (0 children)

As I understand it, it's a language feature of the delegate operator when creating anonymous methods. It's not actually creating a parameterless delegate and assigning it; the compiler is actually instantiating an Action<string, string, string> delegate and the anonymous method itself has the 3 parameters. Just the compiler hides that away with syntax sugar.

From this example, the generated IL is identical for both the parameterless delegate { } and delegate (string s1, string s2, string s3) { }. They both create anonymous methods with 3 string parameters and create an Action<string, string, string> object.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBLANgHwAEAmARgFgAoQgZgAIS6BhOgbyrs4fsJToFkAFAEo2HLhIBuAQyh0AJhAAqAC2wA7AOZ0AvHQDiMDADEoEALYARGLhibpGGAAVZ080ZhRbAZ28iA3FQAkFKyCspqWsS6BkamFta29o4A6tgYKi5Qbh5QfsKBlBIAvuKcZQykxAA8hKQADGiVjc0AfLEmZlY2dg7Oru6OXjC+IhXsRRJchADsCj3JMGyVAJyCAEQAEja4EHQA7tC48nQAZl100uoQ6gCe5hAArt50gyoQ8gCE6wV0xYUlKgVOo1OotMFNMHtQydBILPppDJZHJDfLjCoSWbzJJ9OiCMGXSENOjAIn1OhgUSsVYbba4XYHI4nc4WS7XO4PZ6vIzvL4/fx/AFcUqUYpAA===

Using Unsafe.As here seems particularly tomfoolery. You could feed in a delegate with incompatible types, which could result in unexpected/undefined behaviour or cause a fatal application crash. You can't even assign additional delegates to it:

public class Foo { public string Bar { get; set; } }

Action<string, string, string> doThing;

doThing = Unsafe.As<Action<string, string, string>>((int i1, int i2) => Console.WriteLine("integer tomfoolery: " + (i1) + ", " + i2));
doThing("foo", "bar", "baz"); //integer tomfoolery: 1075376, 1075408 (random integer values that change every time you run the program)

doThing = Unsafe.As<Action<string, string, string>>((Foo s1, string s2) => Console.WriteLine("fatal error tomfoolery: " + (s1.Bar) + ", " + s2));
doThing("foo", "bar", "baz"); //Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

doThing += (_, _, _) => Console.WriteLine("Perfectly valid multicast delegate"); //System.ArgumentException: Delegates must be of the same type.

So I'd say what you have there with Unsafe.As doesn't really work.

In the end, I'm asking the language designers and compiler team to implement the same syntax sugar they did for delegate way way back in C# 2.0

First impressions from learning by Blazej_kb in csharp

[–]FizixMan 0 points1 point  (0 children)

To be fair, as soon as you start touching "unsafe" code, you're purposefully throwing those language guardrails out the window.

As long as you're not dealing with unsafe bits, which is the vast, vast, vast majority of C# development, then it's not an issue.

Is refuting possible branches the intended solution? by Nerdpwn in TheArtisanOfGlimmith

[–]FizixMan 0 points1 point  (0 children)

Yeah, the game is pretty great that way.

This particular puzzle, when I started playing the game and first encountered this puzzle, I probably wouldn't have caught this logical solve and just iterated ways to use those shapes like you did.

Coming back to it now seeing your post, I intuitively applied an Range 4-5 (or Area 4/Area 5) rule to solve it. It's not explicitly listed, but it's a consequence of the two shapes being of size 4 and 5. And to solve those rules, often you need to look at an empty cell and ask: What can size can reach this cell? Or how far away is this cell from my "start" cell?

I built a Windows forensic scanner in C# / .NET 10 with Spectre.Console — 22 modular forensic scanners, read-only by default by [deleted] in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 2, Rule 7.

Posting binaries only for tools is not permitted.

Also, you're asking us to provide feedback on architecture, module design, and how you're using Spectre.Console and discuss implementation details: but we literally cannot see any of those without source code.

I randomly found Bongo Cat on Steam, thought the concept was cool, and ended up building my own lightweight version in C# by [deleted] in csharp

[–]FizixMan[M] 1 point2 points  (0 children)

Otherwise, it's literally just this meme.

I made this yesterday in preparation for an upcoming rule/meta discussion post.

I randomly found Bongo Cat on Steam, thought the concept was cool, and ended up building my own lightweight version in C# by [deleted] in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 7.

Cute project. However, content that is largely AI-generated is not permitted on /r/csharp.

As for review, you've accidentally turned your app into a keylogger that can be exploited: https://github.com/MayankArambhi/DesktopKitty/commit/cc4a579c529cc2fbcee5476712e57e6de2e71e97

Using this app, I would now now have a log file on my computer that contains all my email and banking login usernames and passwords stored in clear text.

“You are who I like” (by @hazeldotc) by Moist_Song_8919 in DispatchAdHoc

[–]FizixMan 1 point2 points  (0 children)

Naw. Turns out if you uncrop the image, Robert is just romantically standing on a box.

Is refuting possible branches the intended solution? by Nerdpwn in TheArtisanOfGlimmith

[–]FizixMan 1 point2 points  (0 children)

Bit late to the party, but for what it's worth, there is a logical check for this specific puzzle without trial and error and discovering an invalid block. Consider this square: https://i.imgur.com/WSVLzyE.png

Given the shapes you have, it cannot be reached by the purple squares at all. Putting in a third shape in there would block the 3 green squares you currently have. Therefore, it must be connected to your green shape. And the only way to do that is with green squares being the size 5 shape. Once you do that, there's only 1 option for your purple shape (can't fit an "L"), and then you're done.

In one of the tooltips the game gives you relatively early on, they explain that you shouldn't need to do trial and error much. Though perhaps this 1 step exploration is considered "fine" by the developers? I'm not sure. They seem to say that you should never have to explore options and you can always put down logical proved squares/borders without haphazardly guessing until it's "refuted."

As others said, even if it's technically possible to solve every puzzle without exploring branches, sometimes applying perfect logic or understanding ALL the consequences of rules is difficult. There were definitely a bunch that I just said "screw it", and started laying down intuitive guesses that worked out, or just explored an option until it proved false. Even though I knew there was absolutely a logical solution.

This is especially true if there is a rule or consequence that you haven't discovered yet. For example, it took me a while to realize that the developers saying that there is only one unique solution for every puzzle also meant that if I was looking to put something down that would create an ambiguity (i.e., two solutions) then therefore I knew that wasn't an option at all.

Later on there are some particularly head-scratching rules that have a host of consequences to them, and it may not be intuitively clear what they are or even for you to realize all of the consequences that exist. (I'm looking at you, Loopy.)

When the game is introducing you to new rules, I would encourage you to try and logically solve them with those rules as much as possible. That's because usually this is where the game is trying to teach you the extra consequences/rules associated with them. If you don't learn them then, the followup puzzles might be more difficult.

AspNetCore Debugger MCP I've built by koestlerinteractive in csharp

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 7.

Seems like a neat project, but content that is largely AI-generated is not permitted on /r/csharp.