News for hackers. Stuff that matters.
Re:The Case for C# and .NET by sandreas on Monday July 25, 2022 @12:24AM (#32220486)
I also think that C# and .NET are awesome. Especially latest releases dotnet 6 and upcoming 7 have a ton of new things to be even more productive.

I like the fact, that you can develop command line apps, Web APIs, Desktop Apps and smartphone apps all with the same toolset, including the fact that deployment is possible on nearly every major platform for every major platform (except iOS and macOS Apps, as always only on macOS). Even systems programming and AOT is doable or full featured static deployment is possible integrating a small runtime into a single binary.

And boy is .NET fast...

This facts made Golang pretty interesting to me, but what I did not like here is the lack of a usable cross platform Plugin-Loader technology, most of the stuff has to be monolithic, then the module management and some of the missing concepts (like generics, which is also now available in go).

The sheer amount of concepts in C# is overwhelming (from basics like Generics to less common ones like Extension-Methods, operator overloading, etc.).

I don't like Visual Studio as IDE, but VS Code is an acceptable alternative tool, although I personally prefer the non-free JetBrains Rider.

Nuget package manager also has it's caveats, e.g. that the official repo can only "unlist" packages, not delete them or that the publish times sometimes have horrible delays, but that's also still acceptable, since you can use the github package registry or bring your own to overcome these issues.

Technologies on my todo list include getting into MAUI (a cross platform UI stack) combined with Blazor[1], which can use Web Components in native UI apps and develop TRULY cross platform (Web, Desktop AND Mobile with the same codebase). Like electron, but without the browser dependency due to native integration.

Although everything is tied pretty tight to Microsoft, there is a huge open source community developing cross platform libraries, that are easy to use. Even though i find that microsoft has often made strange decisions in the past, the current state is clearly a recommendation to have a look.

https://www.youtube.com/watch?v=2eIsQ3Pm2bE

