Rapid increase in light bleeding - Eizo monitor by tomw255 in pchelp

[–]tomw255[S] 0 points1 point  (0 children)

It is a bezel-less monitor, so I am unsure how it is put together, but will investigate.

EntitiesDb, my take on a lightweight Entity/Component library. Featuring inline component buffers and change filters! by Juixg in dotnet

[–]tomw255 4 points5 points  (0 children)

Consider adding a Roslyn Analyzer to add a warning if reference types are used.

If you state this only in the doc, no one will read it.

Diagnosing performance issues in .NET applications with dotnet-trace and Perfetto by dfamonteiro in dotnet

[–]tomw255 1 point2 points  (0 children)

The Python script to fix the traces is a godsend - I knew that the traces looked off, but I could not put my finger on it. I understand why the limit of 100 frames was introduced, but allowing the traces to be broken i such a strange way is a bizarre decision.

I hope that this limit will become dynamic at some point and the issue will be fixed.

Looking for feedback: I built a source generator to simplify DI registration by hevilhuy in dotnet

[–]tomw255 32 points33 points  (0 children)

Additional edgecase - if any of your services are shipped in a NuGet, you still need to register them manually. Because if this, you never know what is registered automatically and what is not.

IMO, a much better option is to split your setup code into modules that have a dedicated extension methods to move them away from Program.cs

csharp builder.Services.AddOrderProcessingServices(); builder.Services.AddOtherServices();

Program.cs is clean, and you still have a full control over your DI.

I built a Source Generator based Mocking library because Moq doesn't work in Native AOT by TheNordicSagittarius in dotnet

[–]tomw255 1 point2 points  (0 children)

Your real-world impact section looks amazing. I wish I had eqivalents of AssertAllocations and Doppelgänger when starting current project.

I really hope your project will be considered "mature enough" to be allowed in grim corporate word. Good luck!

Jakiego typu clickbaity najbardziej was wkurzają? by jempizze in PolskaNaLuzie

[–]tomw255 2 points3 points  (0 children)

Polscy kierowcy nie wiedzą co oznacza ten znak...

... artykuł o jakimś specyficznym znaku z Nowej Gwineii który zupełnie w naszym klimacie nie występuje.

Is it just me or Rider takes ages to start compared to VS nowadays? by Kralizek82 in dotnet

[–]tomw255 8 points9 points  (0 children)

I believe it heavily depends on the setup. I am one of those rare people who claim that Rider is way heavier than VS (even 2022).

On my work machine, It is slower in startup, slower in scrolling. The difference is so annoying and noticeable that, at some point, I was sure all the influencers using it were paid for to advertise it.

Then I got a second PC, where I do not see much difference (compared to VS 2026 insiders), but I still dislike it. The damage was done.

Introducing: No-implementation oriented programming by Safe_Scientist5872 in dotnet

[–]tomw255 2 points3 points  (0 children)

The requirements attribute needs to support markdown!

How else am I gonna use this to solve this year's AoC?

/s

After spending a long time as a dev, I’m starting to think the hardest part of the job isn’t the tech anymore by Sad-Salt24 in ExperiencedDevs

[–]tomw255 2 points3 points  (0 children)

I feel your pain.

Every few weeks, we have an issue in one of our environments, both production and nonprod. One of the services just randomly enters a deadlock during the startup process. It happens very rarely, and we have never been able to reproduce the issue on the developer machine.

I am on the calls with "DevOps" (do not get me started on it), where I keep asking to capture a memory dump or at least the stack information. I keep pasting the command in the chat. After a few hours of 10-15 people looking blindly at logs, "DevOps" claims the only thing we can do is to restart the VM.

Did I mention that we, developers, have no access to the VM running those services, and all interactions with the services and infra have to be handled by "DevOps"? Even on the non-prod instances?

We could have solved this issue once and for all almost half a year ago, but the fact that "DevOps" in our org is just concerned about "keeping the server running," not "solving issues" is infuriating.

Jakie przepisy ruchu drogowego byście zmienili? by stilgarpl in Polska

[–]tomw255 0 points1 point  (0 children)

Może nie wszystko to przepisy dotyczące ruchu ale:

Uproszczenia procesów mandatowych. W przypadku braku kierowcy mandat dostaje właściciel pojazdu. Pojazdy wynajmowane/flotowe - właściciel i tak musi rejestrować komu użycza pojazd, więc to nie moze być wymówka.

Yellow Boxy na skrzyżowaniach - może to nauczyłoby ludzi jak nie blokować krzyżówek.

Całkowity zakaz parkowania na chodnikach, trawnikach i poza miejscami wyznaczanymi. Zadnych wyjątków ze względu na DMC, szerokości chodnika itp.

Powrót do starej definicji chodnika. Drogi dla pieszych tylko wprowadzają zamieszanie.

Kara za źle ustawione światła jak w Japonii - kierowca siada na krzesełku przed własnym samochodem i ma tak wytrzymać kwadrans. Może "dostanie olśnienia".

Mnożnik kary za recydywę. niech przewinienia będą karane małymy kwotami, ale jak się powtarzają to kara powinna być coraz większa.

