An object is never "static", by definition. What you're really asking here is, presumably, "is the argument being passed in coming from a static field". There isn't really any way of answering that at runtime, but this could be validated in a custom Roslyn code analyzer. Typically you would create your own [MustBeStatic]
attribute that you would apply to the semaphore
parameter, and have the analyzer look for this attribute (by full name, not by type - simply because of how the compiler API works), and kick in some logic that would analyze call-sites and check the expression being passed in. This would (by necessity) result in a build-time warning or error, not a runtime exception - since Roslyn analyzers happen as part of the build.
So: it is absolutely possible (I've done very similar things). However! This is an absolute ton of work, using specialized and complicated APIs (the Roslyn API is powerful but very non-trivial). Honestly, unless you genuinely think you're going to use this a lot, I think this is better solved in code-review and testing.