Dennis Doomen

Dennis Doomen

@dennisdoomen.com

Microsoft MVP | Coding Architect | .NET Tech Lead | .NET & C# | TypeScript | Fluent Assertions Author | International Speaker | Occasional Trainer | React & VueJS | Event Sourcing Veteran | DDD Designer | TDD Practitioner | Clean Code Writer

1.7K followers685 following1.4K posts

A couple of people asked me why I created (yet) another .NET HTTP mocking library. I found that hard to explain without criticizing other options, so it's something you need to try to fully understand it. The people that did, were all enthusiastic and helped me fine tune the API.

PackageGuard 2.11 blocks packages that OSV lists as malware, whatever their risk score. It also ranks vulnerabilities with CISA KEV and EPSS exploit data. A new setting accepts a known vulnerability, with a reason. packageguard.org

Treat the results as candidates. The command reads the restore graph, so it cannot see what your code uses directly. Some packages now score lower after scoring fixes. Check risk exceptions tuned to old scores. Thanks to Chrison Simtian for the command.

A week with more architecture and meetings than coding is clearly visible in my Claude usage. I've only used 38% of my weekly budget.

PackageGuard, the fully open-source alternative to tools like Snyk, Black Duck and others, has just received an update that improves the risk report by removing overlapping risk factors and include all the vulnerabilities details. Also check out the new website at packageguard.org

When should a C# operation be a method rather than a property? Use a method if it’s expensive, performs a conversion, returns a different result each call, or causes side effects. Lazy-loading and internal caching are reasonable exceptions. #csharp #codingguidelines #codingconventions

Properties should be stateless with respect to other properties. Setting DataSource then DataMember should have the same result as the reverse. Sounds trivial, but I've seen plenty of classes where properties were anything but simple. #csharp #codingguidelines #classdesign #codingconventions

I've just burned through my 5-hour limit and 13% of my weekly limit in 38 minutes and I don't even understand what happened. Using Cloud Team and Sonnet 5.

PackageGuard, your totally free NuGet/NPM package scanning and risk reporting tool now supports generating a Software Bill Of Materials (SBom) in CycloneDX and SPDX format. Check out the documentation at github.com/dennisdoomen... Stay tuned for even more awesome features soon...

💡And for those that are concerned about the dependency hell. Reflectify ships as a source-only package. In other words, it compiles the code into your project without any visible binary dependencies.

Looking forward to my first real .NET conference in Switzerland. And let's start the conference season on a high note with two talks in the same day. Will I see you there? #mvpbuzz #dotnetdaych

During the weekend, I've released Mockly 1.11, the new in-memory HTTP mocking library in town. This version allows you to simulate delayed responses or requests that throw exceptions. Check out the docs at mockly.org

An interface with one method is often just a named function signature. If it is not likely to grow, a delegate is simpler, more loosely coupled, and easier to test.

Prefer a single-method interface when state matters, the contract is strong (IDisposable, IEquatable), default interface methods help, or more members are likely soon. #codingstandards #csharp #codingguidelines #designpractices #bestpractices

C# 12 primary constructors reduce boilerplate when capturing dependencies. Prefer when: ✅ Constructor only captures dependencies/config ✅ No complex initialization Avoid when: ✅ Validation or non-trivial initialization is needed #csharp #codingguidelines #classdesign

We released Fallout 10.4—the first new version since Nuke was abandoned. Fallout replaces messy YAML pipelines with refactorable, debuggable, navigable C#. • Inspired by Make • Makes Azure DevOps → GitHub Actions migration easier • Used in my OSS & client projects

Choosing between records and classes in C# matters! Records: data-focused, immutable, structural equality (DTOs, value objects) Classes: behavior-focused, mutable state, identity-based Record struct: small immutable values (stack allocation) Mix them and you've got a design problem. #CSharp

In general, if you find a lot of data-only classes in your code base, you probably also have a few (static) classes with a lot of behavior. Use the principles of object-orientation explained and move the logic close to the data it applies to. ⚠️The only exceptions to this rule are classes...

...that are used to transfer data over a communication channel, also called Data Transfer Objects, or a class that wraps several parameters of a method. For DTOs, consider using an immutable record type instead of a class to make the intent explicit. #csharp #codingguidelines #classdesign #

If you find yourself writing code like this someObject.SomeProperty.GetChild().Foo() ...then you may be violating the Law of Demeter. An object should not expose other classes it depends on, because callers may misuse that exposed property or method to access the object behind it...

By doing so, calling code becomes coupled to the underlying class you're using, making it harder to replace or refactor later. 💡 Fluent Interfaces may look like a violation, but they're simply returning themselves to enable method chaining, so they don't break the intent of the rule...

💡 Inversion of Control or Dependency Injection frameworks sometimes require exposing a dependency as a public property. If it's only used for dependency injection and nothing else, I wouldn't consider that a violation. #bestpractices #codingdesign #codingguidelines #csharp

In other words, you should be able to pass an instance of a derived class wherever its base class is expected, without the callee knowing the derived class. A very notorious example of a violation of this rule is throwing a NotImplementedException when overriding methods from a base...

Did you know there's a great way to start building an (open-source) library in .NET that comes with everything you'd expect from a professional package? And did you know it supports GitHub and Azure DevOps? If not, check out github.com/dennisdoomen.... Version 1.9 was released over the weekend.