Re:The Case for C# and .NET by ivraatiems on Monday July 25, 2022 @02:10AM (#32221058)
I've been a .NET developer professionally for seven and a half years. Rider is the way to go. Visual Studio has improved dramatically over the last decade or so, but Rider is still way ahead of it on code search/discovery, performance, and general user experience. I did a tech talk at my company where I demoed Rider vs Visual Studio 2019 performance on our bigger projects... it was embarrassing for VS. VS 2022 was substantially better on performance, but also crashed during the demo.
Re:The Case for C# and .NET by bbkane on Monday July 25, 2022 @05:39AM (#32222312)
I'd love to watch that talk if you're comfortable posting a link
Re:The Case for C# and .NET by ivraatiems on Monday July 25, 2022 @10:27AM (#32224765)
Unfortunately, because it contains proprietary source, I cannot :(.
Re:The Case for C# and .NET by nonbirithm on Monday July 25, 2022 @08:47PM (#32232943)
I'd love to use Rider on Linux or even Windows. Sadly the lack of .NET hot reload on Linux and Rider's issues with hot reload on Windows are what keep me on Visual Studio. (Rider's implementation of hot reload doesn't support assemblies loaded at runtime yet, which my application depends on).

It's sad that the time saved with Visual Studio's hot reload alone seems to outweigh the (massive) performance gains from using Rider, given that I have to restart VS from its memory leaks multiple times a day or it will slow to a crawl. Omnisharp isn't performant or reliable enough for daily use, either. The current state of .NET tooling leaves me unsatisfied.

Re:The Case for C# and .NET by GiorgioG on Monday July 25, 2022 @10:30PM (#32233582)
I’m amazed hot reload works consistently enough for you to be able to use it.
Re:The Case for C# and .NET by the_only_law on Monday July 25, 2022 @08:30AM (#32223408)
Visual Studio is great, but also one of the most broken bits of software I've had to use.
Re:The Case for C# and .NET by 202206241203 on Monday July 25, 2022 @08:06AM (#32223219)
Rider does not have a community edition unlike IDEA. It was created due to a combined threat of VS Code and Roslyn and is the reason ReSharper is almost neglected these days.
Re:The Case for C# and .NET by ziml77 on Monday July 25, 2022 @09:03AM (#32223686)
ReSharper isn't a heavy focus because it's not worth it anymore. To get the same performance as other tools they'd need to throw out a ton of work and rewrite it for Roslyn. With Rider, they get to continue to use their existing ReSharper codebase to power it.
Re:The Case for C# and .NET by 202206241203 on Monday July 25, 2022 @09:10AM (#32223752)
They don't forget to charge same (even increased) fee for minimal updates, though.
Re:The Case for C# and .NET by WorldMaker on Monday July 25, 2022 @03:51PM (#32230023)
Was that comparison both with or without ReSharper? Were you comparing fresh installs with no plugins on both sides?
Re:The Case for C# and .NET by aaaaaaaaata on Monday July 25, 2022 @07:49AM (#32223099)
And...how do both companies compare in what telemetry they're sucking out of devs?
Re:The Case for C# and .NET by SamuelAdams on Monday July 25, 2022 @09:06AM (#32223713)
Fair question, devs who do not want to share telemetry for the dotnet core SDK simply need to set an environment variable. VSCode has a similar setting in the options. Not sure about Visual Studio as I haven’t used it in a while.

https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry

Re:The Case for C# and .NET by fartcannon on Monday July 25, 2022 @09:30AM (#32223973)
Opt out is ridiculous for a programming language. Do you really want to play security whack-a-mole with your development environment?

There are countless, better privacy respecting tools.

Re:The Case for C# and .NET by zubspace on Monday July 25, 2022 @03:01AM (#32221352)
About the 'dependency problem':

It's not as bad as in npm with node_modules, because .NET provides a lot of base functionality in the standard library.

But when you start to use multiple nuget packages, sooner or later you will also enter dependency hell, where managing versions and updates of nuget packages gets very painful.

All in all we have to reference about 10 external libraries. The visual studio nuget package manager started to be frustrating if you need to manage those dependencies in multiple solutions. We therefore switched to Central Package Management [1], but then you realize, that you're just shifting the problem around. Now we have to put the whole dependency tree into the file 'Directory.Packages.props' and have to manage the version of 140 libraries. If there are version conflicts, we force nuget to use the latest version and just hope for the best.

Managing versions of dependencies and dependencies of dependencies is a major pain, but it's an ubiquous pain all programming environments share. And no, .NET won't relieve you from that.

[1] https://docs.microsoft.com/en-us/nuget/consume-packages/cent...

Re:The Case for C# and .NET by banashark on Monday July 25, 2022 @03:07AM (#32221380)
I'm not sure if it will help in your scenario, but faced with a similar problem (~80 project solution, mixed c#/f#, with varying dependencies), I found success with Paket (https://github.com/fsprojects/Paket)

It is much more prevalent in the f# community (at this point `dotnet restore` is a perfectly fine default until you hit trouble), but isn't limited to just being applied there.

Re:The Case for C# and .NET by barking_biscuit on Monday July 25, 2022 @04:35AM (#32221896)
Yeah this is probably one of the biggest pain points, but modern tooling is really helping to the tide on this. Dependency management is never fun in any language, and .NET has some quirks which make it a challenge as you say. I switched to .NET from java about 5 years ago now and I'm pretty I !are the switch as .NET just keeps getting better. Dependency management is one of the last pieces of the puzzle to really solve for in terms of getting a much better experience. That said if you're starting a brand new .NET project today you can set up your CI/CD pipelines to do Continuous Deployment and use Renovate to automatically upgrade your dependencies and merge if your tests are green. In addition the trend is for smaller codebases these days which makes it far easier to upgrade major versions of dependencies due to much smaller scope of breaking changes. I think those two things in combination eliminate some of the pain we've all felt with not being able to upgrade several years out of date dependencies in huge monolithic codebases. I'm pretty excited for the future of .NET to be honest.
Re:The Case for C# and .NET by wizofaus on Monday July 25, 2022 @04:57AM (#32222041)
Did you really mean only 10 external libraries? If you'd said 100 I could understand - I hit a version conflict issue in a recent project on adding what was probably package #60 or so, but solved it easily enough after a bit of googling. And we knew we were using a lot of quite old packages (including .NET 2.1 EF, because of a rare breaking change they introduced with 3.0 that we didn't have a good solution for).
Re:The Case for C# and .NET by js4ever on Monday July 25, 2022 @08:40AM (#32223497)
Technically just 2 libs are enough to produce the issue...
Re:The Case for C# and .NET by neonsunset on Monday July 25, 2022 @06:55AM (#32222780)
Our dev loop playbook at work has an advice to never touch Visual Studio's nuget package manager haha.

