Live data from Hacker News

C# Pattern Matching

docs.microsoft.com

191–200 of 214 posts

Re: C# Pattern Matching

#191
post #3

Resharper has proven to be a great way for me to start learning and integrating new language features. I code in my original style and resharper suggests changes based on new features like pattern matching. At first I didnt see the benefit, but this is a hugely powerful feature once you start to wrap your mind around it.

I don't understand why upcoming programming languages completely ignore the IDE experience or at most throw some basic code completion (which works half of the time) and syntax highlighting at you (not even semantic highlighting). I'll take a "limited" language with excellent IDE support over a "powerful" language that you use notepad with.

I'd argue that Kotlin is still a "Upcomming programming languages" - and I think one of its reasons for success is how well integrated it is into the IDE. (especially if you use intelliJ)

Re: C# Pattern Matching

#192
post #3

Resharper has proven to be a great way for me to start learning and integrating new language features. I code in my original style and resharper suggests changes based on new features like pattern matching. At first I didnt see the benefit, but this is a hugely powerful feature once you start to wrap your mind around it.

I don't understand why upcoming programming languages completely ignore the IDE experience or at most throw some basic code completion (which works half of the time) and syntax highlighting at you (not even semantic highlighting). I'll take a "limited" language with excellent IDE support over a "powerful" language that you use notepad with.

The same applies for other tooling as well; one of the reasons why go is so popular.

Re: C# Pattern Matching

#193
post #53

Earlier quoted context omitted.

I started using Rider recently. It's faster yes, but seems to be a bit more memory hungry out of the gate than VS+Resharper. There is one HUGE thing I miss however - the Package Manager console. There's still a few things I have to do in there and thus have to switch back to VS.

VS is 32 bit, so instead of getting more memory when it needs it slows to a crawl and eventually crashes. I think that the early versions of VS are a bloodbath. VS 2019 just crawled with a small solution just because there were mixed C# and F# projects. I should remember to upgrade always after 2 or 3 minor revisions instead of being a guinea pig for MS. On the other hand some time ago I got a bug in rider where the…

Tests not running might be X86/X64 issue. Certainly nUnit will find the tests but not run them until you change the default architecture (Resharper will run them happily in VS).

Re: C# Pattern Matching

#194
post #3

Resharper has proven to be a great way for me to start learning and integrating new language features. I code in my original style and resharper suggests changes based on new features like pattern matching. At first I didnt see the benefit, but this is a hugely powerful feature once you start to wrap your mind around it.

Reshaper is known to be quite slow, slowing down VS by a lot, how much depends on the project. Besides, newer versions of VS and its refactoring features have come a long way, for me, it has made Resharper obsolete.

https://resharper-support.jetbrains.com/hc/en-us/articles/20...

Re: C# Pattern Matching

#195
post #68
post #3

Resharper has proven to be a great way for me to start learning and integrating new language features. I code in my original style and resharper suggests changes based on new features like pattern matching. At first I didnt see the benefit, but this is a hugely powerful feature once you start to wrap your mind around it.

Resharper is amazing, I absolutely love it but I think it makes me lazy.. Infact, I get nervous when I'm working on a VS without it.. I don't want to NOT know why ReSharper is screaming at me!

Have you attempted to use VS recently without it? Newer versions of VS have come a long way to match its refactoring features. What feature specifically are you missing?

Re: C# Pattern Matching

#196
post #171
post #51

Earlier quoted context omitted.

Technically it's owned by .NET Foundation now, but admittedly it's composed of MSFT people by a large part. Also, language design happens on GitHub, and the community is encouraged to get involved.

As long as Microsoft finances the .NET/C# team, neither runtime/libraries nor the language will include anything which does not fit in their strategies/vision. The .NET Foundation will not change anything here. And that is good. The .NET Foundation ensures that the product is legally usable on Linux/Macs/other non Windows platforms and additionally helps the ecosystem. F# for example is set loose of these constraints…

It has also brought stuff like ARM64 support (from Samsung and Qualcomm) without having to wait for MS to do it though

Re: C# Pattern Matching

#197
C# 8 also has "switch expressions" (1) meaning that all those "return" keywords fall away

so this is valid (although useless) c# 8:

    public static bool Invert(bool value) =>
        value switch
        {
            true => false,
            false => true
        };

I worry though that the "switch" syntax is becoming a big complex monster, and can be used to make utterly unreadable code, rather than simplifying as promised. We'll probably see both in practice.

It might have been nicer if they could have used a new keyword e.g. "match" to carry the new syntax, rather than overloading "switch", but that would not be backwards compatible with C# 1-7, as "match" was not a reserved word. (2)

Hopefully switch the syntax that supports these various cases doesn't get too tricky.

1) https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh...

2) https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...

Re: C# Pattern Matching

#198
post #145
post #136

Earlier quoted context omitted.

My only complaint is I can’t ignore auto-gen’d code like EF migrations in dotCover, so my unit test coverage looks terrible. It doesn’t help that I write terrible unit tests, but still!

I run a little powershell script on build that adds the [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] attribute to generated classes in certain folders. https://gist.github.com/mtone/aded2ff636cb6dd9d428cf5800f344... Funnily, I have no clue how to setup a build script in Rider, did that in VS (Rider do run it).

Holy crap you've made my job infinitely easier. Thank you!

Re: C# Pattern Matching

#199

Earlier quoted context omitted.

I'd say this is probably a bad example of usage for the feature. I use pattern matching in a few places in my own code-base, and it's almost always on interfaces that have a large set of extension methods applied. It's kind of like an entity-component architecture, except the components are added at compile-time, rather than run-time. Unfortunately, real-life use scenarios are verbose and involved and require a lot o…

I personally hate when official documentation uses badly applied approaches because it will be invariably be quoted as source for some "best practices" argument at some point. That's clearly a use case for interfaces and type-level programming. They could have made a better and shorter case with error handling logic.

Oh, I hate the phrase "best practices" in general. Reeks of cargo-culting.

Re: C# Pattern Matching

#200
post #3

Resharper has proven to be a great way for me to start learning and integrating new language features. I code in my original style and resharper suggests changes based on new features like pattern matching. At first I didnt see the benefit, but this is a hugely powerful feature once you start to wrap your mind around it.

Reshaper is known to be quite slow, slowing down VS by a lot, how much depends on the project. Besides, newer versions of VS and its refactoring features have come a long way, for me, it has made Resharper obsolete. https://resharper-support.jetbrains.com/hc/en-us/articles/20...

Having switched from VS to JetBrains Rider a few months ago, I cannot recommend it enough. Way faster and less clunky than VS without Resharper, especially if you're targeting Unity. They're so far ahead I simply don't see any way for Microsoft to catch up any time soon.
Post reply on HN