Questions tagged [.net]

The .NET Framework is a software framework for Microsoft Windows operating systems. It includes an implementation of the Base Class Library, Common Language Runtime, and Dynamic Language Runtime. It supports many programming languages, including C#, VB.NET, F# and C++.

Filter by
Sorted by
Tagged with
-1 votes
3 answers
141 views

Refactoring multiple non-nested if statements [C#]

I have a number of non-nested if statements that look like this: if (!bytes[nameof(PropertyVersion.Price)].SequenceEqual(dbBytes[nameof(PropertyVersion.Price)])) changes += $"Price {TextHelper....
  • 115
0 votes
1 answer
40 views

Proper orchestration of NServiceBus sagas

I'm seeing two ways of orchestrating NServiceBus sagas. I'm not familiar with it so I'm trying to understand if they are just two alternative ways of doing the same thing or if I should follow one or ...
0 votes
0 answers
42 views

Best practices when it comes to extending Service collections in .NET for dependency injection

Most of the information that I can find online is about how to do basic dependency injection in the common flows. eg one DI container where services are registered. For a project we are writing a ...
  • 101
2 votes
0 answers
64 views

Best approach for several steps with user input in between

I've read several questions and I couldn't find one specifically similar to mine. I also don't think there's a design pattern for this situation as I think my system is a legacy system and don't fit ...
0 votes
1 answer
124 views

Correct IHttpClientFactory implementation with dependency injection?

In Microsoft's documentation, in the Named Clients example, they retrieve an HttpClient from the IoC container: var httpClient = _httpClientFactory.CreateClient("GitHub"); In the Typed ...
1 vote
1 answer
57 views

DDD - Modelling a system of groups and users

I'm looking for some advice on a system I'm designing, at its core it will allow users to create/join/manage groups of users. I thought it would be a good idea to try and apply some DDD principles, ...
1 vote
2 answers
155 views

C# - Class creating instances of other classes requiring different services

Context I have a service class whose sole purpose is to interact with a specific API, let's say the Automotive API. The API mostly works with generic AutomativeRecord which basically represents a ...
2 votes
2 answers
309 views

Is updating to a new .NET-version a major or minor version change when using SemVer?

When updating to a new major version of .NET (in this case from .NET 5 to .NET 6) without needing to make any change other than selecting the new target framework in Visual Studio, does this warrant a ...
  • 39
0 votes
3 answers
156 views

Hardcoding endpoints in library alternative

I'm dealing with creating a few internal libraries for a project that can offload emails and logs to a queue (Service bus, storage queue). The issue I'm having is how to configure the the queueing ...
0 votes
0 answers
28 views

SOAP client app design approach - many endpoints with similar contracts

I have a question regarding the code design for a client application that will connect to external SOAP services. Basically, I need to write a client application in .NET that will connect to external ...
  • 109
0 votes
1 answer
297 views

How to implement automatic SemVer from code changes [closed]

Goal I'm working on libraries published as nuget packages and I would like the version of those packages to update automatically based on the changes I make. In other words, I would like something ...
  • 204
0 votes
1 answer
203 views

Alternatives to DDD - Complicated and cumbersome business logic/process

We have inherited a legacy MS CRM 4.0 application and the business wants it re-written to an as vanilla as possible .NET web application. The business wants to go down this route vs another off-the-...
  • 115
3 votes
4 answers
1k views

How to get an ILogger instance from extension methods?

Let's say I have this service abstraction exposed from a library. public interface INavigator { ImmutableList<IPageViewModel> Entries { get; } void NavigateForward(IPageViewModel page); ...
  • 204
0 votes
1 answer
55 views

Trying to implement a "password vault"-like solution for connection strings

I started to work on a 16 years old .net framework app that didnt receive any love for a decade and I have some time to "put it up to standards". One of the things that ruffle my feathers is ...
-1 votes
1 answer
110 views

Writing a API for a hardware device for mutliple platforms

We want to create an API to communicate witha device we currently sell. The API should be available for several platforms like C / C++ / .NET / Python and available for Windows and Linux. The idea is ...
0 votes
1 answer
175 views

Mapping destination object from multiple source objects vs constructing using multiple source objects (as in constructor)

Lets say we have DTO class with 15 properties. Usually DTOs like these are mapped from other objects. But sometimes some DTOs may use values from multiple objects. In these cases, should we “Map” or “...
-3 votes
2 answers
139 views

Case Statements for string to string mapping [duplicate]

I have a class called SomethingProvider that contains: private static string convertMapA(string convertA) { switch (convertA?.ToUpper()) { case "NONE": ...
  • 105
5 votes
2 answers
525 views

Should you write unit tests for templates and frameworks, such as in .NET?

How much (if any) unit tests should be written when you start a new templated project? In particular, let's take as an example a typical .net framework template for asp.net mvc or other similare ones ...
  • 59
-3 votes
3 answers
329 views

Can be logic around `List<T>.Enumerator._version` considered control flow exploitation?

List<T>.Enumerator “snapshots” list version upon creation by _version = list._version;. This allows enumerator to halt enumeration when List<T> changed during it. This behavior likely ...
  • 268
1 vote
1 answer
162 views

Builder design pattern when creating object between many layers

I stumbled on following problem, and I'm curious if it could be done better. A while ago I wrote a factory class that looked something like this: public class Foo { private IDbContext ...
2 votes
2 answers
220 views

How to split logging into streams?

I am looking for an advice (or an example) on how to organize logging streams in my cloud app (C#). In my app there are logging events related to the application infrastructure level and I want to ...
0 votes
0 answers
173 views

.Net Core Api - multiple Dto’s for single entity

I want to know the best Practice is about having multiple dto’s for different use cases. Let’s say we have an api with a set of controllers to handle requests coming from a administration backend and ...
1 vote
1 answer
238 views

How to test around a giant static class?

I am dealing with an old .net code base which has a PrivilegeChecker static class with hundreds of static methods, each of which takes in some user id and some other params, and then fetches some info ...
  • 196
0 votes
0 answers
33 views

Creating entity with external dependency inside the aggregateroot?

Okay, so, I'm working on an AuthService for my microservices system. I'm putting plenty of logic around single instance of User inside of it itself, just so I can avoid repeating code, breaking SRP or ...
  • 221
1 vote
1 answer
147 views

How do I share translations between a .NET application and a react application?

I currently have two applications where one is a landing page (built in react) and another is a web page that lets users explore data (Written in ASP.NET 4.7). I'm currently using resx files to handle ...
  • 121
0 votes
1 answer
140 views

.NET: Microservices, Hexagonal Architecture with lightweight DDD - how to avoid leaky abstraction without a major performance loss?

So, I have a whole system built as microservices.On a service level, I'm utilizing Hexagonal Architecture with lightweight DDD (no events, aggregators etc.) I have a service that fetches Users via ...
  • 221
1 vote
0 answers
93 views

How to improve the coding quality in a problematic company [duplicate]

Due to circumstances I'm now working in a small software company. We make e-mail marketing management software and serve some big customers as our national railways and a big bank. The software has ...
3 votes
4 answers
551 views

C# How to avoid memory leak in this case

I've got a Window, which gets a viewmodel instance injected into its constructor. The window sets its DataContext to that viewmodel. The viewmodel contains a command to "submit" the window ...
26 votes
5 answers
5k views

Why use the discard variable in C#?

When coding resharper recommends that if you're to discard or ignore the return of a method, that you use this syntax: _ = TheMethodICouldCareLessAboutTheReturnValue(); I know you could just call it ...
-1 votes
1 answer
51 views

How can I pass a large amount of data from a JavaScript client to the web server in bulk

I have a Vue/Quasar application that allows the end user to convert an Excel Spreadsheet into an Array and load it into a DataGrid. The Spreadsheet has a list of peoples names, email address, ...
1 vote
1 answer
113 views

Prevent users with multiple sessions using a single use voucher

I'm working on a .Net eCommerce site that allows users to use vouchers to get free products, discounts etc. The problem I have is that there have been instances of users, who have been issued single ...
1 vote
2 answers
304 views

CQRS MediatR Create many items commad - is it a good practise?

I am here to ask question about: is it good practice to insert many records using CQRS and MediatR? how to structure that in terms of names and folders? A have to insert into database over 500 ...
-1 votes
3 answers
444 views

Is it a bad idea to save the database in middleware?

So I've implemented the repository pattern in a lot of projects, but there seems to be a bit of a discussion on what is right with this pattern. Previously, I've always added Update or Create methods ...
0 votes
1 answer
61 views

Extending TypeScript while being futureproof [closed]

C#10 Has extended the property pattern ability, I think it began since #7 EG: { Car: { Interior: pattern } } Meaning you can do some nice pattern matching even in if statements if (car_var is ...
  • 109
-1 votes
1 answer
40 views

Looking for way to store, get, partially update few relatively small JSON documents which has different unique types

I have an app with many individualistic features which behavior is controlled by settings. Let's say these are a few utility services with the following settings that are historically stored in ...
0 votes
1 answer
90 views

Creating a contract for a UDP connection

I'm developing a system in C# who consists in a desktop application running a UDP server and a android app and this app sends data (byte array) to be read by the desktop application with commands and ...
-1 votes
1 answer
200 views

Hardware test GUI with multiple event sources (4 serial ports and user interaction) - best architecture?

I have the following requirements: Write a GUI app for automated testing of some custom PCB hardware. The system must be usable for a technician with little to no advanced PC skills. The test setup ...
0 votes
1 answer
282 views

ASP.NET Core - Using Partial Views inside a Modal window for my Add/Edit/View Details screens?

I've been developing .NET projects for the past 3 years, and on my recent web .NET projects, I've been using Partial Views for all the screens that contain Forms for Add/Update/Delete or other ...
  • 1
0 votes
0 answers
106 views

Multi-threading optimization in-depth

A time ago I participated in an interview process where I was tasked with a simple requirement. I created the best solution I could, using some lock-free implementation. I didn't pass the code ...
1 vote
1 answer
265 views

Are Flate compression in PDF and Deflate different algorithms?

I'm trying to make a program that produces pdf files. I've been studying the pdf format specification and specific pdf files whose format I'm trying to mimic. I found the line /FlateDecode in these ...
  • 509
2 votes
2 answers
706 views

Validations and throwing exceptions in DDD?

I have a question regarding validations and exceptions in DDD. I have a ValueObject say, PasswordText which takes a string argument in it's constructor. Checks if the string matches the password ...
0 votes
1 answer
211 views

How do you identify unused parts of app and web .config files in .NET? [duplicate]

I am working on removing obsolete/unused pieces of configuration from a .NET product starting with appSettings. There are multiple solutions and I've noticed that appSettings can be in a .config file ...
  • 113
1 vote
2 answers
193 views

CQRS: Is it an antipattern if the Command invokes a database interface which contains business logic?

Martin Fowler states that, Command module executes validations and consequential logic which aligns with every CQRS demo app that I've studied. That is to say: validation -- does this Jedi exist? -- ...
  • 1,349
0 votes
1 answer
1k views

why controller lifetime is transient by default in asp.net core? [closed]

I know the lifetime of the controller class is transient by default, but I think it's better to be singleton. should explain to me why creators choose transient instead of singleton or scope lifetime? ...
  • 31
-2 votes
1 answer
166 views

Why running migration turns into timeout in a production environment?

I know this is a theorical question since i don't have code to or any logs to show, but i hope that someone can give me some idea on this question. The problem in question was the following: On my ...
  • 105
2 votes
1 answer
540 views

Strategies to organize multiple projects which may reference each other and managed by different teams in Git?

First actually I don't think Git is a specific involved tool here, it can be any other Source/Version Control tool (TFS, SVN, ...). The point here is how to deal with the scenario in which I have ...
  • 149
-3 votes
1 answer
110 views

Inter application communication .Net

I have multiple WPF applications running different programs some of them are interconnected so one might have to start another at some stage. I need a way to communicate and share large amounts of ...
-1 votes
2 answers
169 views

How to avoid CRUD and layered architectures in REST backends?

I'm creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know: API layer calling a command or query from the application layer using MediatR Application layer ...
-1 votes
1 answer
60 views

Implementation of concurrent purchase for unique items

I am building an API for webshop. I need to implement following scenario: There are x (let's say 500) digital items, which will have same price (let's say each item costs 10$), but unique serial ...
1 vote
0 answers
57 views

VM-images: how protect time-license programs?

One big customer asked me to supply my program to run within a balanced VM-images structure; I mean, the program will be recorded into an image which will be launched in "instances" to ...
  • 119

1
2 3 4 5
29