Instead, dotnet CLI + VS Codes find+replace does a very good job at managing dependencies. It has never been a pain and on project build, all imported version will be consolidated to a single one anyway.

Re:The Case for C# and .NET by bbarn on Monday July 25, 2022 @03:44AM (#32221602)
> I don't like Visual Studio as IDE, but VS Code is an acceptable alternative tool, although I personally prefer the non-free JetBrains Rider.

I've used Visual Studio for 20 years now, and while the tooling has come a long way, I'm starting to feel like MS and the community are abandoning it for VS Code. I don't mind VS code, but unfortunately the stack I'm working in (Dynamics 365) requires plugins for Visual Studio that tend to lag behind the release cycle of Visual Studio versions by a few years. I use Rider for .net core projects on my mac and it's fantastic.

In fact my biggest criticism of my day to day job is Microsoft's support for this incredibly enterprisey framework I have to work in.

Re:The Case for C# and .NET by jve on Monday July 25, 2022 @05:46AM (#32222342)
Hey fellow Dynamics 365 (CRM?) developer.

I see they move in VSCode direction with tools like Power Platform CLI [1], power platform tools extension [2]. PCF (PowerAps Component framework) enabling to develop UI components in frontend framework-of-choice... however none of that is available (yet?) for On-Premise deployment so we're 2nd class citizens. Because of that, haven't been able to play with this and try out so don't know how far that tooling goes.

As a platform, I really like it. Sane, consistent (except some very early stuff there), the backend extensibility - thumbs up for that.

[1] https://docs.microsoft.com/en-us/power-platform/developer/cl...

[2] https://marketplace.visualstudio.com/items?itemName=microsof...

Re:The Case for C# and .NET by bbarn on Monday July 25, 2022 @06:13AM (#32222501)
F&O, sadly...
Re:The Case for C# and .NET by jve on Monday July 25, 2022 @08:34AM (#32223454)
F&O would be former AX? That seems highly rewarded field. I know it only from SQL point of view - It helped grow my SQL skills when SQL would be brought to it's knees (along with the business) due to skewed data distribution and occasional query plan invalidation.
Re:The Case for C# and .NET by bbarn on Monday July 25, 2022 @10:34AM (#32224865)
Yep, it's the replacement for AX. I can't say I love working in it, but the clients are massive and as such, it can be a rewarding financial choice. The tooling is poor and the APIs are a bit difficult but it's made for some fun workarounds :)
Re:The Case for C# and .NET by bmitc on Monday July 25, 2022 @02:18AM (#32221110)
> The sheer amount of concepts in C# is overwhelming

Agreed. But F# is one of the best designed languages around.

Re:The Case for C# and .NET by smcl on Monday July 25, 2022 @04:00AM (#32221699)
I don't disagree, and I love F# but I think it owes a lot of that to OCaml. That said, since we're talking about C#, F# and VS Code I'm gonna vent a little about something that arises when you use all three :D

If you open a C# project in VS Code when the "Ionide" extension (basically the F# extension for VS Code) is installed then the extension thinks it's a F# project and will open some F# stuff after a few seconds (or prompt you to setup some F# stuff in its gitignore). The root cause has been identified (plugin activates when it sees a ".sln" file), a PR has been opened and rejected with no mention as to why (https://github.com/ionide/ionide-vscode-fsharp/pull/1401) and the developers behind it are frustratingly non-communicative about it, closing issues about it (https://github.com/ionide/ionide-vscode-fsharp/issues/1701), they're not present in the discussion (https://github.com/ionide/ionide-vscode-fsharp/discussions/1...). Usual rules about OSS maintainers apply, they don't technically owe us users anything, we should be patient and respectful etc ... but man it is truly bizarre to be ignored or ghosted like this.

