Skip to main content
12 votes
Accepted

Using IServiceScopeFactory without implementing the Service Locator Pattern

I'm of the opinion that this is awesome, and I have a couple of suggestions to add. It's not "Service Locator" because you're explicitly constraining to the exact type that can be resolved---the ...
Granger's user avatar
  • 236
10 votes

Length units converter

Only targeting public string[] Convert(string input) Because this is a public method you should validate the input. Right now ...
Heslacher's user avatar
  • 50.4k
8 votes
Accepted

Return XML file from Web API

Dependency Inversion Priciple The smell is that your code violates the Dependency Inversion Priciple which reads Entities must depend on abstractions not on concretions. It states that the high ...
t3chb0t's user avatar
  • 44.3k
7 votes

Download a file given an url to a restricted area and a cookie container

You mentioned that the download is slower than you'd expect, I'll focus on just that for a quick review. Look at your code here: ...
RobH's user avatar
  • 17k
7 votes
Accepted

Computing a hash value of a file

I think your overall approach is sound: read data into a buffer, update the hash, and repeat until the whole file has been processed. Buffer size may have some impact on performance, so that may be ...
Pieter Witvoet's user avatar
7 votes
Accepted

Adding extension methods to IServiceCollection in ASP.NET Core

Instead of doing services.AddThemes(options => { options = Configuration.GetSection("Themes").Get<ThemesOptions>(); }); you could use ...
saluce's user avatar
  • 186
7 votes

XML design for parsing in C#

You are trying to recreate functionality that is already provided out of the box. Reference Configure an ASP.NET Core App From documentation it supports providers for INI, JSON, and XML. Each ...
Nkosi's user avatar
  • 3,246
7 votes
Accepted

News site in ASP.NET Core

In GetAll, the feedback you've already had seems pretty valid, to be honest; there is really no value in re-throwing an exception you've caught directly; if this is ...
Marc Gravell's user avatar
6 votes
Accepted

A controller on a .net core API

Here I will discuss only about your API, I think something may also be changed in your domain model but I don't see enough code to suggest anything really meaningful. You have some code duplication ...
Adriano Repetti's user avatar
6 votes
Accepted

Notification system

As you have already suspected, your code is trying to do too much. Consider separating functionality out into their own distinct concerns. (SRP/SoC -Single Responsibility Principle / Separation of ...
Nkosi's user avatar
  • 3,246
6 votes
Accepted

Length units converter

The S in SOLID Since you mention SOLID, I'd like to point out that IConverter has too many responsibilities: It converts from one unit to another. It splits input ...
Pieter Witvoet's user avatar
6 votes

User controller for a .net core WebAPI dating app

Errors An assumption: you never ever want to return a 500 HTTP status code (Internal server error). It may leak information you do not want to expose and it's not informative enough. Do not throw ...
Adriano Repetti's user avatar
6 votes
Accepted

ASP.NET Core singleton with a thread-safe property that can be changed

That will lock it down for sure. If you know you will have more reads then writes, which is common, you should look at the ReaderWriterLockSlim class. What you have will only allow one read and one ...
CharlesNRice's user avatar
  • 4,408
5 votes

Wordpress RSS Parser

So TheQuickBrownFox is spot on when they mention the potential exception with Seq.Cast<'T>, and I want to talk about that and introduce a couple new operators ...
Der Kommissar's user avatar
5 votes
Accepted

Wordpress RSS Parser

The Rss helper functions are inside the parse function, even though they don't use any of the state inside that scope. Consider ...
TheQuickBrownFox's user avatar
5 votes

A controller on a .net core API

...
t3chb0t's user avatar
  • 44.3k
5 votes

Download a file given an url to a restricted area and a cookie container

As a matter of fact you should use the IProgress<T> interface for reporting progress that Defines a provider for progress updates. With it you wouldn't be ...
t3chb0t's user avatar
  • 44.3k
5 votes
Accepted

Proper way to work with stored procedures in Entity Framework Core

The biggest thing I would change is to return the connection to the state you found it. ...
Der Kommissar's user avatar
5 votes
Accepted

.NET Core MVC - Future proof Hashing of passwords

Usability It should be easy to use I consider this easy to use because all technical details are hidden from the end-user. ...
dfhwze's user avatar
  • 13.9k
5 votes

Using IServiceScopeFactory without implementing the Service Locator Pattern

At first, I liked your approach quite a bit. However, I think there's a smell here that's being ignored. In limiting the IServiceScopeFactory<T>/...
casperOne's user avatar
  • 151
5 votes
Accepted

Generate secure URL safe token

Minor suggestions: public class UrlToken The class has no instance data, so it could be made static: ...
Jesse C. Slicer's user avatar
5 votes
Accepted

Posting images from request to Azure blob

I have a few ideas... CheckFileSize & CheckFileType should be implemented either via action-filters or Model validation ...
t3chb0t's user avatar
  • 44.3k
5 votes
Accepted

HttpClient Wrapper for standardized API communication

Async/Await In a couple of places, you use Task.Result instead of await Task. This answer explains more verbosely why this is ...
Jeffrey Parks's user avatar
5 votes
Accepted

Validating a date with C# and ASP.NET Core 3.1

You could easily turn your method into a one-liner expression-bodied method with a few tricks: use the _ discard variable instead of the explicit ...
Jesse C. Slicer's user avatar
5 votes

News site in ASP.NET Core

Other minor points: Imports Sort your usings, and move them to the inside of your namespace. Also consider using StyleCop, which ...
Reinderien's user avatar
  • 65.2k
5 votes
Accepted

Implementation of Concurrent List in .NET

There appear to be several threading bugs in this implementation. Just the first line with any logic in it, what if two threads call Insert with ...
Pierre Menard's user avatar
5 votes

Retrieving large batches of online game codes?

Orchestration vs Choreography Whenever you want to execute a sequence of actions then you can pipe them through: choreography: Each and every action knows who is the next in the calling chain Or in ...
Peter Csala's user avatar
  • 9,789
5 votes
Accepted

Refactor to get one more layer of abstraction for less repeated code

One way to reduce repetitive code is through the usage of the template method pattern. In your template method: Establish a connection Execute database operation (this is the customizable step) Close ...
Peter Csala's user avatar
  • 9,789

Only top scored, non community-wiki answers of a minimum length are eligible