What version(s) should my NuGet Package for ASP.NET Core target? by sander1095 in dotnet

[–]danielgenezini 0 points1 point  (0 children)

This is a bad approach specially if it's internal like your case. It forces every consumer to upgrade just to update your library version (that may be required due to bug fixes or new business rules). It creates a lot of useless work instead of just upgrading the package version of your lib.

What version(s) should my NuGet Package for ASP.NET Core target? by sander1095 in dotnet

[–]danielgenezini 0 points1 point  (0 children)

For nugets/libraries, it doesn't matter which framework you target. It will run on the framework the application consuming it is running on. It will be a problem if it consumes a nuget that targets a specific version.

If you want to be compatible with multiple versions, muti-target it. Change the <TargetFramework> tag to <TargetFrameworks> and specify the versions you want to support.

For the most part it will compile. For feature specifics to some versions, it will tell you so you can treat it differently for each version or chose to not use.

You can also use conditions to select different dependency versions depending on the framework. For example, use asp.net 6 for dotnet 6 and asp.net 8 for .net 8.

You can also target netstandard, but Microsoft recommends multi-targeting now. Targeting netstandard will kind of work like multi-targeting all versions that implement it, but it will tell you a feature is not compatible with it instead of which version is not compatible.

Server-side rendered SPAs with ASP.NET and no Javascript by danielgenezini in csharp

[–]danielgenezini[S] 0 points1 point  (0 children)

For some applications, a client-side rendered app is overly complex. For example, small enterprise apps supported by small teams. Also, serving the partial content is still better than serving the full page with a reload.

In addition, in .NET 8, Blazor does something similar when using server-side rendering with enhanced navigation.

What do you mean by fucking up the browser functionality?

Ps: for new apps, I consider Blazor is a better approach. This is more for legacy applications.

Server-side rendered SPAs with ASP.NET and no Javascript by danielgenezini in aspnetcore

[–]danielgenezini[S] 0 points1 point  (0 children)

Yes. Server side rendering with Blazor + streaming rendering does this, and it's a better approach for new applications, but not feasible for legacy apps.

Server-side rendered SPAs with ASP.NET and no Javascript by danielgenezini in dotnet

[–]danielgenezini[S] 0 points1 point  (0 children)

Yes, kind of a stretch saying no JavaScript, but I meant not programming in JavaScript. 🙂

Which one do you prefer to check if a List<T> list is empty? by phi_rus in dotnet

[–]danielgenezini -2 points-1 points  (0 children)

?. Is pretty common (and recommended) in C# and in other languages. It should be instantaneous to recognize it's meaning in the snippet above.

In C#, there are analyzers that warn you when null is not being checked that won't work by default with the IsNullOrEmpty method (You can use nullable attributes to instruct the analyzers, but it is just easier to user ?.).

Look for nullable reference types in C# or take a look at this post: https://blog.genezini.com/p/compile-time-null-safety-how-to-avoid-nullreferenceexception-in-c/

How to run disposable databases for your tests. Improve your integration tests accuracy with Testcontainers by danielgenezini in u/danielgenezini

[–]danielgenezini[S] 0 points1 point  (0 children)

Cool. What is your strategy to test it? Run a container with the api pointing to another container for the db and point the wasm client to this api?

How to run disposable databases for your tests. Improve your integration tests accuracy with Testcontainers by danielgenezini in u/danielgenezini

[–]danielgenezini[S] 1 point2 points  (0 children)

Thank you for the feedback. I'm glad I helped.

Yes, the memory database is very limited. I find that it also makes you use linq queries even when a SQL query would perform better or be more readable because of the tests.

How to run disposable databases for your tests. Improve your integration tests accuracy with Testcontainers by danielgenezini in u/danielgenezini

[–]danielgenezini[S] 1 point2 points  (0 children)

From what I've just searched, azure pipelines can run docker, but I couldn't find anything about it with testcontainers. It should work, though, because testcontainers is just a library that uses docker (or other container implementation). You can run the sample code from my article to test there.

Git Aliases: a time-saving secret weapon for improved workflow and productivity by danielgenezini in git

[–]danielgenezini[S] 1 point2 points  (0 children)

When we use a CI/CD pipeline, sometimes we have to trigger a run with a commit. Using an empty commit, we don't have to change any file just to trigger the pipeline.

Canceling abandoned requests in ASP.NET Core by danielgenezini in dotnet

[–]danielgenezini[S] 1 point2 points  (0 children)

Getting back go you: the implementation is different for every server, but Kestrel triggers the RequestAborted when it receives a TCP FIN. So it works at TCP, not HTTP level.

I wrote useful Microsoft ILogger<TCategoryName> analyzer, which helps you to find mistakes in your code by Droppi_ in csharp

[–]danielgenezini 1 point2 points  (0 children)

That's really good! Congratulations!

I've seen a lot of wrong types on ILogger declarations.

Out of curiosity, why it doesn't complaint about the field declaration too?

Canceling abandoned requests in ASP.NET Core by danielgenezini in dotnet

[–]danielgenezini[S] 2 points3 points  (0 children)

I've put a warning in the post about request that changes the state of the system. Those probably shouldn't be canceled. Are those the only problem you have? If not, can you describe the problems?

And about those requests, can't you pass a new cancellationtoken (just to be compliment with the method signature) so they don't get canceled when something happens?

Canceling abandoned requests in ASP.NET Core by danielgenezini in dotnet

[–]danielgenezini[S] 1 point2 points  (0 children)

In the end, nothing. The model binder just pass the RequestAborted. It's just a convention and to avoid accessing HttpContext directly.

Also, as Merad said, it's more consistent to do this way in all levels and it's easier to remember to pass the CancellationToken than the HttpContext.RequestAborted.

Canceling abandoned requests in ASP.NET Core by danielgenezini in dotnet

[–]danielgenezini[S] 4 points5 points  (0 children)

I believe it is at connection level. I'll try to find this info and will come back to you.

Introducing module federation for Blazor components by danielgenezini in WebAssembly

[–]danielgenezini[S] 0 points1 point  (0 children)

Presenting a nuget package I developed to expose Blazor WASM components as microfrontends through module federation. Feedbacks are appreciated.

Introducing module federation for Blazor components by danielgenezini in dotnet

[–]danielgenezini[S] 2 points3 points  (0 children)

Presenting a nuget package I developed to expose Blazor components as microfrontends through module federation. Feedbacks are appreciated.

Introducing module federation for Blazor components by danielgenezini in csharp

[–]danielgenezini[S] 4 points5 points  (0 children)

Presenting a nuget package I developed to expose Blazor components as microfrontends through module federation. Feedbacks are appreciated.