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
3 votes
1 answer
302 views

Should I favor default interface methods over extension methods?

Default interface methods of C# 8 and extension methods have in common that you can "add" a method with implementation to an interface. "Add" being in quotes here because for ...
  • 191
0 votes
0 answers
43 views

IHttpClientFactory pattern but inherit HttpClient

In looking at all the docs from Microsoft, as well as others, and I'm missing something. It seems to me that the way that Typed Clients are implemented, it's like they're almost repositories - you use ...
  • 101
0 votes
1 answer
91 views

How handle many files effectively?

I'm looking for a way to work with a huge amount (~10^9) of files (all sizes) in .NET using unspecified file system (NTFS, BTRFS...). What I have done up to now is to store them in evenly in a folder-...
0 votes
0 answers
92 views

How inter-process communication is handled on .NET Core?

I have to implement a bi-directional communication between two local process with support to backward compatibility .NET Core/NET Framework and platform architecture x86/x64. The options that i have ...
0 votes
0 answers
44 views

What's a suitable pattern for handling multiple versions of PDF layouts?

I have a class responsible for generating a PDF. The class takes an existing PDF template and builds multiple pages. Each page has various elements that are inserted/manipulated. I now need to handle ...
0 votes
0 answers
79 views

How to avoid duplicate code when working with SOAP proxy classes in different environments?

It's been a long time since I worked with SOAP so my question might be trivial but I just wasn't able to find a satisfying answer so far! Anyways here's what's going on: I got access to a system via ...
0 votes
0 answers
29 views

How to enrich an accesstoken with claims from external system in ADFS (OIDC)

I have a few systems where we are currently using ADFS as our federation and the OpenId connect "protocol". What I would like to achieve is a way where the user authenticates over our Active ...
  • 213
1 vote
3 answers
337 views

When Should I Use a Static Class and When Should I Just Use Functions?

I am currently building a C# application that gets JSON data then it calculates something then stores the results in a database, what is the proper way to design the application. This is how it's now ...
-1 votes
3 answers
168 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
57 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
45 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
66 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
215 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
112 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
158 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
427 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
164 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
29 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
379 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
289 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-...
  • 143
3 votes
4 answers
2k 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
57 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
111 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
322 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
183 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
543 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
346 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
225 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
256 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
212 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
335 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
35 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
175 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
153 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
612 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 ...
27 votes
5 answers
6k 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
116 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
386 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
519 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
42 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
91 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
249 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
354 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
122 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
315 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
822 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
243 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
2 3 4 5
29