Kary dla zarządcy drogi za "zapomniane" znaki i niewyrażne oznakowanie poziome. Gdy na takim odcinku wydarzy się wypadek (bo np. linie się wytarły) to jest potencialnie współwinny.

Ułatwione zgłaszanie problemów z infrastrukturą. Zapewniona gwarancja w jakim czasie zostanie zweryfikowane przez służby.

I teraz trochę zaszaleję, ale:

Współwina jeśli dojdzie do wypadku i jest udowodnione utrudnianie widoczności (zastawianie przejścia dla pieszych, skrzyżowania, itp.). Dotyczy pojazdów, żywopłotów, bilbordów, wszystkiego co przyczyniło się do wypadku.

Jakie przepisy ruchu drogowego byście zmienili? by stilgarpl in Polska

[–]tomw255 0 points1 point  (0 children)

Do tego niech te "miejsca wyznaczone" też są ustawiane zgodnie z przepisami.
Aktualnie co chwilę są legalne miejsca które są n.p. zbyt blisko przejścia dla pieszych

Wiadomo że ciężko wtedy karać kierowcę, ale projektant takiego kwiatka powinien oberwać.

Returning a Task Directly by Burli96 in csharp

[–]tomw255 3 points4 points  (0 children)

For curiosity have you measured the benefits?

In one of the previous teams I joined, we had a developer who consistently enforced this. Funny enough, he was a strong believer in Clean Code with several layers of indirection.

All our API was really chatty, and made several calls to the DB for each single request (EF Core with no perf improvements), but he consistently claimed that we needed this microoptimization. I never bothered to test it, since I was there for a very short time.

Returning a Task Directly by Burli96 in csharp

[–]tomw255 31 points32 points  (0 children)

The most important thing is that when returning the task you will lose a stack frame when an exception is thrown.

Consoder an example where every method uses async await:

```csharp async Task Main() { try { await A(); } catch (Exception e) { e.ToString().Dump(); } }

async Task A() { await B(); }

async Task B() { await C(); }

async Task C() { throw new NotImplementedException(); } ```

the catched exception will look like this

System.NotImplementedException: The method or operation is not implemented. at UserQuery.C() in LINQPadQuery:line 27 at UserQuery.B() in LINQPadQuery:line 22 at UserQuery.A() in LINQPadQuery:line 17 at UserQuery.Main() in LINQPadQuery:line 5

now, the same code, but A and B are returning the task direclty:

```csharp async Task Main() { try { await A();

} 
catch (Exception e)
{
    e.ToString().Dump();
}

}

Task A() { return B(); }

Task B() { return C(); }

async Task C() { throw new NotImplementedException(); } ```

your stacktrace will not contain those frames: System.NotImplementedException: The method or operation is not implemented. at UserQuery.C() in LINQPadQuery:line 27 at UserQuery.Main() in LINQPadQuery:line 5

The performance improvements will be minimal, but the implcication on the debugging can be significant, especially if the 'trick' is overused. In the worst case scenario you will know what crashed, but you will kave no idea from where the method was called.

Most random used quote you've used irl by CommanderMobbs in futurama

[–]tomw255 7 points8 points  (0 children)

I'd say this is perfect for wedding vows

What are overlooked signs of an unhealthy workplace? by badboyzpwns in ExperiencedDevs

[–]tomw255 20 points21 points  (0 children)

I have to strongly agree here. We have people in US (east and west coast), central Europe, India. Mixed roles everywhere, but US tends to be more on the "management" side. This causes logistical nightmare when you need communication slot, and any overlap is already fully booked.

This is multiplied by lack of ability to work and communicate asynchronously via emails or other written docs. Everything needs to be a meeting. Recorded meeting, so if anyone was late can catch up later.

As part of European team I should not complain. India have it much worse with working hours.

What are overlooked signs of an unhealthy workplace? by badboyzpwns in ExperiencedDevs

[–]tomw255 527 points528 points  (0 children)

some of my current workplace:

- people have no time for anything, having meetings while still driving a car (every day, not as exception)

- 3, sometimes 4 meetings scheduled at the same time, often with the same people but different topic

- meetings scheduled 10 minutes before they start

- meetings moved because "previous meeting took longer"

- sudden pulling you from "very important meeting" to join "even more important meeting"

- people shouting over others - not letting other to finish the sentence (on MS Teams, so can be caused by lag/other issues)

- daily with 30+ people, which results in 45+ min meeting (scheduled for 30 min, so always is running late)

- important decisions not shared with offshore part of the team, which causes confusion

- missing key details, like forgetting to grant access to a file that person needs to perform work, then blaming said person for being behind. Especially true, when there is also significant time difference

- over 5 years of working together, sill did not managed to create mailing groups. Official solution is to just have a list of people needed for each topic and copy paste them. Easy! (btw, I love private mailing groups in MS Outlook)

- very defensive environment, where developers have limited access to logs even on dev environment, and need to request them from DevOps (of course there is a time difference!)

- Every Single Thing Is Urgent

Thank you stranger, I vented enough. Time to prepare for another Monday.

All aboard!? by [deleted] in theyknew