Re:The Case for C# and .NET by bmitc on Monday July 25, 2022 @10:02AM (#32224437)
I still need to get into OCaml. I of course know bits by virtue of having used F# and SML, but OCaml definitely has its own unique features. For F#, I appreciate how well it sits upon the host VM for the CLR and .NET. It just integrates almost seamlessly while still being a functional-first ML. When I use F#, it's by far the easiest code I write. I find myself just writing out the domain and boom, I got a working program. Recently, I wrote some bindings for a C/C++ DLL, and F# really made that easy. It's the easiest time I've ever had creating such bindings in a language.

For the Ionide stuff, I agree. I don't use it, even though I use Visual Studio Code for other languages, and am happy enough with Visual Studio on Windows and Visual Studio for Mac on macOS.

Re:The Case for C# and .NET by Kuinox on Monday July 25, 2022 @04:03AM (#32221710)
> that the official repo can only "unlist" packages, not delete them or that the publish times sometimes have horrible delays

It's to avoid the npm left-pad problem. nuget.org packages are idempotent.

For the publish times, I found out you can cut it in more than half if you tell nuget to ignore caches.

Re:The Case for C# and .NET by sandreas on Monday July 25, 2022 @04:34AM (#32221885)
I know... but sometimes it is a bad thing for indie hackers testing around :-)

Draft releases would be awesome.

Re:The Case for C# and .NET by manigandham on Monday July 25, 2022 @05:02AM (#32222085)
You don't have to use Nuget.org, it's just the public community version of a Nuget package repo.

You can use your own private repos like MyGet[1] or Github Packages [2].

1. https://www.myget.org/ 2. https://docs.github.com/en/packages/working-with-a-github-pa...

Re:The Case for C# and .NET by sandreas on Monday July 25, 2022 @06:34AM (#32222638)
Yeah I know all this, you can even use BaGet[1] symbol server to cache or manage private dependencies in an enterprise network. That is not the point... I think that the most used tool / platform should provide more flexibility for non-enterprise or less expierienced developers.

No offense, I like nuget, but I recently made a typo and checked in 0.0.23 instead of 0.0.2. Now, everytime I add a dependency that is < 0.0.23 to a project, that has not been synchronized / validated yet (the other problem I described), it automatically takes the best match, which is 0.0.23 assuming to be the newest package, even if unlisted.

I also burned a 1.0.0 because of a failing script like that... not really bad, but annoying...

https://github.com/loic-sharma/BaGet

Re:The Case for C# and .NET by Kuinox on Monday July 25, 2022 @09:20AM (#32223851)
FYI Nuget also work with folders.

Drop nupkg in a folder, use it as a source, you now have a "feed".

Re:The Case for C# and .NET by metaltyphoon on Monday July 25, 2022 @08:36AM (#32223466)
Why not just setup a local feed?
Re:The Case for C# and .NET by diarrhea on Monday July 25, 2022 @01:03PM (#32227380)
Idempotent, in which way? Do you perhaps mean immutable?
Re:The Case for C# and .NET by Kuinox on Wednesday August 03, 2022 @06:47PM (#32337400)
Yes, sorry, I meant immutable, not idempotent.
Re:The Case for C# and .NET by nwah1 on Monday July 25, 2022 @05:06AM (#32222114)
Just developed something using MAUI's predecessor Xamarin.Forms

It was perfect and exactly what I wanted. I had experience with XAML and MVVM thanks to Silverlight and WPF, so that explains at least some of why it was such a breeze. But it is way nicer than coding for the web, and I've done my fair share of that.

I was able to port over most of the code to MAUI easily, except for the missing controls. But MAUI is very exciting overall, and I look forward to using it more. After a map control is released I will fully port my app.

Re:The Case for C# and .NET by mccorrinall on Monday July 25, 2022 @01:23AM (#32220796)
I tried writing a simple crud api with asp.net, which should parse and respond json. It was the worst development experience I ever had while writing json apis. Validation? Not existent. OpenAPI/swagger documentation generation? Not existent. Then it also tried to force me into using MVC, while acting that it is express with its middlewares.

I switched back to node.js with fastify and wrote my app in an hour.

I really like C# for cli and windows desktop applications, but I probably won’t touch it for the web in the next few years.

Re:The Case for C# and .NET by chocolatemario on Monday July 25, 2022 @02:12AM (#32221069)
As a C# developer I could say the same about my experience dealing with my first foray into [insert random language] and my attempt to develop [something with a non-trivial framework].

