Visual Studio 2017 Unity debugger: some break points get hit, some don't

In Visual Studio Community 2017, I press Debug → Attach Unity Debugger, select proper instance of Unity.

Breakpoints are shown as red filled circles and get hit in SOME .cs files. But NOT IN OTHERS - these are shown as empty red circles with an exclamation point.

It seems random which files work and which don’t. Also, turns out, if a breakpoint that works gets hit, and I continue execution step-by-step, it can come to the point where the other, non-working breakpoint is.

What I have tried to fix this (and none of this worked):

  • installed the latest Unity editor (2021.3.20.f1)

  • clean, rebuild solution

  • deleted Library, obj, all vs related folders

  • switched between .NET Framework and .NET Standard 2.1 in player settings

  • switched to Visual Studio 2019 - it’s the same issue, in some cs files breakpoints work, in some they don’t

This never happened before. Started happening in the last 2 weeks. But I didn’t update Unity. I had a Windows 10 update.

EDIT: in Visual Studio 2019 it seems to start working for some files if you get from a working to a broken breakpoint using step-by-step execution.