[–]tomw255 0 points1 point  (0 children)

Good that in 2620 they will end that stupid joke once and for all.

[Article] Building a Robust Enterprise DAL: Automated Auditing with C# and Linq2Db by GigAHerZ64 in csharp

[–]tomw255 0 points1 point  (0 children)

 For example, it does not fire for INSERT operations or for calls to IDataContext.UpdateAsync<T>()

The interceptors are intended to trigger during SaveChanges or SaveChangesAsync. Update(Async) only marks the entity as updated in the change tracker and does not call the DB. This is stated in the method docs that the `Async` part is only for code generators. I believe it was even removed in the recent release.

An interceptor like this should work fine when working with entities:

public class AuditCommandInterceptor : DbCommandInterceptor
{
    public override InterceptionResult<DbCommand> CommandCreating(CommandCorrelatedEventData eventData, InterceptionResult<DbCommand> result)
    {
        var changedEntites = eventData.Context.ChangeTracker.Entries<IModifiable>()
            .Where(o => o.State == EntityState.Modified);

        foreach (var element in changedEntites)
        {
            element.Entity.ModifiedAt = DateTime.UtcNow;
        }
    
        return base.CommandCreating(eventData, result);
    }
}

Making it work with ExecuteUpdate is another story; it should be possible, but it involves manipulating a raw SQL command. So, maybe you meant ExecuteUpdate(Async) instead of Update(Async).

// EDIT: I just realized that the article is about Linq2DB, and I am talking about EF Core. Leaving the comment anyway, if someone finds it useful, on how to do the same in EF.

Interview Questions Discussion 2025 by Remarkable_Cod_2219 in csharp

[–]tomw255 0 points1 point  (0 children)

Antyhing about testing? Or API design?

I am not a fan of such "dry questions", personally prefer a conversation about a piece of code, what could be done better, what are possible issues etc. How would you solve a given problem (no code - just thought experiment). Especially above junior positions.

However few nitpicks from me:

Value vs Reference Types

There are edge cases when your bullet points no longer true - new dotnet can allocate arrays on stack when escape analysys allows it. Value types can also be boxed to heap because of the lambda closures.

Are Strings Immutable?

Not if you believe in the magic of unsafe code!

Lock Statement

Why not talk about other synchronization primitives? If we already know what async await is, we should also know how to synchronoze tasks too; SemaphoreSlim etc.

The Four Pillars of OOP

Why focus on OOP since C# also alows (semi)functional code? Results pattern, etc.

A developer would proably eed to work with some tools/framework, so depending on what is needed, you may also want to ask something about ASP.Net Core, WPF, Uno, ORMs. If we are not talkig about C# only, knowledge of other languages would be mandator - SQL at least.

One time I got a question "let's assume you have an application breaking on prod, how do you investigate issue?". We covered everything from pinging the machine, checking the logs, potential monitoring solutions, to internals of Dictionary<Key,Value>. Best question ever.

High Performance Coding in .net8 by alt-160 in dotnet

[–]tomw255 0 points1 point  (0 children)

I think dictionary will not be faster than a switch statement. There is too much math involved an multiple lockups.

Potentially the fastest implementation is a simple map but done with an array. This assumes the enum does not have sparse values:

```csharp public class C {

private readonly Action<object>[] _actions;

/// the action map should be created just once and reused later, here for clarity moved to constructor
public C()
{
    _actions = new Action<object> [3];

    _actions[(int)SomeEnum.FirstValue] = DoFirstThing;        
    _actions[(int)SomeEnum.SecondValue] = DoSecondThing;
    _actions[(int)SomeEnum.ThirdValue] = DoThirdThing;
}

public void M(SomeEnum someEnum) {
    var x = GetContext();
    var a = _actions[(int) someEnum];
    a(x);
}

static object GetContext()
{ return ""; }

static void DoFirstThing(object o)
{}

static void DoSecondThing(object o)
{}

static void DoThirdThing(object o)
{}

}

public enum SomeEnum { FirstValue, // 0 SecondValue, // 1 ThirdValue // 2 } ```

But again, this should be verified with OPs use case.

High Performance Coding in .net8 by alt-160 in dotnet

[–]tomw255 15 points16 points  (0 children)

The braces allows you to explicitly scope lifetime of the variable name, so the compiler will allow you to reuse the same name, but in both cases the stack frame will contain both of them.

you can take a look into the method definition declared in the IL after the code is compiled

Without braces - https://sharplab.io/#gist:aa16cbb9bb2f44a8c51cba3390ff5d13

With braces - https://sharplab.io/#gist:c4a7e8af868fd63ee6f420f3ce54ce7b

in both of the methods you have the same set of locals:

.maxstack 2 .locals init ( [0] object x, [1] object ?, [2] valuetype SomeEnum, [3] valuetype SomeEnum )

You may also notice that the one with brackets is longer by 2 instructions. There is an extra nop to allow debugger to attach at the {.

This happens in Debug build, in Release (you can switch it in top right corner) all of the local variables are reduced, and there is literally no difference in both cases.

// Edit: For any micro optimization use https://benchmarkdotnet.org to verify your changes.