The issues you had could be attacked by navigating through this section of documentation, diving into the tutorial referenced in the beginning of the Overview section and the subsequent sections: https://docs.microsoft.com/en-us/aspnet/core/web-api/?view=a.... This is not necessarily in defense of c# and dotnet, but this reads like you barely spent any time trying to digest the documentation.

Re:The Case for C# and .NET by EnKopVand on Monday July 25, 2022 @03:27AM (#32221501)
I’ve been a C# developer for a decade and I still think it’s hopelessly convoluted for getting very simple things up and running. Maybe there is something wrong with me, but it’s just not intuitive to me and it has frankly never been. I do think the move to core and then core to .net has improved things, but it’s still a really weird and way of doing things compared to other languages that I have worked with, and most of the “boiler plate projects” are very rarely useful, so why are they there?

Then once you need to go beyond the standard libraries it becomes a nightmare to deal with. In some cases, like extending the AD libraries, it’s sort of easy to extend classes with methods but the documentation on how to do so tends to assume a lot of domain knowledge. In other cases like if EF’s standard functionality isn’t enough for you, or you need to deal with weirdly formatted XML or non standard SOAP requests (don’t ask) it can be such a nightmare that it’s sometimes easier to write a micro-service in another language to do the “translation”.

I think it speaks of a language that doesn’t see too much use by its own creators. I may be wrong on that, but having build a lot of things for Azure, Typescript has often felt more like a first class citizen than C#. Obviously not for everything, far from it, but sometimes and those sometimes are enough to make C# troublesome because unlike things like typescript that are great second class citizens in the Microsoft ecosystem, C# isn’t. It either fits really well or you have to fight it.

Re:The Case for C# and .NET by pionar on Monday July 25, 2022 @08:38AM (#32223482)
I wholly disagree as a person who worked in C#/.NET for over 15 years and recently waded into Node/JS/TS dev. C# and .NET are hands down the easiest platform to start on.
Re:The Case for C# and .NET by EnKopVand on Thursday July 28, 2022 @04:49AM (#32261857)
In my decade around management that was not my experience with onboarding new people.

Maybe that is because we didn’t have a fascist linter for C# the way we do with Typescript, but it’s always been much, much, harder to get people to make “good” C# code in my experience. It hasn’t been hard to have the build things in C#, but it’s been hard to get people to build things the same way so that they can work on each others code flawlessly. So hard that I would never again consider using resources on it until developers drop significantly in pay, which isn’t likely to happen until I’m retired, if ever.

I wonder if it has to do with regional differences. I’m Danish, everyone (there are odd cases, but it’s more “everyone” than “almost everyone”) here has a CS degree and often they’ve been taught Java, sometimes C# but poorly, while obtaining it.

Re:The Case for C# and .NET by Akronymus on Tuesday July 26, 2022 @06:50AM (#32236583)
> I’ve been a C# developer for a decade and I still think it’s hopelessly convoluted for getting very simple things up and running.

For me, fsharp interactive is one of the best prototyping experience I have ever experienced.

Re:The Case for C# and .NET by mccorrinall on Wednesday July 27, 2022 @09:14AM (#32250011)
You are actually right. Today I opened the documentation again: https://docs.microsoft.com/en-us/aspnet/core/web-api/route-t...

And it says right at the bottom, that OpenAPI and model binding is not supported in their route to code feature.

I initially googled how to create a simple json api, and that’s the documentation which I found. Looks really easy in the beginning, but after you’re done with your routes, you’ll read at the end of the documentation, that OpenAPI generation, model binding etc is not supported. I blame that the guide‘s title is misleading and - of course - that I should’ve read till the end before actually following any step of that tutorial.

Re:The Case for C# and .NET by yyyk on Monday July 25, 2022 @10:01AM (#32224413)
That's true (and minimal APIs help a lot) but ASP.NET still has a real problem with too much magic.

For example, the secret incantations required to output a mere string as raw json mimetype or log incoming deserialization errors* are unintuitive and very labourious - see InvalidModelStateResponseFactory. Or that I had to create a custom output formatter to output raw json. Why? Sometimes I just want ASP.NET to get out of my way and it's not trivial to tell it to let go.

