Questions tagged [c#]
C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform
4,945
questions
0
votes
4
answers
32
views
Exceptions and the Liskov Substitution Principle
Consider the following scenario.
I have an interface IService:
public interface IService
{
void DoSomething();
}
with an implementation:
public class Implementation : IService
{
// This might ...
13
votes
4
answers
3k
views
How to name uppercase variables when using the camelCase convention?
I am writing a C# class and one of the fields is an API endpoint. Being that API is an acronym and is written in all uppercase letters, what is the correct way to name the field _APIEndpoint, ...
0
votes
3
answers
194
views
Adding a CLI to a Windows service
I have a Windows service that I would like to extend and add a CLI to it similar to docker or Elastic Agent, so I have a question about what kind of approach I should use for the *.exe to communicate ...
3
votes
1
answer
246
views
Gradual upgrade of an inherited .NET Framework project
I'm seeking advice on the best approach to upgrade a legacy .NET Framework project to a newer version. The project currently consists of over 80 projects, and a complete rewrite would be a time-...
1
vote
0
answers
71
views
When taking sections of an existing c# codebase to create a module/package of code for general use, how should we configure the module?
When spinning off sections of a (C#) codebase to create libraries/package for use by other users within a team/organization, what are important considerations in terms of code & package ...
0
votes
1
answer
254
views
Is IRepository allowed to know about database entities?
I am trying to apply Robert Martin's Clean Architecture on my .NET project. In one of chapters about boundary, it talks about that database interface should reside in business logic component rather ...
3
votes
3
answers
238
views
Handle hierarchical relationships between large number of enums
I am working on a C# project and I have a somewhat large number of labels (~100) that have some sort of relationships between one another. Here is a minimal dummy example that illustrates this:
...
0
votes
2
answers
112
views
Resolving dependencies independently of the IoC container
I'm working on a component, let's call it MyComponent, which is intended to be used by various applications. These applications will get MyComponent as a NuGet package for instance.
Assume that ...
0
votes
1
answer
74
views
.NET - Communication between services and Power BI
I have the following problem which I don't know much about. I have a ServiceA that returns customer data on transactions and a ServiceB that has reports, also my environment uses Power BI from ...
0
votes
2
answers
139
views
Setting up private properties for unit testing
I'm doing some TDD practice for my own learning.
I'm trying to figure out how to transparently set up private properties of an object to support testing.
I have a binary tree node:
internal class Node ...
0
votes
0
answers
53
views
Multi-tenant (realm based) REST Web API authentication
We're building a multi-tenant setup with a C# Web API and KeyCloak for auth and APISIX as application gateway. APISIX handles the authentication and passes an X-Access-Token to our API when ...
0
votes
3
answers
122
views
Use of environment variable or appsettings as a counter, good or bad practice [closed]
I'm wondering if it's bad practice to have a variable in a webserver which counts the amount of incoming requests and put it in an environment variable.
In C# for example you have System.Configuration....
1
vote
2
answers
249
views
OneOf with multiple steps and early returns
Looking for the best way to use OneOf multiple times, returning early depending on the result, specifically if you can get an Error along the way.
For example, consider a builder where you need to ...
3
votes
2
answers
312
views
Invariant rule in Liskov Substitution Principle
From Liskov Substitution Principle, I am still not very clear about the invariant rule. I read through many posts but I still have doubts.
My example is picked from this blog, the example is slightly ...
4
votes
1
answer
406
views
Does C# 8 reference type nullability make Option/Result monad obsolete?
As the most common exceptions in my project are NullReferenceExceptions I'm trying to find a way to limit the occurrence of problems with unexpected or unhandled nulls to the minimum.
One of the ...