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 ...
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 ...
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 ...
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:
...
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 ...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
5
votes
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 ...
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.
...
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.
...
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>/...
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:
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
asp.net-core × 174c# × 171
.net × 19
entity-framework-core × 16
asp.net × 15
dependency-injection × 15
performance × 14
.net-core × 12
asp.net-core-webapi × 10
asp.net-web-api × 9
design-patterns × 6
repository × 6
thread-safety × 5
entity-framework × 5
async-await × 5
asp.net-mvc × 5
javascript × 4
object-oriented × 4
mvc × 4
api × 4
logging × 4
rest × 4
dapper × 4
beginner × 3
unit-testing × 3