* For example, url?parameter=1 for a boolean parameter, which would have worked with .NET Framework but won't for .NET Core/.NET.

Re:The Case for C# and .NET by throw868788 on Monday July 25, 2022 @02:31AM (#32221177)
I think that's the barrier with C# in general - the framework nature of it means there's a lot of "I don't know what I don't know" especially with ASP.NET which is quite large in scope. Don't get me wrong - that's the usual dev reaction when switching from their familiar language/tools to a new one but I don't think, at least historically, C#/ASP.NET made it as easy as it could of been. Which namespace do I open to import the right extension method to register swagger generation? How do I configure it? All that stuff IS existent actually and having worked with both in my current role the .NET version eventually ends up being a "just works" experience. Its just hard to approach and integrate if you don't already know the "patterns" and the libraries. Sadly there's a lot to learn compared to say Fastify for a basic working app. However it is very configurable and flexible. I've seen the same reaction from dev's to the Spring Framework as well - its just feels bloated for a lack of a better term to people coming from JS.

As per another comment after having seen JS devs switch to F# for very large professional application and not wanting to go back I feel its fine for web. YMMV.

Re:The Case for C# and .NET by mattferderer on Monday July 25, 2022 @09:41AM (#32224128)
> Which namespace do I open to import the right extension method to register swagger generation

If you use the templates provided by .NET Command Line Interface or Visual Studio, you'll get this all baked in & setup.

VS also added a very nice feature where it suggests & imports popular packages if you type a method on a type that's well known. If you already have it added to your project but need a using statement in this file, it'll pick that up fast as well.

They've also improved their docs quite a bit from years ago with lots of good examples for common things.

Re:The Case for C# and .NET by throw868788 on Monday July 25, 2022 @05:56PM (#32231467)
These are nice but:

