Category Archives: C#

C# issues and solutions

Auto-disposing? Empty using syntax?

What do you think? Should this code auto-dispose the X object instance created but not used? If you test it, you’ll see it does not: public class X : IDisposable { … } static void Main(string[] args) {     … Continue reading

Posted in C# | Tagged , , , | Leave a comment

Mocking Entity Framework to unit test your data services

It’s not easy to write unit tests for services that use DbContext and DbSet<T> classes from Entity Framework (or Entity Framework Core), and there are complex solutions to approach this, like separating the data access layer completely, as I propose in my UnitOfWork-EntityFramework implementation. … Continue reading

Posted in Architecture, C# | Tagged , , , , , , | Leave a comment

Change notification chaining

Sometimes you want to define a complex container that aggregates other objects and you would like to chain INotifyPropertyChanged notifications upwards. However, it is difficult to write all the code to wrap up everything needed, and often results in code … Continue reading

Posted in .NET, C# | Tagged , , , , | Leave a comment

Naming items

From time to time I find projects with completely inconsistent naming for their items. While I believe naming things – be them source code files, variables, or enum values – is one of the most important things for the long … Continue reading

Posted in C# | Tagged , , , | Leave a comment

Reverse for

When one writes a for loop for ascending order it will probably be like this: for (int i = 0; i < count; i++) But what if you want to do it in reversed order? The first option would be: … Continue reading

Posted in C# | Tagged , , , | Leave a comment

Bridging

When you, a Microsoft technology-oriented developer, write software today you have to select the target platforms you would like to support. The platforms are then used to select the tools, technologies, and programming languages you can use for coding the different layers of … Continue reading

Posted in .NET, Architecture, C#, Development, JavaScript, Unity | Tagged , , , , | Leave a comment

IReadOnlyCollection instead of IEnumerable

Whenever you expose a service API, either internally to your team, or publicly in a framework, such as with an interface or simply in a method signature and you want the client to pass or receive a collection of objects you have … Continue reading

Posted in .NET, C# | Tagged , , , , , , , | 1 Comment