Live data from Hacker News

.NET 5.0

devblogs.microsoft.com

301–310 of 466 posts

Re: .NET 5.0

#301

Earlier quoted context omitted.

> My biggest bugbear is the way you access your config, which is an absolute and utter kafka-esque mess. Because someone at MS was drinking the DI kool-aid you have to add a minimum of 5 lines of code to any class you want to access config values in I'm not sure if maybe you're referring to the Options stuff? The way I do it is pretty simple. 1. Create a POCO that represents your config. You can have properties for b…

I think the OP is referring to accessing the config 5 layers down from the controller. I've run into it myself. To be able to do that, you have to add Options to the constructor of every class in the chain and then configure DI for it. It just has bad code smell. On my last project, I just assigned the configs to a static class that's available everywhere and the code was just simply much cleaner.

> To be able to do that, you have to add Options to the constructor of every class in the chain and then configure DI for it.

You really don't - just inject your populated config object where you need it.

Re: .NET 5.0

#302
post #258

The future is very bright for .NET. It has the right raison d'etre - .NET is part of the growth story for Nadella-Microsoft. They already have you programming in their editors (VS/Code) and pushing to their VCS (Github). They're even teaching you the C# type system with TypeScript :) If they can just convince you to use their stack, Azure will win you over from AWS every time. As a result, I really wanted to adopt .N…

> Azure will win you over from AWS every time. Going to have to disagree here. That might be the case if Azure was not literally a tire-fire. I have been using Azure for work and it's the most frustrating, inconsistent, often-broken, confusing and stress-inducing cloud service that my teammates and I have ever been subjected to. It left such a bad taste that I am quite certain I would flat-out refuse to use it again…

I've been using Azure for all of my projects for 5 years now, with zero problems.

Re: .NET 5.0

#303

Earlier quoted context omitted.

I mean, nearly all outstanding documentation and tutorials on how to implement speech in Windows is conveyed via those APIs. I know I don't have the skills to replace my System.Speech calls with generic COM interop, I'm willing to bet that would ring true for a lot of .NET developers relying on the .NET Framework today. At minimum, you're adding a "rewrite your accessibility code" cost to anyone moving from .NET Fram…

> At minimum, you're adding a "rewrite your accessibility code" cost to anyone moving from .NET Framework to .NET Core. That would be true if it were common for applications to directly support alternative UI modalities, but that's not how accessibility generally works. An application implements a GUI, including support for the platform accessibility API (hopefully with the help of the GUI framework), and it's up to…

This little discussion got me curious about how hard it actually is to use COM interop with .NET. Using Visual Studio its just a right click on your dependencies, selecting 'Add COM Reference...' and choosing the library you want to use. I was then able to call SAPI very easily like this:

  var voice = new SpeechLib.SpVoiceClass();
  voice.Speak("Hello World!");

The documentation for SAPI could use some love though. The sample code that is supposed to be there is nowhere to be found.

Re: .NET 5.0

#304
Would most people here agree that .NET is a much better platform for developing applications with a plugin-based architecture (which, I think, more or less, implies following Hexagonal aka Clean Architecture / Ports and Adapters Pattern [1]) than popular alternatives (e.g., Python, TypeScript/Node.js) due to a diverse set of comprehensive dependency injection (DI) implementations [2]? While it is possible to use a manual / non-DI approach [3], the trend seems to be in either extending this approach [4-5], or - an arguably more elegant and flexible solution - using DI [6]. Would love to hear opinions on how you would approach developing a heavily plugin-based application (including an ability to use virtualization containers, such as Docker, as functional plugins).

[1] https://www.infoq.com/articles/advanced-architecture-aspnet-...

[2] https://www.claudiobernasconi.ch/2019/01/24/the-ultimate-lis...

[3] https://docs.microsoft.com/en-us/dotnet/core/tutorials/creat...

[4] https://github.com/natemcmaster/DotNetCorePlugins

[5] https://maartenmerken.medium.com/announcing-prise-a-plugin-f...

[6] http://ewer.com.br/plugin-architecture-with-di-containers

Re: .NET 5.0

#305
post #258

The future is very bright for .NET. It has the right raison d'etre - .NET is part of the growth story for Nadella-Microsoft. They already have you programming in their editors (VS/Code) and pushing to their VCS (Github). They're even teaching you the C# type system with TypeScript :) If they can just convince you to use their stack, Azure will win you over from AWS every time. As a result, I really wanted to adopt .N…

The type system in typescript is a lot more advanced than the one available in C#.

Interested in what you mean by 'lot more advanced'?

The optional nature of the typing can be very useful for the web for sure. From my experience that same flexibility means you can't do as much reflection at runtime as in .NET but I have been for the most part away from typescript for last couple of years, so be interested in any resources around this subject.

Re: .NET 5.0

#306
post #208

Earlier quoted context omitted.

I'm so glad I'm not alone. I adore C# and the .NET runtime is so convenient. But the ASP.NET part feels bloated. Is there a simpler .NET framework?

I didn't use it recently but Nancy was quite good: https://nancyfx.org/

Nancy is dead https://github.com/NancyFx/Nancy. Archived and stated that it is no longer maintained.

Re: .NET 5.0

#307

Earlier quoted context omitted.

Aren’t records pretty trivial to create as a custom class in C#?

If you want to see how much code you get 'for free' by defining a record that you used to have to do manually, check out the generated C# here (structural equality, GetHashCode, Deconstruct, cloning for 'with', pretty printing, etc) https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+BYAUANwgQAI...

That’s neat!

It’s also generating code for the main method, which is also a new c# 9 feature

Re: .NET 5.0

#308

> From what we’ve seen and heard so far, .NET 5.0 delivers significant value without much effort to upgrade. From the previous version of .Net Core only. They've done absolutely nothing to make migrating from MVC 5 any easier, while proclaiming that this somehow merges .Net Framework and .Net Core. Going from MVC 5 to .Net 5.0 MVC is a complete re-write of the web layer from an empty project upon up (even according t…

As pointed out earlier, Microsoft has really butchered the proper nouns of their offerings.

If you read a dozen blogs posts about the background for the decisions and are able to hold all that information in your head while you need to make a decision, it is possible to attain clarity for a few moments. But it is not fun.

On the plus side, going back to versioning .Net should help for the next few years to come.

Re: .NET 5.0

#310

Earlier quoted context omitted.

Apart from needing two namespaces, this does look reasonable to me. I'm not sure how you could make constructor-based dependency injection easier without making it less obvious what is happening. And most of the additional lines are stuff your editor can do for you, even in VS Code you can automatically generate the field and assignment and the imports after just typing the constructor parameter. ASP.NET Core does pu…

> ASP.NET Core does push you strongly towards dependency injection, but it does not force you at all to use it. Their own documentation for making queries against SQL Server doesn't provide examples of how to do it that aren't using DI. "Just inject it" it just says. Thanks .net, super helpful. Maybe the docs are there, but I couldn't find them at all when I went looking.

    using(var conn = new SqlConnection(""))
    using(var cmd = new SqlCommand(@"Query here", conn))
    {
      conn.Open();
      cmd.executeNonQuery();
    }
Post reply on HN