- Templates are no substitute for intuitive and minimal code for a number of reasons. (e.g. how to extend, how to customize, confidence that it isn't brittle if I change one thing, etc etc). If a template doesn't have the exact variation you want (e.g. a faster logging library) the learning curve is very high for a newcomer .NET dev. NOTE: I think this applies to some other OO languages too.

- Suggesting popular packages and namespaces is a great tooling improvement. But it could also imply a closed wall garden. The fact that other non C#/Java like languages don't have this problem even with something as minimal as VS Code as your IDE shows that the tooling is trying to cover over a language and/or library problem. With the Java/C#/other old OO lang workflow you need the knowledge you need to use the library itself (convention based, which class, which extension method, which namespace for that object to configure this feature, startup class conventions, etc). It isn't discoverable even with the packages imported. Remember just getting Serilog working in new ASP.Core and it taking a day or so with all the packages, config, etc etc if you don't already know what you are doing.

I like the improved docs. But fundamentally simplification/minimization is better. I think the dev workflow that means I don't need these tooling improvements is still a better experience. I like .NET, but I do understand when using other languages they seem to not have these issues despite not having the uber tooling that C# has. They don't have package suggestions, they barely even have auto complete yet the library design feels a lot more intuitive.

I can look up say a Fastify, Golang, even some F# examples with something like Giraffe and get a web app quickly with little code and no convention magic with everything being explicit yet concise. No fancy attributes I need to remember, no conventions in my startup classes I need to understand if any customisation, even dep injection is something to learn from people coming from some other platforms rather than just standard library calls composed together.

I actually like the .NET platform, don't get me wrong, I do think it is one of the best web platforms right now. Its more intuitive than Spring/Java as a comparison but that isn't saying much IMO. For newcomers I think the user experience to newcomers who are used to a lot less ceremony could be improved further. My first suggestion would be less "developer headspace required" to get started. On a personal note I think natural F# code tends to favor this from the teams I've been in but can't put my exact finger on a reason as to why - it feels more like coding Go/JS to me at least than C#.

Re:The Case for C# and .NET by mattferderer on Tuesday July 26, 2022 @02:31PM (#32242031)
I'm curious who does this well? I've personally not found any specific language or framework that is better than others unless you're using their preferred libraries. At that point it depends more on the library authors than the base framework.

For newcomers, I would say the best user experience (no matter language/framework) is provided by code hinting such as GitHub GitLens & competitors do. If I'm using an unfamiliar framework/language it's great at suggesting what I might want without me having to search.

You might really like the new .NET minimal APIs that are being built for web development. They're very similar to a Node.JS style of API.

In regards to logging specifically, I've found swapping logging tools fairly easy & straightforward as far as adding the logging in the code base. If there has been anything challenging it's been outside the code base & setting up the infrastructure or learning the logging's reporting tools. I'm curious what was challenging for .NET with you. It's usually as simple as using Ilogger no matter the tool & writing a few lines in the program.cs file.

Re:The Case for C# and .NET by GiorgioG on Monday July 25, 2022 @01:28AM (#32220811)
Validation and Swagger/OpenAPI have been available for a long time and well documented. I don't know what resources you used to learn ASP.NET, but they failed you.
Re:The Case for C# and .NET by mccorrinall on Wednesday July 27, 2022 @09:09AM (#32249966)
Looks like I was using the wrong ASP.NET features! Route-to-code does not support OpenAPI.

https://docs.microsoft.com/en-us/aspnet/core/web-api/route-t...

Re:The Case for C# and .NET by pjmlp on Monday July 25, 2022 @01:38AM (#32220864)
All the way back to .NET Framework 4.5 at very least (2012).
Re:The Case for C# and .NET by sandreas on Monday July 25, 2022 @02:25AM (#32221146)
Well, while I understand, what you are trying to say (a simple crud web api should be easy to accomplish), I think that you were just overwhelmed by amount of possibilities, tutorials and outdated information, because C# / .NET is evolving fast.

That said, you may take a look at my small very early state pet project `tonehub`[1], which can be seen as pretty modern CRUD Web API in 2022, utilizing swashbuckle for OpenAPI, JsonApiDotNet for CRUD, Entity Framework 6 for Database, HostedServices for background tasks and some other nice concepts (DI / IoC, Options Pattern, FileStreams, etc.). I could also use SignalR for WebSockets / Realtime, integrated OpenID/OAUTH2 Authentication, FluentValidation for validation, Api Versioning and much more.

I've never accompilished something like this with this small amount of code...

[1] https://github.com/sandreas/tonehub

Re:The Case for C# and .NET by phito on Monday July 25, 2022 @01:47AM (#32220917)
The issue here is that you didn't know what you were doing (which is completely normal when trying a new language)
Re:The Case for C# and .NET by lucidone on Monday July 25, 2022 @01:30AM (#32220820)
FluentValidation and Swashbuckle are two great libraries for the tasks you referenced. This is a good enough reference repository should your curiosity be piqued again in the future: https://github.com/jasontaylordev/CleanArchitecture
Re:The Case for C# and .NET by SideburnsOfDoom on Monday July 25, 2022 @03:57AM (#32221678)
Yep. The problem that the parent commenter had is distinguishing between "Not existent" i.e. the tool that I am trying out sucks; and "I don't know how to use this tool yet" - a completely normal part of the learning experience.

Failing to find the differences between them will impede learning in general.

Re:The Case for C# and .NET by neonsunset on Monday July 25, 2022 @07:07AM (#32222863)
I'm not sure which learning material you used back then but this seems more like an unfortunate accident.

With .NET 6 SDK, 'dotnet new webapi' will give you a template project that does everything you listed save for extended validation logic which you can easily add with 'FluentValidation'.

In addition, to run ASP.NET Core nowadays you only need:

  var builder = WebApplication.CreateBuilder();
  var app = builder.Build();
  app.MapGet("/posts/{name}", ([FromRoute] string name) => /* controller logic, classes will be serialized as JSON */);
  await app.RunAsync("http://localhost:8080");
Re:The Case for C# and .NET by CharlieDigital on Monday July 25, 2022 @09:11AM (#32223759)
You did something wrong.

  dotnet new webapi -minimal
This will scaffold a project which is more or less the exact same as Flask, Express, or any other "easy" framework.

OpenAPI output is built-in, but tooling for development does require a bit of knowledge (agree that Microsoft would benefit from making this work out of the box).

A small repo here showing how to connect OpenAPI and front-end TypeScript client generation: https://github.com/CharlieDigital/dotnet6-openapi

Re:The Case for C# and .NET by JamesBarney on Monday July 25, 2022 @03:11AM (#32221404)
I think for swagger documentation you install the swashbuckle nuget package and then add these three lines

services.AddSwaggerGen();

app.UseSwagger();

app.UseSwaggerUI();

Re:The Case for C# and .NET by orthoxerox on Monday July 25, 2022 @06:04AM (#32222453)
ASP.NET configuration is one of the most arcane parts of .NET that I don't like. You have to perform the incantation thrice: add package reference, add service reference, invoke the builder extension. And there's the right order and the wrong order of invocations, and if you pick the wrong one, your app silently won't work correctly.
Re:The Case for C# and .NET by metaltyphoon on Monday July 25, 2022 @08:44AM (#32223541)
Arcane? What did you expect? Add a package and magically everything works? If you make it work by just adding a reference its “too much magic”, if you make it so people write everything “it’s boilerplate” and if you do something in between “its arcane”.
Re:The Case for C# and .NET by silon42 on Monday July 25, 2022 @04:31AM (#32221860)
Personally, I'd rather generate documentation at compile time.
Re:The Case for C# and .NET by piaste on Monday July 25, 2022 @05:31AM (#32222258)
I do it during tests.

Since I'm already spawning a TestHost and trying out various API calls, one of these tests basically does "curl $host/openapi/openapi.json | diff ./docs/openapi.json". If it spots a change and fails the test, I check that the difference is expected, and if so I temporarily enable and run a different "test" which actually writes the updated file.

Re:The Case for C# and .NET by wizofaus on Monday July 25, 2022 @05:01AM (#32222078)
Which you can do, by adding a post build step.
Re:The Case for C# and .NET by leosarev on Monday July 25, 2022 @07:05AM (#32222852)
> It was the worst development experience I ever had while writing json apis. Validation? Not existent. OpenAPI/swagger documentation generation? Not existent.

They are existent and good.

Re:The Case for C# and .NET by wizofaus on Monday July 25, 2022 @05:00AM (#32222062)
Totally opposite experience for me. C# + .NET ASP core Web Api framework + Swashbuckle + FluentValidation does out of the box what I still haven't seen a good solution for in the NodeJs world (which is the one I'm in now).
Re:The Case for C# and .NET by pas on Monday July 25, 2022 @07:01AM (#32222827)
NestJS seems to hit the sweet spot for these. I'd add a proper Result type (from fp-ts) to get better error handling (than try-catch everywhere) and you're good to go.
Re:The Case for C# and .NET by wizofaus on Monday July 25, 2022 @07:26AM (#32222963)
We've just started looking into that, but the amount of existing raw JS+express we have means adopting something like NestJS is going to be a huge undertaking. What slightly baffles me is that at no point did anyone seem to stop and think if there shouldn't be a better way...
Re:The Case for C# and .NET by kcartlidge on Monday July 25, 2022 @05:02PM (#32230869)
> I switched back to node.js with fastify and wrote my app in an hour.

Of course you did. You're on familiar ground.

Personally I'm also familiar with .Net and could do the same in that stack in that timeframe too. Like with many things worth doing, it requires a time investment to reach that point.

Having said that, .Net APIs support JSON request/response out of the box, validation is available on the models in seconds using a powerful set of attribute annotations, and Swagger is also built in out of the box. And API projects can seem similar to MVC ones as they use the same framework and libraries, but whilst the out of the box APIs have controllers they don't have views.

So to repeat, it's down to familiarity.

Edit: For clarity this is not a criticism. I fully understand why these things may not be obvious up front. Both the validation attributes and the Swagger URL for the default support are not obvious to the newcomer.

Re:The Case for C# and .NET by simooooo on Monday July 25, 2022 @01:40AM (#32220878)
You don’t need to use MVC either since minimal APIs are a thing now
Re:The Case for C# and .NET by manigandham on Monday July 25, 2022 @05:05AM (#32222104)
What do you actually mean by "non-existent"? The asp.net framework includes more functionality by default with its standard libraries than just about anything else.
Re:The Case for C# and .NET by JonoW on Monday July 25, 2022 @08:26AM (#32223368)
But Node.js doesn't ship with those features built-in either?